1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

Use newer version of administrate

This commit is contained in:
Daniel Barber 2016-01-04 17:09:38 +00:00
parent 06e8b36bc0
commit 8484f478dc
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
33 changed files with 433 additions and 262 deletions

View File

@ -7,66 +7,67 @@ GIT
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
actionmailer (4.2.4) actionmailer (4.2.5)
actionpack (= 4.2.4) actionpack (= 4.2.5)
actionview (= 4.2.4) actionview (= 4.2.5)
activejob (= 4.2.4) activejob (= 4.2.5)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.4) actionpack (4.2.5)
actionview (= 4.2.4) actionview (= 4.2.5)
activesupport (= 4.2.4) activesupport (= 4.2.5)
rack (~> 1.6) rack (~> 1.6)
rack-test (~> 0.6.2) rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.4) actionview (4.2.5)
activesupport (= 4.2.4) activesupport (= 4.2.5)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.4) activejob (4.2.5)
activesupport (= 4.2.4) activesupport (= 4.2.5)
globalid (>= 0.3.0) globalid (>= 0.3.0)
activemodel (4.2.4) activemodel (4.2.5)
activesupport (= 4.2.4) activesupport (= 4.2.5)
builder (~> 3.1) builder (~> 3.1)
activerecord (4.2.4) activerecord (4.2.5)
activemodel (= 4.2.4) activemodel (= 4.2.5)
activesupport (= 4.2.4) activesupport (= 4.2.5)
arel (~> 6.0) arel (~> 6.0)
activesupport (4.2.4) activesupport (4.2.5)
i18n (~> 0.7) i18n (~> 0.7)
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4) thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.3.8) addressable (2.3.8)
administrate (0.0.12) administrate (0.1.1)
autoprefixer-rails autoprefixer-rails (~> 6.0)
datetime_picker_rails (~> 0.0.4) datetime_picker_rails (~> 0.0.5)
inline_svg (~> 0.6) inline_svg (~> 0.6)
jquery-rails (~> 4.0)
kaminari (~> 0.16) kaminari (~> 0.16)
momentjs-rails (>= 2.9.0) momentjs-rails (~> 2.8)
neat (~> 1.1) neat (~> 1.1)
normalize-rails (~> 3.0) normalize-rails (~> 3.0)
rails (~> 4.2) rails (~> 4.2)
sass (~> 3.4) sass-rails (~> 5.0)
selectize-rails (~> 0.6) selectize-rails (~> 0.6)
arel (6.0.3) arel (6.0.3)
ast (2.1.0) ast (2.1.0)
astrolabe (1.3.1) astrolabe (1.3.1)
parser (~> 2.2) parser (~> 2.2)
autoprefixer-rails (6.0.3) autoprefixer-rails (6.1.1)
execjs execjs
json json
aws-sdk (2.1.29) aws-sdk (2.2.1)
aws-sdk-resources (= 2.1.29) aws-sdk-resources (= 2.2.1)
aws-sdk-core (2.1.29) aws-sdk-core (2.2.1)
jmespath (~> 1.0) jmespath (~> 1.0)
aws-sdk-resources (2.1.29) aws-sdk-resources (2.2.1)
aws-sdk-core (= 2.1.29) aws-sdk-core (= 2.2.1)
bcrypt (3.1.10) bcrypt (3.1.10)
better_errors (2.1.1) better_errors (2.1.1)
coderay (>= 1.0.0) coderay (>= 1.0.0)
@ -95,9 +96,9 @@ GEM
coffee-script (2.4.1) coffee-script (2.4.1)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.9.1.1) coffee-script-source (1.10.0)
database_cleaner (1.5.0) database_cleaner (1.5.1)
datetime_picker_rails (0.0.4) datetime_picker_rails (0.0.5)
momentjs-rails (>= 2.8.1) momentjs-rails (>= 2.8.1)
debug_inspector (0.0.2) debug_inspector (0.0.2)
diff-lcs (1.2.5) diff-lcs (1.2.5)
@ -121,19 +122,17 @@ GEM
factory_girl_rails (4.5.0) factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0) factory_girl (~> 4.5.0)
railties (>= 3.0.0) railties (>= 3.0.0)
fivemat (1.3.1) fivemat (1.3.2)
fog-aws (0.7.6) fog-aws (0.7.6)
fog-core (~> 1.27) fog-core (~> 1.27)
fog-json (~> 1.0) fog-json (~> 1.0)
fog-xml (~> 0.1) fog-xml (~> 0.1)
ipaddress (~> 0.8) ipaddress (~> 0.8)
fog-core (1.32.1) fog-core (1.34.0)
builder builder
excon (~> 0.45) excon (~> 0.45)
formatador (~> 0.2) formatador (~> 0.2)
mime-types mime-types
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
fog-json (1.0.2) fog-json (1.0.2)
fog-core (~> 1.0) fog-core (~> 1.0)
multi_json (~> 1.10) multi_json (~> 1.10)
@ -152,8 +151,9 @@ GEM
nokogiri (~> 1.6) nokogiri (~> 1.6)
ipaddress (0.8.0) ipaddress (0.8.0)
jmespath (1.1.3) jmespath (1.1.3)
jquery-rails (3.1.4) jquery-rails (4.0.5)
railties (>= 3.0, < 5.0) rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
json (1.8.3) json (1.8.3)
kaminari (0.16.3) kaminari (0.16.3)
@ -168,9 +168,9 @@ GEM
mail (2.6.3) mail (2.6.3)
mime-types (>= 1.16, < 3) mime-types (>= 1.16, < 3)
method_source (0.8.2) method_source (0.8.2)
mime-types (2.6.2) mime-types (2.99)
mini_portile (0.6.2) mini_portile (0.6.2)
minitest (5.8.1) minitest (5.8.3)
momentjs-rails (2.10.6) momentjs-rails (2.10.6)
railties (>= 3.1) railties (>= 3.1)
monban (0.2.1) monban (0.2.1)
@ -183,16 +183,13 @@ GEM
neat (1.7.2) neat (1.7.2)
bourbon (>= 4.0) bourbon (>= 4.0)
sass (>= 3.3) sass (>= 3.3)
net-scp (1.2.1) nokogiri (1.6.6.4)
net-ssh (>= 2.6.5)
net-ssh (3.0.1)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0) mini_portile (~> 0.6.0)
normalize-rails (3.0.3) normalize-rails (3.0.3)
parser (2.2.3.0) parser (2.2.3.0)
ast (>= 1.1, < 3.0) ast (>= 1.1, < 3.0)
pg (0.18.3) pg (0.18.4)
poltergeist (1.7.0) poltergeist (1.8.0)
capybara (~> 2.1) capybara (~> 2.1)
cliver (~> 0.3.1) cliver (~> 0.3.1)
multi_json (~> 1.0) multi_json (~> 1.0)
@ -202,24 +199,24 @@ GEM
powder (0.3.0) powder (0.3.0)
thor (>= 0.11.5) thor (>= 0.11.5)
powerpack (0.1.1) powerpack (0.1.1)
pry (0.10.2) pry (0.10.3)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
puma (2.14.0) puma (2.15.3)
rack (1.6.4) rack (1.6.4)
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rails (4.2.4) rails (4.2.5)
actionmailer (= 4.2.4) actionmailer (= 4.2.5)
actionpack (= 4.2.4) actionpack (= 4.2.5)
actionview (= 4.2.4) actionview (= 4.2.5)
activejob (= 4.2.4) activejob (= 4.2.5)
activemodel (= 4.2.4) activemodel (= 4.2.5)
activerecord (= 4.2.4) activerecord (= 4.2.5)
activesupport (= 4.2.4) activesupport (= 4.2.5)
bundler (>= 1.3.0, < 2.0) bundler (>= 1.3.0, < 2.0)
railties (= 4.2.4) railties (= 4.2.5)
sprockets-rails sprockets-rails
rails-deprecated_sanitizer (1.0.3) rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha) activesupport (>= 4.2.0.alpha)
@ -234,39 +231,40 @@ GEM
rails_stdout_logging rails_stdout_logging
rails_serve_static_assets (0.0.4) rails_serve_static_assets (0.0.4)
rails_stdout_logging (0.0.4) rails_stdout_logging (0.0.4)
railties (4.2.4) railties (4.2.5)
actionpack (= 4.2.4) actionpack (= 4.2.5)
activesupport (= 4.2.4) activesupport (= 4.2.5)
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rainbow (2.0.0) rainbow (2.0.0)
rake (10.4.2) rake (10.4.2)
redcarpet (3.3.3) redcarpet (3.3.3)
rspec-core (3.3.2) rspec-core (3.4.1)
rspec-support (~> 3.3.0) rspec-support (~> 3.4.0)
rspec-expectations (3.3.1) rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0) rspec-support (~> 3.4.0)
rspec-mocks (3.3.2) rspec-mocks (3.4.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0) rspec-support (~> 3.4.0)
rspec-rails (3.3.3) rspec-rails (3.4.0)
actionpack (>= 3.0, < 4.3) actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3) railties (>= 3.0, < 4.3)
rspec-core (~> 3.3.0) rspec-core (~> 3.4.0)
rspec-expectations (~> 3.3.0) rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.3.0) rspec-mocks (~> 3.4.0)
rspec-support (~> 3.3.0) rspec-support (~> 3.4.0)
rspec-support (3.3.0) rspec-support (3.4.1)
rubocop (0.34.2) rubocop (0.35.1)
astrolabe (~> 1.3) astrolabe (~> 1.3)
parser (>= 2.2.2.5, < 3.0) parser (>= 2.2.3.0, < 3.0)
powerpack (~> 0.1) powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0) rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4) ruby-progressbar (~> 1.7)
tins (<= 1.6.0)
ruby-progressbar (1.7.5) ruby-progressbar (1.7.5)
ruby_parser (3.7.1) ruby_parser (3.7.2)
sexp_processor (~> 4.1) sexp_processor (~> 4.1)
sass (3.4.19) sass (3.4.19)
sass-rails (5.0.4) sass-rails (5.0.4)
@ -291,7 +289,7 @@ GEM
json (~> 1.8) json (~> 1.8)
simplecov-html (~> 0.10.0) simplecov-html (~> 0.10.0)
simplecov-html (0.10.0) simplecov-html (0.10.0)
skylight (0.8.1) skylight (0.9.3)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
slop (3.6.0) slop (3.6.0)
slugtastic (1.2.1) slugtastic (1.2.1)
@ -308,6 +306,7 @@ GEM
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (2.0.1) tilt (2.0.1)
tins (1.6.0)
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (2.7.2) uglifier (2.7.2)
@ -318,7 +317,7 @@ GEM
unf_ext (0.0.7.1) unf_ext (0.0.7.1)
warden (1.2.3) warden (1.2.3)
rack (>= 1.0) rack (>= 1.0)
websocket-driver (0.6.2) websocket-driver (0.6.3)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2) websocket-extensions (0.1.2)
xpath (2.0.0) xpath (2.0.0)

