activeadmin 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- data/.gitignore +34 -0
- data/.travis.yml +4 -0
- data/.yardopts +8 -0
- data/CHANGELOG.md +177 -0
- data/Gemfile +21 -32
- data/Guardfile +8 -0
- data/README.rdoc +75 -14
- data/Rakefile +7 -100
- data/activeadmin.gemspec +21 -353
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/admin_notes_icon.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-header-bg.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-input-icon.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-next-link-icon.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-nipple.png +0 -0
- data/app/assets/images/active_admin/datepicker/datepicker-prev-link-icon.png +0 -0
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/loading.gif +0 -0
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/nested_menu_arrow.gif +0 -0
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/nested_menu_arrow_dark.gif +0 -0
- data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/orderable.png +0 -0
- data/app/assets/javascripts/active_admin/base.js +12 -0
- data/{lib/generators/active_admin/install/templates/active_admin_vendor.js → app/assets/javascripts/active_admin/vendor.js} +0 -0
- data/{lib/active_admin/stylesheets/active_admin.scss → app/assets/stylesheets/active_admin/_base.css.scss} +58 -82
- data/{lib/active_admin/stylesheets/active_admin/_forms.scss → app/assets/stylesheets/active_admin/_forms.css.scss} +94 -5
- data/{lib/active_admin/stylesheets/active_admin/_header.scss → app/assets/stylesheets/active_admin/_header.css.scss} +13 -11
- data/app/assets/stylesheets/active_admin/_mixins.css.scss +1 -0
- data/{lib/active_admin/stylesheets/active_admin/_typography.scss → app/assets/stylesheets/active_admin/_typography.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/_comments.scss → app/assets/stylesheets/active_admin/components/_comments.css.scss} +0 -0
- data/app/assets/stylesheets/active_admin/components/_date_picker.css.scss +123 -0
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +38 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_all.scss → app/assets/stylesheets/active_admin/mixins/_all.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_buttons.scss → app/assets/stylesheets/active_admin/mixins/_buttons.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_gradients.scss → app/assets/stylesheets/active_admin/mixins/_gradients.css.scss} +8 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_icons.scss → app/assets/stylesheets/active_admin/mixins/_icons.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_reset.scss → app/assets/stylesheets/active_admin/mixins/_reset.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_rounded.scss → app/assets/stylesheets/active_admin/mixins/_rounded.css.scss} +0 -0
- data/{lib/active_admin/stylesheets/active_admin/mixins/_sections.scss → app/assets/stylesheets/active_admin/mixins/_sections.css.scss} +9 -2
- data/{lib/active_admin/stylesheets/active_admin/mixins/_shadows.scss → app/assets/stylesheets/active_admin/mixins/_shadows.css.scss} +1 -1
- data/{lib/active_admin/stylesheets/active_admin/mixins/_variables.scss → app/assets/stylesheets/active_admin/mixins/_variables.css.scss} +12 -3
- data/{lib/active_admin/views/templates/active_admin_dashboard → app/views/active_admin/dashboard}/index.html.arb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/mailer/reset_password_instructions.html.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/mailer/unlock_instructions.html.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/passwords/edit.html.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/passwords/new.html.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/sessions/new.html.erb +1 -1
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/shared/_links.erb +0 -0
- data/{lib/active_admin/views/templates → app/views}/active_admin/devise/unlocks/new.html.erb +0 -0
- data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/edit.html.arb +0 -0
- data/app/views/active_admin/resource/index.csv.erb +20 -0
- data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/index.html.arb +0 -0
- data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/new.html.arb +0 -0
- data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/show.html.arb +0 -0
- data/app/views/layouts/active_admin.html.arb +1 -0
- data/{lib/active_admin/views/templates → app/views}/layouts/active_admin_logged_out.html.erb +8 -4
- data/docs/0-installation.md +50 -0
- data/docs/1-general-configuration.md +43 -0
- data/docs/2-resource-customization.md +35 -0
- data/docs/3-index-pages.md +55 -0
- data/docs/3-index-pages/index-as-block.md +16 -0
- data/docs/3-index-pages/index-as-blog.md +61 -0
- data/docs/3-index-pages/index-as-grid.md +21 -0
- data/docs/3-index-pages/index-as-table.md +90 -0
- data/docs/4-csv-format.md +14 -0
- data/docs/5-forms.md +39 -0
- data/docs/6-show-screens.md +22 -0
- data/docs/7-sidebars.md +35 -0
- data/docs/8-custom-actions.md +123 -0
- data/features/comments/commenting.feature +31 -4
- data/features/edit_page.feature +30 -1
- data/features/index/filters.feature +35 -0
- data/features/index/format_as_csv.feature +46 -0
- data/features/index/formats.feature +2 -0
- data/features/index/index_as_block.feature +1 -1
- data/features/index/index_as_grid.feature +1 -1
- data/features/index/index_as_table.feature +2 -0
- data/features/index/index_blank_slate.feature +56 -0
- data/features/index/pagination.feature +0 -6
- data/features/registering_assets.feature +2 -2
- data/features/sidebar_sections.feature +7 -8
- data/features/specifying_actions.feature +72 -1
- data/features/step_definitions/action_item_steps.rb +2 -2
- data/features/step_definitions/additional_web_steps.rb +26 -16
- data/features/step_definitions/attribute_steps.rb +5 -7
- data/features/step_definitions/configuration_steps.rb +9 -9
- data/features/step_definitions/factory_steps.rb +4 -3
- data/features/step_definitions/format_steps.rb +29 -1
- data/features/step_definitions/layout_steps.rb +3 -0
- data/features/step_definitions/menu_steps.rb +2 -2
- data/features/step_definitions/sidebar_steps.rb +1 -5
- data/features/step_definitions/user_steps.rb +8 -2
- data/features/step_definitions/web_steps.rb +82 -90
- data/features/sti_resource.feature +12 -0
- data/features/support/env.rb +12 -10
- data/features/support/paths.rb +2 -0
- data/features/support/selectors.rb +45 -0
- data/lib/active_admin.rb +33 -263
- data/lib/active_admin/application.rb +228 -0
- data/lib/active_admin/arbre.rb +10 -10
- data/lib/active_admin/arbre/{html.rb → builder.rb} +29 -2
- data/lib/active_admin/arbre/context.rb +8 -0
- data/lib/active_admin/arbre/{attributes.rb → html/attributes.rb} +0 -0
- data/lib/active_admin/arbre/{class_list.rb → html/class_list.rb} +0 -0
- data/lib/active_admin/arbre/{collection.rb → html/collection.rb} +0 -0
- data/lib/active_admin/arbre/{document.rb → html/document.rb} +0 -0
- data/lib/active_admin/arbre/{element.rb → html/element.rb} +6 -6
- data/lib/active_admin/arbre/{html5_elements.rb → html/html5_elements.rb} +0 -0
- data/lib/active_admin/arbre/{tag.rb → html/tag.rb} +0 -0
- data/lib/active_admin/arbre/{text_node.rb → html/text_node.rb} +0 -0
- data/lib/active_admin/asset_registration.rb +1 -1
- data/lib/active_admin/callbacks.rb +5 -3
- data/lib/active_admin/comments.rb +3 -3
- data/lib/active_admin/comments/comment.rb +6 -0
- data/lib/active_admin/comments/configuration.rb +8 -6
- data/lib/active_admin/comments/namespace_helper.rb +1 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +1 -1
- data/lib/active_admin/csv_builder.rb +45 -0
- data/lib/active_admin/dashboards.rb +1 -1
- data/lib/active_admin/dashboards/dashboard_controller.rb +3 -10
- data/lib/active_admin/dependency_checker.rb +28 -0
- data/lib/active_admin/deprecation.rb +36 -0
- data/lib/active_admin/devise.rb +14 -3
- data/lib/active_admin/dsl.rb +26 -4
- data/lib/active_admin/engine.rb +4 -0
- data/lib/active_admin/form_builder.rb +18 -9
- data/lib/active_admin/helpers/scope_chain.rb +23 -0
- data/lib/active_admin/helpers/settings.rb +70 -0
- data/lib/active_admin/locales/cs.yml +34 -0
- data/lib/active_admin/locales/da.yml +28 -0
- data/lib/active_admin/locales/en.yml +40 -0
- data/lib/active_admin/locales/es.yml +40 -0
- data/lib/active_admin/locales/fr.yml +40 -0
- data/lib/active_admin/locales/it.yml +39 -0
- data/lib/active_admin/locales/pl.yml +34 -0
- data/lib/active_admin/locales/pt-BR.yml +41 -0
- data/lib/active_admin/locales/ru.yml +40 -0
- data/lib/active_admin/locales/zh_cn.yml +40 -0
- data/lib/active_admin/menu_item.rb +6 -0
- data/lib/active_admin/namespace.rb +14 -5
- data/lib/active_admin/reloader.rb +30 -0
- data/lib/active_admin/renderer.rb +1 -1
- data/lib/active_admin/resource.rb +45 -88
- data/lib/active_admin/resource/action_items.rb +88 -0
- data/lib/active_admin/resource/menu.rb +45 -0
- data/lib/active_admin/resource/naming.rb +46 -0
- data/lib/active_admin/resource/scopes.rb +33 -0
- data/lib/active_admin/resource/sidebars.rb +36 -0
- data/lib/active_admin/resource_controller.rb +32 -37
- data/lib/active_admin/resource_controller/action_builder.rb +1 -1
- data/lib/active_admin/resource_controller/actions.rb +66 -40
- data/lib/active_admin/resource_controller/callbacks.rb +1 -1
- data/lib/active_admin/resource_controller/collection.rb +9 -14
- data/lib/active_admin/resource_controller/filters.rb +1 -1
- data/lib/active_admin/resource_controller/form.rb +1 -1
- data/lib/active_admin/resource_controller/menu.rb +1 -1
- data/lib/active_admin/resource_controller/page_configurations.rb +2 -2
- data/lib/active_admin/resource_controller/scoping.rb +1 -1
- data/lib/active_admin/resource_controller/sidebars.rb +1 -21
- data/lib/active_admin/router.rb +85 -0
- data/lib/active_admin/sass/active_admin.scss +3 -0
- data/lib/active_admin/sass/css_loader.rb +16 -0
- data/lib/active_admin/sass/helpers.rb +45 -0
- data/lib/active_admin/scope.rb +16 -2
- data/lib/active_admin/sidebar_section.rb +41 -0
- data/lib/active_admin/stylesheets/active_admin/mixins/_utilities.scss +0 -0
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +5 -3
- data/lib/active_admin/view_helpers.rb +1 -2
- data/lib/active_admin/view_helpers/active_admin_application_helper.rb +12 -0
- data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -1
- data/lib/active_admin/view_helpers/display_helper.rb +1 -1
- data/lib/active_admin/view_helpers/filter_form_helper.rb +26 -14
- data/lib/active_admin/view_helpers/form_helper.rb +1 -0
- data/lib/active_admin/view_helpers/view_factory_helper.rb +1 -1
- data/lib/active_admin/views/components/attributes_table.rb +2 -2
- data/lib/active_admin/views/components/blank_slate.rb +17 -0
- data/lib/active_admin/views/components/columns.rb +1 -3
- data/lib/active_admin/views/components/paginated_collection.rb +26 -8
- data/lib/active_admin/views/components/scopes.rb +13 -8
- data/lib/active_admin/views/components/sidebar_section.rb +1 -3
- data/lib/active_admin/views/components/status_tag.rb +55 -0
- data/lib/active_admin/views/components/table_for.rb +25 -6
- data/lib/active_admin/views/header_renderer.rb +20 -4
- data/lib/active_admin/views/index_as_block.rb +12 -7
- data/lib/active_admin/views/index_as_blog.rb +61 -21
- data/lib/active_admin/views/index_as_grid.rb +22 -1
- data/lib/active_admin/views/index_as_table.rb +97 -6
- data/lib/active_admin/views/pages/base.rb +20 -9
- data/lib/active_admin/views/pages/dashboard.rb +7 -4
- data/lib/active_admin/views/pages/edit.rb +3 -2
- data/lib/active_admin/views/pages/index.rb +30 -5
- data/lib/active_admin/views/pages/layout.rb +26 -0
- data/lib/active_admin/views/pages/new.rb +3 -2
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/active_admin/views/tabbed_navigation.rb +94 -0
- data/lib/generators/active_admin/assets/assets_generator.rb +21 -0
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +427 -0
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +6 -0
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.js +1 -0
- data/lib/generators/active_admin/assets/templates/dashboards.rb +36 -0
- data/lib/generators/active_admin/install/install_generator.rb +2 -4
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +26 -4
- data/lib/generators/active_admin/install/templates/dashboards.rb +4 -2
- data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +2 -2
- data/script/local +44 -0
- data/script/use_rails +46 -0
- data/spec/integration/belongs_to_spec.rb +1 -1
- data/spec/integration/default_namespace.rb +77 -0
- data/spec/integration/javascript_spec.rb +20 -0
- data/spec/integration/stylesheets_spec.rb +41 -0
- data/spec/spec_helper.rb +21 -11
- data/spec/support/detect_rails_version.rb +10 -0
- data/spec/support/integration_example_group.rb +1 -1
- data/spec/support/jslint.yml +80 -0
- data/spec/support/rails_template.rb +1 -1
- data/spec/support/rails_template_with_data.rb +2 -1
- data/spec/support/templates/cucumber.rb +0 -4
- data/spec/unit/active_admin_spec.rb +8 -44
- data/spec/unit/application_spec.rb +78 -0
- data/spec/unit/arbre/context_spec.rb +22 -0
- data/spec/unit/arbre/html/element_finder_methods_spec.rb +2 -2
- data/spec/unit/arbre/html/element_spec.rb +2 -3
- data/spec/unit/arbre/html/tag_attributes_spec.rb +2 -2
- data/spec/unit/arbre/html/tag_spec.rb +2 -2
- data/spec/unit/arbre/html_spec.rb +2 -3
- data/spec/unit/auto_link_spec.rb +2 -1
- data/spec/unit/belongs_to_spec.rb +2 -1
- data/spec/unit/comments_spec.rb +43 -39
- data/spec/unit/controller_filters_spec.rb +11 -3
- data/spec/unit/csv_builder_spec.rb +83 -0
- data/spec/unit/devise_spec.rb +66 -0
- data/spec/unit/display_name_spec.rb +2 -2
- data/spec/unit/filter_form_builder_spec.rb +6 -3
- data/spec/unit/form_builder_spec.rb +20 -2
- data/spec/unit/generators/install_rails_3_1_spec.rb +16 -0
- data/spec/unit/helpers/scope_chain_spec.rb +36 -0
- data/spec/unit/helpers/settings_spec.rb +30 -0
- data/spec/unit/menu_item_spec.rb +6 -0
- data/spec/unit/namespace_spec.rb +68 -19
- data/spec/unit/rails_spec.rb +43 -0
- data/spec/unit/registration_spec.rb +18 -27
- data/spec/unit/reloader_spec.rb +28 -0
- data/spec/unit/resource/action_items_spec.rb +62 -0
- data/spec/unit/resource/menu_spec.rb +80 -0
- data/spec/unit/resource/naming_spec.rb +64 -0
- data/spec/unit/resource/scopes_spec.rb +30 -0
- data/spec/unit/resource/sidebars_spec.rb +50 -0
- data/spec/unit/resource_controller/collection_spec.rb +1 -1
- data/spec/unit/resource_controller_spec.rb +29 -24
- data/spec/unit/resource_spec.rb +78 -94
- data/spec/unit/sass/helpers_spec.rb +47 -0
- data/spec/unit/scope_spec.rb +11 -1
- data/spec/unit/view_factory_spec.rb +4 -1
- data/spec/unit/{components → views/components}/attributes_table_spec.rb +2 -2
- data/spec/unit/views/components/blank_slate_spec.rb +15 -0
- data/spec/unit/{components → views/components}/columns_spec.rb +2 -2
- data/spec/unit/{components → views/components}/panel_spec.rb +1 -3
- data/spec/unit/{components → views/components}/sidebar_section_spec.rb +3 -3
- data/spec/unit/views/components/status_tag_spec.rb +79 -0
- data/spec/unit/{components → views/components}/table_for_spec.rb +2 -1
- data/spec/unit/views/pages/layout_spec.rb +22 -0
- data/spec/unit/views/tabbed_navigation_spec.rb +125 -0
- data/tasks/docs.rake +39 -0
- data/tasks/test.rake +55 -0
- data/tasks/yard.rake +6 -0
- metadata +310 -189
- data/CHANGELOG.rdoc +0 -76
- data/lib/active_admin/action_items.rb +0 -37
- data/lib/active_admin/sidebar.rb +0 -39
- data/lib/active_admin/stylesheets/active_admin/_flash_messages.scss +0 -13
- data/lib/active_admin/view_helpers/status_tag_helper.rb +0 -13
- data/lib/active_admin/view_helpers/table_helper.rb +0 -12
- data/lib/active_admin/views/tabs_renderer.rb +0 -52
- data/lib/active_admin/views/templates/active_admin_default/index.csv.erb +0 -2
- data/lib/active_admin/views/templates/layouts/active_admin.html.erb +0 -39
- data/lib/generators/active_admin/install/templates/active_admin.js +0 -51
- data/spec/controllers/index_as_csv_spec.rb +0 -35
- data/spec/unit/action_items_spec.rb +0 -27
- data/spec/unit/tabs_renderer_spec.rb +0 -56
@@ -0,0 +1,228 @@
|
|
1
|
+
require 'active_admin/router'
|
2
|
+
require 'active_admin/helpers/settings'
|
3
|
+
|
4
|
+
module ActiveAdmin
|
5
|
+
class Application
|
6
|
+
include Settings
|
7
|
+
|
8
|
+
# The default namespace to put controllers and routes inside. Set this
|
9
|
+
# in config/initializers/active_admin.rb using:
|
10
|
+
#
|
11
|
+
# config.default_namespace = :super_admin
|
12
|
+
#
|
13
|
+
setting :default_namespace, :admin
|
14
|
+
|
15
|
+
# The default number of resources to display on index pages
|
16
|
+
setting :default_per_page, 30
|
17
|
+
|
18
|
+
# A hash of all the registered namespaces
|
19
|
+
setting :namespaces, {}
|
20
|
+
|
21
|
+
# The title which gets displayed in the main layout
|
22
|
+
setting :site_title, ""
|
23
|
+
|
24
|
+
# Load paths for admin configurations. Add folders to this load path
|
25
|
+
# to load up other resources for administration. External gems can
|
26
|
+
# include their paths in this load path to provide active_admin UIs
|
27
|
+
setting :load_paths, [File.expand_path('app/admin', Rails.root)]
|
28
|
+
|
29
|
+
# The view factory to use to generate all the view classes. Take
|
30
|
+
# a look at ActiveAdmin::ViewFactory
|
31
|
+
setting :view_factory, ActiveAdmin::ViewFactory.new
|
32
|
+
|
33
|
+
# The method to call in controllers to get the current user
|
34
|
+
setting :current_user_method, false
|
35
|
+
|
36
|
+
# The method to call in the controllers to ensure that there
|
37
|
+
# is a currently authenticated admin user
|
38
|
+
setting :authentication_method, false
|
39
|
+
|
40
|
+
# The path to log user's out with. If set to a symbol, we assume
|
41
|
+
# that it's a method to call which returns the path
|
42
|
+
setting :logout_link_path, :destroy_admin_user_session_path
|
43
|
+
|
44
|
+
# The method to use when generating the link for user logout
|
45
|
+
setting :logout_link_method, :get
|
46
|
+
|
47
|
+
# Active Admin makes educated guesses when displaying objects, this is
|
48
|
+
# the list of methods it tries calling in order
|
49
|
+
setting :display_name_methods, [ :display_name,
|
50
|
+
:full_name,
|
51
|
+
:name,
|
52
|
+
:username,
|
53
|
+
:login,
|
54
|
+
:title,
|
55
|
+
:email,
|
56
|
+
:to_s ]
|
57
|
+
|
58
|
+
# == Deprecated Settings
|
59
|
+
|
60
|
+
# @deprecated The default sort order for index pages
|
61
|
+
deprecated_setting :default_sort_order, 'id_desc'
|
62
|
+
|
63
|
+
# DEPRECATED: This option is deprecated and will be removed. Use
|
64
|
+
# the #allow_comments_in option instead
|
65
|
+
attr_accessor :admin_notes
|
66
|
+
|
67
|
+
|
68
|
+
include AssetRegistration
|
69
|
+
|
70
|
+
def initialize
|
71
|
+
register_default_assets
|
72
|
+
end
|
73
|
+
|
74
|
+
def prepare!
|
75
|
+
remove_active_admin_load_paths_from_rails_autoload_and_eager_load
|
76
|
+
attach_reloader
|
77
|
+
generate_stylesheets
|
78
|
+
end
|
79
|
+
|
80
|
+
# Registers a brand new configuration for the given resource.
|
81
|
+
def register(resource, options = {}, &block)
|
82
|
+
namespace_name = options.has_key?(:namespace) ? options[:namespace] : default_namespace
|
83
|
+
namespace = find_or_create_namespace(namespace_name)
|
84
|
+
namespace.register(resource, options, &block)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Creates a namespace for the given name
|
88
|
+
def find_or_create_namespace(name)
|
89
|
+
name ||= :root
|
90
|
+
return namespaces[name] if namespaces[name]
|
91
|
+
namespace = Namespace.new(self, name)
|
92
|
+
ActiveAdmin::Event.dispatch ActiveAdmin::Namespace::RegisterEvent, namespace
|
93
|
+
namespaces[name] = namespace
|
94
|
+
namespace
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
# Stores if everything has been loaded or we need to reload
|
99
|
+
@@loaded = false
|
100
|
+
|
101
|
+
# Returns true if all the configuration files have been loaded.
|
102
|
+
def loaded?
|
103
|
+
@@loaded
|
104
|
+
end
|
105
|
+
|
106
|
+
# Removes all the controllers that were defined by registering
|
107
|
+
# resources for administration.
|
108
|
+
#
|
109
|
+
# We remove them, then load them on each request in development
|
110
|
+
# to allow for changes without having to restart the server.
|
111
|
+
def unload!
|
112
|
+
namespaces.values.each{|namespace| namespace.unload! }
|
113
|
+
self.namespaces = {}
|
114
|
+
@@loaded = false
|
115
|
+
end
|
116
|
+
|
117
|
+
# Loads all of the ruby files that are within the load path of
|
118
|
+
# ActiveAdmin.load_paths. This should load all of the administration
|
119
|
+
# UIs so that they are available for the router to proceed.
|
120
|
+
#
|
121
|
+
# The files are only loaded if we haven't already loaded all the files
|
122
|
+
# and they aren't marked for re-loading. To mark the files for re-loading
|
123
|
+
# you must first call ActiveAdmin.unload!
|
124
|
+
def load!
|
125
|
+
# No work to do if we've already loaded
|
126
|
+
return false if loaded?
|
127
|
+
|
128
|
+
# Load files
|
129
|
+
files_in_load_path.each{|file| load file }
|
130
|
+
|
131
|
+
# If no configurations, let's make sure you can still login
|
132
|
+
load_default_namespace if namespaces.values.empty?
|
133
|
+
|
134
|
+
# Load Menus
|
135
|
+
namespaces.values.each{|namespace| namespace.load_menu! }
|
136
|
+
|
137
|
+
@@loaded = true
|
138
|
+
end
|
139
|
+
|
140
|
+
# Returns ALL the files to load from all the load paths
|
141
|
+
def files_in_load_path
|
142
|
+
load_paths.flatten.compact.uniq.collect{|path| Dir["#{path}/**/*.rb"] }.flatten
|
143
|
+
end
|
144
|
+
|
145
|
+
def router
|
146
|
+
@router ||= Router.new(self)
|
147
|
+
end
|
148
|
+
|
149
|
+
def routes(rails_router)
|
150
|
+
# Ensure that all the configurations (which define the routes)
|
151
|
+
# are all loaded
|
152
|
+
load!
|
153
|
+
|
154
|
+
router.apply(rails_router)
|
155
|
+
end
|
156
|
+
|
157
|
+
def load_default_namespace
|
158
|
+
find_or_create_namespace(default_namespace)
|
159
|
+
end
|
160
|
+
|
161
|
+
#
|
162
|
+
# Add before, around and after filters to each registered resource.
|
163
|
+
#
|
164
|
+
# eg:
|
165
|
+
#
|
166
|
+
# ActiveAdmin.before_filter :authenticate_admin!
|
167
|
+
#
|
168
|
+
def before_filter(*args, &block)
|
169
|
+
ResourceController.before_filter(*args, &block)
|
170
|
+
end
|
171
|
+
|
172
|
+
def skip_before_filter(*args, &block)
|
173
|
+
ResourceController.skip_before_filter(*args, &block)
|
174
|
+
end
|
175
|
+
|
176
|
+
def after_filter(*args, &block)
|
177
|
+
ResourceController.after_filter(*args, &block)
|
178
|
+
end
|
179
|
+
|
180
|
+
def around_filter(*args, &block)
|
181
|
+
ResourceController.around_filter(*args, &block)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Helper method to add a dashboard section
|
185
|
+
def dashboard_section(name, options = {}, &block)
|
186
|
+
ActiveAdmin::Dashboards.add_section(name, options, &block)
|
187
|
+
end
|
188
|
+
|
189
|
+
private
|
190
|
+
|
191
|
+
def register_default_assets
|
192
|
+
register_stylesheet 'active_admin.css'
|
193
|
+
register_javascript 'active_admin.js'
|
194
|
+
end
|
195
|
+
|
196
|
+
# Since we're dealing with all our own file loading, we need
|
197
|
+
# to remove our paths from the ActiveSupport autoload paths.
|
198
|
+
# If not, file naming becomes very important and can cause clashes.
|
199
|
+
def remove_active_admin_load_paths_from_rails_autoload_and_eager_load
|
200
|
+
ActiveSupport::Dependencies.autoload_paths.reject!{|path| load_paths.include?(path) }
|
201
|
+
# Don't eagerload our configs, we'll deal with them ourselves
|
202
|
+
Rails.application.config.eager_load_paths = Rails.application.config.eager_load_paths.reject do |path|
|
203
|
+
load_paths.include?(path)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def attach_reloader
|
208
|
+
ActiveAdmin::Reloader.new(Rails.version).attach!
|
209
|
+
end
|
210
|
+
|
211
|
+
|
212
|
+
def generate_stylesheets
|
213
|
+
# This must be required after initialization
|
214
|
+
require 'sass/plugin'
|
215
|
+
require 'active_admin/sass/helpers'
|
216
|
+
|
217
|
+
# Create our own asset pipeline in Rails 3.0
|
218
|
+
if ActiveAdmin.use_asset_pipeline?
|
219
|
+
# Add our mixins to the load path for SASS
|
220
|
+
::Sass::Engine::DEFAULT_OPTIONS[:load_paths] << File.expand_path("../../../app/assets/stylesheets", __FILE__)
|
221
|
+
else
|
222
|
+
require 'active_admin/sass/css_loader'
|
223
|
+
::Sass::Plugin.add_template_location(File.expand_path("../../../app/assets/stylesheets", __FILE__))
|
224
|
+
::Sass::Plugin.add_template_location(File.expand_path("../sass", __FILE__))
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
data/lib/active_admin/arbre.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require "active_admin/arbre/
|
2
|
-
require "active_admin/arbre/attributes"
|
1
|
+
require "active_admin/arbre/builder"
|
3
2
|
require "active_admin/arbre/core_extensions"
|
4
|
-
require "active_admin/arbre/element"
|
5
3
|
require "active_admin/arbre/context"
|
6
|
-
require "active_admin/arbre/
|
7
|
-
require "active_admin/arbre/
|
8
|
-
require "active_admin/arbre/
|
9
|
-
require "active_admin/arbre/
|
10
|
-
require "active_admin/arbre/
|
11
|
-
require "active_admin/arbre/
|
4
|
+
require "active_admin/arbre/html/element"
|
5
|
+
require "active_admin/arbre/html/attributes"
|
6
|
+
require "active_admin/arbre/html/collection"
|
7
|
+
require "active_admin/arbre/html/class_list"
|
8
|
+
require "active_admin/arbre/html/tag"
|
9
|
+
require "active_admin/arbre/html/document"
|
10
|
+
require "active_admin/arbre/html/html5_elements"
|
11
|
+
require "active_admin/arbre/html/text_node"
|
12
12
|
|
13
13
|
# Arbre - The DOM Tree in Ruby
|
14
14
|
#
|
@@ -19,5 +19,5 @@ end
|
|
19
19
|
require 'action_view'
|
20
20
|
|
21
21
|
ActionView::Template.register_template_handler :arb, lambda { |template|
|
22
|
-
"self.class.send :include, Arbre::
|
22
|
+
"self.class.send :include, Arbre::Builder; @_helpers = self; @__current_dom_element__ = Arbre::Context.new(assigns, self); begin; #{template.source}; end; current_dom_context"
|
23
23
|
}
|
@@ -1,5 +1,24 @@
|
|
1
1
|
module Arbre
|
2
|
-
|
2
|
+
|
3
|
+
# Include this module in any context to start building html.
|
4
|
+
#
|
5
|
+
# assigns = {}
|
6
|
+
# include Arbre::Builder
|
7
|
+
# span("foo").to_s #=> "<span>foo</span>
|
8
|
+
#
|
9
|
+
# When you include the module, you are required to setup 2 variables:
|
10
|
+
#
|
11
|
+
# * assigns: This is a hash that includes local variables
|
12
|
+
# * helpers: This is an object that provides helper methods to all
|
13
|
+
# objects within the context.
|
14
|
+
module Builder
|
15
|
+
|
16
|
+
# Retrieve the current DOM context.
|
17
|
+
#
|
18
|
+
# If no `@__current_dom_element__` has been set, this method will
|
19
|
+
# setup the initial context.
|
20
|
+
#
|
21
|
+
# @return [Arbre::Element] the current element that is in context
|
3
22
|
def current_dom_context
|
4
23
|
@__current_dom_element__ ||= Arbre::Context.new(assigns, helpers)
|
5
24
|
@__current_dom_element__.current_dom_context
|
@@ -9,6 +28,14 @@ module Arbre
|
|
9
28
|
@_helpers
|
10
29
|
end
|
11
30
|
|
31
|
+
# Implements the method lookup chain. When you call a method that
|
32
|
+
# doesn't exist, we:
|
33
|
+
#
|
34
|
+
# 1. Try to call the method on the current DOM context
|
35
|
+
# 2. Return an assigned variable of the same name
|
36
|
+
# 3. Call the method on the helper object
|
37
|
+
# 4. Call super
|
38
|
+
#
|
12
39
|
def method_missing(name, *args, &block)
|
13
40
|
if current_dom_context.respond_to?(name)
|
14
41
|
current_dom_context.send name, *args, &block
|
@@ -74,7 +101,7 @@ module Arbre
|
|
74
101
|
# Inserts a text node if the tag is a string
|
75
102
|
def insert_text_node_if_string(tag)
|
76
103
|
if tag.is_a?(String)
|
77
|
-
current_dom_context << TextNode.from_string(tag)
|
104
|
+
current_dom_context << Arbre::HTML::TextNode.from_string(tag)
|
78
105
|
end
|
79
106
|
end
|
80
107
|
end
|
@@ -1,8 +1,16 @@
|
|
1
|
+
require 'active_admin/arbre/html/element'
|
2
|
+
|
1
3
|
module Arbre
|
2
4
|
class Context < Arbre::HTML::Element
|
3
5
|
def indent_level
|
4
6
|
# A context does not increment the indent_level
|
5
7
|
super - 1
|
6
8
|
end
|
9
|
+
|
10
|
+
def length
|
11
|
+
to_html.length
|
12
|
+
end
|
13
|
+
alias :bytesize :length
|
14
|
+
|
7
15
|
end
|
8
16
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,16 +2,16 @@ module Arbre
|
|
2
2
|
module HTML
|
3
3
|
|
4
4
|
class Element
|
5
|
-
include ::Arbre::
|
6
|
-
include ::Arbre::
|
5
|
+
include ::Arbre::Builder
|
6
|
+
include ::Arbre::Builder::BuilderMethods
|
7
7
|
|
8
8
|
attr_accessor :parent
|
9
9
|
attr_reader :children
|
10
10
|
|
11
11
|
def self.builder_method(method_name)
|
12
|
-
::Arbre::
|
12
|
+
::Arbre::Builder::BuilderMethods.class_eval <<-EOF, __FILE__, __LINE__
|
13
13
|
def #{method_name}(*args, &block)
|
14
|
-
insert_tag
|
14
|
+
insert_tag ::#{self.name}, *args, &block
|
15
15
|
end
|
16
16
|
EOF
|
17
17
|
end
|
@@ -48,7 +48,7 @@ module Arbre
|
|
48
48
|
|
49
49
|
# If its not an element, wrap it in a TextNode
|
50
50
|
unless child.is_a?(Element)
|
51
|
-
child = TextNode.from_string(child)
|
51
|
+
child = Arbre::HTML::TextNode.from_string(child)
|
52
52
|
end
|
53
53
|
|
54
54
|
if child.respond_to?(:parent)
|
@@ -129,7 +129,7 @@ module Arbre
|
|
129
129
|
case element
|
130
130
|
when Element, Collection
|
131
131
|
else
|
132
|
-
element = TextNode.from_string(element)
|
132
|
+
element = Arbre::HTML::TextNode.from_string(element)
|
133
133
|
end
|
134
134
|
Collection.new([self]) + element
|
135
135
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -58,12 +58,14 @@ module ActiveAdmin
|
|
58
58
|
def define_active_admin_callbacks(*names)
|
59
59
|
names.each do |name|
|
60
60
|
[:before, :after].each do |type|
|
61
|
-
# Create an inheritable accessor array for the callbacks
|
62
|
-
class_inheritable_array "#{type}_#{name}_callbacks".to_sym
|
63
|
-
send("#{type}_#{name}_callbacks=".to_sym, [])
|
64
61
|
|
65
62
|
# Define a method to set the callback
|
66
63
|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
64
|
+
# def self.before_create_callbacks
|
65
|
+
def self.#{type}_#{name}_callbacks
|
66
|
+
@#{type}_#{name}_callbacks ||= []
|
67
|
+
end
|
68
|
+
|
67
69
|
# def self.before_create
|
68
70
|
def self.#{type}_#{name}(method = nil, &block)
|
69
71
|
#{type}_#{name}_callbacks << (method || block)
|
@@ -6,7 +6,7 @@ require 'active_admin/comments/namespace_helper'
|
|
6
6
|
require 'active_admin/comments/resource_helper'
|
7
7
|
|
8
8
|
# Add the comments configuration
|
9
|
-
ActiveAdmin.
|
9
|
+
ActiveAdmin::Application.send :include, ActiveAdmin::Comments::Configuration
|
10
10
|
|
11
11
|
# Add the comments module to ActiveAdmin::Namespace
|
12
12
|
ActiveAdmin::Namespace.send :include, ActiveAdmin::Comments::NamespaceHelper
|
@@ -15,7 +15,7 @@ ActiveAdmin::Namespace.send :include, ActiveAdmin::Comments::NamespaceHelper
|
|
15
15
|
ActiveAdmin::Resource.send :include, ActiveAdmin::Comments::ResourceHelper
|
16
16
|
|
17
17
|
# Add the module to the show page
|
18
|
-
ActiveAdmin.view_factory.show_page.send :include, ActiveAdmin::Comments::ShowPageHelper
|
18
|
+
ActiveAdmin.application.view_factory.show_page.send :include, ActiveAdmin::Comments::ShowPageHelper
|
19
19
|
|
20
20
|
# Generate a Comment resource when namespaces are registered
|
21
21
|
ActiveAdmin::Event.subscribe ActiveAdmin::Namespace::RegisterEvent do |namespace|
|
@@ -36,7 +36,7 @@ ActiveAdmin::Event.subscribe ActiveAdmin::Namespace::RegisterEvent do |namespace
|
|
36
36
|
|
37
37
|
# Only view comments in this namespace
|
38
38
|
scope :all, :default => true do |comments|
|
39
|
-
comments.where(:namespace => active_admin_config.namespace.name)
|
39
|
+
comments.where(:namespace => active_admin_config.namespace.name.to_s)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Always redirect to the resource on show
|
@@ -1,5 +1,10 @@
|
|
1
|
+
require 'kaminari/models/active_record_extension'
|
2
|
+
|
1
3
|
module ActiveAdmin
|
2
4
|
|
5
|
+
# manually initialize kaminari for this model
|
6
|
+
::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension
|
7
|
+
|
3
8
|
class Comment < ActiveRecord::Base
|
4
9
|
self.table_name = "active_admin_comments"
|
5
10
|
|
@@ -13,3 +18,4 @@ module ActiveAdmin
|
|
13
18
|
end
|
14
19
|
|
15
20
|
end
|
21
|
+
|