diff --git a/app/assets/stylesheets/administrate/overrides.css.scss b/app/assets/stylesheets/administrate/overrides.css.scss
index e9c6116..13d5ecb 100644
--- a/app/assets/stylesheets/administrate/overrides.css.scss
+++ b/app/assets/stylesheets/administrate/overrides.css.scss
@@ -1,8 +1,10 @@
-.sign_out {
+.logout {
position: absolute;
bottom: 1.5em;
}
.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 dff706f..4fc94ca 100644
--- a/app/controllers/admin/application_controller.rb
+++ b/app/controllers/admin/application_controller.rb
@@ -4,14 +4,16 @@
#
# If you want to add pagination or other controller-level concerns,
# you're free to overwrite the RESTful controller actions.
-class Admin::ApplicationController < Administrate::ApplicationController
- include Monban::ControllerHelpers
+module Admin
+ class ApplicationController < Administrate::ApplicationController
+ include Monban::ControllerHelpers
- before_filter :require_login
+ before_filter :require_login
- # Override this value to specify the number of elements to display at a time
- # on index pages. Defaults to 20.
- # def records_per_page
- # params[:per_page] || 20
- # end
+ # Override this value to specify the number of elements to display at a time
+ # on index pages. Defaults to 20.
+ # def records_per_page
+ # params[:per_page] || 20
+ # end
+ end
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index c9ecd45..25ccf0b 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,5 +1,5 @@
class SessionsController < ApplicationController
- layout 'administrate/login'
+ layout 'admin/login'
skip_before_action :require_login, only: [:new, :create]
diff --git a/app/dashboards/category_dashboard.rb b/app/dashboards/category_dashboard.rb
index 454dc49..f2027c2 100644
--- a/app/dashboards/category_dashboard.rb
+++ b/app/dashboards/category_dashboard.rb
@@ -8,15 +8,16 @@ class CategoryDashboard < Administrate::BaseDashboard
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
+ photos: Field::HasMany,
id: Field::Number,
name: Field::String,
- slug: Field::String,
description: Field::Text,
created_at: Field::DateTime,
updated_at: Field::DateTime,
- base_colour: Field::ColourField,
+ photo_id: Field::Number,
+ base_colour: Field::String,
sort: Field::Number,
- photos: Field::HasMany,
+ slug: Field::String,
}
# COLLECTION_ATTRIBUTES
@@ -25,25 +26,43 @@ class CategoryDashboard < 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 = [
- :base_colour,
:name,
- :description,
+ :base_colour,
:photos,
]
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
- SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
+ SHOW_PAGE_ATTRIBUTES = [
+ :id,
+ :name,
+ :slug,
+ :base_colour,
+ :description,
+ :created_at,
+ :updated_at,
+ :photo_id,
+ :sort,
+ :photos,
+ ]
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
+ :photos,
:name,
- :slug,
:description,
+ :photo_id,
:base_colour,
:sort,
- :photos,
+ :slug,
]
+
+ # Overwrite this method to customize how categories are displayed
+ # across all pages of the admin dashboard.
+ #
+ def display_resource(category)
+ category.name
+ end
end
diff --git a/app/dashboards/page_dashboard.rb b/app/dashboards/page_dashboard.rb
index fd7a849..c010d9b 100644
--- a/app/dashboards/page_dashboard.rb
+++ b/app/dashboards/page_dashboard.rb
@@ -8,10 +8,10 @@ class PageDashboard < Administrate::BaseDashboard
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
- title: Field::String,
- content: Field::MarkdownField,
id: Field::Number,
name: Field::String,
+ title: Field::String,
+ content: Field::Text,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}
@@ -22,14 +22,20 @@ 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 = [
- :name,
:title,
- :content,
+ :name,
]
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
- SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
+ SHOW_PAGE_ATTRIBUTES = [
+ :id,
+ :name,
+ :title,
+ :content,
+ :created_at,
+ :updated_at,
+ ]
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
@@ -39,4 +45,11 @@ class PageDashboard < Administrate::BaseDashboard
:title,
:content,
]
+
+ # Overwrite this method to customize how pages are displayed
+ # across all pages of the admin dashboard.
+ #
+ def display_resource(page)
+ page.title
+ end
end
diff --git a/app/dashboards/photo_dashboard.rb b/app/dashboards/photo_dashboard.rb
index 855f48f..df69416 100644
--- a/app/dashboards/photo_dashboard.rb
+++ b/app/dashboards/photo_dashboard.rb
@@ -8,19 +8,21 @@ class PhotoDashboard < Administrate::BaseDashboard
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
- title: Field::String,
- image: Field::Image,
- description: Field::Text,
+ categories: Field::HasMany,
+ id: Field::Number,
flickr_url: Field::String,
- taken_at: Field::DateTime,
created_at: Field::DateTime,
updated_at: Field::DateTime,
+ title: Field::String,
+ description: Field::Text,
+ sort: Field::Number,
featured: Field::Boolean,
enabled: Field::Boolean,
- id: Field::Number,
- sort: Field::Number,
+ taken_at: Field::DateTime,
views: Field::Number,
- categories: Field::HasMany,
+ image_uid: Field::String,
+ image_name: Field::String,
+ image_cloudinary_id: Field::String,
}
# COLLECTION_ATTRIBUTES
@@ -29,28 +31,54 @@ class PhotoDashboard < 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 = [
- :image,
:title,
:taken_at,
- :views,
+ :featured,
+ :categories,
]
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
- SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
+ SHOW_PAGE_ATTRIBUTES = [
+ :categories,
+ :id,
+ :flickr_url,
+ :created_at,
+ :updated_at,
+ :title,
+ :description,
+ :sort,
+ :featured,
+ :enabled,
+ :taken_at,
+ :views,
+ :image_uid,
+ :image_name,
+ :image_cloudinary_id,
+ ]
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
- :title,
- :image,
- :description,
+ :categories,
:flickr_url,
- :taken_at,
+ :title,
+ :description,
:sort,
:featured,
:enabled,
- :categories,
+ :taken_at,
+ :views,
+ :image_uid,
+ :image_name,
+ :image_cloudinary_id,
]
+
+ # 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 a387992..b5dcefb 100644
--- a/app/dashboards/user_dashboard.rb
+++ b/app/dashboards/user_dashboard.rb
@@ -21,15 +21,18 @@ class UserDashboard < 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 = [
- :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
+ SHOW_PAGE_ATTRIBUTES = [
+ :id,
+ :email,
+ :password_digest,
+ :created_at,
+ :updated_at,
+ ]
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
@@ -38,4 +41,11 @@ class UserDashboard < Administrate::BaseDashboard
:email,
:password_digest,
]
+
+ # Overwrite this method to customize how users are displayed
+ # across all pages of the admin dashboard.
+ #
+ # def display_resource(user)
+ # "User ##{user.id}"
+ # end
end
diff --git a/app/fields/colour_field.rb b/app/fields/colour_field.rb
deleted file mode 100644
index 9e74533..0000000
--- a/app/fields/colour_field.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require "administrate/fields/base"
-
-class ColourField < Administrate::Field::Base
-end
diff --git a/app/fields/markdown_field.rb b/app/fields/markdown_field.rb
deleted file mode 100644
index 67f9a0a..0000000
--- a/app/fields/markdown_field.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-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/application/_flashes.html.erb b/app/views/admin/application/_flashes.html.erb
new file mode 100644
index 0000000..ff3a9f5
--- /dev/null
+++ b/app/views/admin/application/_flashes.html.erb
@@ -0,0 +1,20 @@
+<%#
+# Flash Partial
+
+This partial renders flash messages on every page.
+
+## Relevant Helpers:
+
+- `flash`:
+ Returns a hash,
+ where the keys are the type of flash (alert, error, notice, etc)
+ and the values are the message to be displayed.
+%>
+
+<% if flash.any? %>
+
+ <% flash.each do |key, value| -%>
+
<%= value %>
+ <% end -%>
+
+<% end %>
diff --git a/app/views/admin/application/_javascript.html.erb b/app/views/admin/application/_javascript.html.erb
new file mode 100644
index 0000000..499323b
--- /dev/null
+++ b/app/views/admin/application/_javascript.html.erb
@@ -0,0 +1,19 @@
+<%#
+# Javascript Partial
+
+This partial imports the necessary javascript on each page.
+By default, it includes the application JS,
+but each page can define additional JS sources
+by providing a `content_for(:javascript)` block.
+%>
+
+<%= javascript_include_tag "administrate/application" %>
+
+<%= yield :javascript %>
+
+<% if Rails.env.test? %>
+ <%= javascript_tag do %>
+ $.fx.off = true;
+ $.ajaxSetup({ async: false });
+ <% end %>
+<% end %>
diff --git a/app/views/admin/application/_sidebar.html.erb b/app/views/admin/application/_sidebar.html.erb
new file mode 100644
index 0000000..aa2a5fd
--- /dev/null
+++ b/app/views/admin/application/_sidebar.html.erb
@@ -0,0 +1,20 @@
+<%#
+# 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
+%>
+
+
diff --git a/app/views/admin/applications/_collection.html.erb b/app/views/admin/applications/_collection.html.erb
deleted file mode 100644
index a11e8fd..0000000
--- a/app/views/admin/applications/_collection.html.erb
+++ /dev/null
@@ -1,74 +0,0 @@
-<%#
-# 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
-%>
-
-
-
-
- <% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
- |
- <%= link_to(params.merge(
- collection_presenter.order_params_for(attr_name)
- )) do %>
- <%= attr_name.to_s.titleize %>
-
- <% if collection_presenter.ordered_by?(attr_name) %>
-
- <%= inline_svg("administrate/sort_arrow.svg") %>
-
- <% end %>
- <% end %>
- |
- <% end %>
- |
-
-
-
-
- <% resources.each do |resource| %>
-
- <% collection_presenter.attributes_for(resource).each do |attribute| %>
- |
- <%= render_field attribute %>
- |
- <% end %>
-
- <%= link_to(
- t("administrate.actions.edit"),
- [:edit, Administrate::NAMESPACE, resource],
- class: "action-edit",
- ) %> |
-
- <%= link_to(
- t("administrate.actions.destroy"),
- [Administrate::NAMESPACE, resource],
- class: "table__action--destroy",
- method: :delete,
- data: { confirm: t("administrate.actions.confirm") }
- ) %> |
-
- <% end %>
-
-
diff --git a/app/views/admin/applications/_form.html.erb b/app/views/admin/applications/_form.html.erb
deleted file mode 100644
index 2cea728..0000000
--- a/app/views/admin/applications/_form.html.erb
+++ /dev/null
@@ -1,44 +0,0 @@
-<%#
-# 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:
-
-
-
- <% page.resource.errors.full_messages.each do |message| %>
- - <%= message %>
- <% end %>
-
-
- <% end %>
-
-
-
-
- <%= f.submit %>
-
-<% end %>
diff --git a/app/views/admin/applications/edit.html.erb b/app/views/admin/applications/edit.html.erb
deleted file mode 100644
index b604a5b..0000000
--- a/app/views/admin/applications/edit.html.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-<%#
-# 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}" } %>
-
-
-
-<%= render "form", page: page %>
diff --git a/app/views/admin/applications/index.html.erb b/app/views/admin/applications/index.html.erb
deleted file mode 100644
index c99dd6b..0000000
--- a/app/views/admin/applications/index.html.erb
+++ /dev/null
@@ -1,55 +0,0 @@
-<%#
-# 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 %>
-
-<% end %>
-
-
-
-<%= 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
deleted file mode 100644
index 46a7063..0000000
--- a/app/views/admin/applications/new.html.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-<%#
-# 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}" } %>
-
-
-
-<%= render 'form', page: page %>
diff --git a/app/views/admin/applications/show.html.erb b/app/views/admin/applications/show.html.erb
deleted file mode 100644
index 7c01eaf..0000000
--- a/app/views/admin/applications/show.html.erb
+++ /dev/null
@@ -1,37 +0,0 @@
-<%#
-# 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 } %>
-
-
-
-
- <% page.attributes.each do |attribute| %>
- - <%= attribute.name.titleize %>
-
- - <%= render_field attribute %>
- <% end %>
-
diff --git a/app/views/layouts/admin/application.html.erb b/app/views/layouts/admin/application.html.erb
new file mode 100644
index 0000000..07ef1bb
--- /dev/null
+++ b/app/views/layouts/admin/application.html.erb
@@ -0,0 +1,48 @@
+<%#
+# Application Layout
+
+This view template is used as the layout
+for every page that Administrate generates.
+
+By default, it renders:
+- Sidebar for navigation
+- Content for a search bar
+ (if provided by a `content_for` block in a nested page)
+- Flashes
+- Links to stylesheets and Javascripts
+%>
+
+
+
+
+
+
+
+ <%= content_for(:title) %> | <%= Rails.application.class.parent_name.titlecase %>
+ <%= stylesheet_link_tag "administrate/application", media: "all" %>
+ <%= stylesheet_link_tag "administrate/overrides", media: "all" %>
+ <%= csrf_meta_tags %>
+
+
+
+
+
+
+
+
+
+ <%= content_for(:search) %>
+ <%= render "flashes" -%>
+ <%= yield %>
+
+
+
+
+ <%= render "javascript" %>
+
+
diff --git a/app/views/layouts/admin/login.html.erb b/app/views/layouts/admin/login.html.erb
new file mode 100644
index 0000000..48a875b
--- /dev/null
+++ b/app/views/layouts/admin/login.html.erb
@@ -0,0 +1,40 @@
+<%#
+# Application Layout
+
+This view template is used as the layout
+for every page that Administrate generates.
+
+By default, it renders:
+- Sidebar for navigation
+- Content for a search bar
+ (if provided by a `content_for` block in a nested page)
+- Flashes
+- Links to stylesheets and Javascripts
+%>
+
+
+
+
+
+
+
+ <%= Rails.application.class.parent_name.titlecase %>
+ <%= stylesheet_link_tag "administrate/application", media: "all" %>
+ <%= stylesheet_link_tag "administrate/overrides", media: "all" %>
+ <%= csrf_meta_tags %>
+
+
+
+
+
+
+
+ <%= render "admin/application/flashes" -%>
+ <%= yield %>
+
+
+
+
+ <%= render "admin/application/javascript" %>
+
+
diff --git a/app/views/layouts/administrate/application.html.erb b/app/views/layouts/administrate/application.html.erb
deleted file mode 100644
index f1ea89d..0000000
--- a/app/views/layouts/administrate/application.html.erb
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
- <%= content_for(:title) %> | <%= Rails.application.class.parent_name.titlecase %>
- <%= stylesheet_link_tag "//fonts.googleapis.com/css?family=Lato:300,400,900", media: "all" %>
- <%= stylesheet_link_tag "administrate/application", media: "all" %>
- <%= stylesheet_link_tag "administrate/overrides", media: "all" %>
- <%= csrf_meta_tags %>
-
-
-
-
-
-
-
- <%= content_for(:search) %>
-
- <%= render "flashes" -%>
- <%= yield %>
-
-
-
-
- <%= render "javascript" %>
-
-
diff --git a/app/views/layouts/administrate/login.html.erb b/app/views/layouts/administrate/login.html.erb
deleted file mode 100644
index b494e67..0000000
--- a/app/views/layouts/administrate/login.html.erb
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
- <%= Rails.application.class.parent_name.titlecase %>
- <%= stylesheet_link_tag "//fonts.googleapis.com/css?family=Lato:300,400,900", media: "all" %>
- <%= stylesheet_link_tag "administrate/application", media: "all" %>
- <%= stylesheet_link_tag "administrate/overrides", media: "all" %>
- <%= csrf_meta_tags %>
-
-
-
-
-
-
- <%= render "administrate/application/flashes" -%>
- <%= yield %>
-
-
-
-
-
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
index 7afd523..1088c1a 100644
--- a/app/views/sessions/new.html.erb
+++ b/app/views/sessions/new.html.erb
@@ -4,14 +4,22 @@
<%= form_for :session, url: session_path do |form| %>