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
@@ -0,0 +1,42 @@
1
+ <h2>Overview</h2>
2
+
3
+ <div class="splitcontentleft">
4
+ <p>
5
+ Welcome to the admin area!
6
+ This file is in <%= link_to('/app/views/admin/index.html.erb', "file://#{File.join(RAILS_ROOT, '/app/views/admin/index.html.erb')}", :class => 'external') %>.<br />You should change it.
7
+ </p>
8
+ Styling is pretty simpel but useful. It all comes from Redmine :).
9
+ <ul>
10
+ <li>Google: <a href="http://www.google.com">http://www.google.com</a></li>
11
+ <li>More links:
12
+ <a href="#">Something</a>,
13
+ <a href="#">Something</a>
14
+ </li>
15
+ </ul>
16
+
17
+ <div class="box">
18
+ <h3 class="icon22 icon22-tracker">Nice boxes</h3>
19
+ <ul>
20
+ <li>
21
+ <a href="#">Something</a>:
22
+ info
23
+ </li>
24
+ <li>
25
+ <a href="#">Something</a>:
26
+ info
27
+ </li>
28
+ </ul>
29
+ <p><a href="#">View all</a></p>
30
+ </div>
31
+ </div>
32
+
33
+ <div class="splitcontentright">
34
+ <div class="box">
35
+ <h3 class="icon22 icon22-users">More boxes</h3>
36
+ <p>
37
+ This: <a href="#">Something</a>, <a href="#">Something</a><br />
38
+ </p>
39
+ </div>
40
+ </div>
41
+
42
+ <div style="clear:both;"></div>
@@ -0,0 +1,52 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
6
+ <title>Admin</title>
7
+ <%= stylesheet_link_tag('admin') %>
8
+ <%= javascript_include_tag :defaults %>
9
+ <%= javascript_include_tag 'jquery.admin.js' %>
10
+ <%= csrf_meta_tag %>
11
+ </head>
12
+ <body>
13
+ <a name="top"></a>
14
+ <div id="wrapper">
15
+ <div id="top-menu">
16
+ <div id="loggedas">
17
+ Signed in as <%= '-put code here-' || link_to(current_user, current_user) -%>
18
+ <%= '-logout-' || link_to('logout', logout_path) %>
19
+ </div>
20
+ <ul><li><a class="home" href="/">Back to main site</a></li></ul>
21
+ </div>
22
+ <div id="header">
23
+ <h1><%= link_to 'Admin', admin_root_path %></h1>
24
+ <div id="main-menu">
25
+ <div class="tabs" id="admin_tabnav">
26
+ <ul>
27
+ <%= content_tag(:li, link_to('Overview', '/admin', :class => ((controller_name == 'admin') ? 'selected' : ''))) %>
28
+ <% Admin::BaseController.tabs.each do |tab| %>
29
+ <%= content_tag(:li, link_to(tab.humanize, {:controller => "admin/#{tab}"}, :class => ((controller_name == tab) ? 'active' : ''))) %>
30
+ <% end %>
31
+ </ul>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <%= tag('div', {:id => 'main', :class => (has_content?(:sidebar) ? '' : 'nosidebar')}, true) %>
36
+ <div id="sidebar">
37
+ <%= yield :sidebar %>
38
+ </div>
39
+ <div id="content">
40
+ <%= render_flash_messages %>
41
+ <%= yield %>
42
+ </div>
43
+ </div>
44
+
45
+ <div id="ajax-indicator" style="display:none;"><span>Loading...</span></div>
46
+
47
+ <div id="footer">
48
+ Powered by <a href="mailto:team@truvolabs.com">TruvoLabs</a> &copy; 2009
49
+ </div>
50
+ </div>
51
+ </body>
52
+ </html>
@@ -0,0 +1,20 @@
1
+ Description:
2
+ Similar to original Rails scaffold generator but for admin interface.
3
+ Does NOT create model since you probably have it already.
4
+
5
+ Scaffolds controller and views for use in your admin view. The resource is
6
+ ready to use as a starting point for your RESTful, resource-oriented
7
+ application.
8
+
9
+ Pass the name of the model (in singular form), either CamelCased or
10
+ under_scored, as the first argument, and an optional list of attribute
11
+ pairs.
12
+
13
+ Attribute pairs are column_name:sql_type arguments specifying the
14
+ model's attributes. Timestamps are added by default, so you don't have to
15
+ specify them by hand as 'created_at:datetime updated_at:datetime'.
16
+
17
+ Examples:
18
+ `./script/generate admin_scaffold post`
19
+ `./script/generate admin_scaffold post title:string body:text published:boolean`
20
+ `./script/generate admin_scaffold purchase order_id:integer amount:decimal`
@@ -0,0 +1,135 @@
1
+ require 'rails/generators/resource_helpers'
2
+ class AdminScaffoldGenerator < Rails::Generators::NamedBase
3
+
4
+ # See: http://railsapi.com/doc/rails-v3.0.7/classes/Rails/Generators/ResourceHelpers.html
5
+ include Rails::Generators::ResourceHelpers
6
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
+
8
+ source_root File.expand_path("../templates", __FILE__)
9
+
10
+ CONTROLLER_PATH = 'app/controllers/admin'
11
+ # MODEL_PATH = 'app/models/admin'
12
+ VIEW_PATH = 'app/views/admin'
13
+
14
+ # default_options :skip_timestamps => false, :skip_migration => false, :force_plural => false
15
+
16
+ def controller_plural_name
17
+ @name.pluralize.downcase
18
+ end
19
+
20
+ alias_method :controller_file_name, :controller_file_name
21
+ alias_method :controller_table_name, :controller_plural_name
22
+
23
+ def create_admin_scaffold
24
+ @name = file_name
25
+
26
+ if @name == @name.pluralize && !options[:force_plural]
27
+ puts "Plural version of the model detected, using singularized version. Override with --force-plural."
28
+ @name = @name.singularize
29
+ end
30
+
31
+ for action in scaffold_views
32
+ template(
33
+ "view_#{action}.html.erb",
34
+ File.join(VIEW_PATH, controller_class_path, controller_file_name, "#{action}.html.erb")
35
+ )
36
+ end
37
+ template 'view_form_partial.html.erb', File.join(VIEW_PATH, controller_class_path, controller_file_name, "_form.html.erb")
38
+
39
+ readme 'INSTALL'
40
+ end
41
+
42
+ private
43
+
44
+ def scaffold_views
45
+ %w[ index show new edit ]
46
+ end
47
+
48
+ # def create_admin_scaffold
49
+ # @name = file_name
50
+ #
51
+ # if @name == @name.pluralize && !options[:force_plural]
52
+ # logger.warning "Plural version of the model detected, using singularized version. Override with --force-plural."
53
+ # @name = @name.singularize
54
+ # end
55
+ #
56
+ # @controller_name = @name.pluralize
57
+ #
58
+ # base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
59
+ # @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
60
+ # @controller_singular_name=base_name.singularize
61
+ # if @controller_class_nesting.empty?
62
+ # @controller_class_name = @controller_class_name_without_nesting
63
+ # else
64
+ # @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
65
+ # end
66
+ # end
67
+ #
68
+ # def manifest
69
+ # # Check for class naming collisions.
70
+ # # m.class_collisions("Admin::#{controller_class_name}Controller")
71
+ # # m.class_collisions(class_name)
72
+ #
73
+ # # Controller, helper, views, test and stylesheets directories.
74
+ # # m.directory(File.join('app/models', class_path))
75
+ # directory(File.join(CONTROLLER_PATH, controller_class_path))
76
+ # # m.directory(File.join('app/helpers', controller_class_path))
77
+ # directory(File.join(VIEW_PATH, controller_class_path, controller_file_name))
78
+ # # m.directory(File.join('app/views/layouts', controller_class_path))
79
+ # # m.directory(File.join('test/functional', controller_class_path))
80
+ # # m.directory(File.join('test/unit', class_path))
81
+ # # m.directory(File.join('test/unit/helpers', class_path))
82
+ # # m.directory(File.join('public/stylesheets', class_path))
83
+ #
84
+ # for action in scaffold_views
85
+ # template(
86
+ # "view_#{action}.html.erb",
87
+ # File.join(VIEW_PATH, controller_class_path, controller_file_name, "#{action}.html.erb")
88
+ # )
89
+ # end
90
+ # template 'view_form_partial.html.erb', File.join(VIEW_PATH, controller_class_path, controller_file_name, "_form.html.erb")
91
+ #
92
+ # # Layout and stylesheet.
93
+ # # m.template('layout.html.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb"))
94
+ # # m.template('style.css', 'public/stylesheets/scaffold.css')
95
+ #
96
+ # template(
97
+ # 'controller.rb', File.join(CONTROLLER_PATH, controller_class_path, "#{controller_file_name}_controller.rb")
98
+ # )
99
+ #
100
+ # # m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
101
+ # # m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
102
+ # # m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb"))
103
+ #
104
+ # # m.route_resources controller_file_name
105
+ #
106
+ # # m.dependency 'model', [name] + @args, :collision => :skip
107
+ #
108
+ # readme 'INSTALL'
109
+ # end
110
+ #
111
+ # protected
112
+ # # Override with your own usage banner.
113
+ # def banner
114
+ # "Usage: #{$0} scaffold ModelName [field:type, field:type]"
115
+ # end
116
+ #
117
+ # def add_options!(opt)
118
+ # opt.separator ''
119
+ # opt.separator 'Options:'
120
+ # opt.on("--skip-timestamps",
121
+ # "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
122
+ # opt.on("--skip-migration",
123
+ # "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
124
+ # opt.on("--force-plural",
125
+ # "Forces the generation of a plural ModelName") { |v| options[:force_plural] = v }
126
+ # end
127
+ #
128
+ # def scaffold_views
129
+ # %w[ index show new edit ]
130
+ # end
131
+ #
132
+ # def model_name
133
+ # class_name.demodulize
134
+ # end
135
+ end
@@ -0,0 +1,8 @@
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
+
@@ -0,0 +1,5 @@
1
+ class Admin::<%= controller_class_name %>Controller < Admin::ResourceController
2
+
3
+ # See admin/resource_controller.rb for more info..
4
+
5
+ end
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
4
+ test "should get index" do
5
+ get :index
6
+ assert_response :success
7
+ assert_not_nil assigns(:<%= table_name %>)
8
+ end
9
+
10
+ test "should get new" do
11
+ get :new
12
+ assert_response :success
13
+ end
14
+
15
+ test "should create <%= file_name %>" do
16
+ assert_difference('<%= class_name %>.count') do
17
+ post :create, :<%= file_name %> => { }
18
+ end
19
+
20
+ assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
21
+ end
22
+
23
+ test "should show <%= file_name %>" do
24
+ get :show, :id => <%= table_name %>(:one).to_param
25
+ assert_response :success
26
+ end
27
+
28
+ test "should get edit" do
29
+ get :edit, :id => <%= table_name %>(:one).to_param
30
+ assert_response :success
31
+ end
32
+
33
+ test "should update <%= file_name %>" do
34
+ put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
35
+ assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
36
+ end
37
+
38
+ test "should destroy <%= file_name %>" do
39
+ assert_difference('<%= class_name %>.count', -1) do
40
+ delete :destroy, :id => <%= table_name %>(:one).to_param
41
+ end
42
+
43
+ assert_redirected_to <%= table_name %>_path
44
+ end
45
+ end
@@ -0,0 +1,2 @@
1
+ module <%= controller_class_name %>Helper
2
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>HelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title><%= controller_class_name %>: <%%= controller.action_name %></title>
8
+ <%%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%%= flash[:notice] %></p>
13
+
14
+ <%%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,54 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ .fieldWithErrors {
20
+ padding: 2px;
21
+ background-color: red;
22
+ display: table;
23
+ }
24
+
25
+ #errorExplanation {
26
+ width: 400px;
27
+ border: 2px solid red;
28
+ padding: 7px;
29
+ padding-bottom: 12px;
30
+ margin-bottom: 20px;
31
+ background-color: #f0f0f0;
32
+ }
33
+
34
+ #errorExplanation h2 {
35
+ text-align: left;
36
+ font-weight: bold;
37
+ padding: 5px 5px 5px 15px;
38
+ font-size: 12px;
39
+ margin: -7px;
40
+ background-color: #c00;
41
+ color: #fff;
42
+ }
43
+
44
+ #errorExplanation p {
45
+ color: #333;
46
+ margin-bottom: 0;
47
+ padding: 5px;
48
+ }
49
+
50
+ #errorExplanation ul li {
51
+ font-size: 12px;
52
+ list-style: square;
53
+ }
54
+
@@ -0,0 +1,15 @@
1
+ <div class="contextual">
2
+ <%%= link_to 'Show', [:admin, @<%= singular_name %>], :class => 'icon icon-details' %>
3
+ <%%= link_to 'Destroy', [:admin, @<%= singular_name %>], :confirm => 'Are you sure?', :method => :delete, :class => 'icon icon-del' %>
4
+ </div>
5
+
6
+ <h2>Editing <%= singular_name %></h2>
7
+
8
+ <%%= form_for(@<%= singular_name %>, :url => [:admin, @<%= singular_name %>], :html => {:class => 'tabular'}) do |form| %>
9
+ <%%= form.error_messages %>
10
+
11
+ <%%= render :partial => form %>
12
+
13
+ <%%= form.submit 'Update' %>
14
+ <%%= link_to 'Back', admin_<%= plural_name %>_path %>
15
+ <%% end %>
@@ -0,0 +1,16 @@
1
+ <%% content_for(:sidebar) do %>
2
+ <h3>Sidebar</h3>
3
+ You can add information in the sidebar if you like.
4
+
5
+ <h3>Or not</h3>
6
+ Or you can leave it out by removing content_for.
7
+ <%% end %>
8
+
9
+ <div class="box">
10
+ <% for attribute in attributes -%>
11
+ <p>
12
+ <%%= form.label :<%= attribute.name %> %>
13
+ <%%= form.<%= attribute.field_type %> :<%= attribute.name %> %>
14
+ </p>
15
+ <% end -%>
16
+ </div>
@@ -0,0 +1,59 @@
1
+ <div class="contextual">
2
+ <%%= link_to 'New <%= singular_name %>', new_admin_<%= singular_name %>_path, :class => 'icon icon-add' %>
3
+ </div>
4
+
5
+ <h2><%= plural_name.humanize %></h2>
6
+
7
+ <%% if @<%= plural_name %>.blank? %>
8
+ <p class="nodata">No data to display</p>
9
+ <%% else %>
10
+ <table class="list issues">
11
+ <thead>
12
+ <tr>
13
+ <th class="checkbox"><%%= image_tag "admin/true.png" %></th>
14
+ <% for attribute in attributes -%>
15
+ <% if defined?(Searchlogic) -%>
16
+ <th><%%= order(@search, {:by => :<%= attribute.name %>}) %></th>
17
+ <% else -%>
18
+ <th><%= attribute.human_name %></th>
19
+ <% end -%>
20
+ <% end -%>
21
+ <th></th>
22
+ </tr>
23
+ </thead>
24
+
25
+ <%%= form_tag(destroy_all_admin_<%= plural_name %>_path, :method => :delete) do %>
26
+ <tbody>
27
+ <%% @<%= plural_name %>.each do |<%= singular_name %>| %>
28
+ <tr class="<%%= cycle('odd', 'even') %>">
29
+ <td class="checkbox">
30
+ <%%= check_box_tag('ids[]', <%= singular_name %>.id, nil, :id => "ids_#{<%= singular_name %>.id}") %>
31
+ </td>
32
+ <% for attribute in attributes -%>
33
+ <td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
34
+ <% end -%>
35
+ <td class="buttons">
36
+ <%%= link_to 'Show', [:admin, <%= singular_name %>], :class => 'icon icon-details' %>
37
+ <%%= link_to 'Edit', edit_admin_<%= singular_name %>_path(<%= singular_name %>), :class => 'icon icon-edit' %>
38
+ <%%= link_to 'Destroy', [:admin, <%= singular_name %>], :confirm => 'Are you sure?', :method => :delete, :class => 'icon icon-del' %>
39
+ </td>
40
+ </tr>
41
+ <%% end %>
42
+ </tbody>
43
+ <tfoot>
44
+ <tr>
45
+ <th></th>
46
+ <th colspan="<%= attributes.size %>"><%%= submit_tag "Delete", :confirm => 'Are you sure?' %></th>
47
+ <th></th>
48
+ </tr>
49
+ </tfoot>
50
+ <%% end %>
51
+ </table>
52
+ <%% end %>
53
+ <%
54
+ # Remove unneeded stuff here
55
+ if defined?(Searchlogic) || defined?(WillPaginate)
56
+ # If you have WillPaginate installed (you should!)
57
+ %>
58
+ <%%= will_paginate(@<%= plural_name %>) %>
59
+ <% end %>