engine_room 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. data/.gitignore +10 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +159 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.rdoc +44 -0
  6. data/Rakefile +30 -0
  7. data/TODO +3 -0
  8. data/app/controllers/engine_room/content_controller.rb +117 -0
  9. data/app/controllers/engine_room/fields_controller.rb +119 -0
  10. data/app/controllers/engine_room/models_controller.rb +89 -0
  11. data/app/controllers/engine_room/pages_controller.rb +17 -0
  12. data/app/controllers/engine_room/sections_controller.rb +74 -0
  13. data/app/controllers/engine_room/users_controller.rb +84 -0
  14. data/app/controllers/er_devise/passwords_controller.rb +6 -0
  15. data/app/controllers/er_devise/registrations_controller.rb +8 -0
  16. data/app/controllers/er_devise/sessions_controller.rb +6 -0
  17. data/app/helpers/engine_room/content_helper.rb +103 -0
  18. data/app/helpers/engine_room/models_helper.rb +21 -0
  19. data/app/models/field.rb +89 -0
  20. data/app/models/section.rb +68 -0
  21. data/app/models/user.rb +31 -0
  22. data/app/views/engine_room/content/_form.html.erb +13 -0
  23. data/app/views/engine_room/content/_overview.html.erb +28 -0
  24. data/app/views/engine_room/content/_sidebar.html.erb +14 -0
  25. data/app/views/engine_room/content/edit.html.erb +38 -0
  26. data/app/views/engine_room/content/index.html.erb +1 -0
  27. data/app/views/engine_room/content/new.html.erb +1 -0
  28. data/app/views/engine_room/content/overview.html.erb +3 -0
  29. data/app/views/engine_room/fields/_form.html.erb +57 -0
  30. data/app/views/engine_room/fields/edit.html.erb +1 -0
  31. data/app/views/engine_room/fields/new.html.erb +1 -0
  32. data/app/views/engine_room/models/_form.html.erb +0 -0
  33. data/app/views/engine_room/models/edit.html.erb +14 -0
  34. data/app/views/engine_room/models/index.html.erb +16 -0
  35. data/app/views/engine_room/models/new.html.erb +14 -0
  36. data/app/views/engine_room/models/overview.html.erb +14 -0
  37. data/app/views/engine_room/pages/dashboard.html.erb +1 -0
  38. data/app/views/engine_room/pages/settings.html.erb +1 -0
  39. data/app/views/engine_room/sections/_form.html.erb +34 -0
  40. data/app/views/engine_room/sections/_sidebar.html.erb +11 -0
  41. data/app/views/engine_room/sections/edit.html.erb +81 -0
  42. data/app/views/engine_room/sections/index.html.erb +3 -0
  43. data/app/views/engine_room/sections/new.html.erb +1 -0
  44. data/app/views/engine_room/users/_form.html.erb +47 -0
  45. data/app/views/engine_room/users/edit.html.erb +11 -0
  46. data/app/views/engine_room/users/index.html.erb +24 -0
  47. data/app/views/engine_room/users/new.html.erb +1 -0
  48. data/app/views/er_devise/mailer/confirmation_instructions.html.erb +5 -0
  49. data/app/views/er_devise/mailer/reset_password_instructions.html.erb +8 -0
  50. data/app/views/er_devise/mailer/unlock_instructions.html.erb +7 -0
  51. data/app/views/er_devise/passwords/edit.html.erb +16 -0
  52. data/app/views/er_devise/passwords/new.html.erb +13 -0
  53. data/app/views/er_devise/registrations/edit.html.erb +42 -0
  54. data/app/views/er_devise/registrations/new.html.erb +21 -0
  55. data/app/views/er_devise/sessions/new.html.erb +23 -0
  56. data/app/views/er_devise/shared/_links.erb +19 -0
  57. data/app/views/layouts/engine_room.html.erb +103 -0
  58. data/app/views/layouts/login.html.erb +71 -0
  59. data/app/views/shared/_content_layout_selector.html.erb +45 -0
  60. data/app/views/shared/_error_messages.html.erb +17 -0
  61. data/config/initializers/devise.rb +146 -0
  62. data/config/initializers/locale.rb +5 -0
  63. data/config/locales/devise.de.yml +42 -0
  64. data/config/locales/devise.en.yml +39 -0
  65. data/config/locales/engine_room.de.yml +33 -0
  66. data/config/locales/engine_room.en.yml +42 -0
  67. data/config/routes.rb +62 -0
  68. data/engine_room.gemspec +35 -0
  69. data/lib/engine_room.rb +17 -0
  70. data/lib/engine_room/action_controller/controller_methods.rb +21 -0
  71. data/lib/engine_room/action_view/view_methods.rb +8 -0
  72. data/lib/engine_room/active_record/record_methods.rb +18 -0
  73. data/lib/engine_room/crummy/custom_renderer.rb +63 -0
  74. data/lib/engine_room/engine.rb +40 -0
  75. data/lib/engine_room/railties/tasks.rake +6 -0
  76. data/lib/engine_room/version.rb +3 -0
  77. data/lib/generators/engine_room/create_image_generator.rb +26 -0
  78. data/lib/generators/engine_room/setup_generator.rb +30 -0
  79. data/lib/generators/engine_room/templates/001_devise_create_users.rb +28 -0
  80. data/lib/generators/engine_room/templates/002_create_sections.rb +16 -0
  81. data/lib/generators/engine_room/templates/003_create_fields.rb +18 -0
  82. data/lib/generators/engine_room/templates/004_create_images.rb +19 -0
  83. data/lib/generators/engine_room/templates/image.rb +4 -0
  84. data/lib/tasks/dummy.rake +45 -0
  85. data/lib/tasks/templates/migrate/050_create_dogs.rb +18 -0
  86. data/lib/tasks/templates/models/dog.rb +3 -0
  87. data/public/images/er/accept.png +0 -0
  88. data/public/images/er/add.png +0 -0
  89. data/public/images/er/add_small.png +0 -0
  90. data/public/images/er/ajax-loader.gif +0 -0
  91. data/public/images/er/attach.png +0 -0
  92. data/public/images/er/back_disabled.jpg +0 -0
  93. data/public/images/er/back_enabled.jpg +0 -0
  94. data/public/images/er/bg/header_gradient_center.jpg +0 -0
  95. data/public/images/er/bg/header_gradient_left.jpg +0 -0
  96. data/public/images/er/bg/header_gradient_right.jpg +0 -0
  97. data/public/images/er/cancel.png +0 -0
  98. data/public/images/er/cog.png +0 -0
  99. data/public/images/er/database_add.png +0 -0
  100. data/public/images/er/delete.png +0 -0
  101. data/public/images/er/delete_small.png +0 -0
  102. data/public/images/er/down_arrow.gif +0 -0
  103. data/public/images/er/down_arrow.png +0 -0
  104. data/public/images/er/email.png +0 -0
  105. data/public/images/er/exclamation.png +0 -0
  106. data/public/images/er/forward_disabled.jpg +0 -0
  107. data/public/images/er/forward_enabled.jpg +0 -0
  108. data/public/images/er/help.png +0 -0
  109. data/public/images/er/image_add.png +0 -0
  110. data/public/images/er/information.png +0 -0
  111. data/public/images/er/link.png +0 -0
  112. data/public/images/er/loader.gif +0 -0
  113. data/public/images/er/telephone.png +0 -0
  114. data/public/images/er/up_arrow.gif +0 -0
  115. data/public/images/er/up_arrow.png +0 -0
  116. data/public/images/er/user.png +0 -0
  117. data/public/images/er/wrench.png +0 -0
  118. data/public/images/er/zoom.png +0 -0
  119. data/public/javascripts/er/dd_belatedpng.js +328 -0
  120. data/public/javascripts/er/fancybox/blank.gif +0 -0
  121. data/public/javascripts/er/fancybox/fancy_close.png +0 -0
  122. data/public/javascripts/er/fancybox/fancy_loading.png +0 -0
  123. data/public/javascripts/er/fancybox/fancy_nav_left.png +0 -0
  124. data/public/javascripts/er/fancybox/fancy_nav_right.png +0 -0
  125. data/public/javascripts/er/fancybox/fancy_shadow_e.png +0 -0
  126. data/public/javascripts/er/fancybox/fancy_shadow_n.png +0 -0
  127. data/public/javascripts/er/fancybox/fancy_shadow_ne.png +0 -0
  128. data/public/javascripts/er/fancybox/fancy_shadow_nw.png +0 -0
  129. data/public/javascripts/er/fancybox/fancy_shadow_s.png +0 -0
  130. data/public/javascripts/er/fancybox/fancy_shadow_se.png +0 -0
  131. data/public/javascripts/er/fancybox/fancy_shadow_sw.png +0 -0
  132. data/public/javascripts/er/fancybox/fancy_shadow_w.png +0 -0
  133. data/public/javascripts/er/fancybox/fancy_title_left.png +0 -0
  134. data/public/javascripts/er/fancybox/fancy_title_main.png +0 -0
  135. data/public/javascripts/er/fancybox/fancy_title_over.png +0 -0
  136. data/public/javascripts/er/fancybox/fancy_title_right.png +0 -0
  137. data/public/javascripts/er/fancybox/fancybox-x.png +0 -0
  138. data/public/javascripts/er/fancybox/fancybox-y.png +0 -0
  139. data/public/javascripts/er/fancybox/fancybox.png +0 -0
  140. data/public/javascripts/er/fancybox/jquery.fancybox-1.3.4.css +359 -0
  141. data/public/javascripts/er/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
  142. data/public/javascripts/er/jquery-1.4.4.min.js +167 -0
  143. data/public/javascripts/er/jquery-ui-1.8.6.custom.min.js +477 -0
  144. data/public/javascripts/er/modernizr-1.5.min.js +28 -0
  145. data/public/javascripts/er/plugins.js +48 -0
  146. data/public/javascripts/er/rails.js +156 -0
  147. data/public/javascripts/er/script.js +50 -0
  148. data/public/stylesheets/.gitkeep +0 -0
  149. data/public/stylesheets/admin.css +417 -0
  150. data/public/stylesheets/boilerplate.css +264 -0
  151. data/public/stylesheets/handheld.css +7 -0
  152. data/public/stylesheets/login.css +125 -0
  153. data/public/stylesheets/skin.css +2 -0
  154. data/public/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  155. data/public/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  156. data/public/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  157. data/public/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  158. data/public/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  159. data/public/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  160. data/public/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  161. data/public/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  162. data/public/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
  163. data/public/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  164. data/public/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
  165. data/public/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
  166. data/public/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  167. data/public/stylesheets/smoothness/jquery-ui-1.8.6.custom.css +479 -0
  168. data/spec/controllers/content_controller_spec.rb +132 -0
  169. data/spec/controllers/fields_controller_spec.rb +103 -0
  170. data/spec/controllers/models_controller_spec.rb +65 -0
  171. data/spec/controllers/pages_controller_spec.rb +40 -0
  172. data/spec/controllers/sections_controller_spec.rb +124 -0
  173. data/spec/dummy/Rakefile +7 -0
  174. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  175. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  176. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  177. data/spec/dummy/config.ru +4 -0
  178. data/spec/dummy/config/application.rb +45 -0
  179. data/spec/dummy/config/boot.rb +10 -0
  180. data/spec/dummy/config/database.yml +22 -0
  181. data/spec/dummy/config/environment.rb +5 -0
  182. data/spec/dummy/config/environments/development.rb +26 -0
  183. data/spec/dummy/config/environments/production.rb +49 -0
  184. data/spec/dummy/config/environments/test.rb +35 -0
  185. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  186. data/spec/dummy/config/initializers/inflections.rb +10 -0
  187. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  188. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  189. data/spec/dummy/config/initializers/session_store.rb +8 -0
  190. data/spec/dummy/config/locales/en.yml +5 -0
  191. data/spec/dummy/config/routes.rb +58 -0
  192. data/spec/dummy/public/404.html +26 -0
  193. data/spec/dummy/public/422.html +26 -0
  194. data/spec/dummy/public/500.html +26 -0
  195. data/spec/dummy/public/favicon.ico +0 -0
  196. data/spec/dummy/public/javascripts/application.js +2 -0
  197. data/spec/dummy/public/javascripts/controls.js +965 -0
  198. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  199. data/spec/dummy/public/javascripts/effects.js +1123 -0
  200. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  201. data/spec/dummy/public/javascripts/rails.js +175 -0
  202. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  203. data/spec/dummy/script/rails +6 -0
  204. data/spec/engine_room_spec.rb +7 -0
  205. data/spec/factories.rb +32 -0
  206. data/spec/integration/navigation_spec.rb +9 -0
  207. data/spec/models/dog_spec.rb +14 -0
  208. data/spec/models/field_spec.rb +74 -0
  209. data/spec/models/section_spec.rb +70 -0
  210. data/spec/models/user_spec.rb +77 -0
  211. data/spec/routing/models_routing_spec.rb +66 -0
  212. data/spec/spec_helper.rb +39 -0
  213. data/spec/support/devise.rb +3 -0
  214. metadata +492 -0
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .DS_Store
2
+ .rspec
3
+ .bundle/
4
+ log/*.log
5
+ pkg/
6
+ *.swp
7
+ spec/dummy/app/models/*
8
+ spec/dummy/db/
9
+ spec/dummy/log/*.log
10
+ spec/dummy/tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in new_gem.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ engine_room (0.5.0)
5
+ crummy (~> 1.0.1)
6
+ devise (~> 1.1.3)
7
+ paperclip
8
+ rails (~> 3.0.3)
9
+ will_paginate (= 3.0.pre2)
10
+
11
+ GEM
12
+ remote: http://rubygems.org/
13
+ specs:
14
+ abstract (1.0.0)
15
+ actionmailer (3.0.3)
16
+ actionpack (= 3.0.3)
17
+ mail (~> 2.2.9)
18
+ actionpack (3.0.3)
19
+ activemodel (= 3.0.3)
20
+ activesupport (= 3.0.3)
21
+ builder (~> 2.1.2)
22
+ erubis (~> 2.6.6)
23
+ i18n (~> 0.4)
24
+ rack (~> 1.2.1)
25
+ rack-mount (~> 0.6.13)
26
+ rack-test (~> 0.5.6)
27
+ tzinfo (~> 0.3.23)
28
+ activemodel (3.0.3)
29
+ activesupport (= 3.0.3)
30
+ builder (~> 2.1.2)
31
+ i18n (~> 0.4)
32
+ activerecord (3.0.3)
33
+ activemodel (= 3.0.3)
34
+ activesupport (= 3.0.3)
35
+ arel (~> 2.0.2)
36
+ tzinfo (~> 0.3.23)
37
+ activeresource (3.0.3)
38
+ activemodel (= 3.0.3)
39
+ activesupport (= 3.0.3)
40
+ activesupport (3.0.3)
41
+ arel (2.0.6)
42
+ bcrypt-ruby (2.1.2)
43
+ builder (2.1.2)
44
+ capybara (0.4.0)
45
+ celerity (>= 0.7.9)
46
+ culerity (>= 0.2.4)
47
+ mime-types (>= 1.16)
48
+ nokogiri (>= 1.3.3)
49
+ rack (>= 1.0.0)
50
+ rack-test (>= 0.5.4)
51
+ selenium-webdriver (>= 0.0.27)
52
+ xpath (~> 0.1.2)
53
+ celerity (0.8.5)
54
+ childprocess (0.1.4)
55
+ ffi (~> 0.6.3)
56
+ crummy (1.0.1)
57
+ culerity (0.2.12)
58
+ devise (1.1.5)
59
+ bcrypt-ruby (~> 2.1.2)
60
+ warden (~> 1.0.2)
61
+ diff-lcs (1.1.2)
62
+ erubis (2.6.6)
63
+ abstract (>= 1.0.0)
64
+ factory_girl (1.3.2)
65
+ factory_girl_rails (1.0)
66
+ factory_girl (~> 1.3)
67
+ rails (>= 3.0.0.beta4)
68
+ ffi (0.6.3)
69
+ rake (>= 0.8.7)
70
+ fuubar (0.0.3)
71
+ rspec (~> 2.0)
72
+ rspec-instafail (~> 0.1.4)
73
+ ruby-progressbar (~> 0.0.9)
74
+ i18n (0.5.0)
75
+ json_pure (1.4.6)
76
+ mail (2.2.12)
77
+ activesupport (>= 2.3.6)
78
+ i18n (>= 0.4.0)
79
+ mime-types (~> 1.16)
80
+ treetop (~> 1.4.8)
81
+ mime-types (1.16)
82
+ nokogiri (1.4.4)
83
+ paperclip (2.3.8)
84
+ activerecord
85
+ activesupport
86
+ polyglot (0.3.1)
87
+ rack (1.2.1)
88
+ rack-mount (0.6.13)
89
+ rack (>= 1.0.0)
90
+ rack-test (0.5.6)
91
+ rack (>= 1.0)
92
+ rails (3.0.3)
93
+ actionmailer (= 3.0.3)
94
+ actionpack (= 3.0.3)
95
+ activerecord (= 3.0.3)
96
+ activeresource (= 3.0.3)
97
+ activesupport (= 3.0.3)
98
+ bundler (~> 1.0)
99
+ railties (= 3.0.3)
100
+ railties (3.0.3)
101
+ actionpack (= 3.0.3)
102
+ activesupport (= 3.0.3)
103
+ rake (>= 0.8.7)
104
+ thor (~> 0.14.4)
105
+ rake (0.8.7)
106
+ rspec (2.3.0)
107
+ rspec-core (~> 2.3.0)
108
+ rspec-expectations (~> 2.3.0)
109
+ rspec-mocks (~> 2.3.0)
110
+ rspec-core (2.3.0)
111
+ rspec-expectations (2.3.0)
112
+ diff-lcs (~> 1.1.2)
113
+ rspec-instafail (0.1.5)
114
+ rspec-mocks (2.3.0)
115
+ rspec-rails (2.3.0)
116
+ actionpack (~> 3.0)
117
+ activesupport (~> 3.0)
118
+ railties (~> 3.0)
119
+ rspec (~> 2.3.0)
120
+ ruby-progressbar (0.0.9)
121
+ rubyzip (0.9.4)
122
+ selenium-webdriver (0.1.1)
123
+ childprocess (= 0.1.4)
124
+ ffi (~> 0.6.3)
125
+ json_pure
126
+ rubyzip
127
+ spork (0.8.4)
128
+ sqlite3-ruby (1.3.2)
129
+ thor (0.14.6)
130
+ treetop (1.4.9)
131
+ polyglot (>= 0.3.1)
132
+ tzinfo (0.3.23)
133
+ warden (1.0.3)
134
+ rack (>= 1.0.0)
135
+ webrat (0.7.2)
136
+ nokogiri (>= 1.2.0)
137
+ rack (>= 1.0)
138
+ rack-test (>= 0.5.3)
139
+ will_paginate (3.0.pre2)
140
+ xpath (0.1.2)
141
+ nokogiri (~> 1.3)
142
+
143
+ PLATFORMS
144
+ ruby
145
+
146
+ DEPENDENCIES
147
+ capybara (>= 0.3.9)
148
+ crummy (~> 1.0.1)
149
+ devise (~> 1.1.3)
150
+ engine_room!
151
+ factory_girl_rails (= 1.0)
152
+ fuubar
153
+ paperclip
154
+ rails (~> 3.0.3)
155
+ rspec-rails (~> 2.3.0)
156
+ spork
157
+ sqlite3-ruby
158
+ webrat
159
+ will_paginate (= 3.0.pre2)
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2010 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,44 @@
1
+ = EngineRoom
2
+
3
+ EngineRoom aims to be a simple to use, unobtrusive admin interface for rails applications. It is designed to be an add-on for existing web apps and not a full blown CMS. Just add EngineRoom to an app and it will create a customizable interface for editing the content data.
4
+
5
+ Development is still in its early stages, not ready for production use yet.
6
+
7
+ = Features
8
+
9
+ * configure which models and which fields are editable
10
+ * customize form fields
11
+ * support for has_many and belongs_to relationships
12
+ * authentication und user management using Devise[http://github.com/plataformatec/devise]
13
+ * currently supports admin and non-admin roles, where the admin can configure the interface and create new users
14
+ * support for image uploads
15
+ * localization support (currently English and German)
16
+
17
+ = Installation
18
+
19
+ Add to your Gemfile
20
+
21
+ gem 'engine_room'
22
+
23
+ then
24
+
25
+ bundle install
26
+
27
+ to setup engine_room, run the following generator:
28
+
29
+ rails generator engine_room:setup
30
+
31
+ which will create a few needed models, and finally:
32
+
33
+ rake db:migrate
34
+
35
+ then start your server and go to /admin to access the admin interface.
36
+
37
+ = Gem Dependencies
38
+
39
+ * rails 3
40
+ * devise
41
+ * will_paginate
42
+ * paperclip
43
+ * crummy
44
+
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'bundler'
10
+ Bundler::GemHelper.install_tasks
11
+
12
+ require 'rake'
13
+ require 'rake/rdoctask'
14
+
15
+ require 'rspec/core'
16
+ require 'rspec/core/rake_task'
17
+
18
+ RSpec::Core::RakeTask.new(:spec)
19
+
20
+ load "tasks/dummy.rake"
21
+
22
+ task :default => :spec
23
+
24
+ Rake::RDocTask.new(:rdoc) do |rdoc|
25
+ rdoc.rdoc_dir = 'rdoc'
26
+ rdoc.title = 'EngineRoom'
27
+ rdoc.options << '--line-numbers' << '--inline-source'
28
+ rdoc.rdoc_files.include('README.rdoc')
29
+ rdoc.rdoc_files.include('lib/**/*.rb')
30
+ end
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+ TODO
2
+ =========
3
+
@@ -0,0 +1,117 @@
1
+ module EngineRoom
2
+ class ContentController < ApplicationController
3
+ before_filter :authenticate_er_devise_user!
4
+ before_filter :init_section, :except => [:overview]
5
+
6
+ layout 'engine_room'
7
+
8
+ helper_method :sort_column, :sort_direction
9
+
10
+ unloadable
11
+
12
+ def init_section
13
+ @sections = Section.all
14
+ @layout = 'columns'
15
+ @section = Section.find_by_name(params[:section_name])
16
+ if @section.nil?
17
+ flash[:alert] = "No section named #{params[:section_name]} was found."
18
+ redirect_to :action => :overview
19
+ else
20
+ @model = get_model(@section.model_name) # TODO: catch exception
21
+ if params[:bt_section] && params[:bt_id]
22
+ bt_section = Section.find_by_name(params[:bt_section])
23
+ if params.has_key?(@section.model_name) && @section.name != bt_section.name
24
+ # setup foreign key for has_many relationships
25
+ params[@section.model_name]["#{bt_section.model_name.singularize}_id"] = params[:bt_id]
26
+ end
27
+ add_crumb bt_section.name.titleize, {:controller => 'engine_room/content', :section_name => bt_section.name, :action => :index}
28
+ add_crumb params[:bt_id], {:controller => 'engine_room/content', :section_name => bt_section.name, :id => params[:bt_id], :action => :edit}
29
+ else
30
+ add_crumb @section.name.titleize, {:controller => 'engine_room/content', :action => :index, :section_name => @section.name}
31
+ end
32
+ end
33
+ end
34
+
35
+ def overview
36
+ @sections = Section.all
37
+ @layout = 'columns'
38
+ end
39
+
40
+ def index
41
+ if @section.view_type == 'detail'
42
+ @element = @model.where(@section.condition).first
43
+ if @element
44
+ render :action => :edit
45
+ else
46
+ flash[:alert] = "No matching item could be found for section \"#{@section.name.titleize}\"."
47
+ redirect_to :action => :overview
48
+ end
49
+ else
50
+ @elements = @model.order(sort_column + " " + sort_direction).paginate :page => params[:page], :per_page => 20
51
+ end
52
+ end
53
+
54
+ def new
55
+ @element = @model.new
56
+ add_crumb "New #{@section.model_name.humanize}"
57
+ end
58
+
59
+ def create
60
+ @element = @model.new(params[@section.model_name])
61
+ if @element.save
62
+ flash[:notice] = "#{@section.model_name.humanize} was successfully created."
63
+ redirect_to_or_back :action => :index
64
+ else
65
+ add_crumb "New #{@section.model_name.humanize}"
66
+ render :action => :new
67
+ end
68
+ end
69
+
70
+ def edit
71
+ @element = @model.find(params[:id])
72
+ add_crumb "Edit #{@section.model_name.humanize}"
73
+ end
74
+
75
+ def update
76
+ @element = @model.find(params[:id])
77
+ if @element.update_attributes(params[@section.model_name])
78
+ flash[:notice] = "#{@section.model_name.humanize} was successfully updated."
79
+ redirect_to_or_back :action => :index
80
+ else
81
+ add_crumb "Edit #{@section.model_name.humanize}"
82
+ render :action => :edit
83
+ end
84
+ end
85
+
86
+ def destroy
87
+ @element = @model.find(params[:id])
88
+ @element.destroy
89
+
90
+ flash[:notice] = "#{@section.model_name.humanize} was successfully deleted."
91
+ redirect_to_or_back :action => :index
92
+ end
93
+
94
+ private
95
+
96
+ def redirect_to_or_back options
97
+ if params[:bt_section] && params[:bt_id]
98
+ redirect_to :action => :edit, :section_name => params[:bt_section], :id => params[:bt_id]
99
+ else
100
+ redirect_to options
101
+ end
102
+ end
103
+
104
+ def get_model model_name
105
+ model = Object.const_get(model_name.classify)
106
+ end
107
+
108
+ def sort_column
109
+ #params[:sort] || "id"
110
+ @model.column_names.include?(params[:sort]) ? params[:sort] : "id"
111
+ end
112
+
113
+ def sort_direction
114
+ %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,119 @@
1
+ module EngineRoom
2
+ class FieldsController < ApplicationController
3
+ before_filter :authenticate_er_devise_user!
4
+ before_filter :init_sections
5
+
6
+ layout 'engine_room'
7
+
8
+ unloadable
9
+
10
+ def init_sections
11
+ @sections = Section.all
12
+ @layout = 'columns'
13
+ @sidebar = 'engine_room/sections'
14
+ end
15
+
16
+ # GET /sections
17
+ def index
18
+ @fields = Field.all
19
+ # index.html.erb
20
+ end
21
+
22
+ # GET /fields/1
23
+ def show
24
+ @field = Field.find(params[:id])
25
+ # show.html.erb
26
+ end
27
+
28
+ # GET /fields/new
29
+ def new
30
+ @field = Field.new
31
+ @section = Section.find(params[:section_id])
32
+
33
+ add_crumb(@section.name.titleize, edit_engine_room_section_path(@section.id))
34
+ add_crumb 'New Field'
35
+ end
36
+
37
+ # GET /fields/1/edit
38
+ def edit
39
+ @field = Field.find(params[:id])
40
+ @section = Section.find(params[:section_id])
41
+
42
+ add_crumb(@section.name.titleize, edit_engine_room_section_path(@section.id))
43
+ add_crumb('Edit Field', edit_engine_room_section_field_path(@section, @field.id))
44
+ end
45
+
46
+ # POST /fields
47
+ def create
48
+ @field = Field.new(params[:field])
49
+ @section = Section.find(params[:section_id])
50
+
51
+ if(params[:s_action]=='reload')
52
+ return reload_new
53
+ end
54
+
55
+ if @field.save
56
+ flash[:notice] = 'Field was successfully created.'
57
+ redirect_to edit_engine_room_section_url(@section.id)
58
+ else
59
+ render :action => :new
60
+ end
61
+ end
62
+
63
+ # PUT /fields/1
64
+ def update
65
+ @field = Field.find(params[:id])
66
+ @section = Section.find(params[:section_id])
67
+
68
+ if(params[:s_action]=='reload')
69
+ return reload_edit
70
+ end
71
+
72
+ @field.options = nil # remove all old options
73
+ if @field.update_attributes(params[:field])
74
+ flash[:notice] = 'Field was successfully updated.'
75
+ redirect_to edit_engine_room_section_url(@section.id)
76
+ else
77
+ #render :action => :edit
78
+ reload_edit
79
+ end
80
+ end
81
+
82
+ # DELETE /fields/1
83
+ def destroy
84
+ @field = Field.find(params[:id])
85
+ @field.destroy
86
+
87
+ flash[:notice] = 'Field was successfully deleted.'
88
+
89
+ section_id = params[:section_id]
90
+ redirect_to edit_engine_room_section_url(section_id)
91
+ end
92
+
93
+ private
94
+
95
+ def reload_new
96
+ @field.attributes = params[:field]
97
+
98
+ if params[:field][:display_type] == 'has_many'
99
+ @field.column = 'id'
100
+ @field.field_type = 'has_many'
101
+ end
102
+
103
+ add_crumb(@section.name.titleize, edit_engine_room_section_path(@section.id))
104
+ add_crumb('New Field')
105
+
106
+ render :action => :new
107
+ end
108
+
109
+ def reload_edit
110
+ @field.attributes = params[:field]
111
+
112
+ add_crumb(@section.name.titleize, edit_engine_room_section_path(@section.id))
113
+ add_crumb('Edit Field', edit_engine_room_section_field_path(@section, @field.id))
114
+
115
+ render :action => :edit
116
+ end
117
+
118
+ end
119
+ end