activeadmin 0.1.1 → 0.2.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.

Files changed (255) hide show
  1. data/CHANGELOG.rdoc +15 -1
  2. data/Gemfile +41 -11
  3. data/LICENSE +5 -0
  4. data/README.rdoc +202 -87
  5. data/Rakefile +51 -15
  6. data/activeadmin.gemspec +310 -131
  7. data/cucumber.yml +1 -0
  8. data/features/comments/commenting.feature +81 -0
  9. data/features/comments/viewing_index.feature +19 -0
  10. data/features/edit_page.feature +77 -0
  11. data/features/first_boot.feature +16 -0
  12. data/features/global_navigation.feature +30 -0
  13. data/features/index/formats.feature +10 -0
  14. data/features/index/index_as_block.feature +15 -0
  15. data/features/index/index_as_blog.feature +50 -0
  16. data/features/index/index_as_grid.feature +45 -0
  17. data/features/index/index_as_table.feature +79 -0
  18. data/features/index/index_scopes.feature +52 -0
  19. data/features/index/pagination.feature +23 -0
  20. data/features/new_page.feature +75 -0
  21. data/features/registering_assets.feature +35 -0
  22. data/features/registering_resources.feature +33 -0
  23. data/features/show/default_content.feature +43 -0
  24. data/features/show/page_title.feature +33 -0
  25. data/features/sidebar_sections.feature +128 -0
  26. data/features/specifying_actions.feature +16 -0
  27. data/features/step_definitions/action_item_steps.rb +7 -0
  28. data/features/step_definitions/additional_web_steps.rb +67 -0
  29. data/features/step_definitions/asset_steps.rb +7 -0
  30. data/features/step_definitions/attribute_steps.rb +15 -0
  31. data/features/step_definitions/comment_steps.rb +8 -0
  32. data/features/step_definitions/configuration_steps.rb +31 -0
  33. data/features/step_definitions/factory_steps.rb +28 -0
  34. data/features/step_definitions/flash_steps.rb +3 -0
  35. data/features/step_definitions/format_steps.rb +7 -0
  36. data/features/step_definitions/index_scope_steps.rb +20 -0
  37. data/features/step_definitions/pagination_steps.rb +8 -0
  38. data/features/step_definitions/sidebar_steps.rb +11 -0
  39. data/features/step_definitions/tab_steps.rb +3 -0
  40. data/features/step_definitions/user_steps.rb +20 -0
  41. data/features/step_definitions/web_steps.rb +219 -0
  42. data/features/support/env.rb +88 -0
  43. data/features/support/paths.rb +48 -0
  44. data/features/users/logging_in.feature +34 -0
  45. data/features/users/logging_out.feature +13 -0
  46. data/lib/active_admin.rb +155 -79
  47. data/lib/active_admin/abstract_view_factory.rb +95 -0
  48. data/lib/active_admin/action_items.rb +4 -15
  49. data/lib/active_admin/arbre.rb +23 -0
  50. data/lib/active_admin/arbre/attributes.rb +20 -0
  51. data/lib/active_admin/arbre/class_list.rb +28 -0
  52. data/lib/active_admin/arbre/collection.rb +27 -0
  53. data/lib/active_admin/arbre/context.rb +8 -0
  54. data/lib/active_admin/arbre/core_extensions.rb +5 -0
  55. data/lib/active_admin/arbre/document.rb +42 -0
  56. data/lib/active_admin/arbre/element.rb +151 -0
  57. data/lib/active_admin/arbre/html.rb +84 -0
  58. data/lib/active_admin/arbre/html5_elements.rb +47 -0
  59. data/lib/active_admin/arbre/tag.rb +129 -0
  60. data/lib/active_admin/arbre/text_node.rb +35 -0
  61. data/lib/active_admin/callbacks.rb +87 -0
  62. data/lib/active_admin/comments.rb +73 -0
  63. data/lib/active_admin/comments/comment.rb +15 -0
  64. data/lib/active_admin/comments/configuration.rb +16 -0
  65. data/lib/active_admin/comments/namespace_helper.rb +14 -0
  66. data/lib/active_admin/comments/resource_helper.rb +17 -0
  67. data/lib/active_admin/comments/show_page_helper.rb +23 -0
  68. data/lib/active_admin/comments/views.rb +3 -0
  69. data/lib/active_admin/comments/views/active_admin_comment.rb +0 -0
  70. data/lib/active_admin/comments/views/active_admin_comments.rb +82 -0
  71. data/lib/active_admin/component.rb +22 -0
  72. data/lib/active_admin/controller_action.rb +12 -0
  73. data/lib/active_admin/dashboards.rb +0 -2
  74. data/lib/active_admin/dashboards/dashboard_controller.rb +10 -5
  75. data/lib/active_admin/dashboards/section.rb +5 -14
  76. data/lib/active_admin/devise.rb +43 -0
  77. data/lib/active_admin/dsl.rb +202 -0
  78. data/lib/active_admin/event.rb +31 -0
  79. data/lib/active_admin/form_builder.rb +68 -50
  80. data/lib/active_admin/iconic.rb +51 -0
  81. data/lib/active_admin/iconic/icons.rb +142 -0
  82. data/lib/active_admin/namespace.rb +102 -16
  83. data/lib/active_admin/renderer.rb +18 -3
  84. data/lib/active_admin/resource.rb +110 -9
  85. data/lib/active_admin/resource/belongs_to.rb +31 -0
  86. data/lib/active_admin/resource_controller.rb +45 -260
  87. data/lib/active_admin/resource_controller/action_builder.rb +21 -0
  88. data/lib/active_admin/resource_controller/actions.rb +53 -0
  89. data/lib/active_admin/resource_controller/callbacks.rb +47 -0
  90. data/lib/active_admin/resource_controller/collection.rb +142 -0
  91. data/lib/active_admin/resource_controller/filters.rb +58 -0
  92. data/lib/active_admin/resource_controller/form.rb +42 -0
  93. data/lib/active_admin/resource_controller/menu.rb +29 -0
  94. data/lib/active_admin/resource_controller/page_configurations.rb +53 -0
  95. data/lib/active_admin/resource_controller/scoping.rb +36 -0
  96. data/lib/active_admin/resource_controller/sidebars.rb +38 -0
  97. data/lib/active_admin/scope.rb +17 -0
  98. data/lib/active_admin/sidebar.rb +8 -47
  99. data/lib/active_admin/stylesheets/active_admin.scss +418 -0
  100. data/lib/active_admin/stylesheets/active_admin/_comments.scss +40 -0
  101. data/lib/active_admin/stylesheets/active_admin/_flash_messages.scss +13 -0
  102. data/lib/active_admin/stylesheets/active_admin/_forms.scss +168 -0
  103. data/lib/active_admin/stylesheets/active_admin/_header.scss +108 -0
  104. data/lib/active_admin/stylesheets/active_admin/_typography.scss +100 -0
  105. data/lib/active_admin/stylesheets/active_admin/mixins/_all.scss +8 -0
  106. data/lib/active_admin/stylesheets/active_admin/mixins/_buttons.scss +27 -0
  107. data/lib/active_admin/stylesheets/active_admin/mixins/_gradients.scss +21 -0
  108. data/lib/active_admin/stylesheets/active_admin/mixins/_icons.scss +20 -0
  109. data/lib/active_admin/stylesheets/active_admin/mixins/_reset.scss +165 -0
  110. data/lib/active_admin/stylesheets/active_admin/mixins/_rounded.scss +43 -0
  111. data/lib/active_admin/stylesheets/active_admin/mixins/_sections.scss +27 -0
  112. data/lib/active_admin/stylesheets/active_admin/mixins/_shadows.scss +21 -0
  113. data/lib/active_admin/stylesheets/active_admin/mixins/_variables.scss +12 -0
  114. data/lib/active_admin/version.rb +1 -1
  115. data/lib/active_admin/view_factory.rb +21 -0
  116. data/lib/active_admin/view_helpers.rb +17 -100
  117. data/lib/active_admin/view_helpers/assigns_with_indifferent_access_helper.rb +7 -0
  118. data/lib/active_admin/view_helpers/auto_link_helper.rb +41 -0
  119. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +29 -0
  120. data/lib/active_admin/view_helpers/display_helper.rb +38 -0
  121. data/lib/active_admin/view_helpers/filter_form_helper.rb +174 -0
  122. data/lib/active_admin/view_helpers/form_helper.rb +12 -0
  123. data/lib/active_admin/view_helpers/icon_helper.rb +12 -0
  124. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +26 -0
  125. data/lib/active_admin/view_helpers/renderer_helper.rb +29 -0
  126. data/lib/active_admin/view_helpers/sidebar_helper.rb +15 -0
  127. data/lib/active_admin/view_helpers/status_tag_helper.rb +13 -0
  128. data/lib/active_admin/view_helpers/table_helper.rb +12 -0
  129. data/lib/active_admin/view_helpers/title_helper.rb +11 -0
  130. data/lib/active_admin/view_helpers/view_factory_helper.rb +11 -0
  131. data/lib/active_admin/views.rb +8 -0
  132. data/lib/active_admin/views/action_items.rb +17 -0
  133. data/lib/active_admin/views/components/attributes_table.rb +66 -0
  134. data/lib/active_admin/views/components/columns.rb +49 -0
  135. data/lib/active_admin/views/components/paginated_collection.rb +74 -0
  136. data/lib/active_admin/views/components/panel.rb +26 -0
  137. data/lib/active_admin/views/components/scopes.rb +64 -0
  138. data/lib/active_admin/views/components/sidebar_section.rb +30 -0
  139. data/lib/active_admin/views/components/table_for.rb +174 -0
  140. data/lib/active_admin/views/dashboard_section_renderer.rb +19 -0
  141. data/lib/active_admin/views/header_renderer.rb +37 -0
  142. data/lib/active_admin/views/index_as_block.rb +24 -0
  143. data/lib/active_admin/views/index_as_blog.rb +89 -0
  144. data/lib/active_admin/views/index_as_grid.rb +49 -0
  145. data/lib/active_admin/views/index_as_table.rb +73 -0
  146. data/lib/active_admin/views/pages/base.rb +138 -0
  147. data/lib/active_admin/views/pages/dashboard.rb +61 -0
  148. data/lib/active_admin/views/pages/edit.rb +27 -0
  149. data/lib/active_admin/views/pages/index.rb +64 -0
  150. data/lib/active_admin/views/pages/new.rb +27 -0
  151. data/lib/active_admin/views/pages/show.rb +56 -0
  152. data/lib/active_admin/views/tabs_renderer.rb +52 -0
  153. data/lib/active_admin/views/templates/active_admin/devise/mailer/reset_password_instructions.html.erb +8 -0
  154. data/lib/active_admin/views/templates/active_admin/devise/mailer/unlock_instructions.html.erb +7 -0
  155. data/lib/active_admin/views/templates/active_admin/devise/passwords/edit.html.erb +16 -0
  156. data/lib/active_admin/views/templates/active_admin/devise/passwords/new.html.erb +14 -0
  157. data/lib/active_admin/views/templates/active_admin/devise/sessions/new.html.erb +18 -0
  158. data/lib/active_admin/views/templates/active_admin/devise/shared/_links.erb +20 -0
  159. data/lib/active_admin/views/templates/active_admin/devise/unlocks/new.html.erb +12 -0
  160. data/lib/active_admin/views/templates/active_admin_dashboard/index.html.arb +1 -0
  161. data/lib/active_admin/views/templates/active_admin_default/edit.html.arb +1 -0
  162. data/lib/active_admin/views/{active_admin_default → templates/active_admin_default}/index.csv.erb +0 -0
  163. data/lib/active_admin/views/templates/active_admin_default/index.html.arb +1 -0
  164. data/lib/active_admin/views/templates/active_admin_default/new.html.arb +1 -0
  165. data/lib/active_admin/views/templates/active_admin_default/show.html.arb +1 -0
  166. data/lib/active_admin/views/{layouts → templates/layouts}/active_admin.html.erb +3 -4
  167. data/lib/active_admin/views/templates/layouts/active_admin_logged_out.html.erb +31 -0
  168. data/lib/generators/active_admin/devise/devise_generator.rb +45 -0
  169. data/lib/generators/active_admin/install/install_generator.rb +18 -3
  170. data/lib/generators/active_admin/install/templates/active_admin.js +41 -0
  171. data/lib/generators/active_admin/install/templates/{active_admin.rb → active_admin.rb.erb} +33 -3
  172. data/lib/generators/active_admin/install/templates/active_admin_vendor.js +1 -1
  173. data/lib/generators/active_admin/install/templates/dashboards.rb +3 -4
  174. data/lib/generators/active_admin/install/templates/images/admin_notes_icon.png +0 -0
  175. data/lib/generators/active_admin/install/templates/images/loading.gif +0 -0
  176. data/lib/generators/active_admin/install/templates/images/nested_menu_arrow.gif +0 -0
  177. data/lib/generators/active_admin/install/templates/images/nested_menu_arrow_dark.gif +0 -0
  178. data/lib/generators/active_admin/install/templates/images/orderable.png +0 -0
  179. data/lib/generators/active_admin/install/templates/migrations/1_create_admin_notes.rb +16 -0
  180. data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +25 -0
  181. data/spec/integration/belongs_to_spec.rb +42 -0
  182. data/spec/integration/index_as_table_spec.rb +0 -119
  183. data/spec/integration/layout_spec.rb +3 -37
  184. data/spec/spec_helper.rb +89 -50
  185. data/spec/support/integration_example_group.rb +37 -0
  186. data/spec/support/rails_template.rb +21 -9
  187. data/spec/support/rails_template_with_data.rb +32 -0
  188. data/spec/support/templates/cucumber.rb +28 -0
  189. data/spec/unit/abstract_view_factory_spec.rb +79 -0
  190. data/spec/unit/action_builder_spec.rb +19 -7
  191. data/spec/unit/action_items_spec.rb +16 -30
  192. data/spec/unit/active_admin_spec.rb +10 -22
  193. data/spec/unit/arbre/html/element_finder_methods_spec.rb +54 -0
  194. data/spec/unit/arbre/html/element_spec.rb +224 -0
  195. data/spec/unit/arbre/html/tag_attributes_spec.rb +61 -0
  196. data/spec/unit/arbre/html/tag_spec.rb +63 -0
  197. data/spec/unit/arbre/html_spec.rb +185 -0
  198. data/spec/unit/auto_link_spec.rb +38 -0
  199. data/spec/unit/belongs_to_spec.rb +44 -0
  200. data/spec/unit/breadcrumbs_spec.rb +110 -0
  201. data/spec/unit/comments_spec.rb +53 -0
  202. data/spec/unit/component_spec.rb +18 -0
  203. data/spec/unit/components/attributes_table_spec.rb +100 -0
  204. data/spec/unit/components/columns_spec.rb +75 -0
  205. data/spec/unit/components/panel_spec.rb +31 -0
  206. data/spec/unit/components/sidebar_section_spec.rb +37 -0
  207. data/spec/unit/components/table_for_spec.rb +130 -0
  208. data/spec/unit/dashboard_controller_spec.rb +26 -0
  209. data/spec/unit/dashboard_section_spec.rb +10 -17
  210. data/spec/unit/display_name_spec.rb +29 -0
  211. data/spec/unit/event_spec.rb +41 -0
  212. data/spec/unit/filter_form_builder_spec.rb +99 -77
  213. data/spec/unit/form_builder_spec.rb +69 -69
  214. data/spec/unit/namespace_spec.rb +61 -3
  215. data/spec/unit/pretty_format_spec.rb +35 -0
  216. data/spec/unit/registration_spec.rb +40 -1
  217. data/spec/unit/renderer_spec.rb +8 -0
  218. data/spec/unit/resource_controller_spec.rb +105 -6
  219. data/spec/unit/resource_spec.rb +78 -11
  220. data/spec/unit/routing_spec.rb +82 -6
  221. data/spec/unit/scope_spec.rb +31 -0
  222. data/spec/unit/tabs_renderer_spec.rb +24 -2
  223. data/spec/unit/view_factory_spec.rb +16 -0
  224. metadata +268 -82
  225. data/.gitignore +0 -25
  226. data/active_admin.gemspec +0 -22
  227. data/lib/active_admin/action_builder.rb +0 -60
  228. data/lib/active_admin/breadcrumbs.rb +0 -26
  229. data/lib/active_admin/dashboards/renderer.rb +0 -45
  230. data/lib/active_admin/dashboards/section_renderer.rb +0 -28
  231. data/lib/active_admin/filters.rb +0 -189
  232. data/lib/active_admin/pages.rb +0 -11
  233. data/lib/active_admin/pages/base.rb +0 -92
  234. data/lib/active_admin/pages/edit.rb +0 -21
  235. data/lib/active_admin/pages/index.rb +0 -58
  236. data/lib/active_admin/pages/index/blog.rb +0 -65
  237. data/lib/active_admin/pages/index/table.rb +0 -48
  238. data/lib/active_admin/pages/index/thumbnails.rb +0 -40
  239. data/lib/active_admin/pages/new.rb +0 -21
  240. data/lib/active_admin/pages/show.rb +0 -54
  241. data/lib/active_admin/table_builder.rb +0 -162
  242. data/lib/active_admin/tabs_renderer.rb +0 -39
  243. data/lib/active_admin/views/active_admin_dashboard/index.html.erb +0 -1
  244. data/lib/active_admin/views/active_admin_default/edit.html.erb +0 -1
  245. data/lib/active_admin/views/active_admin_default/index.html.erb +0 -1
  246. data/lib/active_admin/views/active_admin_default/new.html.erb +0 -1
  247. data/lib/active_admin/views/active_admin_default/show.html.erb +0 -1
  248. data/lib/generators/active_admin/install/templates/active_admin.css +0 -325
  249. data/lib/generators/active_admin/install/templates/images/orderable.gif +0 -0
  250. data/spec/integration/index_as_blog_spec.rb +0 -65
  251. data/spec/integration/index_as_thumbnails_spec.rb +0 -43
  252. data/spec/integration/new_view_spec.rb +0 -52
  253. data/spec/integration/show_view_spec.rb +0 -91
  254. data/spec/unit/sidebar_spec.rb +0 -96
  255. data/spec/unit/table_builder_spec.rb +0 -162
