wheels 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (300) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +17 -0
  3. data/Rakefile +22 -22
  4. data/VERSION +1 -0
  5. data/app/controllers/access_control_entries_controller.rb +38 -0
  6. data/app/controllers/app_configs_controller.rb +17 -0
  7. data/app/controllers/application_controller.rb +39 -0
  8. data/app/controllers/attachments_controller.rb +16 -0
  9. data/app/controllers/blogs_controller.rb +39 -0
  10. data/app/controllers/discussions_controller.rb +10 -0
  11. data/app/controllers/external_links_controller.rb +5 -0
  12. data/app/controllers/feedbacks_controller.rb +10 -0
  13. data/app/controllers/forum_messages_controller.rb +13 -0
  14. data/app/controllers/forums_controller.rb +2 -0
  15. data/app/controllers/galleries_controller.rb +60 -0
  16. data/app/controllers/images_controller.rb +30 -0
  17. data/app/controllers/menus_controller.rb +2 -0
  18. data/app/controllers/pages_controller.rb +80 -0
  19. data/app/controllers/profiles_controller.rb +16 -0
  20. data/app/controllers/sitemaps_controller.rb +135 -0
  21. data/app/controllers/users_controller.rb +28 -0
  22. data/app/helpers/access_control_entries_helper.rb +2 -0
  23. data/app/helpers/app_configs_helper.rb +2 -0
  24. data/app/helpers/application_helper.rb +43 -0
  25. data/app/helpers/blogs_helper.rb +10 -0
  26. data/app/helpers/discussions_helper.rb +2 -0
  27. data/app/helpers/external_links_helper.rb +2 -0
  28. data/app/helpers/feedbacks_helper.rb +2 -0
  29. data/app/helpers/forums_helper.rb +2 -0
  30. data/app/helpers/menus_helper.rb +2 -0
  31. data/app/helpers/pages_helper.rb +192 -0
  32. data/app/helpers/sitemaps_helper.rb +12 -0
  33. data/app/mailers/feedback_mailer.rb +10 -0
  34. data/app/models/ability.rb +43 -0
  35. data/app/models/access_control_entry.rb +109 -0
  36. data/app/models/app_config.rb +26 -0
  37. data/app/models/attachment.rb +10 -0
  38. data/app/models/blog.rb +10 -0
  39. data/app/models/discussion.rb +19 -0
  40. data/app/models/external_link.rb +10 -0
  41. data/app/models/feedback.rb +11 -0
  42. data/app/models/forum.rb +4 -0
  43. data/app/models/forum_message.rb +5 -0
  44. data/app/models/gallery.rb +5 -0
  45. data/app/models/image.rb +10 -0
  46. data/app/models/menu.rb +5 -0
  47. data/app/models/page.rb +8 -0
  48. data/app/models/page_revision.rb +2 -0
  49. data/app/models/profile.rb +12 -0
  50. data/app/models/role.rb +29 -0
  51. data/app/models/s3_provider.rb +84 -0
  52. data/app/models/sitemap.rb +175 -0
  53. data/app/models/tagging.rb +4 -0
  54. data/app/models/user.rb +69 -0
  55. data/app/validators/email_validator.rb +22 -0
  56. data/app/views/access_control_entries/_form.html.haml +33 -0
  57. data/app/views/access_control_entries/_index.html.haml +53 -0
  58. data/app/views/access_control_entries/_show.html.haml +12 -0
  59. data/app/views/access_control_entries/create.js.haml +3 -0
  60. data/app/views/access_control_entries/destroy.js.haml +3 -0
  61. data/app/views/access_control_entries/edit.html.haml +7 -0
  62. data/app/views/access_control_entries/edit.js.haml +3 -0
  63. data/app/views/access_control_entries/index.html.haml +2 -0
  64. data/app/views/access_control_entries/index.js.haml +3 -0
  65. data/app/views/access_control_entries/new.html.haml +5 -0
  66. data/app/views/access_control_entries/new.js.haml +3 -0
  67. data/app/views/access_control_entries/show.html.haml +2 -0
  68. data/app/views/access_control_entries/show.js.haml +4 -0
  69. data/app/views/access_control_entries/update.js.haml +3 -0
  70. data/app/views/app_configs/_form.html.haml +11 -0
  71. data/app/views/app_configs/_index.html.haml +6 -0
  72. data/app/views/app_configs/_show.html.haml +3 -0
  73. data/app/views/app_configs/create.js.haml +3 -0
  74. data/app/views/app_configs/css.css.haml +2 -0
  75. data/app/views/app_configs/destroy.js.haml +3 -0
  76. data/app/views/app_configs/edit.html.haml +2 -0
  77. data/app/views/app_configs/edit.js.haml +3 -0
  78. data/app/views/app_configs/index.html.haml +2 -0
  79. data/app/views/app_configs/index.js.haml +3 -0
  80. data/app/views/app_configs/new.html.haml +2 -0
  81. data/app/views/app_configs/new.js.haml +3 -0
  82. data/app/views/app_configs/show.html.haml +2 -0
  83. data/app/views/app_configs/show.js.haml +3 -0
  84. data/app/views/app_configs/update.js.haml +3 -0
  85. data/app/views/attachments/_form.html.haml +26 -0
  86. data/app/views/attachments/_index.html.haml +9 -0
  87. data/app/views/attachments/_show.html.haml +6 -0
  88. data/app/views/attachments/_uploadify.html.erb +12 -0
  89. data/app/views/attachments/create.js.haml +3 -0
  90. data/app/views/attachments/destroy.js.haml +3 -0
  91. data/app/views/attachments/edit.js.haml +3 -0
  92. data/app/views/attachments/index.html.haml +2 -0
  93. data/app/views/attachments/index.js.haml +3 -0
  94. data/app/views/attachments/new.html.haml +3 -0
  95. data/app/views/attachments/new.js.haml +3 -0
  96. data/app/views/attachments/show.html.haml +2 -0
  97. data/app/views/attachments/show.js.haml +3 -0
  98. data/app/views/attachments/update.js.haml +3 -0
  99. data/app/views/blogs/_form.html.haml +22 -0
  100. data/app/views/blogs/edit.html.haml +8 -0
  101. data/app/views/blogs/index.html.haml +21 -0
  102. data/app/views/blogs/index.xml.builder +27 -0
  103. data/app/views/blogs/new.html.haml +6 -0
  104. data/app/views/blogs/show.html.haml +25 -0
  105. data/app/views/discussions/_form.html.haml +16 -0
  106. data/app/views/discussions/edit.html.haml +7 -0
  107. data/app/views/discussions/index.html.haml +10 -0
  108. data/app/views/discussions/new.html.haml +25 -0
  109. data/app/views/discussions/show.html.haml +16 -0
  110. data/app/views/external_links/_fields_for.html.haml +2 -0
  111. data/app/views/external_links/_form.html.haml +18 -0
  112. data/app/views/external_links/_show.html.haml +7 -0
  113. data/app/views/external_links/create.js.haml +3 -0
  114. data/app/views/external_links/destroy.js.haml +3 -0
  115. data/app/views/external_links/edit.html.haml +7 -0
  116. data/app/views/external_links/edit.js.haml +3 -0
  117. data/app/views/external_links/index.html.haml +23 -0
  118. data/app/views/external_links/index.js.haml +3 -0
  119. data/app/views/external_links/new.html.haml +5 -0
  120. data/app/views/external_links/new.js.haml +3 -0
  121. data/app/views/external_links/show.html.haml +2 -0
  122. data/app/views/external_links/show.js.haml +3 -0
  123. data/app/views/external_links/update.js.haml +3 -0
  124. data/app/views/feedback_mailer/submit_feedback.html.haml +22 -0
  125. data/app/views/feedbacks/_form.html.haml +38 -0
  126. data/app/views/feedbacks/index.html.haml +27 -0
  127. data/app/views/feedbacks/new.html.haml +6 -0
  128. data/app/views/feedbacks/show.html.haml +19 -0
  129. data/app/views/forum_messages/_form.html.haml +6 -0
  130. data/app/views/forum_messages/index.html.haml +11 -0
  131. data/app/views/forum_messages/new.html.haml +5 -0
  132. data/app/views/forums/_form.html.haml +13 -0
  133. data/app/views/forums/edit.html.haml +7 -0
  134. data/app/views/forums/index.html.haml +23 -0
  135. data/app/views/forums/new.html.haml +5 -0
  136. data/app/views/forums/show.html.haml +20 -0
  137. data/app/views/galleries/_form.html.haml +30 -0
  138. data/app/views/galleries/_show.html.haml +21 -0
  139. data/app/views/galleries/edit.html.haml +7 -0
  140. data/app/views/galleries/index.html.haml +15 -0
  141. data/app/views/galleries/new.html.haml +5 -0
  142. data/app/views/galleries/show.html.haml +4 -0
  143. data/app/views/images/_form.html.haml +10 -0
  144. data/app/views/images/create.js.haml +3 -0
  145. data/app/views/images/destroy.js.haml +3 -0
  146. data/app/views/images/edit.html.haml +7 -0
  147. data/app/views/images/edit.js.haml +3 -0
  148. data/app/views/images/index.html.haml +17 -0
  149. data/app/views/images/index.js.haml +3 -0
  150. data/app/views/images/new.html.haml +5 -0
  151. data/app/views/images/new.js.haml +3 -0
  152. data/app/views/images/show.html.haml +5 -0
  153. data/app/views/images/show.js.haml +3 -0
  154. data/app/views/images/update.js.haml +3 -0
  155. data/app/views/layouts/application.html.haml +60 -0
  156. data/app/views/layouts/bare.html.haml +2 -0
  157. data/app/views/layouts/image_dialog.html.haml +18 -0
  158. data/app/views/loadbehind/_destroy.js.haml +3 -0
  159. data/app/views/loadbehind/_edit.js.haml +4 -0
  160. data/app/views/loadbehind/_errors.html.haml +5 -0
  161. data/app/views/loadbehind/_growl_template.html.haml +65 -0
  162. data/app/views/loadbehind/_show_box.html.haml +9 -0
  163. data/app/views/loadbehind/_view.js.haml +4 -0
  164. data/app/views/loadbehind/growl.js.haml +4 -0
  165. data/app/views/loadbehind/index.js.haml +4 -0
  166. data/app/views/menus/_form.html.haml +13 -0
  167. data/app/views/menus/edit.html.haml +7 -0
  168. data/app/views/menus/index.html.haml +19 -0
  169. data/app/views/menus/new.html.haml +5 -0
  170. data/app/views/menus/show.html.haml +7 -0
  171. data/app/views/pages/_child_pages_links.html.haml +5 -0
  172. data/app/views/pages/_control_panel.html.haml +15 -0
  173. data/app/views/pages/_form.html.haml +27 -0
  174. data/app/views/pages/_form_fields.html.haml +23 -0
  175. data/app/views/pages/_show.html.haml +4 -0
  176. data/app/views/pages/_show_attachment.html.haml +6 -0
  177. data/app/views/pages/_show_small.html.haml +2 -0
  178. data/app/views/pages/create.js.haml +3 -0
  179. data/app/views/pages/destroy.js.haml +3 -0
  180. data/app/views/pages/edit.html.haml +16 -0
  181. data/app/views/pages/edit.js.haml +4 -0
  182. data/app/views/pages/index.html.haml +19 -0
  183. data/app/views/pages/index.js.haml +3 -0
  184. data/app/views/pages/new.html.haml +5 -0
  185. data/app/views/pages/new.js.haml +3 -0
  186. data/app/views/pages/show.html.haml +18 -0
  187. data/app/views/pages/show.js.haml +3 -0
  188. data/app/views/pages/update.js.haml +3 -0
  189. data/app/views/profiles/_form.html.haml +26 -0
  190. data/app/views/profiles/edit.html.haml +7 -0
  191. data/app/views/profiles/index.html.haml +25 -0
  192. data/app/views/profiles/new.html.haml +5 -0
  193. data/app/views/profiles/show.html.haml +21 -0
  194. data/app/views/sitemaps/edit.html.haml +12 -0
  195. data/app/views/sitemaps/index.html.haml +83 -0
  196. data/app/views/sitemaps/index.json.erb +23 -0
  197. data/app/views/sitemaps/new.html.haml +8 -0
  198. data/app/views/sitemaps/new.js.erb +0 -0
  199. data/app/views/users/edit.html.haml +45 -0
  200. data/app/views/users/index.html.haml +19 -0
  201. data/config/amazon_s3.yml +15 -0
  202. data/db/migrate/0000_devise_create_users.rb +26 -0
  203. data/db/migrate/0010_add_fields_to_users.rb +28 -0
  204. data/db/migrate/0020_create_blogs.rb +16 -0
  205. data/db/migrate/0030_create_galleries.rb +15 -0
  206. data/db/migrate/0040_create_images.rb +17 -0
  207. data/db/migrate/0050_create_profiles.rb +24 -0
  208. data/db/migrate/0060_insert_admin_user_and_roles.rb +24 -0
  209. data/db/migrate/0070_create_pages.rb +16 -0
  210. data/db/migrate/0080_create_forums.rb +13 -0
  211. data/db/migrate/0090_create_discussions.rb +14 -0
  212. data/db/migrate/0100_create_forum_messages.rb +15 -0
  213. data/db/migrate/0110_create_access_control_entries.rb +23 -0
  214. data/db/migrate/0120_create_attachments.rb +17 -0
  215. data/db/migrate/0130_create_roles.rb +13 -0
  216. data/db/migrate/0140_create_feedbacks.rb +20 -0
  217. data/db/migrate/0150_create_external_links.rb +14 -0
  218. data/db/migrate/0160_create_sitemaps.rb +17 -0
  219. data/db/migrate/0170_create_menus.rb +14 -0
  220. data/db/migrate/0180_acts_as_taggable_on_migration.rb +28 -0
  221. data/db/migrate/20100912194121_add_stylesheet_to_pages.rb +9 -0
  222. data/db/migrate/20100913073354_add_position_to_access_control_entries.rb +9 -0
  223. data/init.rb +2 -0
  224. data/lib/{core_extensions.rb → generators/core_extensions.rb} +2 -2
  225. data/lib/generators/templates/haml/app/views/layouts/application.html.haml +0 -0
  226. data/lib/generators/wheels/wheels_generator.rb +2 -0
  227. data/lib/generators/wheels_update/wheels_update_generator.rb +1 -1
  228. data/lib/wheels/routes.rb +13 -2
  229. data/wheels.gemspec +254 -122
  230. metadata +268 -124
  231. data/README +0 -2
  232. data/lib/generators/wheels/recipes/public.rb +0 -9
  233. data/lib/generators/wheels_update/core_extensions.3.rb +0 -64
  234. data/lib/wheels/base.rb +0 -7
  235. data/test/functional/access_control_entries_controller_test.rb +0 -49
  236. data/test/functional/app_configs_controller_test.rb +0 -49
  237. data/test/functional/discussions_controller_test.rb +0 -49
  238. data/test/functional/external_links_controller_test.rb +0 -49
  239. data/test/functional/feedback_mailer_test.rb +0 -8
  240. data/test/functional/feedbacks_controller_test.rb +0 -49
  241. data/test/functional/forums_controller_test.rb +0 -49
  242. data/test/functional/layouts_controller_test.rb +0 -49
  243. data/test/functional/member_pages_controller_test.rb +0 -49
  244. data/test/functional/members_controller_test.rb +0 -8
  245. data/test/functional/menus_controller_test.rb +0 -49
  246. data/test/functional/pages_controller_test.rb +0 -49
  247. data/test/functional/product_revisions_controller_test.rb +0 -49
  248. data/test/performance/browsing_test.rb +0 -9
  249. data/test/test_helper.rb +0 -13
  250. data/test/unit/access_control_entry_test.rb +0 -8
  251. data/test/unit/app_config_test.rb +0 -8
  252. data/test/unit/attachment_test.rb +0 -8
  253. data/test/unit/discussion_test.rb +0 -8
  254. data/test/unit/external_link_test.rb +0 -8
  255. data/test/unit/feedback_test.rb +0 -8
  256. data/test/unit/forum_message_test.rb +0 -8
  257. data/test/unit/forum_test.rb +0 -8
  258. data/test/unit/helpers/access_control_entries_helper_test.rb +0 -4
  259. data/test/unit/helpers/app_configs_helper_test.rb +0 -4
  260. data/test/unit/helpers/discussions_helper_test.rb +0 -4
  261. data/test/unit/helpers/external_links_helper_test.rb +0 -4
  262. data/test/unit/helpers/feedbacks_helper_test.rb +0 -4
  263. data/test/unit/helpers/forums_helper_test.rb +0 -4
  264. data/test/unit/helpers/layouts_helper_test.rb +0 -4
  265. data/test/unit/helpers/member_pages_helper_test.rb +0 -4
  266. data/test/unit/helpers/members_helper_test.rb +0 -4
  267. data/test/unit/helpers/menus_helper_test.rb +0 -4
  268. data/test/unit/helpers/pages_helper_test.rb +0 -4
  269. data/test/unit/helpers/product_revisions_helper_test.rb +0 -4
  270. data/test/unit/layout_test.rb +0 -8
  271. data/test/unit/member_page_test.rb +0 -8
  272. data/test/unit/menu_test.rb +0 -8
  273. data/test/unit/page_revision_test.rb +0 -8
  274. data/test/unit/page_test.rb +0 -8
  275. data/test/unit/product_revision_test.rb +0 -8
  276. data/test/unit/settings_test.rb +0 -8
  277. data/test/unit/sitemap_test.rb +0 -8
  278. data/test/unit/user_test.rb +0 -8
  279. /data/{lib/generators/wheels/templates/haml/app/views/layouts/application.html.haml → app/views/sitemaps/edit.js.erb} +0 -0
  280. /data/lib/generators/{wheels/recipes → recipes}/cancan.rb +0 -0
  281. /data/lib/generators/{wheels/recipes → recipes}/cucumber.rb +0 -0
  282. /data/lib/generators/{wheels/recipes → recipes}/default.rb +0 -0
  283. /data/lib/generators/{wheels/recipes → recipes}/design.rb +0 -0
  284. /data/lib/generators/{wheels/recipes → recipes}/devise.rb +0 -0
  285. /data/lib/generators/{wheels/recipes → recipes}/factory_girl.rb +0 -0
  286. /data/lib/generators/{wheels/recipes → recipes}/haml.rb +0 -0
  287. /data/lib/generators/{wheels/recipes → recipes}/jquery.rb +0 -0
  288. /data/lib/generators/{wheels/recipes → recipes}/mongoid.rb +0 -0
  289. /data/lib/generators/{wheels/recipes → recipes}/postgresql.rb +0 -0
  290. /data/lib/generators/{wheels/recipes → recipes}/recipes.rb +0 -0
  291. /data/lib/generators/{wheels/recipes → recipes}/remarkable.rb +0 -0
  292. /data/lib/generators/{wheels/recipes → recipes}/rspec.rb +0 -0
  293. /data/lib/generators/{wheels/recipes → recipes}/wheels.rb +0 -0
  294. /data/lib/generators/{wheels_update/recipes/wheels.rb → recipes/wheels_update.rb} +0 -0
  295. /data/lib/generators/{wheels/snippets → snippets}/cucumber/database_config +0 -0
  296. /data/lib/generators/{wheels/templates → templates}/cancan/ability.rb +0 -0
  297. /data/lib/generators/{wheels/templates → templates}/database/postgresql.yml +0 -0
  298. /data/lib/generators/{wheels/templates → templates}/git/gitignore +0 -0
  299. /data/lib/generators/{wheels/templates → templates}/mongoid/features/step_definitions/mongoid_steps.rb +0 -0
  300. /data/lib/generators/{wheels/templates → templates}/mongoid/features/support/hooks.rb +0 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Tyler Gannon
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,17 @@
1
+ = wheels
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (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)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Tyler Gannon. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,34 +1,34 @@
1
-
1
+ require 'rubygems'
2
+ require 'rake'
2
3
  PKG_FILES = FileList[
3
4
  'wheels.gemspec',
4
5
  'Gemfile',
5
- 'install.rb',
6
- 'Rakefile', 'README', 'uninstall.rb',
7
- 'assets/**/*',
6
+ 'init.rb',
7
+ 'Rakefile', 'README', 'LICENSE', 'README.rdoc', 'VERSION',
8
+ 'app/**/*',
9
+ 'config/**/*',
10
+ 'db/**/*',
8
11
  'lib/**/*',
9
- 'rails/**/*',
12
+ 'public/**/*',
10
13
  'test/**/*'
11
14
  ]