View File

@ -0,0 +1,19 @@
module Admin
class UsersController < Admin::ApplicationController
# To customize the behavior of this controller,
# simply overwrite any of the RESTful actions. For example:
#
# def index
# super
# @resources = User.all.paginate(10, params[:page])
# end
# Define a custom finder by overriding the `find_resource` method:
# def find_resource(param)
# User.find_by!(slug: param)
# end
# See https://administrate-docs.herokuapp.com/customizing_controller_actions
# for more information
end
end

View File

@ -1,13 +1,6 @@
require "administrate/base_dashboard" require "administrate/base_dashboard"
require "administrate/fields/colour"
class CategoryDashboard < Administrate::BaseDashboard class CategoryDashboard < Administrate::BaseDashboard
READ_ONLY_ATTRIBUTES = [
:id,
:created_at,
:updated_at,
]
# ATTRIBUTE_TYPES # ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields. # a hash that describes the type of each of the model's fields.
# #
@ -18,21 +11,25 @@ class CategoryDashboard < Administrate::BaseDashboard
id: Field::Number, id: Field::Number,
name: Field::String, name: Field::String,
slug: Field::String, slug: Field::String,
description: Field::String, description: Field::Text,
created_at: Field::DateTime, created_at: Field::DateTime,
updated_at: Field::DateTime, updated_at: Field::DateTime,
# photo_id: Field::Number, base_colour: Field::ColourField,
base_colour: Field::Colour,
sort: Field::Number, sort: Field::Number,
photos: Field::HasMany, photos: Field::HasMany,
} }
# TABLE_ATTRIBUTES # COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page. # an array of attributes that will be displayed on the model's index page.
# #
# By default, it's limited to four items to reduce clutter on index pages. # By default, it's limited to four items to reduce clutter on index pages.
# Feel free to remove the limit or customize the returned array. # Feel free to add, remove, or rearrange items.
TABLE_ATTRIBUTES = %i(base_colour name description photos) COLLECTION_ATTRIBUTES = [
:base_colour,
:name,
:description,
:photos,
]
# SHOW_PAGE_ATTRIBUTES # SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page. # an array of attributes that will be displayed on the model's show page.
@ -41,5 +38,12 @@ class CategoryDashboard < Administrate::BaseDashboard
# FORM_ATTRIBUTES # FORM_ATTRIBUTES
# an array of attributes that will be displayed # an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages. # on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = ATTRIBUTE_TYPES.keys - READ_ONLY_ATTRIBUTES FORM_ATTRIBUTES = [
:name,
:slug,
:description,
:base_colour,
:sort,
:photos,
]
end end