@@ -1,4 +1,18 @@
1
- == 0.1.1
1
+ == 0.2.0 (2011-05-12)
2
+
3
+ 0.2.0 is essentially an entire re-write of Active Admin. Here are some
4
+ of the highlights. 250 commits. Enough said.
5
+
6
+ * Features & Enhancements
7
+ * Full visual redesign
8
+ * Integrated Devise for authentication
9
+ * Brand new view and component layer called Arbre (Project coming soon)
10
+ * Added ActiveAdmin::Comments
11
+
12
+ * Bug Fixes
13
+ * Too many to list! Been in production for close to a year
14
+
15
+ == 0.1.1 (2010-09-15)
2
16
 
3
17
  * Bug Fixes
4
18
  * Fixed issues running on Ruby 1.9.2
data/Gemfile CHANGED
@@ -1,16 +1,46 @@
1
1
  # These resources are needed to setup the test env
2
2
  source 'http://rubygems.org'
3
3
 
4
- # Rails & ActiveAdmin Dependencies
5
- gem 'rails', '3.0.0'
6
- gem 'sqlite3-ruby', :require => 'sqlite3'
7
- gem 'haml', '3.0.18'
8
- gem 'formtastic', '1.1.0.beta'
9
- gem 'will_paginate', '3.0.pre2'
10
- gem "meta_search", '0.9.2'
4
+ # Set the RAILS env variable to test against diffirent versions of rails
5
+ case ENV["RAILS"]
6
+ when "3.0.0"
7
+ gem 'rails', '= 3.0.0'
8
+ when "3.0.1"
9
+ gem 'rails', '= 3.0.1'
10
+ when "3.0.2"
11
+ gem 'rails', '= 3.0.2'
12
+ when "3.0.3"
13
+ gem 'rails', '= 3.0.3'
14
+ when "3.0.4"
15
+ gem 'rails', '= 3.0.4'
16
+ when "3.0.5"
17
+ gem 'rails', '= 3.0.5'
18
+ when "3.0.6"
19
+ gem 'rails', '= 3.0.6'
20
+ else
21
+ # Default gems for in the gemspec
22
+ gem 'rails', '>= 3.0.0'
23
+ end
24
+
25
+ gem "meta_search", '>= 0.9.2'
26
+ gem 'devise', '>= 1.1.2'
27
+ gem 'formtastic', '>= 1.1.0'
28
+ gem 'will_paginate', '>= 3.0.pre2'
11
29
  gem 'inherited_views'