12
15
 
13
- require 'rubygems'
14
- require 'rake'
15
-
16
16
  begin
17
17
  require 'jeweler'
18
- Jeweler::Tasks.new do |s|
19
- s.name = "wheels"
20
- s.author = "Tyler Gannon"
21
- s.email = "t--g__a--nnon@gmail.com"
22
- s.homepage = "http://github.com/tylergannon/wheels"
23
- s.platform = Gem::Platform::RUBY
24
- s.description = "some extra stuff for rails apps"
25
- s.summary = "My favorite rails goodies all in one"
26
- s.files = PKG_FILES.to_a
27
- s.require_path = "lib"
28
- s.has_rdoc = false
29
- s.extra_rdoc_files = ["README"]
18
+ Jeweler::Tasks.new do |gem|
19
+ gem.name = "wheels"
20
+ gem.summary = "Generator builds a web site with blog, user profile, etc."
21
+ gem.description = "Call rails generate wheels."
22
+ gem.email = "tgannon@gmail.com"
23
+ gem.homepage = "http://github.com/tylergannon/wheels"
24
+ gem.authors = ["Tyler Gannon"]
25
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
26
+ gem.files = PKG_FILES.to_a
27
+ gem.require_path = "lib"
28
+ gem.has_rdoc = false
29
+ gem.extra_rdoc_files = ["README.rdoc"]
30
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
30
31
  end