View File

@ -13,6 +13,7 @@ class DashboardManifest
:photos, :photos,
:categories, :categories,
:pages, :pages,
:users,
] ]
# `ROOT_DASHBOARD` # `ROOT_DASHBOARD`

View File

@ -1,13 +1,6 @@
require "administrate/base_dashboard" require "administrate/base_dashboard"
require "administrate/fields/markdown"
class PageDashboard < Administrate::BaseDashboard class PageDashboard < Administrate::BaseDashboard
READ_ONLY_ATTRIBUTES = [
:id,
:created_at,
:updated_at,
]
# ATTRIBUTE_TYPES # ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields. # a hash that describes the type of each of the model's fields.
# #
@ -16,19 +9,23 @@ class PageDashboard < Administrate::BaseDashboard
# on pages throughout the dashboard. # on pages throughout the dashboard.
ATTRIBUTE_TYPES = { ATTRIBUTE_TYPES = {
title: Field::String, title: Field::String,
content: Field::Markdown, content: Field::MarkdownField,
id: Field::Number, id: Field::Number,
name: Field::String, name: Field::String,
created_at: Field::DateTime, created_at: Field::DateTime,
updated_at: Field::DateTime, updated_at: Field::DateTime,
} }
# TABLE_ATTRIBUTES # COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page. # an array of attributes that will be displayed on the model's index page.
# #
# By default, it's limited to four items to reduce clutter on index pages. # By default, it's limited to four items to reduce clutter on index pages.
# Feel free to remove the limit or customize the returned array. # Feel free to add, remove, or rearrange items.
TABLE_ATTRIBUTES = ATTRIBUTE_TYPES.keys.first(4) COLLECTION_ATTRIBUTES = [
:name,
:title,
:content,
]
# SHOW_PAGE_ATTRIBUTES # SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page. # an array of attributes that will be displayed on the model's show page.
@ -37,5 +34,9 @@ class PageDashboard < Administrate::BaseDashboard
# FORM_ATTRIBUTES # FORM_ATTRIBUTES
# an array of attributes that will be displayed # an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages. # on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = ATTRIBUTE_TYPES.keys - READ_ONLY_ATTRIBUTES FORM_ATTRIBUTES = [
:name,
:title,
:content,
]
end end

