diff --git a/Gemfile b/Gemfile index 0189349..0e8b30c 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,7 @@ group :production do end gem 'administrate' +gem 'administrate-field-image' gem 'dragonfly' gem 'dragonfly-s3_data_store' gem 'kaminari' diff --git a/Gemfile.lock b/Gemfile.lock index 5c20020..9bdd65e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -48,6 +48,8 @@ GEM momentjs-rails (~> 2.8) sass-rails (~> 5.0) selectize-rails (~> 0.6) + administrate-field-image (1.1.0) + administrate (>= 0.2.0.rc1) arel (6.0.4) ast (2.3.0) autoprefixer-rails (7.1.2.3) @@ -330,6 +332,7 @@ PLATFORMS DEPENDENCIES administrate + administrate-field-image aws-sdk better_errors binding_of_caller diff --git a/app/assets/stylesheets/administrate/overrides.css.scss b/app/assets/stylesheets/administrate/overrides.css.scss index 13d5ecb..b2729dc 100644 --- a/app/assets/stylesheets/administrate/overrides.css.scss +++ b/app/assets/stylesheets/administrate/overrides.css.scss @@ -1,9 +1,9 @@ -.logout { +.navigation__link--logout { position: absolute; - bottom: 1.5em; + bottom: 3em; } -.login { +.main-content--login { margin-left: auto; margin-right: auto; max-width: 50em; diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb index 4fc94ca..273ff84 100644 --- a/app/controllers/admin/application_controller.rb +++ b/app/controllers/admin/application_controller.rb @@ -1,6 +1,6 @@ # All Administrate controllers inherit from this `Admin::ApplicationController`, # making it the ideal place to put authentication logic or other -# before_filters. +# before_actions. # # If you want to add pagination or other controller-level concerns, # you're free to overwrite the RESTful controller actions. @@ -8,7 +8,7 @@ module Admin class ApplicationController < Administrate::ApplicationController include Monban::ControllerHelpers - before_filter :require_login + before_action :require_login # Override this value to specify the number of elements to display at a time # on index pages. Defaults to 20. diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index 2ed78b7..4f88995 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -1,11 +1,13 @@ module Admin class CategoriesController < Admin::ApplicationController # To customize the behavior of this controller, - # simply overwrite any of the RESTful actions. For example: + # you can overwrite any of the RESTful actions. For example: # # def index # super - # @resources = Category.all.paginate(10, params[:page]) + # @resources = Category. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ module Admin # Category.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 126f048..f058900 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -1,11 +1,13 @@ module Admin class PagesController < Admin::ApplicationController # To customize the behavior of this controller, - # simply overwrite any of the RESTful actions. For example: + # you can overwrite any of the RESTful actions. For example: # # def index # super - # @resources = Page.all.paginate(10, params[:page]) + # @resources = Page. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ module Admin # Page.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/photos_controller.rb b/app/controllers/admin/photos_controller.rb index 1b181ad..bad8773 100644 --- a/app/controllers/admin/photos_controller.rb +++ b/app/controllers/admin/photos_controller.rb @@ -1,11 +1,13 @@ module Admin class PhotosController < Admin::ApplicationController # To customize the behavior of this controller, - # simply overwrite any of the RESTful actions. For example: + # you can overwrite any of the RESTful actions. For example: # # def index # super - # @resources = Photo.all.paginate(10, params[:page]) + # @resources = Photo. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ module Admin # Photo.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions # for more information end end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 43795c3..70251c0 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,11 +1,13 @@ module Admin class UsersController < Admin::ApplicationController # To customize the behavior of this controller, - # simply overwrite any of the RESTful actions. For example: + # you can overwrite any of the RESTful actions. For example: # # def index # super - # @resources = User.all.paginate(10, params[:page]) + # @resources = User. + # page(params[:page]). + # per(10) # end # Define a custom finder by overriding the `find_resource` method: @@ -13,7 +15,7 @@ module Admin # User.find_by!(slug: param) # end - # See https://administrate-docs.herokuapp.com/customizing_controller_actions + # See https://administrate-prototype.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 dac6abc..7e090ea 100644 --- a/app/dashboards/category_dashboard.rb +++ b/app/dashboards/category_dashboard.rb @@ -18,7 +18,7 @@ class CategoryDashboard < Administrate::BaseDashboard base_colour: ColourField, sort: Field::Number, slug: Field::String, - } + }.freeze # COLLECTION_ATTRIBUTES # an array of attributes that will be displayed on the model's index page. @@ -29,7 +29,7 @@ class CategoryDashboard < Administrate::BaseDashboard :name, :base_colour, :photos, - ] + ].freeze # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. @@ -44,25 +44,24 @@ class CategoryDashboard < Administrate::BaseDashboard :photo_id, :sort, :photos, - ] + ].freeze # FORM_ATTRIBUTES # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. FORM_ATTRIBUTES = [ - :photos, :name, + :slug, + :base_colour, :description, :photo_id, - :base_colour, :sort, - :slug, - ] + ].freeze # Overwrite this method to customize how categories are displayed # across all pages of the admin dashboard. # - def display_resource(category) - category.name - end + # def display_resource(category) + # "Category ##{category.id}" + # end end diff --git a/app/dashboards/page_dashboard.rb b/app/dashboards/page_dashboard.rb index aae4e06..ec6fe42 100644 --- a/app/dashboards/page_dashboard.rb +++ b/app/dashboards/page_dashboard.rb @@ -14,7 +14,7 @@ class PageDashboard < Administrate::BaseDashboard content: MarkdownField, created_at: Field::DateTime, updated_at: Field::DateTime, - } + }.freeze # COLLECTION_ATTRIBUTES # an array of attributes that will be displayed on the model's index page. @@ -22,9 +22,9 @@ class PageDashboard < Administrate::BaseDashboard # By default, it's limited to four items to reduce clutter on index pages. # Feel free to add, remove, or rearrange items. COLLECTION_ATTRIBUTES = [ - :title, :name, - ] + :title, + ].freeze # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. @@ -35,7 +35,7 @@ class PageDashboard < Administrate::BaseDashboard :content, :created_at, :updated_at, - ] + ].freeze # FORM_ATTRIBUTES # an array of attributes that will be displayed @@ -44,12 +44,12 @@ class PageDashboard < Administrate::BaseDashboard :name, :title, :content, - ] + ].freeze # Overwrite this method to customize how pages are displayed # across all pages of the admin dashboard. # - def display_resource(page) - page.title - end + # def display_resource(page) + # "Page ##{page.id}" + # end end diff --git a/app/dashboards/photo_dashboard.rb b/app/dashboards/photo_dashboard.rb index 985beed..6573d2b 100644 --- a/app/dashboards/photo_dashboard.rb +++ b/app/dashboards/photo_dashboard.rb @@ -21,7 +21,7 @@ class PhotoDashboard < Administrate::BaseDashboard taken_at: Field::DateTime, views: Field::Number, image: Field::Image, - } + }.freeze # COLLECTION_ATTRIBUTES # an array of attributes that will be displayed on the model's index page. @@ -34,7 +34,7 @@ class PhotoDashboard < Administrate::BaseDashboard :taken_at, :featured, :categories, - ] + ].freeze # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. @@ -52,7 +52,7 @@ class PhotoDashboard < Administrate::BaseDashboard :enabled, :views, :categories, - ] + ].freeze # FORM_ATTRIBUTES # an array of attributes that will be displayed @@ -70,9 +70,12 @@ class PhotoDashboard < Administrate::BaseDashboard :enabled, :views, :categories, - ] + ].freeze - def display_resource(photo) - photo.title - end + # Overwrite this method to customize how photos are displayed + # across all pages of the admin dashboard. + # + # def display_resource(photo) + # "Photo ##{photo.id}" + # end end diff --git a/app/dashboards/user_dashboard.rb b/app/dashboards/user_dashboard.rb index b5dcefb..4a686af 100644 --- a/app/dashboards/user_dashboard.rb +++ b/app/dashboards/user_dashboard.rb @@ -13,7 +13,7 @@ class UserDashboard < Administrate::BaseDashboard password_digest: Field::String, created_at: Field::DateTime, updated_at: Field::DateTime, - } + }.freeze # COLLECTION_ATTRIBUTES # an array of attributes that will be displayed on the model's index page. @@ -22,25 +22,24 @@ class UserDashboard < Administrate::BaseDashboard # Feel free to add, remove, or rearrange items. COLLECTION_ATTRIBUTES = [ :email, - ] + :created_at, + ].freeze # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. SHOW_PAGE_ATTRIBUTES = [ :id, :email, - :password_digest, :created_at, :updated_at, - ] + ].freeze # FORM_ATTRIBUTES # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. FORM_ATTRIBUTES = [ :email, - :password_digest, - ] + ].freeze # Overwrite this method to customize how users are displayed # across all pages of the admin dashboard. diff --git a/app/views/admin/application/_flashes.html.erb b/app/views/admin/application/_flashes.html.erb index ff3a9f5..07d4265 100644 --- a/app/views/admin/application/_flashes.html.erb +++ b/app/views/admin/application/_flashes.html.erb @@ -14,7 +14,7 @@ This partial renders flash messages on every page. <% if flash.any? %>