12
- gem 'jeweler'
30
+ gem 'haml', '>= 3.0.18'
31
+
32
+ group :development, :test do
33
+ gem 'sqlite3-ruby', :require => 'sqlite3'
34
+ gem 'jeweler', '1.5.2'
35
+ end
13
36
 
14
- # Testing Dependencies
15
- gem 'rspec', '2.0.0.beta.20'
16
- gem 'rspec-rails', '2.0.0.beta.20'
37
+ group :test do
38
+ gem 'rspec', '2.0.0.beta.22'
39
+ gem 'rspec-rails', '2.0.0.beta.22'
40
+ gem 'capybara', '0.3.9'
41
+ gem 'cucumber', '0.9.2'
42
+ gem 'cucumber-rails', '0.3.2'
43
+ gem 'database_cleaner'
44
+ gem 'shoulda', '2.11.2', :require => nil
45
+ gem 'launchy'
46
+ end
data/LICENSE CHANGED
@@ -18,3 +18,8 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ Iconic Icons are designed by P.J. Onori and are shared under
23
+ the Creative Commons Attribution-Share Alike 3.0 license:
24
+ http://creativecommons.org/licenses/by-sa/3.0/us
25
+ http://somerandomdude.com/projects/iconic/
@@ -1,143 +1,238 @@
1
1
  = Active Admin