View File

@ -1,12 +1,6 @@
require "administrate/base_dashboard" require "administrate/base_dashboard"
class PhotoDashboard < Administrate::BaseDashboard class PhotoDashboard < Administrate::BaseDashboard
READ_ONLY_ATTRIBUTES = [
:id,
:created_at,
:updated_at,
]
# ATTRIBUTE_TYPES # ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields. # a hash that describes the type of each of the model's fields.
# #
@ -16,25 +10,30 @@ class PhotoDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = { ATTRIBUTE_TYPES = {
title: Field::String, title: Field::String,
image: Field::Image, image: Field::Image,
description: Field::String, description: Field::Text,
taken_at: Field::DateTime,
id: Field::Number,
flickr_url: Field::String, flickr_url: Field::String,
taken_at: Field::DateTime,
created_at: Field::DateTime, created_at: Field::DateTime,
updated_at: Field::DateTime, updated_at: Field::DateTime,
sort: Field::Number,
featured: Field::Boolean, featured: Field::Boolean,
enabled: Field::Boolean, enabled: Field::Boolean,
id: Field::Number,
sort: Field::Number,
views: Field::Number, views: Field::Number,
categories: Field::HasMany, categories: Field::HasMany,
} }
# TABLE_ATTRIBUTES # COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page. # an array of attributes that will be displayed on the model's index page.
# #
# By default, it's limited to four items to reduce clutter on index pages. # By default, it's limited to four items to reduce clutter on index pages.
# Feel free to remove the limit or customize the returned array. # Feel free to add, remove, or rearrange items.
TABLE_ATTRIBUTES = %i(image title taken_at views) COLLECTION_ATTRIBUTES = [
:image,
:title,
:taken_at,
:views,
]
# SHOW_PAGE_ATTRIBUTES # SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page. # an array of attributes that will be displayed on the model's show page.
@ -43,5 +42,15 @@ class PhotoDashboard < Administrate::BaseDashboard
# FORM_ATTRIBUTES # FORM_ATTRIBUTES
# an array of attributes that will be displayed # an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages. # on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = ATTRIBUTE_TYPES.keys - READ_ONLY_ATTRIBUTES FORM_ATTRIBUTES = [
:title,
:image,
:description,
:flickr_url,
:taken_at,
:sort,
:featured,
:enabled,
:categories,
]
end end

