mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Update to the newest Administrate
This commit is contained in:
parent
83f7e28a92
commit
c9109312c9
1
Gemfile
1
Gemfile
@ -53,6 +53,7 @@ group :production do
|
||||
end
|
||||
|
||||
gem 'administrate'
|
||||
gem 'administrate-field-image'
|
||||
gem 'dragonfly'
|
||||
gem 'dragonfly-s3_data_store'
|
||||
gem 'kaminari'
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -14,7 +14,7 @@ This partial renders flash messages on every page.
|
||||
<% if flash.any? %>
|
||||
<div class="flashes">
|
||||
<% flash.each do |key, value| -%>
|
||||
<div class="flash flash--<%= key %>"><%= value %></div>
|
||||
<div class="flash flash-<%= key %>"><%= value %></div>
|
||||
<% end -%>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@ -7,7 +7,9 @@ but each page can define additional JS sources
|
||||
by providing a `content_for(:javascript)` block.
|
||||
%>
|
||||
|
||||
<%= javascript_include_tag "administrate/application" %>
|
||||
<% Administrate::Engine.javascripts.each do |js_path| %>
|
||||
<%= javascript_include_tag js_path %>
|
||||
<% end %>
|
||||
|
||||
<%= yield :javascript %>
|
||||
|
||||
|
||||
25
app/views/admin/application/_navigation.html.erb
Normal file
25
app/views/admin/application/_navigation.html.erb
Normal file
@ -0,0 +1,25 @@
|
||||
<%#
|
||||
# Navigation
|
||||
|
||||
This partial is used to display the navigation in Administrate.
|
||||
By default, the navigation contains navigation links
|
||||
for all resources in the admin dashboard,
|
||||
as defined by the routes in the `admin/` namespace
|
||||
%>
|
||||
|
||||
<nav class="navigation" role="navigation">
|
||||
<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
|
||||
<%= link_to(
|
||||
display_resource_name(resource),
|
||||
[namespace, resource.path],
|
||||
class: "navigation__link navigation__link--#{nav_link_state(resource)}"
|
||||
) %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to(
|
||||
"Log out",
|
||||
session_path,
|
||||
method: :delete,
|
||||
class: "navigation__link navigation__link--logout",
|
||||
) %>
|
||||
</nav>
|
||||
@ -1,20 +0,0 @@
|
||||
<%#
|
||||
# Sidebar
|
||||
|
||||
This partial is used to display the sidebar in Administrate.
|
||||
By default, the sidebar contains navigation links
|
||||
for all resources in the admin dashboard,
|
||||
as defined by the routes in the `admin/` namespace
|
||||
%>
|
||||
|
||||
<ul class="sidebar__list">
|
||||
<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
|
||||
<li>
|
||||
<%= link_to(
|
||||
display_resource_name(resource),
|
||||
[namespace, resource],
|
||||
class: "sidebar__link sidebar__link--#{nav_link_state(resource)}"
|
||||
) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
16
app/views/admin/application/_stylesheet.html.erb
Normal file
16
app/views/admin/application/_stylesheet.html.erb
Normal file
@ -0,0 +1,16 @@
|
||||
<%#
|
||||
# Stylesheet Partial
|
||||
|
||||
This partial imports the necessary stylesheets on each page.
|
||||
By default, it includes the application CSS,
|
||||
but each page can define additional CSS sources
|
||||
by providing a `content_for(:stylesheet)` block.
|
||||
%>
|
||||
|
||||
<% Administrate::Engine.stylesheets.each do |css_path| %>
|
||||
<%= stylesheet_link_tag css_path %>
|
||||
<% end %>
|
||||
|
||||
<%= stylesheet_link_tag "administrate/overrides", media: "all" %>
|
||||
|
||||
<%= yield :stylesheet %>
|
||||
@ -5,42 +5,35 @@ This view template is used as the layout
|
||||
for every page that Administrate generates.
|
||||
|
||||
By default, it renders:
|
||||
- Sidebar for navigation
|
||||
- Navigation
|
||||
- Content for a search bar
|
||||
(if provided by a `content_for` block in a nested page)
|
||||
- Flashes
|
||||
- Links to stylesheets and Javascripts
|
||||
- Links to stylesheets and JavaScripts
|
||||
%>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%= I18n.locale %>">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="ROBOTS" content="NOODP" />
|
||||
<meta name="viewport" content="initial-scale=1" />
|
||||
<title><%= content_for(:title) %> | <%= Rails.application.class.parent_name.titlecase %></title>
|
||||
<%= stylesheet_link_tag "administrate/application", media: "all" %>
|
||||
<%= stylesheet_link_tag "administrate/overrides", media: "all" %>
|
||||
<meta charset="utf-8">
|
||||
<meta name="ROBOTS" content="NOODP">
|
||||
<meta name="viewport" content="initial-scale=1">
|
||||
<title>
|
||||
<%= content_for(:title) %> - <%= Rails.application.class.parent_name.titlecase %>
|
||||
</title>
|
||||
<%= render "stylesheet" %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= render "icons" %>
|
||||
|
||||
<div class="app-container">
|
||||
|
||||
<div class="sidebar">
|
||||
<%= render "sidebar" -%>
|
||||
<%= content_tag :div, class: :logout do %>
|
||||
<%= link_to "Log out", session_path, method: :delete %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render "navigation" -%>
|
||||
|
||||
<main class="main-content" role="main">
|
||||
<%= content_for(:search) %>
|
||||
<%= render "flashes" -%>
|
||||
<%= yield %>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
|
||||
<%= render "javascript" %>
|
||||
|
||||
@ -18,21 +18,19 @@ By default, it renders:
|
||||
<meta charset="utf-8" />
|
||||
<meta name="ROBOTS" content="NOODP" />
|
||||
<meta name="viewport" content="initial-scale=1" />
|
||||
<title><%= Rails.application.class.parent_name.titlecase %></title>
|
||||
<%= stylesheet_link_tag "administrate/application", media: "all" %>
|
||||
<%= stylesheet_link_tag "administrate/overrides", media: "all" %>
|
||||
<title>
|
||||
<%= content_for(:title) %> - <%= Rails.application.class.parent_name.titlecase %>
|
||||
</title>
|
||||
<%= render "admin/application/stylesheet" %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="app-container">
|
||||
|
||||
<main class="main-content login" role="main">
|
||||
<main class="main-content main-content--login" role="main">
|
||||
<%= render "admin/application/flashes" -%>
|
||||
<%= yield %>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
|
||||
<%= render "admin/application/javascript" %>
|
||||
|
||||
@ -1,29 +1,31 @@
|
||||
<header class="header">
|
||||
<h1>Sign In</h1>
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title" id="page-title">Sign In</h1>
|
||||
</header>
|
||||
|
||||
<%= form_for :session, url: session_path do |form| %>
|
||||
<div class="form-inputs">
|
||||
<div class="field-unit field-unit--string">
|
||||
<div class="field-unit__label">
|
||||
<%= form.label :email %>
|
||||
<section class="main-content__body main-content__body--flush">
|
||||
<%= form_for :session, url: session_path do |form| %>
|
||||
<div class="form-inputs">
|
||||
<div class="field-unit field-unit--string">
|
||||
<div class="field-unit__label">
|
||||
<%= form.label :email %>
|
||||
</div>
|
||||
<div class="field-unit__field">
|
||||
<%= form.email_field :email %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field-unit__field">
|
||||
<%= form.email_field :email %>
|
||||
|
||||
<div class="field-unit field-unit--string">
|
||||
<div class="field-unit__label">
|
||||
<%= form.label :password %>
|
||||
</div>
|
||||
<div class="field-unit__field">
|
||||
<%= form.password_field :password %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-unit field-unit--string">
|
||||
<div class="field-unit__label">
|
||||
<%= form.label :password %>
|
||||
</div>
|
||||
<div class="field-unit__field">
|
||||
<%= form.password_field :password %>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<%= form.submit "Sign in" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= form.submit "Sign in" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user