admin_interface 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. data/README.rdoc +87 -0
  2. data/admin_interface.gemspec +17 -0
  3. data/lib/generators/admin_interface/USAGE +1 -0
  4. data/lib/generators/admin_interface/admin_interface_generator.rb +42 -0
  5. data/lib/generators/admin_interface/templates/INSTALL +10 -0
  6. data/lib/generators/admin_interface/templates/controllers/base_controller.rb +32 -0
  7. data/lib/generators/admin_interface/templates/controllers/resource_controller.rb +92 -0
  8. data/lib/generators/admin_interface/templates/helpers/admin_helper.rb +24 -0
  9. data/lib/generators/admin_interface/templates/images/1downarrow.png +0 -0
  10. data/lib/generators/admin_interface/templates/images/1uparrow.png +0 -0
  11. data/lib/generators/admin_interface/templates/images/22x22/.svn/all-wcprops +89 -0
  12. data/lib/generators/admin_interface/templates/images/22x22/.svn/entries +210 -0
  13. data/lib/generators/admin_interface/templates/images/22x22/.svn/format +1 -0
  14. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/authent.png.svn-base +5 -0
  15. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/comment.png.svn-base +5 -0
  16. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/file.png.svn-base +5 -0
  17. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/info.png.svn-base +5 -0
  18. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/notifications.png.svn-base +5 -0
  19. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/options.png.svn-base +5 -0
  20. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/package.png.svn-base +5 -0
  21. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/plugin.png.svn-base +5 -0
  22. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/projects.png.svn-base +5 -0
  23. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/role.png.svn-base +5 -0
  24. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/settings.png.svn-base +5 -0
  25. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/tracker.png.svn-base +5 -0
  26. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/users.png.svn-base +5 -0
  27. data/lib/generators/admin_interface/templates/images/22x22/.svn/prop-base/workflow.png.svn-base +5 -0
  28. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/authent.png.svn-base +0 -0
  29. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/comment.png.svn-base +0 -0
  30. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/file.png.svn-base +0 -0
  31. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/info.png.svn-base +0 -0
  32. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/notifications.png.svn-base +0 -0
  33. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/options.png.svn-base +0 -0
  34. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/package.png.svn-base +0 -0
  35. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/plugin.png.svn-base +0 -0
  36. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/projects.png.svn-base +0 -0
  37. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/role.png.svn-base +0 -0
  38. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/settings.png.svn-base +0 -0
  39. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/tracker.png.svn-base +0 -0
  40. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/users.png.svn-base +0 -0
  41. data/lib/generators/admin_interface/templates/images/22x22/.svn/text-base/workflow.png.svn-base +0 -0
  42. data/lib/generators/admin_interface/templates/images/22x22/authent.png +0 -0
  43. data/lib/generators/admin_interface/templates/images/22x22/comment.png +0 -0
  44. data/lib/generators/admin_interface/templates/images/22x22/file.png +0 -0
  45. data/lib/generators/admin_interface/templates/images/22x22/info.png +0 -0
  46. data/lib/generators/admin_interface/templates/images/22x22/notifications.png +0 -0
  47. data/lib/generators/admin_interface/templates/images/22x22/options.png +0 -0
  48. data/lib/generators/admin_interface/templates/images/22x22/package.png +0 -0
  49. data/lib/generators/admin_interface/templates/images/22x22/plugin.png +0 -0
  50. data/lib/generators/admin_interface/templates/images/22x22/projects.png +0 -0
  51. data/lib/generators/admin_interface/templates/images/22x22/role.png +0 -0
  52. data/lib/generators/admin_interface/templates/images/22x22/settings.png +0 -0
  53. data/lib/generators/admin_interface/templates/images/22x22/tracker.png +0 -0
  54. data/lib/generators/admin_interface/templates/images/22x22/users.png +0 -0
  55. data/lib/generators/admin_interface/templates/images/22x22/workflow.png +0 -0
  56. data/lib/generators/admin_interface/templates/images/2downarrow.png +0 -0
  57. data/lib/generators/admin_interface/templates/images/2uparrow.png +0 -0
  58. data/lib/generators/admin_interface/templates/images/add.png +0 -0
  59. data/lib/generators/admin_interface/templates/images/arrow_collapsed.png +0 -0
  60. data/lib/generators/admin_interface/templates/images/arrow_down.png +0 -0
  61. data/lib/generators/admin_interface/templates/images/arrow_expanded.png +0 -0
  62. data/lib/generators/admin_interface/templates/images/attachment.png +0 -0
  63. data/lib/generators/admin_interface/templates/images/bullet_add.png +0 -0
  64. data/lib/generators/admin_interface/templates/images/bullet_arrow_left.png +0 -0
  65. data/lib/generators/admin_interface/templates/images/bullet_arrow_right.png +0 -0
  66. data/lib/generators/admin_interface/templates/images/bullet_black.png +0 -0
  67. data/lib/generators/admin_interface/templates/images/bullet_blue.png +0 -0
  68. data/lib/generators/admin_interface/templates/images/bullet_delete.png +0 -0
  69. data/lib/generators/admin_interface/templates/images/bullet_diamond.png +0 -0
  70. data/lib/generators/admin_interface/templates/images/bullet_end.png +0 -0
  71. data/lib/generators/admin_interface/templates/images/bullet_go.png +0 -0
  72. data/lib/generators/admin_interface/templates/images/bullet_orange.png +0 -0
  73. data/lib/generators/admin_interface/templates/images/bullet_purple.png +0 -0
  74. data/lib/generators/admin_interface/templates/images/bullet_toggle_minus.png +0 -0
  75. data/lib/generators/admin_interface/templates/images/bullet_toggle_plus.png +0 -0
  76. data/lib/generators/admin_interface/templates/images/calendar.png +0 -0
  77. data/lib/generators/admin_interface/templates/images/cancel.png +0 -0
  78. data/lib/generators/admin_interface/templates/images/changeset.png +0 -0
  79. data/lib/generators/admin_interface/templates/images/close.png +0 -0
  80. data/lib/generators/admin_interface/templates/images/close_hl.png +0 -0
  81. data/lib/generators/admin_interface/templates/images/comment.png +0 -0
  82. data/lib/generators/admin_interface/templates/images/comments.png +0 -0
  83. data/lib/generators/admin_interface/templates/images/copy.png +0 -0
  84. data/lib/generators/admin_interface/templates/images/database_key.png +0 -0
  85. data/lib/generators/admin_interface/templates/images/delete.png +0 -0
  86. data/lib/generators/admin_interface/templates/images/destroy.png +0 -0
  87. data/lib/generators/admin_interface/templates/images/document.png +0 -0
  88. data/lib/generators/admin_interface/templates/images/download.png +0 -0
  89. data/lib/generators/admin_interface/templates/images/draft.png +0 -0
  90. data/lib/generators/admin_interface/templates/images/duplicate.png +0 -0
  91. data/lib/generators/admin_interface/templates/images/edit.png +0 -0
  92. data/lib/generators/admin_interface/templates/images/email.png +0 -0
  93. data/lib/generators/admin_interface/templates/images/exclamation.png +0 -0
  94. data/lib/generators/admin_interface/templates/images/external.png +0 -0
  95. data/lib/generators/admin_interface/templates/images/false.png +0 -0
  96. data/lib/generators/admin_interface/templates/images/fav.png +0 -0
  97. data/lib/generators/admin_interface/templates/images/fav_off.png +0 -0
  98. data/lib/generators/admin_interface/templates/images/feed.png +0 -0
  99. data/lib/generators/admin_interface/templates/images/files/c.png +0 -0
  100. data/lib/generators/admin_interface/templates/images/files/csharp.png +0 -0
  101. data/lib/generators/admin_interface/templates/images/files/default.png +0 -0
  102. data/lib/generators/admin_interface/templates/images/files/image.png +0 -0
  103. data/lib/generators/admin_interface/templates/images/files/pdf.png +0 -0
  104. data/lib/generators/admin_interface/templates/images/files/php.png +0 -0
  105. data/lib/generators/admin_interface/templates/images/files/ruby.png +0 -0
  106. data/lib/generators/admin_interface/templates/images/files/text.png +0 -0
  107. data/lib/generators/admin_interface/templates/images/files/xml.png +0 -0
  108. data/lib/generators/admin_interface/templates/images/files/zip.png +0 -0
  109. data/lib/generators/admin_interface/templates/images/folder.png +0 -0
  110. data/lib/generators/admin_interface/templates/images/folder_open.png +0 -0
  111. data/lib/generators/admin_interface/templates/images/folder_open_add.png +0 -0
  112. data/lib/generators/admin_interface/templates/images/folder_open_orange.png +0 -0
  113. data/lib/generators/admin_interface/templates/images/group.png +0 -0
  114. data/lib/generators/admin_interface/templates/images/help.png +0 -0
  115. data/lib/generators/admin_interface/templates/images/history.png +0 -0
  116. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_bq.png +0 -0
  117. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_bq_remove.png +0 -0
  118. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_code.png +0 -0
  119. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_del.png +0 -0
  120. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_em.png +0 -0
  121. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_h1.png +0 -0
  122. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_h2.png +0 -0
  123. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_h3.png +0 -0
  124. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_img.png +0 -0
  125. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_ins.png +0 -0
  126. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_link.png +0 -0
  127. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_ol.png +0 -0
  128. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_pre.png +0 -0
  129. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_strong.png +0 -0
  130. data/lib/generators/admin_interface/templates/images/jstoolbar/bt_ul.png +0 -0
  131. data/lib/generators/admin_interface/templates/images/lightning.png +0 -0
  132. data/lib/generators/admin_interface/templates/images/link.png +0 -0
  133. data/lib/generators/admin_interface/templates/images/loading.gif +0 -0
  134. data/lib/generators/admin_interface/templates/images/locked.png +0 -0
  135. data/lib/generators/admin_interface/templates/images/message.png +0 -0
  136. data/lib/generators/admin_interface/templates/images/milestone.png +0 -0
  137. data/lib/generators/admin_interface/templates/images/move.png +0 -0
  138. data/lib/generators/admin_interface/templates/images/news.png +0 -0
  139. data/lib/generators/admin_interface/templates/images/openid-bg.gif +0 -0
  140. data/lib/generators/admin_interface/templates/images/package.png +0 -0
  141. data/lib/generators/admin_interface/templates/images/page_go.png +0 -0
  142. data/lib/generators/admin_interface/templates/images/plugin.png +0 -0
  143. data/lib/generators/admin_interface/templates/images/projects.png +0 -0
  144. data/lib/generators/admin_interface/templates/images/reload.png +0 -0
  145. data/lib/generators/admin_interface/templates/images/report.png +0 -0
  146. data/lib/generators/admin_interface/templates/images/save.png +0 -0
  147. data/lib/generators/admin_interface/templates/images/search.png +0 -0
  148. data/lib/generators/admin_interface/templates/images/server_key.png +0 -0
  149. data/lib/generators/admin_interface/templates/images/sort_asc.png +0 -0
  150. data/lib/generators/admin_interface/templates/images/sort_desc.png +0 -0
  151. data/lib/generators/admin_interface/templates/images/stats.png +0 -0
  152. data/lib/generators/admin_interface/templates/images/table_multiple.png +0 -0
  153. data/lib/generators/admin_interface/templates/images/task_done.png +0 -0
  154. data/lib/generators/admin_interface/templates/images/task_late.png +0 -0
  155. data/lib/generators/admin_interface/templates/images/task_parent_end.png +0 -0
  156. data/lib/generators/admin_interface/templates/images/task_todo.png +0 -0
  157. data/lib/generators/admin_interface/templates/images/text_list_bullets.png +0 -0
  158. data/lib/generators/admin_interface/templates/images/textfield.png +0 -0
  159. data/lib/generators/admin_interface/templates/images/ticket.png +0 -0
  160. data/lib/generators/admin_interface/templates/images/ticket_checked.png +0 -0
  161. data/lib/generators/admin_interface/templates/images/ticket_edit.png +0 -0
  162. data/lib/generators/admin_interface/templates/images/ticket_go.png +0 -0
  163. data/lib/generators/admin_interface/templates/images/ticket_note.png +0 -0
  164. data/lib/generators/admin_interface/templates/images/time.png +0 -0
  165. data/lib/generators/admin_interface/templates/images/time_add.png +0 -0
  166. data/lib/generators/admin_interface/templates/images/toggle_check.png +0 -0
  167. data/lib/generators/admin_interface/templates/images/true.png +0 -0
  168. data/lib/generators/admin_interface/templates/images/unlock.png +0 -0
  169. data/lib/generators/admin_interface/templates/images/user.png +0 -0
  170. data/lib/generators/admin_interface/templates/images/user_go.png +0 -0
  171. data/lib/generators/admin_interface/templates/images/warning.png +0 -0
  172. data/lib/generators/admin_interface/templates/images/wiki_edit.png +0 -0
  173. data/lib/generators/admin_interface/templates/images/zoom_in.png +0 -0
  174. data/lib/generators/admin_interface/templates/images/zoom_in_g.png +0 -0
  175. data/lib/generators/admin_interface/templates/images/zoom_out.png +0 -0
  176. data/lib/generators/admin_interface/templates/images/zoom_out_g.png +0 -0
  177. data/lib/generators/admin_interface/templates/javascripts/jquery.admin.js +25 -0
  178. data/lib/generators/admin_interface/templates/views/admin.css +921 -0
  179. data/lib/generators/admin_interface/templates/views/index.html.erb +42 -0
  180. data/lib/generators/admin_interface/templates/views/layout.html.erb +52 -0
  181. data/lib/generators/admin_scaffold/USAGE +20 -0
  182. data/lib/generators/admin_scaffold/admin_scaffold_generator.rb +135 -0
  183. data/lib/generators/admin_scaffold/templates/INSTALL +8 -0
  184. data/lib/generators/admin_scaffold/templates/controller.rb +5 -0
  185. data/lib/generators/admin_scaffold/templates/functional_test.rb +45 -0
  186. data/lib/generators/admin_scaffold/templates/helper.rb +2 -0
  187. data/lib/generators/admin_scaffold/templates/helper_test.rb +4 -0
  188. data/lib/generators/admin_scaffold/templates/layout.html.erb +17 -0
  189. data/lib/generators/admin_scaffold/templates/style.css +54 -0
  190. data/lib/generators/admin_scaffold/templates/view_edit.html.erb +15 -0
  191. data/lib/generators/admin_scaffold/templates/view_form_partial.html.erb +16 -0
  192. data/lib/generators/admin_scaffold/templates/view_index.html.erb +59 -0
  193. data/lib/generators/admin_scaffold/templates/view_new.html.erb +10 -0
  194. data/lib/generators/admin_scaffold/templates/view_show.html.erb +18 -0
  195. metadata +249 -0