2
2
 
3
- Active Admin is a tool to facilitate the generation of administration style interfaces.
4
-
3
+ Active Admin is a framework for creating administration style interfaces. It
4
+ abstracts common business application patterns to make it simple for developers
5
+ to implement beautiful and elegant interfaces with very little effort.
5
6
 
6
7
  == Goals
7
8
 
8
- Although Active Admin is very young in its development cycle, here are its current goals:
9
+ 1. Allow developers to quickly create gorgeous administration interfaces
10
+ <strong>(Not Just CRUD)</strong>
11
+ 2. Build a DSL for developers and an interface for businesses.
12
+ 3. Ensure that developers can easily customize every nook and cranny of the interface.
13
+ 4. Build common interfaces as shareable gems so that the entire community benefits.
9
14
 
10
- 1. Build a toolset to quickly create template-able administration interfaces
11
- 2. Allow the toolset to be entirely customizable (ie: we use standard rails coding practices
12
- which can be overridden at any point)
13
- 3. Design an interface which looks great!
14
- 4. Build administration interfaces for common rails plugins as gems and share with the
15
- community (ie: devise admin)
16
15
 
17
- == Status
16
+ == Getting Started
18
17
 
19
- Active Admin is very young. Although the code is well tested and is being used in production,
20
- the project is under heavy development. Once we get it to a point that has a relatively stable api,
21
- we will begin numbered releases starting with a 0.1 release.
18
+ Active Admin is released as a Ruby Gem. The gem is to be installed within a Ruby
19
+ on Rails 3 application. To install, simply add the following to your Gemfile:
22
20
 