View File

@ -0,0 +1,41 @@
require "administrate/base_dashboard"
class UserDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
email: Field::String,
password_digest: Field::String,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [
:id,
:email,
:password_digest,
:created_at,
]
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
:email,
:password_digest,
]
end

View File

@ -0,0 +1,4 @@
require "administrate/fields/base"
class ColourField < Administrate::Field::Base
end

View File

@ -0,0 +1,21 @@
require "administrate/fields/base"
class MarkdownField < Administrate::Field::Base
def rendered
renderer.render(data).html_safe
end
def truncate
data.to_s[0...truncation_length]
end
private
def renderer
Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions: {})
end
def truncation_length
options.fetch(:truncate, 50)
end
end

View File

@ -1,17 +1,37 @@
<%#
# Table
This partial is used on the `index` and `show` pages
to display a collection of resources in an HTML table.
## Local variables:
- `table_presenter`:
An instance of [Administrate::Page::Table][1].
The table presenter uses `ResourceDashboard::TABLE_ATTRIBUTES` to determine
the columns displayed in the table
- `resources`:
An ActiveModel::Relation collection of resources to be displayed in the table.
By default, the number of resources is limited by pagination
or by a hard limit to prevent excessive page load times
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Table
%>
<table> <table>
<thead> <thead>
<tr> <tr>
<% table_presenter.attribute_types.each do |attr_name, attr_type| %> <% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
<th class="cell-label cell-label--<%= attr_type.html_class %> <th class="cell-label cell-label--<%= attr_type.html_class %>
cell-label--<%= table_presenter.ordered_html_class(attr_name) %> cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
"> ">
<%= link_to(params.merge( <%= link_to(params.merge(
table_presenter.order_params_for(attr_name) collection_presenter.order_params_for(attr_name)
)) do %> )) do %>
<%= attr_name.to_s.titleize %> <%= attr_name.to_s.titleize %>
<% if table_presenter.ordered_by?(attr_name) %> <% if collection_presenter.ordered_by?(attr_name) %>
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= table_presenter.ordered_html_class(attr_name) %>"> <span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
<%= inline_svg("administrate/sort_arrow.svg") %> <%= inline_svg("administrate/sort_arrow.svg") %>
</span> </span>
<% end %> <% end %>
@ -29,7 +49,7 @@
tabindex="0" tabindex="0"
data-url="<%= polymorphic_path([Administrate::NAMESPACE, resource]) -%>" data-url="<%= polymorphic_path([Administrate::NAMESPACE, resource]) -%>"
> >
<% table_presenter.attributes_for(resource).each do |attribute| %> <% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>"> <td class="cell-data cell-data--<%= attribute.html_class %>">
<%= render_field attribute %> <%= render_field attribute %>
</td> </td>

View File