data/README.rdoc ADDED
@@ -0,0 +1,87 @@
1
+ = AdminInterface
2
+
3
+ A Rails admin interface generator for Rails 3. Theme stolen from Redmine. Similar to web-app-theme.
4
+
5
+ == More info
6
+
7
+ Generator to create some nifty admin scaffolds. It can work with SearchLogic and WillPaginate.
8
+ It also has admin authentication really well implemented.
9
+
10
+ == Install
11
+
12
+ Add following to your Gemfile
13
+
14
+ group :development, :test do
15
+ # Generators
16
+ gem 'admin_interface'
17
+ end
18
+
19
+ Or install as plugin from Github.
20
+
21
+ rails plugin install git://github.com/joost/admin_interface.git
22
+
23
+ == Usage / Example
24
+
25
+ === Generate the initial framework (layout, etc.)
26
+
27
+ rails generate admin_interface
28
+
29
+ This will:
30
+ * But some images (stolen from Redmine) into public/images/admin/
31
+ * Create an Admin::BaseController in app/controllers/admin/base_controller.rb
32
+ * Create a layout in app/views/layouts/admin.html.erb
33
+ * Add some jQuery javascripts and CSS
34
+
35
+ Next, add following routes to config/routes.rb.
36
+
37
+ namespace :admin do
38
+ root :to => 'base#index'
39
+ # Add the following after you've used the admin_scaffold generator
40
+ resources :model do
41
+ delete 'delete_all', :on => :collection
42
+ end
43
+ end
44
+
45
+ Change the app/controllers/admin/base_controller.rb to have a before filter
46
+ only allowing admins to access it.
47
+
48
+ === Generate admin models and controllers
49
+
50
+ Create a scaffold for a model, for example:
51
+
52
+ rails generate admin_scaffold post
53
+ rails generate admin_scaffold post title:string body:text published:boolean
54
+ rails generate admin_scaffold purchase order_id:integer amount:decimal
55
+
56
+ This will:
57
+ * Create stuff similar to original Rails scaffold generator but for admin interface.
58
+ * NOT create model since you probably have it already.
59
+
60
+ Pass the name of the model (in singular form), either CamelCased or
61
+ under_scored, as the first argument, and an optional list of attribute
62
+ pairs.
63
+
64
+ Attribute pairs are column_name:sql_type arguments specifying the
65
+ model's attributes. Timestamps are added by default, so you don't have to
66
+ specify them by hand as 'created_at:datetime updated_at:datetime'.
67
+
68
+ === See it in action
69
+
70
+ Go to /admin and you can see everything in action.
71
+
72
+ == Error messages
73
+
74
+ Add this to your environment.rb (see: http://railscasts.com/episodes/39-customize-field-error)
75
+ This will make sure the admin errors will show in correct styling.
76
+
77
+ # Change the error from div to span
78
+ ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag|
79
+ "<span class='fieldWithErrors'>#{html_tag}</span>"
80
+ end
81
+
82
+ == Kudos
83
+
84
+ Kudos, credits or whatever you like more go to:
85
+ * Jean-Philippe Lang (creator of {Redmine}[http://www.redmine.org/]).
86
+
87
+ Copyright (c) 2010 Joost Hietbrink, released under the MIT license
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "devise/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "admin_interface"
7
+ s.version = '1.0.0'
8
+ s.platform = Gem::Platform::RUBY
9
+ s.summary = "A Rails admin interface generator. Theme stolen from Redmine."
10
+ s.email = "joost@joopp.com"
11
+ s.homepage = "http://github.com/joost/admin_interface"
12
+ s.description = "A Rails admin interface generator. Theme stolen from Redmine. Similar to web-app-theme."
13
+ s.authors = ['Joost Hietbrink']
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.require_paths = ["lib"]
17
+ end
@@ -0,0 +1 @@
1
+ Nothing much to say.. just run it.
@@ -0,0 +1,42 @@
1
+ class AdminInterfaceGenerator < Rails::Generators::Base
2
+
3
+ source_root File.expand_path("../templates", __FILE__)
4
+
5
+ def copy_image_files
6
+ # Images
7
+ # Copy all images to public/images/admin
8
+ admin_image_dir = File.join('public', 'images', 'admin')
9
+ directory('images', admin_image_dir)
10
+ end
11
+
12
+ def copy_controller_files
13
+ copy_file("controllers/base_controller.rb", "app/controllers/admin/base_controller.rb")
14
+ copy_file("controllers/resource_controller.rb", "app/controllers/admin/resource_controller.rb")
15
+ end
16
+
17
+ def copy_view_files
18
+ copy_file("views/layout.html.erb", "app/views/layouts/admin.html.erb")
19
+ copy_file("views/index.html.erb", "app/views/admin/index.html.erb")
20
+ end
21
+
22
+ def copy_javascript_files
23
+ copy_file("javascripts/jquery.admin.js", "public/javascripts/jquery.admin.js")
24
+ end
25
+
26
+ def copy_stylesheet_files
27
+ copy_file("views/admin.css", "public/stylesheets/admin.css")
28
+ end
29
+
30
+ def copy_helper_files
31
+ copy_file("helpers/admin_helper.rb", "app/helpers/admin_helper.rb")
32
+ end
33
+
34
+ # def add_admin_route
35
+ # route("namespace :admin do\n root :to => 'base#index'\n # resources :some_model do\n # delete 'delete_all', :on => :collection\n # end\n end")
36
+ # end
37
+
38
+ def show_readme
39
+ readme("INSTALL")
40
+ end
41
+
42
+ end
@@ -0,0 +1,10 @@
1
+ Add following routes to config/routes.rb
2
+
3
+ map.admin 'admin', :controller => 'admin'
4
+ map.namespace :admin do |admin|
5
+ # Add the following after you've used the admin_scaffold generator
6
+ # admin.resources :model, :collection => {:destroy_all => :delete}
7
+ end
8
+
9
+ Change the app/controllers/admin_controller.rb to have a before filter
10
+ only allowing admins to access it.
@@ -0,0 +1,32 @@
1
+ # The AdminController is the parent class that makes sure all administrator actions
2
+ # require a logged-in User with an admin Role.
3
+ class Admin::BaseController < ApplicationController
4
+
5
+ layout 'admin'
6
+
7
+ # Replace this with your own authentication / authorization stuff
8
+ before_filter :http_authentication
9
+ # Example when using Devise gem
10
+ # before_filter :authenticate_admin!
11
+
12
+ # Add controller names you want to include as tab. Eg.
13
+ # @@tabs = %w(messages) # if you created a Admin::MessagesController using the admin_scaffold generator.
14
+ cattr_accessor :tabs
15
+ @@tabs = %w()
16
+
17
+ # GET /admin/
18
+ def index
19
+ end
20
+
21
+ private
22
+
23
+ ADMIN_USERNAME = 'admin'
24
+ ADMIN_PASSWORD = 'admin'
25
+
26
+ def http_authentication
27
+ authenticate_or_request_with_http_basic do |username, password|
28
+ username == ADMIN_USERNAME && password == ADMIN_PASSWORD
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,92 @@
1
+ class Admin::ResourceController < Admin::BaseController
2
+
3
+ before_filter :filter_load_resources, :only => [:index]
4
+ before_filter :filter_load_resource, :only => [:show, :edit, :update, :destroy]
5
+
6
+ def index
7
+ @resources = resource_class.paginate(:page => params[:page], :per_page => params[:per_page])
8
+ end
9
+
10
+ def show
11
+ end
12
+
13
+ def new
14
+ @resource = resource_class.new
15
+ instance_variable_set("@#{resource_instance_variable_name}", @resource)
16
+ end
17
+
18
+ def edit
19
+ end
20
+
21
+ def create
22
+ @resource = resource_class.new(params_hash_for_resource)
23
+ instance_variable_set("@#{resource_instance_variable_name}", @resource)
24
+
25
+ if @resource.save
26
+ redirect_to([:admin, @resource], :notice => 'Object was successfully created.')
27
+ else
28
+ render :action => "new"
29
+ end
30
+ end
31
+
32
+ def update
33
+ if @resource.update_attributes(params_hash_for_resource)
34
+ redirect_to([:admin, @resource], :notice => 'Object was successfully updated.')
35
+ else
36
+ render :action => "edit"
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ @resource.destroy
42
+
43
+ redirect_to :action => :index
44
+ end
45
+
46
+ def destroy_all
47
+ destroyed_resources = resource_class.destroy_all(:id => params[:ids])
48
+ flash[:notice] = "#{destroyed_resources.size} objects destroyed."
49
+ redirect_to :action => :index
50
+ end
51
+
52
+ protected
53
+
54
+ def current_resources
55
+ @resources ||= resource_class.paginate(:page => params[:page], :per_page => params[:per_page])
56
+ end
57
+
58
+ def current_resource
59
+ @resource ||= resource_class.find(params[:id])
60
+ end
61
+
62
+ def resource_class
63
+ controller_name.singularize.camelize.constantize
64
+ end
65
+
66
+ def filter_load_resources
67
+ instance_variable_set("@#{resources_instance_variable_name}", current_resources)
68
+ end
69
+
70
+ def filter_load_resource
71
+ instance_variable_set("@#{resource_instance_variable_name}", current_resource)
72
+ end
73
+
74
+ def resources_instance_variable_name
75
+ instance_variable_name
76
+ end
77
+
78
+ def resource_instance_variable_name
79
+ instance_variable_name.singularize
80
+ end
81
+
82
+ # The name of the instance variable that load_object should assign to.
83
+ # By default this is the controller_name.
84
+ def instance_variable_name
85
+ controller_name
86
+ end
87
+
88
+ def params_hash_for_resource
89
+ params[resource_instance_variable_name]
90
+ end
91
+
92
+ end
@@ -0,0 +1,24 @@
1
+ module AdminHelper
2
+
3
+ # Following methods are ripped from RedMine but very nice!
4
+
5
+ def content_for(name, content = nil, &block)
6
+ @has_content ||= {}
7
+ @has_content[name] = true
8
+ super(name, content, &block)
9
+ end
10
+
11
+ def has_content?(name)
12
+ (@has_content && @has_content[name]) || false
13
+ end
14
+
15
+ # Renders flash messages
16
+ def render_flash_messages
17
+ flash_string = ''
18
+ flash.each do |k,v|
19
+ flash_string << content_tag('div', v, :class => "flash #{k}")
20
+ end
21
+ flash_string.html_safe
22
+ end
23
+
24
+ end
@@ -0,0 +1,89 @@
1
+ K 25
2
+ svn:wc:ra_dav:version-url
3
+ V 43
4
+ /svn/!svn/ver/752/trunk/public/images/22x22
5
+ END
6
+ plugin.png
7
+ K 25
8
+ svn:wc:ra_dav:version-url
9
+ V 54
10
+ /svn/!svn/ver/752/trunk/public/images/22x22/plugin.png
11
+ END
12
+ file.png
13
+ K 25
14
+ svn:wc:ra_dav:version-url
15
+ V 52
16
+ /svn/!svn/ver/157/trunk/public/images/22x22/file.png
17
+ END
18
+ settings.png
19
+ K 25
20
+ svn:wc:ra_dav:version-url
21
+ V 56
22
+ /svn/!svn/ver/167/trunk/public/images/22x22/settings.png
23
+ END
24
+ role.png
25
+ K 25
26
+ svn:wc:ra_dav:version-url
27
+ V 52
28
+ /svn/!svn/ver/157/trunk/public/images/22x22/role.png
29
+ END
30
+ users.png
31
+ K 25
32
+ svn:wc:ra_dav:version-url
33
+ V 53
34
+ /svn/!svn/ver/157/trunk/public/images/22x22/users.png
35
+ END
36
+ comment.png
37
+ K 25
38
+ svn:wc:ra_dav:version-url
39
+ V 55
40
+ /svn/!svn/ver/529/trunk/public/images/22x22/comment.png
41
+ END
42
+ authent.png
43
+ K 25
44
+ svn:wc:ra_dav:version-url
45
+ V 55
46
+ /svn/!svn/ver/157/trunk/public/images/22x22/authent.png
47
+ END
48
+ notifications.png
49
+ K 25
50
+ svn:wc:ra_dav:version-url
51
+ V 61
52
+ /svn/!svn/ver/157/trunk/public/images/22x22/notifications.png
53
+ END
54
+ projects.png
55
+ K 25
56
+ svn:wc:ra_dav:version-url
57
+ V 56
58
+ /svn/!svn/ver/157/trunk/public/images/22x22/projects.png
59
+ END
60
+ workflow.png
61
+ K 25
62
+ svn:wc:ra_dav:version-url
63
+ V 56
64
+ /svn/!svn/ver/157/trunk/public/images/22x22/workflow.png
65
+ END
66
+ info.png
67
+ K 25
68
+ svn:wc:ra_dav:version-url
69
+ V 52
70
+ /svn/!svn/ver/157/trunk/public/images/22x22/info.png
71
+ END
72
+ options.png
73
+ K 25
74
+ svn:wc:ra_dav:version-url
75
+ V 55
76
+ /svn/!svn/ver/157/trunk/public/images/22x22/options.png
77
+ END
78
+ package.png
79
+ K 25
80
+ svn:wc:ra_dav:version-url
81
+ V 55
82
+ /svn/!svn/ver/164/trunk/public/images/22x22/package.png
83
+ END
84
+ tracker.png
85
+ K 25
86
+ svn:wc:ra_dav:version-url
87
+ V 55
88
+ /svn/!svn/ver/157/trunk/public/images/22x22/tracker.png
89
+ END
@@ -0,0 +1,210 @@
1
+ 8
2
+
3
+ dir
4
+ 2744
5
+ http://redmine.rubyforge.org/svn/trunk/public/images/22x22
6
+ http://redmine.rubyforge.org/svn
7
+
8
+
9
+
10
+ 2007-09-23T17:19:27.414302Z
11
+ 752
12
+ jplang
13
+
14
+
15
+ svn:special svn:externals svn:needs-lock
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ e93f8b46-1217-0410-a6f0-8f06a7374b81
28
+
29
+ plugin.png
30
+ file
31
+
32
+
33
+
34
+
35
+ 2009-05-16T12:05:29.000000Z
36
+ 32ae7e9669b540005c55e2fd631ae82f
37
+ 2007-09-23T17:19:27.414302Z
38
+ 752
39
+ jplang
40
+ has-props
41
+
42
+ file.png
43
+ file
44
+
45
+
46
+
47
+
48
+ 2009-05-16T12:05:29.000000Z
49
+ 77b52b5eaca4d4d49c2e45e7bb4517ac
50
+ 2007-01-08T19:21:59.140156Z
51
+ 157
52
+ jplang
53
+ has-props
54
+
55
+ settings.png
56
+ file
57
+
58
+
59
+
60
+
61
+ 2009-05-16T12:05:29.000000Z
62
+ be61e0c45535750b21d00fdc958384cf
63
+ 2007-01-21T11:50:22.864544Z
64
+ 167
65
+ jplang
66
+ has-props
67
+
68
+ role.png
69
+ file
70
+
71
+
72
+
73
+
74
+ 2009-05-16T12:05:29.000000Z
75
+ 8f90fc8e800d46206b3535c34909547a
76
+ 2007-01-08T19:21:59.140156Z
77
+ 157
78
+ jplang
79
+ has-props
80
+
81
+ users.png
82
+ file
83
+
84
+
85
+
86
+
87
+ 2009-05-16T12:05:29.000000Z
88
+ ecd3405a134857f862a7728c1e37bcb0
89
+ 2007-01-08T19:21:59.140156Z
90
+ 157
91
+ jplang
92
+ has-props
93
+
94
+ comment.png
95
+ file
96
+
97
+
98
+
99
+
100
+ 2009-05-16T12:05:29.000000Z
101
+ 751aecd22b463fe4195dc0ca48b7f346
102
+ 2007-05-13T17:09:56.765659Z
103
+ 529
104
+ jplang
105
+ has-props
106
+
107
+ authent.png
108
+ file
109
+
110
+
111
+
112
+
113
+ 2009-05-16T12:05:29.000000Z
114
+ 044dc1865020a28ee079d589a56502f9
115
+ 2007-01-08T19:21:59.140156Z
116
+ 157
117
+ jplang
118
+ has-props
119
+
120
+ notifications.png
121
+ file
122
+
123
+
124
+
125
+
126
+ 2009-05-16T12:05:29.000000Z
127
+ 122667ef626bce599397e1dcc1f71ec7
128
+ 2007-01-08T19:21:59.140156Z
129
+ 157
130
+ jplang
131
+ has-props
132
+
133
+ projects.png
134
+ file
135
+
136
+
137
+
138
+
139
+ 2009-05-16T12:05:29.000000Z
140
+ 09496465ad3e12b20daf7755facbb76b
141
+ 2007-01-08T19:21:59.140156Z
142
+ 157
143
+ jplang
144
+ has-props
145
+
146
+ workflow.png
147
+ file
148
+
149
+
150
+
151
+
152
+ 2009-05-16T12:05:29.000000Z
153
+ 0153917416905d5bde62a73eb4c664db
154
+ 2007-01-08T19:21:59.140156Z
155
+ 157
156
+ jplang
157
+ has-props
158
+
159
+ info.png
160
+ file
161
+
162
+
163
+
164
+
165
+ 2009-05-16T12:05:29.000000Z
166
+ e57082db2c35e65f200e2bc8a59bc58d
167
+ 2007-01-08T19:21:59.140156Z
168
+ 157
169
+ jplang
170
+ has-props
171
+
172
+ options.png
173
+ file
174
+
175
+
176
+
177
+
178
+ 2009-05-16T12:05:29.000000Z
179
+ 7aa134d4b5879703730cfd508407ddb2
180
+ 2007-01-08T19:21:59.140156Z
181
+ 157
182
+ jplang
183
+ has-props
184
+
185
+ package.png
186
+ file
187
+
188
+
189
+
190
+
191
+ 2009-05-16T12:05:29.000000Z
192
+ 17099a3ca91a9e1ed7eb96d009258990
193
+ 2007-01-15T20:14:06.587659Z
194
+ 164
195
+ jplang
196
+ has-props
197
+
198
+ tracker.png
199
+ file
200
+
201
+
202
+
203
+
204
+ 2009-05-16T12:05:29.000000Z
205
+ f7bc5d71c8659e3f1154c6e479e78e10
206
+ 2007-01-08T19:21:59.140156Z
207
+ 157
208
+ jplang
209
+ has-props
210
+