saulolso-activeadmin 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +32 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.rdoc +76 -0
- data/Gemfile +26 -0
- data/LICENSE +25 -0
- data/README.rdoc +450 -0
- data/Rakefile +100 -0
- data/activeadmin.gemspec +28 -0
- data/cucumber.yml +2 -0
- data/features/comments/commenting.feature +99 -0
- data/features/comments/viewing_index.feature +19 -0
- data/features/dashboard.feature +26 -0
- data/features/edit_page.feature +77 -0
- data/features/first_boot.feature +16 -0
- data/features/global_navigation.feature +30 -0
- data/features/index/format_as_csv.feature +45 -0
- data/features/index/formats.feature +10 -0
- data/features/index/index_as_block.feature +15 -0
- data/features/index/index_as_blog.feature +50 -0
- data/features/index/index_as_grid.feature +45 -0
- data/features/index/index_as_table.feature +79 -0
- data/features/index/index_scopes.feature +52 -0
- data/features/index/pagination.feature +23 -0
- data/features/menu.feature +26 -0
- data/features/new_page.feature +75 -0
- data/features/registering_assets.feature +35 -0
- data/features/registering_resources.feature +33 -0
- data/features/show/default_content.feature +43 -0
- data/features/show/page_title.feature +33 -0
- data/features/sidebar_sections.feature +127 -0
- data/features/specifying_actions.feature +60 -0
- data/features/step_definitions/action_item_steps.rb +7 -0
- data/features/step_definitions/additional_web_steps.rb +67 -0
- data/features/step_definitions/asset_steps.rb +7 -0
- data/features/step_definitions/attribute_steps.rb +15 -0
- data/features/step_definitions/comment_steps.rb +8 -0
- data/features/step_definitions/configuration_steps.rb +31 -0
- data/features/step_definitions/dashboard_steps.rb +11 -0
- data/features/step_definitions/factory_steps.rb +28 -0
- data/features/step_definitions/flash_steps.rb +3 -0
- data/features/step_definitions/format_steps.rb +34 -0
- data/features/step_definitions/index_scope_steps.rb +20 -0
- data/features/step_definitions/menu_steps.rb +7 -0
- data/features/step_definitions/pagination_steps.rb +8 -0
- data/features/step_definitions/sidebar_steps.rb +11 -0
- data/features/step_definitions/tab_steps.rb +3 -0
- data/features/step_definitions/user_steps.rb +20 -0
- data/features/step_definitions/web_steps.rb +219 -0
- data/features/sti_resource.feature +49 -0
- data/features/support/env.rb +92 -0
- data/features/support/paths.rb +48 -0
- data/features/users/logging_in.feature +34 -0
- data/features/users/logging_out.feature +13 -0
- data/lib/active_admin/abstract_view_factory.rb +95 -0
- data/lib/active_admin/action_items.rb +37 -0
- data/lib/active_admin/application.rb +204 -0
- data/lib/active_admin/arbre/attributes.rb +20 -0
- data/lib/active_admin/arbre/class_list.rb +28 -0
- data/lib/active_admin/arbre/collection.rb +27 -0
- data/lib/active_admin/arbre/context.rb +8 -0
- data/lib/active_admin/arbre/core_extensions.rb +5 -0
- data/lib/active_admin/arbre/document.rb +42 -0
- data/lib/active_admin/arbre/element.rb +151 -0
- data/lib/active_admin/arbre/html.rb +84 -0
- data/lib/active_admin/arbre/html5_elements.rb +47 -0
- data/lib/active_admin/arbre/tag.rb +137 -0
- data/lib/active_admin/arbre/text_node.rb +35 -0
- data/lib/active_admin/arbre.rb +23 -0
- data/lib/active_admin/asset_registration.rb +34 -0
- data/lib/active_admin/callbacks.rb +87 -0
- data/lib/active_admin/comments/comment.rb +21 -0
- data/lib/active_admin/comments/configuration.rb +18 -0
- data/lib/active_admin/comments/namespace_helper.rb +14 -0
- data/lib/active_admin/comments/resource_helper.rb +17 -0
- data/lib/active_admin/comments/show_page_helper.rb +23 -0
- data/lib/active_admin/comments/views/active_admin_comment.rb +0 -0
- data/lib/active_admin/comments/views/active_admin_comments.rb +82 -0
- data/lib/active_admin/comments/views.rb +3 -0
- data/lib/active_admin/comments.rb +88 -0
- data/lib/active_admin/component.rb +22 -0
- data/lib/active_admin/controller_action.rb +12 -0
- data/lib/active_admin/csv_builder.rb +45 -0
- data/lib/active_admin/dashboards/dashboard_controller.rb +47 -0
- data/lib/active_admin/dashboards/section.rb +34 -0
- data/lib/active_admin/dashboards.rb +48 -0
- data/lib/active_admin/devise.rb +43 -0
- data/lib/active_admin/dsl.rb +215 -0
- data/lib/active_admin/event.rb +31 -0
- data/lib/active_admin/form_builder.rb +109 -0
- data/lib/active_admin/helpers/optional_display.rb +34 -0
- data/lib/active_admin/iconic/icons.rb +142 -0
- data/lib/active_admin/iconic.rb +51 -0
- data/lib/active_admin/locales/da.yml +26 -0
- data/lib/active_admin/locales/en.yml +34 -0
- data/lib/active_admin/locales/es.yml +34 -0
- data/lib/active_admin/locales/pt.yml +34 -0
- data/lib/active_admin/menu.rb +42 -0
- data/lib/active_admin/menu_item.rb +73 -0
- data/lib/active_admin/namespace.rb +198 -0
- data/lib/active_admin/page_config.rb +15 -0
- data/lib/active_admin/renderer.rb +87 -0
- data/lib/active_admin/resource/belongs_to.rb +31 -0
- data/lib/active_admin/resource.rb +229 -0
- data/lib/active_admin/resource_controller/action_builder.rb +21 -0
- data/lib/active_admin/resource_controller/actions.rb +79 -0
- data/lib/active_admin/resource_controller/callbacks.rb +47 -0
- data/lib/active_admin/resource_controller/collection.rb +144 -0
- data/lib/active_admin/resource_controller/filters.rb +58 -0
- data/lib/active_admin/resource_controller/form.rb +42 -0
- data/lib/active_admin/resource_controller/menu.rb +29 -0
- data/lib/active_admin/resource_controller/page_configurations.rb +53 -0
- data/lib/active_admin/resource_controller/scoping.rb +36 -0
- data/lib/active_admin/resource_controller/sidebars.rb +38 -0
- data/lib/active_admin/resource_controller.rb +119 -0
- data/lib/active_admin/router.rb +85 -0
- data/lib/active_admin/scope.rb +17 -0
- data/lib/active_admin/sidebar.rb +43 -0
- data/lib/active_admin/stylesheets/active_admin/_comments.scss +40 -0
- data/lib/active_admin/stylesheets/active_admin/_flash_messages.scss +13 -0
- data/lib/active_admin/stylesheets/active_admin/_forms.scss +168 -0
- data/lib/active_admin/stylesheets/active_admin/_header.scss +108 -0
- data/lib/active_admin/stylesheets/active_admin/_typography.scss +100 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_all.scss +8 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_buttons.scss +27 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_gradients.scss +21 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_icons.scss +20 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_reset.scss +165 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_rounded.scss +43 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_sections.scss +27 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_shadows.scss +21 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_variables.scss +12 -0
- data/lib/active_admin/stylesheets/active_admin.scss +429 -0
- data/lib/active_admin/version.rb +3 -0
- data/lib/active_admin/view_factory.rb +21 -0
- data/lib/active_admin/view_helpers/active_admin_application_helper.rb +12 -0
- data/lib/active_admin/view_helpers/assigns_with_indifferent_access_helper.rb +7 -0
- data/lib/active_admin/view_helpers/auto_link_helper.rb +42 -0
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +29 -0
- data/lib/active_admin/view_helpers/display_helper.rb +38 -0
- data/lib/active_admin/view_helpers/filter_form_helper.rb +185 -0
- data/lib/active_admin/view_helpers/form_helper.rb +12 -0
- data/lib/active_admin/view_helpers/icon_helper.rb +12 -0
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +26 -0
- data/lib/active_admin/view_helpers/renderer_helper.rb +29 -0
- data/lib/active_admin/view_helpers/sidebar_helper.rb +15 -0
- data/lib/active_admin/view_helpers/table_helper.rb +12 -0
- data/lib/active_admin/view_helpers/title_helper.rb +11 -0
- data/lib/active_admin/view_helpers/view_factory_helper.rb +11 -0
- data/lib/active_admin/view_helpers.rb +23 -0
- data/lib/active_admin/views/action_items.rb +17 -0
- data/lib/active_admin/views/components/attributes_table.rb +66 -0
- data/lib/active_admin/views/components/columns.rb +47 -0
- data/lib/active_admin/views/components/paginated_collection.rb +92 -0
- data/lib/active_admin/views/components/panel.rb +26 -0
- data/lib/active_admin/views/components/scopes.rb +70 -0
- data/lib/active_admin/views/components/sidebar_section.rb +30 -0
- data/lib/active_admin/views/components/status_tag.rb +55 -0
- data/lib/active_admin/views/components/table_for.rb +193 -0
- data/lib/active_admin/views/dashboard_section_renderer.rb +19 -0
- data/lib/active_admin/views/header_renderer.rb +37 -0
- data/lib/active_admin/views/index_as_block.rb +24 -0
- data/lib/active_admin/views/index_as_blog.rb +89 -0
- data/lib/active_admin/views/index_as_grid.rb +49 -0
- data/lib/active_admin/views/index_as_table.rb +75 -0
- data/lib/active_admin/views/pages/base.rb +144 -0
- data/lib/active_admin/views/pages/dashboard.rb +59 -0
- data/lib/active_admin/views/pages/edit.rb +27 -0
- data/lib/active_admin/views/pages/index.rb +66 -0
- data/lib/active_admin/views/pages/new.rb +27 -0
- data/lib/active_admin/views/pages/show.rb +56 -0
- data/lib/active_admin/views/tabs_renderer.rb +58 -0
- data/lib/active_admin/views/templates/active_admin/dashboard/index.html.arb +1 -0
- data/lib/active_admin/views/templates/active_admin/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/lib/active_admin/views/templates/active_admin/devise/mailer/unlock_instructions.html.erb +7 -0
- data/lib/active_admin/views/templates/active_admin/devise/passwords/edit.html.erb +16 -0
- data/lib/active_admin/views/templates/active_admin/devise/passwords/new.html.erb +14 -0
- data/lib/active_admin/views/templates/active_admin/devise/sessions/new.html.erb +18 -0
- data/lib/active_admin/views/templates/active_admin/devise/shared/_links.erb +20 -0
- data/lib/active_admin/views/templates/active_admin/devise/unlocks/new.html.erb +12 -0
- data/lib/active_admin/views/templates/active_admin/resource/edit.html.arb +1 -0
- data/lib/active_admin/views/templates/active_admin/resource/index.csv.erb +20 -0
- data/lib/active_admin/views/templates/active_admin/resource/index.html.arb +1 -0
- data/lib/active_admin/views/templates/active_admin/resource/new.html.arb +1 -0
- data/lib/active_admin/views/templates/active_admin/resource/show.html.arb +1 -0
- data/lib/active_admin/views/templates/layouts/active_admin.html.erb +39 -0
- data/lib/active_admin/views/templates/layouts/active_admin_logged_out.html.erb +31 -0
- data/lib/active_admin/views.rb +8 -0
- data/lib/active_admin.rb +71 -0
- data/lib/activeadmin.rb +1 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +49 -0
- data/lib/generators/active_admin/install/install_generator.rb +46 -0
- data/lib/generators/active_admin/install/templates/active_admin.js +51 -0
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +78 -0
- data/lib/generators/active_admin/install/templates/active_admin_vendor.js +382 -0
- data/lib/generators/active_admin/install/templates/dashboards.rb +38 -0
- data/lib/generators/active_admin/install/templates/images/admin_notes_icon.png +0 -0
- data/lib/generators/active_admin/install/templates/images/loading.gif +0 -0
- data/lib/generators/active_admin/install/templates/images/nested_menu_arrow.gif +0 -0
- data/lib/generators/active_admin/install/templates/images/nested_menu_arrow_dark.gif +0 -0
- data/lib/generators/active_admin/install/templates/images/orderable.png +0 -0
- data/lib/generators/active_admin/install/templates/migrations/1_create_admin_notes.rb +16 -0
- data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +25 -0
- data/lib/generators/active_admin/resource/resource_generator.rb +16 -0
- data/lib/generators/active_admin/resource/templates/admin.rb +3 -0
- data/spec/integration/belongs_to_spec.rb +42 -0
- data/spec/spec_helper.rb +156 -0
- data/spec/support/integration_example_group.rb +33 -0
- data/spec/support/rails_template.rb +32 -0
- data/spec/support/rails_template_with_data.rb +32 -0
- data/spec/support/templates/cucumber.rb +24 -0
- data/spec/unit/abstract_view_factory_spec.rb +79 -0
- data/spec/unit/action_builder_spec.rb +88 -0
- data/spec/unit/action_items_spec.rb +27 -0
- data/spec/unit/application_spec.rb +67 -0
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +54 -0
- data/spec/unit/arbre/html/element_spec.rb +224 -0
- data/spec/unit/arbre/html/tag_attributes_spec.rb +61 -0
- data/spec/unit/arbre/html/tag_spec.rb +63 -0
- data/spec/unit/arbre/html_spec.rb +210 -0
- data/spec/unit/asset_registration_spec.rb +37 -0
- data/spec/unit/auto_link_spec.rb +39 -0
- data/spec/unit/belongs_to_spec.rb +45 -0
- data/spec/unit/breadcrumbs_spec.rb +110 -0
- data/spec/unit/comments_spec.rb +57 -0
- data/spec/unit/component_spec.rb +18 -0
- data/spec/unit/components/attributes_table_spec.rb +100 -0
- data/spec/unit/components/columns_spec.rb +75 -0
- data/spec/unit/components/panel_spec.rb +31 -0
- data/spec/unit/components/sidebar_section_spec.rb +37 -0
- data/spec/unit/components/status_tag_spec.rb +81 -0
- data/spec/unit/components/table_for_spec.rb +130 -0
- data/spec/unit/controller_filters_spec.rb +27 -0
- data/spec/unit/csv_builder_spec.rb +83 -0
- data/spec/unit/dashboard_controller_spec.rb +26 -0
- data/spec/unit/dashboard_section_spec.rb +56 -0
- data/spec/unit/dashboards_spec.rb +59 -0
- data/spec/unit/display_name_spec.rb +29 -0
- data/spec/unit/event_spec.rb +41 -0
- data/spec/unit/filter_form_builder_spec.rb +179 -0
- data/spec/unit/form_builder_spec.rb +238 -0
- data/spec/unit/menu_item_spec.rb +143 -0
- data/spec/unit/menu_spec.rb +53 -0
- data/spec/unit/namespace_spec.rb +203 -0
- data/spec/unit/pretty_format_spec.rb +35 -0
- data/spec/unit/registration_spec.rb +76 -0
- data/spec/unit/renderer_spec.rb +108 -0
- data/spec/unit/resource_controller/collection_spec.rb +34 -0
- data/spec/unit/resource_controller_spec.rb +147 -0
- data/spec/unit/resource_spec.rb +290 -0
- data/spec/unit/routing_spec.rb +88 -0
- data/spec/unit/scope_spec.rb +31 -0
- data/spec/unit/tabs_renderer_spec.rb +85 -0
- data/spec/unit/view_factory_spec.rb +16 -0
- metadata +482 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
5
|
+
|
|
6
|
+
<title><%= [@page_title, active_admin_application.site_title].join(" | ") %></title>
|
|
7
|
+
|
|
8
|
+
<%= stylesheet_link_tag *active_admin_application.stylesheets %>
|
|
9
|
+
<%= javascript_include_tag *active_admin_application.javascripts %>
|
|
10
|
+
<%= csrf_meta_tag %>
|
|
11
|
+
|
|
12
|
+
</head>
|
|
13
|
+
<body class="<%= controller.action_name %>">
|
|
14
|
+
<div id="wrapper">
|
|
15
|
+
<div id="header">
|
|
16
|
+
<%= yield :header %>
|
|
17
|
+
</div>
|
|
18
|
+
<div id="title_bar">
|
|
19
|
+
<%= yield :title_bar %>
|
|
20
|
+
</div>
|
|
21
|
+
<div id="content" class="<%= skip_sidebar? ? 'without_sidebar' : 'with_sidebar' %>">
|
|
22
|
+
<%= flash_messages %>
|
|
23
|
+
<div id="main_content_wrapper">
|
|
24
|
+
<div id="main_content">
|
|
25
|
+
<%= yield %>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<% unless skip_sidebar? %>
|
|
29
|
+
<div id="sidebar">
|
|
30
|
+
<%= yield :sidebar %>
|
|
31
|
+
</div>
|
|
32
|
+
<% end %>
|
|
33
|
+
</div>
|
|
34
|
+
<div id="footer">
|
|
35
|
+
<%= yield :footer %>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</body>
|
|
39
|
+
</html>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
5
|
+
|
|
6
|
+
<title><%= [@page_title, active_admin_application.site_title].join(" | ") %></title>
|
|
7
|
+
|
|
8
|
+
<%= stylesheet_link_tag *active_admin_application.stylesheets %>
|
|
9
|
+
<%= javascript_include_tag *active_admin_application.javascripts %>
|
|
10
|
+
<%= csrf_meta_tag %>
|
|
11
|
+
|
|
12
|
+
</head>
|
|
13
|
+
<body class="logged_out <%= controller.action_name %>">
|
|
14
|
+
<div id="wrapper">
|
|
15
|
+
|
|
16
|
+
<div id="content_wrapper">
|
|
17
|
+
<% if flash.keys.any? %>
|
|
18
|
+
<% flash.each do |type, message| %>
|
|
19
|
+
<%= content_tag :div, message, :class => "flash flash_#{type}" %>
|
|
20
|
+
<% end %>
|
|
21
|
+
<% end %>
|
|
22
|
+
<div id="active_admin_content">
|
|
23
|
+
<%= yield %>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div id="footer">
|
|
27
|
+
<%= yield :footer %>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
data/lib/active_admin.rb
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require 'meta_search'
|
|
2
|
+
require 'devise'
|
|
3
|
+
require 'kaminari'
|
|
4
|
+
require 'sass'
|
|
5
|
+
require 'active_admin/arbre'
|
|
6
|
+
|
|
7
|
+
module ActiveAdmin
|
|
8
|
+
|
|
9
|
+
autoload :VERSION, 'active_admin/version'
|
|
10
|
+
autoload :ActionItems, 'active_admin/action_items'
|
|
11
|
+
autoload :Application, 'active_admin/application'
|
|
12
|
+
autoload :AssetRegistration, 'active_admin/asset_registration'
|
|
13
|
+
autoload :Breadcrumbs, 'active_admin/breadcrumbs'
|
|
14
|
+
autoload :Callbacks, 'active_admin/callbacks'
|
|
15
|
+
autoload :Component, 'active_admin/component'
|
|
16
|
+
autoload :ControllerAction, 'active_admin/controller_action'
|
|
17
|
+
autoload :CSVBuilder, 'active_admin/csv_builder'
|
|
18
|
+
autoload :Dashboards, 'active_admin/dashboards'
|
|
19
|
+
autoload :Devise, 'active_admin/devise'
|
|
20
|
+
autoload :DSL, 'active_admin/dsl'
|
|
21
|
+
autoload :Event, 'active_admin/event'
|
|
22
|
+
autoload :FormBuilder, 'active_admin/form_builder'
|
|
23
|
+
autoload :Iconic, 'active_admin/iconic'
|
|
24
|
+
autoload :Menu, 'active_admin/menu'
|
|
25
|
+
autoload :MenuItem, 'active_admin/menu_item'
|
|
26
|
+
autoload :Namespace, 'active_admin/namespace'
|
|
27
|
+
autoload :PageConfig, 'active_admin/page_config'
|
|
28
|
+
autoload :Resource, 'active_admin/resource'
|
|
29
|
+
autoload :ResourceController, 'active_admin/resource_controller'
|
|
30
|
+
autoload :Renderer, 'active_admin/renderer'
|
|
31
|
+
autoload :Scope, 'active_admin/scope'
|
|
32
|
+
autoload :Sidebar, 'active_admin/sidebar'
|
|
33
|
+
autoload :TableBuilder, 'active_admin/table_builder'
|
|
34
|
+
autoload :ViewFactory, 'active_admin/view_factory'
|
|
35
|
+
autoload :ViewHelpers, 'active_admin/view_helpers'
|
|
36
|
+
autoload :Views, 'active_admin/views'
|
|
37
|
+
|
|
38
|
+
class Railtie < ::Rails::Railtie
|
|
39
|
+
# Add load paths straight to I18n, so engines and application can overwrite it.
|
|
40
|
+
require 'active_support/i18n'
|
|
41
|
+
I18n.load_path += Dir[File.expand_path('../active_admin/locales/*.yml', __FILE__)]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The instance of the configured application
|
|
45
|
+
@@application = ::ActiveAdmin::Application.new
|
|
46
|
+
mattr_accessor :application
|
|
47
|
+
|
|
48
|
+
class << self
|
|
49
|
+
|
|
50
|
+
# Gets called within the initializer
|
|
51
|
+
def setup
|
|
52
|
+
yield(application)
|
|
53
|
+
application.prepare!
|
|
54
|
+
|
|
55
|
+
# Dispatch request which gets triggered once in production
|
|
56
|
+
# and on every require in development mode
|
|
57
|
+
ActionDispatch::Callbacks.to_prepare :active_admin do
|
|
58
|
+
ActiveAdmin.unload!
|
|
59
|
+
Rails.application.reload_routes!
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
delegate :register, :to => :application
|
|
64
|
+
delegate :unload!, :to => :application
|
|
65
|
+
delegate :load!, :to => :application
|
|
66
|
+
delegate :routes, :to => :application
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
require 'active_admin/comments'
|
data/lib/activeadmin.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'active_admin'
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module ActiveAdmin
|
|
2
|
+
module Generators
|
|
3
|
+
class DeviseGenerator < Rails::Generators::NamedBase
|
|
4
|
+
desc "Creates an admin user and uses Devise for authentication"
|
|
5
|
+
|
|
6
|
+
argument :name, :type => :string, :default => "AdminUser"
|
|
7
|
+
|
|
8
|
+
class_option :registerable, :type => :boolean, :default => false,
|
|
9
|
+
:desc => "Should the generated resource be registerable?"
|
|
10
|
+
|
|
11
|
+
def install_devise
|
|
12
|
+
require 'devise'
|
|
13
|
+
if File.exists?(File.join(destination_root, "config", "initializers", "devise.rb"))
|
|
14
|
+
log :generate, "No need to install devise, already done."
|
|
15
|
+
else
|
|
16
|
+
log :generate, "devise:install"
|
|
17
|
+
invoke "devise:install"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def create_admin_user
|
|
22
|
+
invoke "devise", [name]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def remove_registerable_from_model
|
|
26
|
+
unless options[:registerable]
|
|
27
|
+
model_file = File.join(destination_root, "app", "models", "#{file_path}.rb")
|
|
28
|
+
gsub_file model_file, /\:registerable([.]*,)?/, ""
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def set_namespace_for_path
|
|
33
|
+
routes_file = File.join(destination_root, "config", "routes.rb")
|
|
34
|
+
gsub_file routes_file, /devise_for :#{table_name}/, "devise_for :#{table_name}, ActiveAdmin::Devise.config"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def add_default_user_to_migration
|
|
38
|
+
# Don't assume that we have a migration!
|
|
39
|
+
devise_migrations = Dir["db/migrate/*_devise_create_#{table_name}.rb"]
|
|
40
|
+
if devise_migrations.size > 0
|
|
41
|
+
inject_into_file Dir["db/migrate/*_devise_create_#{table_name}.rb"].first,
|
|
42
|
+
"# Create a default user\n #{class_name}.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password')\n\n ",
|
|
43
|
+
:before => "add_index :#{table_name}, :email"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module ActiveAdmin
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
desc "Installs Active Admin and generats the necessary migrations"
|
|
5
|
+
|
|
6
|
+
hook_for :users, :default => "devise", :desc => "Admin user generator to run. Skip with --skip-users"
|
|
7
|
+
|
|
8
|
+
include Rails::Generators::Migration
|
|
9
|
+
|
|
10
|
+
def self.source_root
|
|
11
|
+
@_active_admin_source_root ||= File.expand_path("../templates", __FILE__)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.next_migration_number(dirname)
|
|
15
|
+
Time.now.strftime("%Y%m%d%H%M%S")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def copy_initializer
|
|
19
|
+
template 'active_admin.rb.erb', 'config/initializers/active_admin.rb'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def setup_directory
|
|
23
|
+
empty_directory "app/admin"
|
|
24
|
+
template 'dashboards.rb', 'app/admin/dashboards.rb'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def setup_routes
|
|
28
|
+
route "ActiveAdmin.routes(self)"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def copy_assets
|
|
32
|
+
template 'active_admin_vendor.js', 'public/javascripts/active_admin_vendor.js'
|
|
33
|
+
template 'active_admin.js', 'public/javascripts/active_admin.js'
|
|
34
|
+
directory 'images', 'public/images/active_admin'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def create_migrations
|
|
38
|
+
Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
|
|
39
|
+
name = File.basename(filepath)
|
|
40
|
+
migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
|
|
41
|
+
sleep 1
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* Active Admin JS */
|
|
2
|
+
|
|
3
|
+
$(function(){
|
|
4
|
+
$(".datepicker").datepicker({dateFormat: 'dd-mm-yyyy'});
|
|
5
|
+
|
|
6
|
+
$(".clear_filters_btn").click(function(){
|
|
7
|
+
window.location.search = "";
|
|
8
|
+
return false;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// AJAX Comments
|
|
12
|
+
$('form#admin_note_new').submit(function() {
|
|
13
|
+
|
|
14
|
+
if ($(this).find('#admin_note_body').val() != "") {
|
|
15
|
+
$(this).fadeOut('slow', function() {
|
|
16
|
+
$('.loading_indicator').fadeIn();
|
|
17
|
+
$.ajax({
|
|
18
|
+
url: $(this).attr('action'),
|
|
19
|
+
type: 'POST',
|
|
20
|
+
dataType: 'json',
|
|
21
|
+
data: $(this).serialize(),
|
|
22
|
+
success: function(data, textStatus, xhr) {
|
|
23
|
+
$('.loading_indicator').fadeOut('slow', function(){
|
|
24
|
+
|
|
25
|
+
// Hide the empty message
|
|
26
|
+
$('.admin_notes_list li.empty').fadeOut().remove();
|
|
27
|
+
|
|
28
|
+
// Add the note
|
|
29
|
+
$('.admin_notes_list').append(data['note']);
|
|
30
|
+
|
|
31
|
+
// Update the number of notes
|
|
32
|
+
$('.admin_notes h3 span.admin_notes_count').html("(" + data['number_of_notes'] + ")");
|
|
33
|
+
|
|
34
|
+
// Reset the form
|
|
35
|
+
$('form#new_active_admin_admin_note').find('#active_admin_admin_note_body').val("");
|
|
36
|
+
|
|
37
|
+
// Show the form
|
|
38
|
+
$('form#new_active_admin_admin_note').fadeIn('slow');
|
|
39
|
+
})
|
|
40
|
+
},
|
|
41
|
+
error: function(xhr, textStatus, errorThrown) {
|
|
42
|
+
//called when there is an error
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return false;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
ActiveAdmin.setup do |config|
|
|
2
|
+
|
|
3
|
+
# == Site Title
|
|
4
|
+
#
|
|
5
|
+
# Set the title that is displayed on the main layout
|
|
6
|
+
# for each of the active admin pages.
|
|
7
|
+
#
|
|
8
|
+
config.site_title = "<%= Rails.application.class.name.split("::").first.titlecase %>"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# == Default Namespace
|
|
12
|
+
#
|
|
13
|
+
# Set the default namespace each administration resource
|
|
14
|
+
# will be added to.
|
|
15
|
+
#
|
|
16
|
+
# eg:
|
|
17
|
+
# config.default_namespace = :hello_world
|
|
18
|
+
#
|
|
19
|
+
# This will create resources in the HelloWorld module and
|
|
20
|
+
# will namespace routes to /hello_world/*
|
|
21
|
+
#
|
|
22
|
+
# To set no namespace by default, use:
|
|
23
|
+
# config.default_namespace = false
|
|
24
|
+
config.default_namespace = :admin
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# == User Authentication
|
|
28
|
+
#
|
|
29
|
+
# Active Admin will automatically call an authentication
|
|
30
|
+
# method in a before filter of all controller actions to
|
|
31
|
+
# ensure that there is a currently logged in admin user.
|
|
32
|
+
#
|
|
33
|
+
# This setting changes the method which Active Admin calls
|
|
34
|
+
# within the controller.
|
|
35
|
+
config.authentication_method = :authenticate_admin_user!
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# == Current User
|
|
39
|
+
#
|
|
40
|
+
# Active Admin will associate actions with the current
|
|
41
|
+
# user performing them.
|
|
42
|
+
#
|
|
43
|
+
# This setting changes the method which Active Admin calls
|
|
44
|
+
# to return the currently logged in user.
|
|
45
|
+
config.current_user_method = :current_admin_user
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# == Admin Comments
|
|
49
|
+
#
|
|
50
|
+
# Admin comments allow you to add comments to any model for admin use
|
|
51
|
+
#
|
|
52
|
+
# Admin comments are enabled by default in the default
|
|
53
|
+
# namespace only. You can turn them on in a namesapce
|
|
54
|
+
# by adding them to the comments array.
|
|
55
|
+
#
|
|
56
|
+
# config.allow_comments_in = [:admin]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# == Controller Filters
|
|
60
|
+
#
|
|
61
|
+
# You can add before, after and around filters to all of your
|
|
62
|
+
# Active Admin resources from here.
|
|
63
|
+
#
|
|
64
|
+
# config.before_filter :do_something_awesome
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# == Register Stylesheets & Javascripts
|
|
68
|
+
#
|
|
69
|
+
# We recommend using the built in Active Admin layout and loading
|
|
70
|
+
# up your own stylesheets / javascripts to customize the look
|
|
71
|
+
# and feel.
|
|
72
|
+
#
|
|
73
|
+
# To load a stylesheet:
|
|
74
|
+
# config.register_stylesheet 'my_stylesheet.css'
|
|
75
|
+
#
|
|
76
|
+
# To load a javascript file:
|
|
77
|
+
# config.register_javascript 'my_javascript.js'
|
|
78
|
+
end
|