diff --git a/Gemfile.lock b/Gemfile.lock index e856e32..310ce3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,66 +7,67 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (4.2.4) - actionpack (= 4.2.4) - actionview (= 4.2.4) - activejob (= 4.2.4) + actionmailer (4.2.5) + actionpack (= 4.2.5) + actionview (= 4.2.5) + activejob (= 4.2.5) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.4) - actionview (= 4.2.4) - activesupport (= 4.2.4) + actionpack (4.2.5) + actionview (= 4.2.5) + activesupport (= 4.2.5) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.4) - activesupport (= 4.2.4) + actionview (4.2.5) + activesupport (= 4.2.5) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.4) - activesupport (= 4.2.4) + activejob (4.2.5) + activesupport (= 4.2.5) globalid (>= 0.3.0) - activemodel (4.2.4) - activesupport (= 4.2.4) + activemodel (4.2.5) + activesupport (= 4.2.5) builder (~> 3.1) - activerecord (4.2.4) - activemodel (= 4.2.4) - activesupport (= 4.2.4) + activerecord (4.2.5) + activemodel (= 4.2.5) + activesupport (= 4.2.5) arel (~> 6.0) - activesupport (4.2.4) + activesupport (4.2.5) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.8) - administrate (0.0.12) - autoprefixer-rails - datetime_picker_rails (~> 0.0.4) + administrate (0.1.1) + autoprefixer-rails (~> 6.0) + datetime_picker_rails (~> 0.0.5) inline_svg (~> 0.6) + jquery-rails (~> 4.0) kaminari (~> 0.16) - momentjs-rails (>= 2.9.0) + momentjs-rails (~> 2.8) neat (~> 1.1) normalize-rails (~> 3.0) rails (~> 4.2) - sass (~> 3.4) + sass-rails (~> 5.0) selectize-rails (~> 0.6) arel (6.0.3) ast (2.1.0) astrolabe (1.3.1) parser (~> 2.2) - autoprefixer-rails (6.0.3) + autoprefixer-rails (6.1.1) execjs json - aws-sdk (2.1.29) - aws-sdk-resources (= 2.1.29) - aws-sdk-core (2.1.29) + aws-sdk (2.2.1) + aws-sdk-resources (= 2.2.1) + aws-sdk-core (2.2.1) jmespath (~> 1.0) - aws-sdk-resources (2.1.29) - aws-sdk-core (= 2.1.29) + aws-sdk-resources (2.2.1) + aws-sdk-core (= 2.2.1) bcrypt (3.1.10) better_errors (2.1.1) coderay (>= 1.0.0) @@ -95,9 +96,9 @@ GEM coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.9.1.1) - database_cleaner (1.5.0) - datetime_picker_rails (0.0.4) + coffee-script-source (1.10.0) + database_cleaner (1.5.1) + datetime_picker_rails (0.0.5) momentjs-rails (>= 2.8.1) debug_inspector (0.0.2) diff-lcs (1.2.5) @@ -121,19 +122,17 @@ GEM factory_girl_rails (4.5.0) factory_girl (~> 4.5.0) railties (>= 3.0.0) - fivemat (1.3.1) + fivemat (1.3.2) fog-aws (0.7.6) fog-core (~> 1.27) fog-json (~> 1.0) fog-xml (~> 0.1) ipaddress (~> 0.8) - fog-core (1.32.1) + fog-core (1.34.0) builder excon (~> 0.45) formatador (~> 0.2) mime-types - net-scp (~> 1.1) - net-ssh (>= 2.1.3) fog-json (1.0.2) fog-core (~> 1.0) multi_json (~> 1.10) @@ -152,8 +151,9 @@ GEM nokogiri (~> 1.6) ipaddress (0.8.0) jmespath (1.1.3) - jquery-rails (3.1.4) - railties (>= 3.0, < 5.0) + jquery-rails (4.0.5) + rails-dom-testing (~> 1.0) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.3) kaminari (0.16.3) @@ -168,9 +168,9 @@ GEM mail (2.6.3) mime-types (>= 1.16, < 3) method_source (0.8.2) - mime-types (2.6.2) + mime-types (2.99) mini_portile (0.6.2) - minitest (5.8.1) + minitest (5.8.3) momentjs-rails (2.10.6) railties (>= 3.1) monban (0.2.1) @@ -183,16 +183,13 @@ GEM neat (1.7.2) bourbon (>= 4.0) sass (>= 3.3) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (3.0.1) - nokogiri (1.6.6.2) + nokogiri (1.6.6.4) mini_portile (~> 0.6.0) normalize-rails (3.0.3) parser (2.2.3.0) ast (>= 1.1, < 3.0) - pg (0.18.3) - poltergeist (1.7.0) + pg (0.18.4) + poltergeist (1.8.0) capybara (~> 2.1) cliver (~> 0.3.1) multi_json (~> 1.0) @@ -202,24 +199,24 @@ GEM powder (0.3.0) thor (>= 0.11.5) powerpack (0.1.1) - pry (0.10.2) + pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - puma (2.14.0) + puma (2.15.3) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.4) - actionmailer (= 4.2.4) - actionpack (= 4.2.4) - actionview (= 4.2.4) - activejob (= 4.2.4) - activemodel (= 4.2.4) - activerecord (= 4.2.4) - activesupport (= 4.2.4) + rails (4.2.5) + actionmailer (= 4.2.5) + actionpack (= 4.2.5) + actionview (= 4.2.5) + activejob (= 4.2.5) + activemodel (= 4.2.5) + activerecord (= 4.2.5) + activesupport (= 4.2.5) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.4) + railties (= 4.2.5) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) @@ -234,39 +231,40 @@ GEM rails_stdout_logging rails_serve_static_assets (0.0.4) rails_stdout_logging (0.0.4) - railties (4.2.4) - actionpack (= 4.2.4) - activesupport (= 4.2.4) + railties (4.2.5) + actionpack (= 4.2.5) + activesupport (= 4.2.5) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.0.0) rake (10.4.2) redcarpet (3.3.3) - rspec-core (3.3.2) - rspec-support (~> 3.3.0) - rspec-expectations (3.3.1) + rspec-core (3.4.1) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-mocks (3.3.2) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-rails (3.3.3) + rspec-support (~> 3.4.0) + rspec-rails (3.4.0) actionpack (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3) railties (>= 3.0, < 4.3) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-support (~> 3.3.0) - rspec-support (3.3.0) - rubocop (0.34.2) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) + rubocop (0.35.1) astrolabe (~> 1.3) - parser (>= 2.2.2.5, < 3.0) + parser (>= 2.2.3.0, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) - ruby-progressbar (~> 1.4) + ruby-progressbar (~> 1.7) + tins (<= 1.6.0) ruby-progressbar (1.7.5) - ruby_parser (3.7.1) + ruby_parser (3.7.2) sexp_processor (~> 4.1) sass (3.4.19) sass-rails (5.0.4) @@ -291,7 +289,7 @@ GEM json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) - skylight (0.8.1) + skylight (0.9.3) activesupport (>= 3.0.0) slop (3.6.0) slugtastic (1.2.1) @@ -308,6 +306,7 @@ GEM thor (0.19.1) thread_safe (0.3.5) tilt (2.0.1) + tins (1.6.0) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.7.2) @@ -318,7 +317,7 @@ GEM unf_ext (0.0.7.1) warden (1.2.3) rack (>= 1.0) - websocket-driver (0.6.2) + websocket-driver (0.6.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) xpath (2.0.0) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb new file mode 100644 index 0000000..43795c3 --- /dev/null +++ b/app/controllers/admin/users_controller.rb @@ -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 diff --git a/app/dashboards/category_dashboard.rb b/app/dashboards/category_dashboard.rb index d96da41..454dc49 100644 --- a/app/dashboards/category_dashboard.rb +++ b/app/dashboards/category_dashboard.rb @@ -1,13 +1,6 @@ require "administrate/base_dashboard" -require "administrate/fields/colour" class CategoryDashboard < Administrate::BaseDashboard - READ_ONLY_ATTRIBUTES = [ - :id, - :created_at, - :updated_at, - ] - # ATTRIBUTE_TYPES # a hash that describes the type of each of the model's fields. # @@ -18,21 +11,25 @@ class CategoryDashboard < Administrate::BaseDashboard id: Field::Number, name: Field::String, slug: Field::String, - description: Field::String, + description: Field::Text, created_at: Field::DateTime, updated_at: Field::DateTime, - # photo_id: Field::Number, - base_colour: Field::Colour, + base_colour: Field::ColourField, sort: Field::Number, photos: Field::HasMany, } - # TABLE_ATTRIBUTES + # 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 remove the limit or customize the returned array. - TABLE_ATTRIBUTES = %i(base_colour name description photos) + # Feel free to add, remove, or rearrange items. + COLLECTION_ATTRIBUTES = [ + :base_colour, + :name, + :description, + :photos, + ] # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. @@ -41,5 +38,12 @@ class CategoryDashboard < Administrate::BaseDashboard # FORM_ATTRIBUTES # an array of attributes that will be displayed # 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 diff --git a/app/dashboards/dashboard_manifest.rb b/app/dashboards/dashboard_manifest.rb index 4951b28..b735497 100644 --- a/app/dashboards/dashboard_manifest.rb +++ b/app/dashboards/dashboard_manifest.rb @@ -13,6 +13,7 @@ class DashboardManifest :photos, :categories, :pages, + :users, ] # `ROOT_DASHBOARD` diff --git a/app/dashboards/page_dashboard.rb b/app/dashboards/page_dashboard.rb index da82c75..fd7a849 100644 --- a/app/dashboards/page_dashboard.rb +++ b/app/dashboards/page_dashboard.rb @@ -1,13 +1,6 @@ require "administrate/base_dashboard" -require "administrate/fields/markdown" class PageDashboard < Administrate::BaseDashboard - READ_ONLY_ATTRIBUTES = [ - :id, - :created_at, - :updated_at, - ] - # ATTRIBUTE_TYPES # 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. ATTRIBUTE_TYPES = { title: Field::String, - content: Field::Markdown, + content: Field::MarkdownField, id: Field::Number, name: Field::String, created_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. # # 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. - TABLE_ATTRIBUTES = ATTRIBUTE_TYPES.keys.first(4) + # Feel free to add, remove, or rearrange items. + COLLECTION_ATTRIBUTES = [ + :name, + :title, + :content, + ] # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. @@ -37,5 +34,9 @@ class PageDashboard < Administrate::BaseDashboard # FORM_ATTRIBUTES # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. - FORM_ATTRIBUTES = ATTRIBUTE_TYPES.keys - READ_ONLY_ATTRIBUTES + FORM_ATTRIBUTES = [ + :name, + :title, + :content, + ] end diff --git a/app/dashboards/photo_dashboard.rb b/app/dashboards/photo_dashboard.rb index 52a8754..855f48f 100644 --- a/app/dashboards/photo_dashboard.rb +++ b/app/dashboards/photo_dashboard.rb @@ -1,12 +1,6 @@ require "administrate/base_dashboard" class PhotoDashboard < Administrate::BaseDashboard - READ_ONLY_ATTRIBUTES = [ - :id, - :created_at, - :updated_at, - ] - # ATTRIBUTE_TYPES # a hash that describes the type of each of the model's fields. # @@ -16,25 +10,30 @@ class PhotoDashboard < Administrate::BaseDashboard ATTRIBUTE_TYPES = { title: Field::String, image: Field::Image, - description: Field::String, - taken_at: Field::DateTime, - id: Field::Number, + description: Field::Text, flickr_url: Field::String, + taken_at: Field::DateTime, created_at: Field::DateTime, updated_at: Field::DateTime, - sort: Field::Number, featured: Field::Boolean, enabled: Field::Boolean, + id: Field::Number, + sort: Field::Number, views: Field::Number, categories: Field::HasMany, } - # TABLE_ATTRIBUTES + # 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 remove the limit or customize the returned array. - TABLE_ATTRIBUTES = %i(image title taken_at views) + # Feel free to add, remove, or rearrange items. + COLLECTION_ATTRIBUTES = [ + :image, + :title, + :taken_at, + :views, + ] # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. @@ -43,5 +42,15 @@ class PhotoDashboard < Administrate::BaseDashboard # FORM_ATTRIBUTES # an array of attributes that will be displayed # 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 diff --git a/app/dashboards/user_dashboard.rb b/app/dashboards/user_dashboard.rb new file mode 100644 index 0000000..a387992 --- /dev/null +++ b/app/dashboards/user_dashboard.rb @@ -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 diff --git a/app/fields/colour_field.rb b/app/fields/colour_field.rb new file mode 100644 index 0000000..9e74533 --- /dev/null +++ b/app/fields/colour_field.rb @@ -0,0 +1,4 @@ +require "administrate/fields/base" + +class ColourField < Administrate::Field::Base +end diff --git a/app/fields/markdown_field.rb b/app/fields/markdown_field.rb new file mode 100644 index 0000000..67f9a0a --- /dev/null +++ b/app/fields/markdown_field.rb @@ -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 diff --git a/app/views/admin/photos/_table.html.erb b/app/views/admin/applications/_collection.html.erb similarity index 55% rename from app/views/admin/photos/_table.html.erb rename to app/views/admin/applications/_collection.html.erb index 3d0663c..a11e8fd 100644 --- a/app/views/admin/photos/_table.html.erb +++ b/app/views/admin/applications/_collection.html.erb @@ -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_presenter.attribute_types.each do |attr_name, attr_type| %> + <% collection_presenter.attribute_types.each do |attr_name, attr_type| %> diff --git a/app/views/admin/applications/_form.html.erb b/app/views/admin/applications/_form.html.erb new file mode 100644 index 0000000..2cea728 --- /dev/null +++ b/app/views/admin/applications/_form.html.erb @@ -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? %> +
+