23
- == Installation (Rails 3)
21
+ # Gemfile
22
+ gem 'activeadmin'
24
23
 
25
- Active Admin is released as a Gem. Installing the gem deals with all its dependencies, however
26
- WillPaginate seems to have some Rails 3 issues still. For now:
24
+ After updating your bundle, run the installer
27
25
 
28
- Add the following to your Gemfile:
26
+ $> rails generate active_admin:install
29
27
 
30
- gem 'will_paginate', :git => "git://github.com/mislav/will_paginate.git", :branch => 'rails3'
31
- gem 'activeadmin'
28
+ The installer creates an initializer used for configuring defaults used by Active Admin as well
29
+ as a new folder at <tt>app/admin</tt> to put all your admin configurations.
30
+
31
+ Migrate your db and start the server:
32
+
33
+ $> rake db:migrate
34
+ $> rails server
35
+
36
+ Visit http://localhost:3000/admin and log in using:
37
+
38
+ * *User*: admin@example.com
39
+ * *Password*: password
40
+
41
+ Voila! You're on your brand new Active Admin dashboard.
42
+
43
+ To register your first model, run:
44
+
45
+ $> rails generate active_admin:resource [MyModelName]
46
+
47
+ This creates a file at <tt>app/admin/my_model_names.rb</tt> for configuring the resource.
48
+ Refresh your web browser to see the interface.
49
+
50
+ To learn how to further configure your admin section, keep on reading!
51
+
52
+ == General Configuration
53
+
54
+ === Admin Users
55
+
56
+ By default Active Admin will include Devise and create a new model called
57
+ AdminUser. If you would like to use another name, you can pass it in to the
58
+ installer through the user option:
59
+
60
+ $> rails generate active_admin:install UserClassName
61
+
62
+ If you don't want the generator to create any user classes:
32
63
 