@ -0,0 +1,44 @@
<%#
# Form Partial
This partial is rendered on a resource's `new` and `edit` pages,
and renders all form fields for a resource's editable attributes.
## Local variables:
- `page`:
An instance of [Administrate::Page::Form][1].
Contains helper methods to display a form,
and knows which attributes should be displayed in the resource's form.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
%>
<%= form_for([Administrate::NAMESPACE, page.resource], class: "form") do |f| %>
<% if page.resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(page.resource.errors.count, "error") %>
prohibited this <%= page.resource_name %> from being saved:
</h2>
<ul>
<% page.resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="form-inputs">
<% page.attributes.each do |attribute| -%>
<div class="form-field form-field--<%= attribute.html_class %>">
<%= render_field attribute, f: f %>
</div>
<% end -%>
</div>
<div class="form-actions">
<%= f.submit %>
</div>
<% end %>

View File

@ -0,0 +1,25 @@
<%#
# Edit
This view is the template for the edit page.
It displays a header, and renders the `_form` partial to do the heavy lifting.
## Local variables:
- `page`:
An instance of [Administrate::Page::Form][1].
Contains helper methods to help display a form,
and knows which attributes should be displayed in the resource's form.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
%>
<% content_for(:title) { "Edit #{page.page_title}" } %>
<header class="header">
<h1 class="header-heading"><%= content_for(:title) %></h1>
<%= link_to "Show #{page.resource}", [Administrate::NAMESPACE, page.resource], class: "button" %>
</header>
<%= render "form", page: page %>

View File

@ -0,0 +1,55 @@
<%#
# Index
This view is the template for the index page.
It is responsible for rendering the search bar, header and pagination.
It renders the `_table` partial to display details about the resources.
## Local variables:
- `page`:
An instance of [Administrate::Page::Table][1].
Contains helper methods to help display a table,
and knows which attributes should be displayed in the resource's table.
- `resources`:
An instance of `ActiveRecord::Relation` containing the resources
that match the user's search criteria.
By default, these resources are passed to the table partial to be displayed.
- `search_term`:
A string containing the term the user has searched for, if any.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Table
%>
<% content_for(:title) { page.resource_name.pluralize.titleize } %>
<% content_for(:search) do %>
<form class="search">
<span class="search__icon">
<%= inline_svg "administrate/search.svg" %>
</span>
<input
type="text"
name="search"
class="search__input"
placeholder="Search"
value="<%= search_term %>"
/>
<span class="search__hint">
Press enter to search
</span>
</form>
<% end %>
<header class="header">
<h1 class="header-heading"><%= content_for(:title) %></h1>
<%= link_to(
"New #{page.resource_name.titleize.downcase}",
[:new, Administrate::NAMESPACE, page.resource_name],
class: "button",
) %>
</header>
<%= render "collection", collection_presenter: page, resources: resources %>
<%= paginate resources %>

View File

@ -0,0 +1,25 @@
<%#
# New
This view is the template for the "new resource" page.
It displays a header, and then renders the `_form` partial
to do the heavy lifting.
## Local variables:
- `page`:
An instance of [Administrate::Page::Form][1].
Contains helper methods to help display a form,
and knows which attributes should be displayed in the resource's form.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
%>
<% content_for(:title) { "New #{page.resource_name.titleize}" } %>
<header class="header">
<h1 class="header-heading"><%= content_for(:title) %></h1>
<%= link_to 'Back', :back, class: "button" %>
</header>
<%= render 'form', page: page %>

View File

@ -0,0 +1,37 @@
<%#
# Show
This view is the template for the show page.
It renders the attributes of a resource,
as well as a link to its edit page.
## Local variables:
- `page`:
An instance of [Administrate::Page::Show][1].
Contains methods for accessing the resource to be displayed on the page,
as well as helpers for describing how each attribute of the resource
should be displayed.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
%>
<% content_for(:title) { page.page_title } %>
<header class="header">
<h1 class="header-heading"><%= content_for(:title) %></h1>
<%= link_to(
"Edit",
[:edit, Administrate::NAMESPACE, page.resource],
class: "button",
) %>
</header>
<dl>
<% page.attributes.each do |attribute| %>
<dt class="attribute-label"><%= attribute.name.titleize %></dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute %></dd>
<% end %>
</dl>

View File