+ <%= pluralize(page.resource.errors.count, "error") %> + prohibited this <%= page.resource_name %> from being saved: +

+ + +
+ <% end %> + +
+ <% page.attributes.each do |attribute| -%> +
+ <%= render_field attribute, f: f %> +
+ <% end -%> +
+ +
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/admin/applications/edit.html.erb b/app/views/admin/applications/edit.html.erb new file mode 100644 index 0000000..b604a5b --- /dev/null +++ b/app/views/admin/applications/edit.html.erb @@ -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}" } %> + +
+

<%= content_for(:title) %>

+ <%= link_to "Show #{page.resource}", [Administrate::NAMESPACE, page.resource], class: "button" %> +
+ +<%= render "form", page: page %> diff --git a/app/views/admin/applications/index.html.erb b/app/views/admin/applications/index.html.erb new file mode 100644 index 0000000..c99dd6b --- /dev/null +++ b/app/views/admin/applications/index.html.erb @@ -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 %> + + + <%= inline_svg "administrate/search.svg" %> + + + + Press enter to search + + +<% end %> + +
+

<%= content_for(:title) %>

+ <%= link_to( + "New #{page.resource_name.titleize.downcase}", + [:new, Administrate::NAMESPACE, page.resource_name], + class: "button", + ) %> +
+ +<%= render "collection", collection_presenter: page, resources: resources %> + +<%= paginate resources %> diff --git a/app/views/admin/applications/new.html.erb b/app/views/admin/applications/new.html.erb new file mode 100644 index 0000000..46a7063 --- /dev/null +++ b/app/views/admin/applications/new.html.erb @@ -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}" } %> + +
+