33
- Then, run the installer:
64
+ $> rails generate active_admin:install --skip-users
34
65
 
35
- rails generate active_admin:install
66
+ === Authentication
36
67
 
37
- This will create an initializer which is used for configuring defaults used by Active Admin as well
38
- as a new folder at app/admin to put all your admin configurations. Note: All ruby files in
39
- the Active Admin load path get loaded into the rails application.
68
+ Active Admin requires two settings to authenticate and use the current user
69
+ within your application. Both are set in
70
+ <tt>config/initializers/active_admin.rb</tt>. By default they are setup for use
71
+ with Devise and a model named AdminUser. If you chose a different model name,
72
+ you will need to update these settings.
40
73
 
41
- == Usage
74
+ Set the method that controllers should call to authenticate the current user
75
+ with:
42
76
 
43
- Let's build up an example using a Post model and the provided admin generator.
77
+ # config/initializers/active_admin.rb
78
+ config.authentication_method = :authenticate_admin_user!
44
79
 
45
- rails generate active_admin:resource post
46
-
47
- That's all you need to get a full CRUD, beautiful administration interface!
80
+ Set the method to call within the view to access the current admin user
48
81
 
49
- The generator will create a new file app/admin/posts.rb that will
50
- look like the following:
82
+ # config/initializers/active_admin.rb
83
+ config.current_user_method = :current_admin_user
51
84
 
52
- ActiveAdmin.register Post
85
+ Both of these settings can be set to false to turn off authentication.
53
86
 