31
-
32
32
  Jeweler::GemcutterTasks.new
33
33
  rescue LoadError
34
34
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
@@ -63,7 +63,7 @@ Rake::RDocTask.new do |rdoc|
63
63
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
64
64
 
65
65
  rdoc.rdoc_dir = 'rdoc'
66
- rdoc.title = "da_huangs_ruby_extensions #{version}"
66
+ rdoc.title = "wheels #{version}"
67
67
  rdoc.rdoc_files.include('README*')
68
68
  rdoc.rdoc_files.include('lib/**/*.rb')
69
69
  end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.12
@@ -0,0 +1,38 @@
1
+ class AccessControlEntriesController < InheritedResources::Base
2
+ ajax_loading
3
+ before_filter :authenticate_user!
4
+ belongs_to :sitemap, :page, :forum, :user, :role, :polymorphic => true, :optional=>true
5
+ has_scope :by_role, :using=>[:role_id]
6
+ has_scope :by_class, :using=>[:class]
7
+ respond_to :html, :js
8
+
9
+ def create
10
+ parent = params.slice(:sitemap_id, :page_id, :forum_id, :user_id, :role_id).
11
+ to_a[0]
12
+ parent = parent[0].gsub(/_id/, '').camelize.constantize.find(parent[1]) if parent
13
+ @access_control_entry = parent.access_control_entries.create(params[:access_control_entry])
14
+ respond_with @access_control_entry
15
+ end
16
+
17
+ def new_ace
18
+ a = AccessControlEntry.new
19
+ a.user_id = params[:user_id]
20
+ a.role_id = params[:role_id]
21
+ a.resource_type = case true
22
+ when params.include?(:sitemap_id) then "Sitemap"
23
+ when params.include?(:page_id) then "Page"
24
+ when params.include?(:forum_id) then "Forum"
25
+ else nil
26
+ end
27
+ return a
28
+ end
29
+
30
+ def sort
31
+ order = params[:ids]
32
+ parent.access_control_entries.
33
+ Image.order(order)
34
+ render :text => order.inspect
35
+ end
36
+ helper_method :new_ace
37
+ end
38
+
@@ -0,0 +1,17 @@
1
+ class AppConfigsController < InheritedResources::Base
2
+ respond_to :html, :js
3
+ respond_to :css, :only=>:css
4
+ ajax_loading
5
+
6
+ def css
7
+ @stylesheet = AppConfig["stylesheet"]
8
+ if params[:page_id]
9
+ page = Page.find(params[:page_id])
10
+ @stylesheet += '\n/* Page-level styles' + page.stylesheet
11
+ end
12
+ respond_with @stylesheet do |format|
13
+ format.css{render :layout=>'bare'}
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,39 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ def include_jqueryui
4
+ content_for :head do
5
+ stylesheet_link_tag("ui-lightness/jquery-ui-1.8.4.custom")
6
+ javascript_include_tag("jquery-ui")
7
+ end
8
+ end
9
+
10
+ load_main_menu
11
+
12
+
13
+ def self.resource_attributes(*parameters)
14
+ for action in [:show, :new, :edit, :create]
15
+ a = "def #{action};" + ([:new, :create].include?(action) ?
16
+ "@#{resource_class.name.underscore} = resource_class.new;" : ""
17
+ ) +
18
+ parameters.map{|p|
19
+ if p.class == Hash
20
+ meth, prm = [p.to_a.flatten[0], p.to_a.flatten[1]]
21
+ else
22
+ meth, prm = [p, p]
23
+ end
24
+ meth = meth.to_s + "="
25
+
26
+ if prm == :current_user
27
+ val = "current_user"
28
+ else
29
+ val = "params[:#{prm}]"
30
+ end
31
+ "resource.send(\"#{meth}\", #{val})"
32
+ }.join(";") +
33
+ ";#{action}!;end;"
34
+ class_eval a
35
+ puts a
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,16 @@
1
+ class AttachmentsController < InheritedResources::Base
2
+ respond_to :html, :js
3
+ belongs_to :page
4
+ before_filter :authenticate_user!
5
+ ajax_loading
6
+
7
+ def index
8
+ index! do |format|
9
+ @attachment = @page.attachments.build
10
+ end
11
+ end
12
+ def create
13
+ create! {collection_url}
14
+ end
15
+ end
16
+
@@ -0,0 +1,39 @@
1
+ class BlogsController < InheritedResources::Base
2
+ before_filter :load_maybe
3
+ belongs_to :user, :optional => true
4
+ has_scope :tagged_with, :as => :tag
5
+ helper_method :tags
6
+ respond_to :html, :xml
7
+
8
+
9
+ def load_maybe
10
+ unless params[:user_id]
11
+ @user = (current_user || User.root)
12
+ end
13
+ end
14
+
15
+ def parent
16
+ @user ||= User.find(params[:user_id])
17
+ end
18
+
19
+ def tags
20
+ @tags ||= Blog.where(:user_id=>parent.id).tag_counts.sort{|t, u| t.count <=> u.count}
21
+ end
22
+
23
+ def collection
24
+ @blogs ||= Blog.where(:user_id=>parent.id).
25
+ paginate(:page => params[:page], :order => 'created_at DESC' )
26
+ end
27
+
28
+ before_filter :authenticate_user!, :except=>[:show, :index]
29
+ # before_filter :maybe_authenticate, :only=>[:show, :index]
30
+ before_filter :resource, :only=>[:update, :show, :destroy, :edit]
31
+ authorize_resource
32
+
33
+ def maybe_authenticate
34
+ unless user_signed_in?
35
+ authenticate_user! unless current_ability.can? :read, resource
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,10 @@
1
+ class DiscussionsController < InheritedResources::Base
2
+ belongs_to :forum
3
+
4
+ def new
5
+ new! do |format|
6
+ @new_message = ForumMessage.new(:discussion=>resource, :author=>current_user)
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,5 @@
1
+ class ExternalLinksController < InheritedResources::Base
2
+ respond_to :html, :js
3
+ ajax_loading
4
+ end
5
+
@@ -0,0 +1,10 @@
1
+ class FeedbacksController < InheritedResources::Base
2
+ def create
3
+ create! do |format|
4
+ FeedbackMailer.submit_feedback(@feedback).deliver
5
+ flash[:notice] = "Thanks for your feedback!"
6
+ format.html { redirect_to "/" }
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,13 @@
1
+ class ForumMessagesController < InheritedResources::Base
2
+ belongs_to :forum, :discussion
3
+
4
+ resource_attributes({:author => :current_user})
5
+
6
+ def create
7
+ create! {forum_discussion_path(@discussion.forum, @discussion)}
8
+ end
9
+ def update
10
+ update! {forum_discussion_path(@discussion.forum, @discussion)}
11
+ end
12
+ end
13
+
@@ -0,0 +1,2 @@
1
+ class ForumsController < InheritedResources::Base
2
+ end
@@ -0,0 +1,60 @@
1
+ class GalleriesController < InheritedResources::Base
2
+ belongs_to :user, :optional=>true
3
+ before_filter :load_user
4
+
5
+ def index
6
+ index! do |format|
7
+ if params[:CKEditorFuncNum]
8
+ format.html{
9
+ render :action=>:index, :layout=>"image_dialog"
10
+ }
11
+ end
12
+ end
13
+ end
14
+
15
+ def edit
16
+ edit! do |format|
17
+ if params[:CKEditorFuncNum]
18
+ format.html{
19
+ render :action=>:edit, :layout=>"image_dialog"
20
+ }
21
+ end
22
+ end
23
+ end
24
+
25
+ def show
26
+ show! do |format|
27
+ @images = paginated_images_for(@gallery)
28
+ if params[:CKEditorFuncNum]
29
+ format.html{
30
+ render :action=>:show, :layout=>"image_dialog"
31
+ }
32
+ end
33
+ end
34
+ end
35
+
36
+ def new
37
+ @gallery = Gallery.create(:user=>@user)
38
+ new!
39
+ end
40
+
41
+ def create
42
+ create! {images_path(params.slice(:CKEditor, :CKEditorFuncNum, :langCode))}
43
+ end
44
+
45
+ def load_user
46
+ unless params[:user_id]
47
+ @user ||= (current_user ? User.find(current_user.id) : super_user)
48
+ end
49
+ end
50
+ helper_method :ckeditor_params, :paginated_images_for
51
+
52
+ def paginated_images_for(gallery)
53
+ @images ||= Image.where(:gallery_id=>gallery.id).paginate(:page => params[:page], :order => 'created_at DESC' )
54
+ end
55
+
56
+ def ckeditor_params
57
+ params.slice(:CKEditor, :CKEditorFuncNum, :langCode)
58
+ end
59
+ end
60
+
@@ -0,0 +1,30 @@
1
+ class ImagesController < InheritedResources::Base
2
+ respond_to :html, :js, :xml
3
+ belongs_to :gallery
4
+
5
+ def index
6
+ index! do |format|
7
+ if params[:CKEditorFuncNum]
8
+ format.html {render :action=>:index, :layout=>"image_dialog"}
9
+ end
10
+ end
11
+ end
12
+
13
+ def create
14
+ create! {edit_gallery_path(@gallery, params.slice(:CKEditor, :CKEditorFuncNum, :langCode))}
15
+ end
16
+
17
+ def show
18
+ show! do |format|
19
+ if params[:CKEditorFuncNum]
20
+ format.html {render :layout=>"image_dialog"}
21
+ end
22
+ end
23
+ end
24
+
25
+ def collection
26
+ @images ||= end_of_association_chain.
27
+ paginate(:page => params[:page], :order => 'created_at DESC' )
28
+ end
29
+ end
30
+
@@ -0,0 +1,2 @@
1
+ class MenusController < InheritedResources::Base
2
+ end
@@ -0,0 +1,80 @@
1
+ class PagesController < InheritedResources::Base
2
+ respond_to :js, :html
3
+ ajax_loading
4
+ before_filter :authenticate_user!, :except=>[:show]
5
+ before_filter :parse_request_url, :only=>:show
6
+ before_filter :resource, :only=>[:update, :show, :destroy, :edit]
7
+ before_filter :maybe_authenticate, :only=>[:show]
8
+ before_filter :set_collection_name
9
+ authorize_resource
10
+ has_scope :tagged_with, :as => :tag
11
+
12
+ has_scope :accessible_by, :type=>:boolean, :default=>true do |c,s|
13
+ s.accessible_by(c.current_ability)
14
+ end
15
+
16
+ def show
17
+ resource
18
+ @sidebar = true
19
+ @child_pages = @sitemap.children.accessible_by(current_ability)
20
+ show!
21
+ end
22
+
23
+ def edit
24
+ edit! do |format|
25
+ @attachment = Attachment.new(:page=>@page)
26
+ @s3provider = S3Provider.new(:key=>"attachments/#{current_user.id}")
27
+ end
28
+ end
29
+
30
+ def create
31
+ create! { (@parent_page ? page_child_path(@parent_page, @page) : @page) }
32
+ end
33
+
34
+ def update
35
+ update! do |format|
36
+ if params[:child_id]
37
+ @parent_page = @page
38
+ @page = Page.find(params[:child_id])
39
+ @page.parent = @parent_page
40
+ @page.save
41
+ end
42
+ end
43
+ end
44
+
45
+ def set_collection_name
46
+ if params[:page_id]
47
+ self.resources_configuration[:self][:collection_name] = :children
48
+ end
49
+ end
50
+
51
+ def parse_request_url
52
+ if params["level1"]
53
+ @sitemap = Sitemap.find_by_path(*[1,2,3,4].map{|i|params["level#{i}"]})
54
+ @page = @sitemap.resource
55
+ end
56
+ end
57
+
58
+
59
+ def resource
60
+ unless @page
61
+ page_id = params[:id]
62
+ if page_id.is_numeric?
63
+ @page ||= Page.find(page_id)
64
+ else
65
+ @page ||= Page.where(["lower(pages.title) = ?", page_id.downcase.gsub(/[_]/, ' ')]).first
66
+ end
67
+ @attachments ||= @page.attachments
68
+ end
69
+ @sitemap ||= @page.sitemaps.sort{|t,u| t.url.size <=> u.url.size}[0]
70
+ @page
71
+ end
72
+
73
+ def maybe_authenticate
74
+ unless user_signed_in?
75
+ authenticate_user! unless current_ability.can? :read, resource
76
+ end
77
+ end
78
+
79
+ end
80
+
@@ -0,0 +1,16 @@
1
+ class ProfilesController < InheritedResources::Base
2
+ respond_to :html
3
+ before_filter :load_current_user
4
+ belongs_to :user, :optional => true, :singleton=>true
5
+
6
+ def load_current_user
7
+ unless params[:user_id]
8
+ @user ||= (current_user ? User.find(current_user.id) : super_user)
9
+ end
10
+ end
11
+
12
+ def resource
13
+ @profile ||= Profile.find_by_user_id(@user.id)
14
+ end
15
+ end
16
+
@@ -0,0 +1,135 @@
1
+ class SitemapsController < InheritedResources::Base
2
+ ajax_loading
3
+ respond_to :html, :js, :json
4
+ before_filter :parse_request_url, :only=>:show
5
+ before_filter :resource, :except=>[:new, :create, :index]
6
+ before_filter :collection, :only=>[:index]
7
+ before_filter :new_resource, :only=>[:new, :create]
8
+ before_filter :authenticate_user!, :authorize_action!
9
+
10
+ def index
11
+ collection.reject!{|t| t==Sitemap.lost_and_found} if Sitemap.lost_and_found.children.empty?
12
+ index! do |format|
13
+ format.json{render :json=>collection.as_json}
14
+ end
15
+ end
16
+
17
+ def parse_request_url
18
+ if params[:level1]
19
+ @sitemap = Sitemap.find_by_path(*[1,2,3,4].map{|t|params["level#{i}".to_sym]})
20
+ end
21
+ end
22
+
23
+ def create
24
+ @sitemap = new_resource
25
+ @sitemap.resource = @sitemap.resource_type.constantize.new
26
+ @sitemap.save
27
+ respond_with @sitemap do |format|
28
+ format.json {render :json=> json_obj.as_json}
29
+ end
30
+ end
31
+
32
+ def json_obj
33
+ {
34
+ :status => @sitemap.errors.empty? ? 1 : 0,
35
+ :errors => @sitemap.errors,
36
+ :id => @sitemap.id,
37
+ :resource_type => @sitemap.resource_type,
38
+ :resource_id => @sitemap.resource_id,
39
+ :menu_text => @sitemap.menu_text,
40
+ }
41
+ end
42
+
43
+ def show
44
+ show! do |format|
45
+ format.html{
46
+ if resource.resource.is_a? ExternalLink
47
+ redirect_to resource.resource.url
48
+ elsif resource.resource.is_a? Page
49
+
50
+ end
51
+ }
52
+ format.json{render :json=>resource.as_json}
53
+ format.js{redirect_to(url_for(resource.resource)+'.js')}
54
+ end
55
+ end
56
+
57
+ def destroy
58
+ if (resource.parent == Sitemap.lost_and_found) || (resource.resource.is_a? AppConfig)
59
+ resource.destroy
60
+ else
61
+ resource.parent = Sitemap.lost_and_found
62
+ resource.save
63
+ end
64
+ respond_with resource
65
+ end
66
+
67
+ def update
68
+ resource.parent = parent
69
+ update! do |format|
70
+ if params.stringify_keys["sitemap"]["position"]
71
+ childrunz = Array.new(parent.children.sorted)
72
+ childrunz.delete(resource)
73
+ childrunz.insert(params.stringify_keys["sitemap"]["position"].to_i, resource)
74
+ childrunz.each_with_index do |child, idx|
75
+ child.position = idx
76
+ child.save
77
+ end
78
+ end
79
+ format.json {render :json=> json_obj.as_json}
80
+ end
81
+ end
82
+
83
+ def sort
84
+ params[:formula_herb_children].each_with_index do |id, index|
85
+ FormulaHerb.update_all(['position=?', index+1], ['id=?', id])
86
+ end
87
+ render :nothing => true
88
+ end
89
+
90
+
91
+
92
+ #helper methods
93
+
94
+ def authorize_action!
95
+ authorize! :manage, Sitemap
96
+ end
97
+
98
+ def resource
99
+ @sitemap ||= Sitemap.find(params[:id]) if params[:id]
100
+ end
101
+
102
+ def collection
103
+ @sitemaps ||= SitemapArray.new(parent.children)
104
+ end
105
+
106
+ def new_resource
107
+ @sitemap ||= Sitemap.new(params[:sitemap])
108
+ end
109
+
110
+ def parent
111
+ unless @parent
112
+ if params[:parent_id]
113
+ @parent = Sitemap.find(params[:parent_id])
114
+ else
115
+ if params[:action] == "index"
116
+ @parent = Sitemap.root
117
+ else
118
+ @parent = resource.try(:parent)
119
+ end
120
+ end
121
+ end
122
+ @parent
123
+ end
124
+
125
+ private
126
+ def resource_would_be_orphaned?
127
+ resource.resource.sitemaps.size==1 &&
128
+ resource.resource.sitemaps[0] == resource
129
+ end
130
+
131
+ def resource_is_in_lost_and_found?
132
+ resource.parent==Sitemap.lost_and_found
133
+ end
134
+ end
135
+
@@ -0,0 +1,28 @@
1
+ class UsersController < InheritedResources::Base
2
+ respond_to :html, :js, :only=>[:edit, :show, :update]
3
+ respond_to :json, :only=>[:verify_password]
4
+
5
+ before_filter :authenticate_user!, :resource
6
+
7
+ def edit
8
+ respond_with(resource)
9
+ end
10
+
11
+ def update
12
+ update! do |success, failure|
13
+ failure.html{redirect_to "/change_password"}
14
+ success.html{flash[:notice] = "Your password has been updated."; redirect_to root_url}
15
+ end
16
+ end
17
+
18
+ def verify
19
+ respond_with resource do |format|
20
+ format.json {render :json=> resource.valid_password?(params[:password]).to_json}
21
+ end
22
+ end
23
+
24
+ def resource
25
+ @user ||= FullyValidatedUser.find(current_user)
26
+ end
27
+ end
28
+
@@ -0,0 +1,2 @@
1
+ module AccessControlEntriesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module AppConfigsHelper
2
+ end