<%= content_for(:title) %>

+ <%= link_to 'Back', :back, class: "button" %> +
+ +<%= render 'form', page: page %> diff --git a/app/views/admin/applications/show.html.erb b/app/views/admin/applications/show.html.erb new file mode 100644 index 0000000..7c01eaf --- /dev/null +++ b/app/views/admin/applications/show.html.erb @@ -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 } %> + +
+

<%= content_for(:title) %>

+ <%= link_to( + "Edit", + [:edit, Administrate::NAMESPACE, page.resource], + class: "button", + ) %> +
+ +
+ <% page.attributes.each do |attribute| %> +
<%= attribute.name.titleize %>
+ +
<%= render_field attribute %>
+ <% end %> +
diff --git a/app/views/admin/photos/_form.html.erb b/app/views/admin/photos/_form.html.erb deleted file mode 100644 index 893abb4..0000000 --- a/app/views/admin/photos/_form.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<%= form_for([Administrate::NAMESPACE, @page.resource], class: "form") do |f| %> - <% if @page.resource.errors.any? %> -
-

- <%= pluralize(@page.resource.errors.count, "error") %> - prohibited this <%= @page.resource_name %> from being saved: -

- - -
- <% end %> - -
- <% @page.attributes.each do |attribute| -%> -
- <%= render_field attribute, f: f %> -
- <% end -%> -
- -
- <%= f.submit %> -
-<% end %> diff --git a/app/views/admin/photos/edit.html.erb b/app/views/admin/photos/edit.html.erb deleted file mode 100644 index 38ba4d7..0000000 --- a/app/views/admin/photos/edit.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<% content_for(:title) { "Edit #{@page.page_title}" } %> - -
-