54
- === Customize the Index Page
87
+ # Turn off authentication all together
88
+ config.authentication_method = false
89
+ config.current_user_method = false
90
+
91
+ === Site Title
92
+
93
+ You can update the title used for the site in the initializer also. By default
94
+ it is set to the name of your Rails.application class name.
95
+
96
+ # config/initializers/active_admin.rb
97
+ config.site_title = "My Admin Site"
98
+
99
+ == Customizing the Index Page
100
+
101
+ Filtering and listing resources is one of the most important tasks for
102
+ administering a web application. Active Admin provides many different tools for
103
+ you to build a compelling interface into your data for the admin staff.
104
+
105
+ Built in, Active Admin has the following index renderers:
106
+
107
+ * *Table*: A table drawn with each row being a resource
108
+ * *Grid*: A set of rows and columns each cell being a resource
109
+ * *Blocks*: A set of rows (not tabular) each row being a resource
110
+ * *Blog*: A title and body content, similar to a blog index
111
+
112
+ All index pages also support scopes, filters, pagination, action items, and
113
+ sidebar sections.
114
+
115
+ === Index as a Table
55
116
 
56
117
  By default, the index page is a table with each of the models content columns and links to
57
- show, edit and delete the object. There are many ways to customize what gets displayed:
118
+ show, edit and delete the object. There are many ways to customize what gets
119
+ displayed.
58
120
 
59
- ==== Simple Columns
121
+ ==== Defining Columns
60
122
 
61
- If all you need to do is change the columns which get displayed, you can do so by passing
62
- them to the columns method:
123
+ To display an attribute or a method on a resource, simply pass a symbol into the
124
+ column method:
63
125
 
64
- ActiveAdmin.register Post do
65
-
66
- index do |display|
67
- display.columns :title, :comments_count, :created_at
126
+ index do
127
+ column :title
68
128
  end
69
129
 
70
- end
130
+ If the default title does not work for you, pass it as the first argument:
131
+
132
+ index do
133
+ column "My Custom Title", :title
134
+ end
71
135
 
72
- Or you can pass them in individually:
136
+ Sometimes calling methods just isn't enough and you need to write some view
137
+ specific code. For example, say we wanted a colum called Title which holds a
138
+ link to the posts admin screen.
73
139
 
74
- ActiveAdmin.register Post do
75
-
76
- index do |display|
140
+ The column method accepts a block as an argument which will then be rendered
141
+ within the context of the view for each of the objects in the collection.
142
+
143
+ index do
144
+ column "Title" do |post|
145
+ link_to post.title, admin_post_path(post)
146
+ end
147
+ end
77
148
 
78
- # This will title the column 'Title' and call the #title method on each object
79
- display.column :title
149
+ The block gets called once for each resource in the collection. The resource gets passed into
150
+ the block as an argument.
80
151
 
81
- # This will title the column 'How many comments?' and call the #comments_count method on each object
82
- display.column 'How many comments?', :comments_count
83
152
 
84
- # You can add methods to the table builder which builds common things (ie: selectable checkboxes)
85
- display.default_actions
153
+ ==== Sorting
154
+
155
+ When a column is generated from an Active Record attribute, the table is
156
+ sortable by default. If you are creating a custom column, you may need to give
157
+ Active Admin a hint for how to sort the table.
86
158
 
159
+ If a column is defined using a block, you must pass the key to turn on sorting. The key
160
+ is the attribute which gets used to sort objects using Active Record.
161
+
162
+ index do
163
+ column "Title", :sortable => :title do |post|
164
+ link_to post.title, admin_post_path(post)
87
165
  end
166
+ end
88
167
 
168
+ You can turn off sorting on any column by passing false:
169
+
170
+ index do
171
+ column :title, :sortable => false
89
172
  end
90
-
91
- ==== Advanced Columns
92
173
 
93
- Sometimes calling methods just isn't enough and you need to write some view specific code. For
94
- example, say we wanted a colum called Title which holds a link to the posts admin screen.
174
+ ==== Showing and Hiding Columns
95
175
 
96
- You can pass a block to a column which will then be rendered within the context of the view
97
- for each of the objects in the collection.
176
+ The entire index block is rendered within the context of the view, so you can
177
+ easily do things that show or hide columns based on the current context.
98
178
 
99
-
100
- ActiveAdmin.register Post do
101
-
102
- index do |display|
103
- display.column("Title"){|post| link_to post.title, admin_post_path(post) }
179
+ For example, if you were using CanCan:
180
+
181
+ index do
182
+ column :title, :sortable => false
183
+ if can? :manage, Post
184
+ column :some_secret_data
104
185
  end
186
+ end
187
+
188
+ === Index as a Grid
189
+
190
+ Sometimes you want to display the index screen for a set of resources as a grid
191
+ (possibly a grid of thumbnail images). To do so, use the :grid option for the
192
+ index block.
105
193
 