@ -1,28 +0,0 @@
<%= form_for([Administrate::NAMESPACE, @page.resource], class: "form") do |f| %>
<% if @page.resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(@page.resource.errors.count, "error") %>
prohibited this <%= @page.resource_name %> from being saved:
</h2>
<ul>
<% @page.resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="form-inputs">
<% @page.attributes.each do |attribute| -%>
<div class="form-field form-field--<%= attribute.html_class %>">
<%= render_field attribute, f: f %>
</div>
<% end -%>
</div>
<div class="form-actions">
<%= f.submit %>
</div>
<% end %>

View File

@ -1,8 +0,0 @@
<% content_for(:title) { "Edit #{@page.page_title}" } %>
<header class="header">
<h1 class="header-heading"><%= content_for(:title) %></h1>
<%= link_to "Show #{@page.resource}", [Administrate::NAMESPACE, @page.resource], class: "button" %>
</header>
<%= render "form" %>

View File

@ -1,32 +0,0 @@
<% content_for(:title) { @page.resource_name.pluralize.titleize } %>
<% content_for(:search) do %>
<form class="search">
<span class="search__icon">
<%= inline_svg "administrate/search.svg" %>
</span>
<input
type="text"
name="search"
class="search__input"
placeholder="Search"
value="<%= @search_term %>"
/>
<span class="search__hint">
Press enter to search
</span>
</form>
<% end %>
<header class="header">
<h1 class="header-heading"><%= content_for(:title) %></h1>
<%= link_to(
"New #{@page.resource_name.titleize.downcase}",
[:new, Administrate::NAMESPACE, @page.resource_name],
class: "button",
) %>
</header>
<%= render "table", table_presenter: @page, resources: @resources %>
<%= paginate @resources %>

View File

@ -1,8 +0,0 @@
<% content_for(:title) { "New #{@page.resource_name.titleize}" } %>
<header class="header">
<h1 class="header-heading"><%= content_for(:title) %></h1>
<%= link_to 'Back', @page.resource_name.pluralize, class: "button" %>
</header>
<%= render 'form' %>

View File

@ -1,19 +0,0 @@
<% content_for(:title) { @page.page_title } %>
<header class="header">
<h1 class="header-heading"><%= content_for(:title) %></h1>
<%= link_to(
"Edit",
[:edit, Administrate::NAMESPACE, @page.resource],
class: "button",
) %>
</header>
<dl>
<% @page.attributes.each do |attribute| %>
<dt class="attribute-label"><%= attribute.name.titleize %></dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute %></dd>
<% end %>
</dl>

View File

@ -1,2 +0,0 @@
<%= f.label field.attribute %>
<%= f.text_area field.attribute %>

View File

@ -1 +0,0 @@
<%= field.truncate %>

View File

@ -1 +0,0 @@
<%= field.data %>

View File

@ -2,11 +2,6 @@ require 'monban/constraints/signed_in'
require 'monban/constraints/signed_out' require 'monban/constraints/signed_out'
DanBarberPhoto::Application.routes.draw do DanBarberPhoto::Application.routes.draw do
resource :session, only: [:new, :create, :destroy]
resources :users, only: [:new, :create]
resource :session, only: [:new, :create, :destroy]
resources :users, only: [:new, :create]
namespace :admin do namespace :admin do
DashboardManifest::DASHBOARDS.each do |dashboard_resource| DashboardManifest::DASHBOARDS.each do |dashboard_resource|
resources dashboard_resource resources dashboard_resource
@ -15,6 +10,11 @@ DanBarberPhoto::Application.routes.draw do
root controller: DashboardManifest::ROOT_DASHBOARD, action: :index root controller: DashboardManifest::ROOT_DASHBOARD, action: :index
end end
resource :session, only: [:new, :create, :destroy]
resources :users, only: [:new, :create]
resource :session, only: [:new, :create, :destroy]
resources :users, only: [:new, :create]
resources :contacts resources :contacts
resources :categories do resources :categories do

View File

@ -1,6 +0,0 @@
module Administrate
module Field
class Colour < Administrate::Field::Base
end
end
end

View File

@ -1,23 +0,0 @@
module Administrate
module Field
class Markdown < Administrate::Field::Base
def rendered
renderer.render(data).html_safe
end
def truncate
data.to_s[0...truncation_length]
end
private
def renderer
Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions: {})
end
def truncation_length
options.fetch(:truncate, 50)
end
end
end
end

View File

@ -1,6 +0,0 @@
module Administrate
module Field
class Text < Administrate::Field::Base
end
end
end