<%= content_for(:title) %>

- <%= link_to "Show #{@page.resource}", [Administrate::NAMESPACE, @page.resource], class: "button" %> -
- -<%= render "form" %> diff --git a/app/views/admin/photos/index.html.erb b/app/views/admin/photos/index.html.erb deleted file mode 100644 index a123a91..0000000 --- a/app/views/admin/photos/index.html.erb +++ /dev/null @@ -1,32 +0,0 @@ -<% content_for(:title) { @page.resource_name.pluralize.titleize } %> - -<% content_for(:search) do %> - - - <%= inline_svg "administrate/search.svg" %> - - - - Press enter to search - - -<% end %> - -
-

<%= content_for(:title) %>

- <%= link_to( - "New #{@page.resource_name.titleize.downcase}", - [:new, Administrate::NAMESPACE, @page.resource_name], - class: "button", - ) %> -
- -<%= render "table", table_presenter: @page, resources: @resources %> - -<%= paginate @resources %> diff --git a/app/views/admin/photos/new.html.erb b/app/views/admin/photos/new.html.erb deleted file mode 100644 index 0074b10..0000000 --- a/app/views/admin/photos/new.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<% content_for(:title) { "New #{@page.resource_name.titleize}" } %> - -
-

<%= content_for(:title) %>