194
+ index :as => :grid do |product|
195
+ link_to(image_tag(product.image_path), admin_products_path(product))
106
196
  end
107
197
 
108
- The block gets called once for each resource in the collection. The resource gets passed into
109
- the block as an argument.
198
+ The block is rendered within a cell in the grid once for each resource in the
199
+ collection. The resource is passed into the block for you to use in the view.
110
200
 
111
- ==== Sorting
201
+ You can customize the number of colums that are rendered using the columns
202
+ option:
112
203
 
113
- The index views in Active Admin include sorting by default.
114
-
115
- ActiveAdmin.register Post do
116
-
117
- index do |display|
204
+ index :as => :grid, :columns => 5 do |product|
205
+ link_to(image_tag(product.image_path), admin_products_path(product))
206
+ end
118
207
 
119
- # A column created by a method call assumes its sortable
120
- display.column :id
121
208
 
122
- # If a column is defined using a block, you must pass the key to turn on sorting. The key
123
- # is the attribute which gets used to sort objects using Active Record.
124
- display.column("Title", :sortable => :title){|post| link_to post.title, admin_post_path(post) }
209
+ === Index as a Block
125
210
 
126
- # Turn off sorting by passing false
127
- display.column :do_not_sort_me, :sortable => false
211
+ If you want to fully customize the display of your resources on the index
212
+ screen, Index as a Block allows you to render a block of content for each
213
+ resource.
128
214
 
215
+ index :as => :block do |product|
216
+ div :for => product do
217
+ h2 auto_link(product.title)
218
+ div do
219
+ simple_format product.description
220
+ end
129
221
  end
130
-
131
222
  end
132
223
 
133
224
 
134
- === Customize the Form
225
+ === Index Filters
226
+
227
+ === Index Scopes
228
+
229
+ == Customizing the Form
135
230
 
136
231
  Active Admin gives complete control over the output of the form by creating a thin DSL on top of
137
232
  the fabulous DSL created by Formtastic (http://github.com/justinfrench/formtastic).
138
-
233
+
139
234
  ActiveAdmin.register Post do
140
-
235
+
141
236
  form do |f|
142
237
  f.inputs "Details" do
143
238
  f.input :title
@@ -156,6 +251,21 @@ Please view the documentation for Formtastic to see all the wonderful things you
156
251
  http://github.com/justinfrench/formtastic
157
252
 
158
253
 
254
+ == Customizing the Show Screen
255
+
256
+ == Action Items
257
+
258
+ == Sidebar Sections
259
+
260
+ == The Dashboard
261
+
262
+ == Custom Actions
263
+
264
+ === Collection Actions
265
+
266
+ === Member Actions
267
+
268
+
159
269
  == Tools Being Used
160
270
 
161
271
  We believe strongly in not writing code unless we have to, so Active Admin is built using many
@@ -168,8 +278,12 @@ InheritedViews::
168
278
  Inherited Views is a thin addition to Inherited Resources which adds in html views to the mix
169
279
  Formtastic::
170
280
  A DSL for semantically building amazing forms.
281
+ Devise::
282
+ User authentication is done using Devise
171
283
  WillPaginate::
172
284
  Pagination for rails apps
285
+ Iconic Icons::
286
+ Excellent SVG icon set designed by P.J. Onori: http://somerandomdude.com/projects/iconic
173
287
 
174
288
 
175
289
  == Contributors
@@ -179,23 +293,24 @@ WillPaginate::
179
293
  * Sam Vincent http://github.com/samvincent
180
294
  * Matt Vague http://github.com/mattvague
181
295
  * Dan Kubb http://github.com/dkubb
296
+ * Sam Reh http://github.com/samuelreh
182
297
 
183
298
 
184
299
  == Roadmap & Issue Tracking
185
300
 
186
- We are using the awesome Lighthouse ticketing system. The project can be found at:
187
- http://activeadmin.lighthouseapp.com
301
+ We are using the awesome Github issues!
188
302
 
189
303
  == Note on Patches/Pull Requests
190
304
 
191
305
  * Fork the project.
192
- * Make your feature addition or bug fix.
193
- * Add tests for it. This is important so I don't break it in a
306
+ * Make your feature addition or bug fix on a new topic branch
307
+ * Add specs and cukes for it. This is important so I don't break it in a
194
308
  future version unintentionally.
195
309
  * Commit, do not mess with rakefile, version, or history.
196
310
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
197
- * Send me a pull request. Bonus points for topic branches.
311
+ * Send me a pull request.
198
312
 
199
313
  == Copyright
200
314
 
201
315
  Copyright (c) 2010 Greg Bell, VersaPay Corporation. See LICENSE for details.
316
+