Skip to content

Commit

Permalink
Adding a generator for the AdminController
Browse files Browse the repository at this point in the history
  • Loading branch information
carolyncole committed Sep 22, 2016
1 parent ff8cd23 commit f3fd695
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/generators/curation_concerns/admin_dashboard_generator.rb
@@ -0,0 +1,15 @@
require 'rails/generators'

module CurationConcerns
class AdminDashboardGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)

desc 'This generator makes the following changes to your application:
1. Creates an admin dashboard controller.
'

def create_controller
copy_file 'app/controllers/curation_concerns/admin_controller.rb', 'app/controllers/curation_concerns/admin_controller.rb'
end
end
end
2 changes: 2 additions & 0 deletions lib/generators/curation_concerns/install_generator.rb
Expand Up @@ -26,6 +26,8 @@ def run_required_generators
generate 'hydra:head -f'
say_status('warning', '[CurationConcerns] GENERATING CURATION_CONCERNS MODELS', :yellow)
generate "curation_concerns:models#{options[:force] ? ' -f' : ''}"
say_status('warning', '[CurationConcerns] GENERATING CURATION_CONCERNS ADMIN DASHBOARD', :yellow)
generate "curation_concerns:admin_dashboard#{options[:force] ? ' -f' : ''}"
end

def inject_application_controller_behavior
Expand Down
@@ -0,0 +1,61 @@
module CurationConcerns
# Controller for displaying the Administration console.
#
# This controller provides a framework for reading in a configuration
# and displaying administrative widgets on an admistrative dashboard.
#
# This configuration is included in config/initializers/curation_concerns.rb
#
# The administrative dashbord is divided into two columns, a left side menu
# and the right action display.
#
# The menu is configured by listing actions in display order.
#
# The actions are then defined in the configuration and
# automatically display the partials listed. You can override
# this default behavior by implementing your action in the controller.
#
# The configuration also includes named data sources that can be used in
# any view to access system level data.
#
# Example Configuration:
# @dashboard_configuration ||= {
# menu: {
# index: {},
# other_action: {},
# complex_action: {}
# },
# actions: {
# index: {
# partials: [
# "total_objects"
# ]
# },
# other_action: {
# partials: [
# "other_objects_view"
# ]
# },
# complex_action: {
# # rendered in the action
# }
# },
# data_sources: {
# resource_stats: CurationConcerns::ResourceStatisticsSource
# }
# }
#
# Example AdminController
# class AdminController < ApplicationController
# include CurationConcerns::AdminControllerBehavior
#
# def complex_action
# # do complex stuff and render how I want
# ...
# end
# end
#
class AdminController < ApplicationController
include CurationConcerns::AdminControllerBehavior
end
end

0 comments on commit f3fd695

Please sign in to comment.