- <%= link_to 'Back', @page.resource_name.pluralize, class: "button" %> -
- -<%= render 'form' %> diff --git a/app/views/admin/photos/show.html.erb b/app/views/admin/photos/show.html.erb deleted file mode 100644 index 38c1c37..0000000 --- a/app/views/admin/photos/show.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<% content_for(:title) { @page.page_title } %> - -
-

<%= content_for(:title) %>

- <%= link_to( - "Edit", - [:edit, Administrate::NAMESPACE, @page.resource], - class: "button", - ) %> -
- -
- <% @page.attributes.each do |attribute| %> -
<%= attribute.name.titleize %>
- -
<%= render_field attribute %>
- <% end %> -
diff --git a/app/views/fields/colour/_form.html.erb b/app/views/fields/colour_field/_form.html.erb similarity index 100% rename from app/views/fields/colour/_form.html.erb rename to app/views/fields/colour_field/_form.html.erb diff --git a/app/views/fields/colour/_index.html.erb b/app/views/fields/colour_field/_index.html.erb similarity index 100% rename from app/views/fields/colour/_index.html.erb rename to app/views/fields/colour_field/_index.html.erb diff --git a/app/views/fields/colour/_show.html.erb b/app/views/fields/colour_field/_show.html.erb similarity index 100% rename from app/views/fields/colour/_show.html.erb rename to app/views/fields/colour_field/_show.html.erb diff --git a/app/views/fields/markdown/_form.html.erb b/app/views/fields/markdown_field/_form.html.erb similarity index 100% rename from app/views/fields/markdown/_form.html.erb rename to app/views/fields/markdown_field/_form.html.erb diff --git a/app/views/fields/markdown/_index.html.erb b/app/views/fields/markdown_field/_index.html.erb similarity index 100% rename from app/views/fields/markdown/_index.html.erb rename to app/views/fields/markdown_field/_index.html.erb diff --git a/app/views/fields/markdown/_show.html.erb b/app/views/fields/markdown_field/_show.html.erb similarity index 100% rename from app/views/fields/markdown/_show.html.erb rename to app/views/fields/markdown_field/_show.html.erb diff --git a/app/views/fields/text/_form.html.erb b/app/views/fields/text/_form.html.erb deleted file mode 100644 index 60b9685..0000000 --- a/app/views/fields/text/_form.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= f.label field.attribute %> -<%= f.text_area field.attribute %> diff --git a/app/views/fields/text/_index.html.erb b/app/views/fields/text/_index.html.erb deleted file mode 100644 index d683ccc..0000000 --- a/app/views/fields/text/_index.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= field.truncate %> diff --git a/app/views/fields/text/_show.html.erb b/app/views/fields/text/_show.html.erb deleted file mode 100644 index 5177ca4..0000000 --- a/app/views/fields/text/_show.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= field.data %> diff --git a/config/routes.rb b/config/routes.rb index 0c4174b..c276f5a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,11 +2,6 @@ require 'monban/constraints/signed_in' require 'monban/constraints/signed_out' 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 DashboardManifest::DASHBOARDS.each do |dashboard_resource| resources dashboard_resource @@ -15,6 +10,11 @@ DanBarberPhoto::Application.routes.draw do root controller: DashboardManifest::ROOT_DASHBOARD, action: :index 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 :categories do diff --git a/lib/administrate/fields/colour.rb b/lib/administrate/fields/colour.rb deleted file mode 100644 index 9a4dfbd..0000000 --- a/lib/administrate/fields/colour.rb +++ /dev/null @@ -1,6 +0,0 @@ -module Administrate - module Field - class Colour < Administrate::Field::Base - end - end -end diff --git a/lib/administrate/fields/markdown.rb b/lib/administrate/fields/markdown.rb deleted file mode 100644 index 6ffe51a..0000000 --- a/lib/administrate/fields/markdown.rb +++ /dev/null @@ -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 diff --git a/lib/administrate/fields/text.rb b/lib/administrate/fields/text.rb deleted file mode 100644 index b60d25f..0000000 --- a/lib/administrate/fields/text.rb +++ /dev/null @@ -1,6 +0,0 @@ -module Administrate - module Field - class Text < Administrate::Field::Base - end - end -end
<%= link_to(params.merge( - table_presenter.order_params_for(attr_name) + collection_presenter.order_params_for(attr_name) )) do %> <%= attr_name.to_s.titleize %> - <% if table_presenter.ordered_by?(attr_name) %> - + <% if collection_presenter.ordered_by?(attr_name) %> + <%= inline_svg("administrate/sort_arrow.svg") %> <% end %> @@ -29,7 +49,7 @@ tabindex="0" data-url="<%= polymorphic_path([Administrate::NAMESPACE, resource]) -%>" > - <% table_presenter.attributes_for(resource).each do |attribute| %> + <% collection_presenter.attributes_for(resource).each do |attribute| %> <%= render_field attribute %>