wheels 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (298) hide show
  1. data/README +2 -0
  2. data/Rakefile +22 -22
  3. data/lib/{generators/core_extensions.rb → core_extensions.rb} +2 -2
  4. data/lib/generators/{recipes → wheels/recipes}/cancan.rb +0 -0
  5. data/lib/generators/{recipes → wheels/recipes}/cucumber.rb +0 -0
  6. data/lib/generators/{recipes → wheels/recipes}/default.rb +0 -0
  7. data/lib/generators/{recipes → wheels/recipes}/design.rb +0 -0
  8. data/lib/generators/{recipes → wheels/recipes}/devise.rb +0 -0
  9. data/lib/generators/{recipes → wheels/recipes}/factory_girl.rb +0 -0
  10. data/lib/generators/{recipes → wheels/recipes}/haml.rb +0 -0
  11. data/lib/generators/{recipes → wheels/recipes}/jquery.rb +0 -0
  12. data/lib/generators/{recipes → wheels/recipes}/mongoid.rb +0 -0
  13. data/lib/generators/{recipes → wheels/recipes}/postgresql.rb +0 -0
  14. data/lib/generators/wheels/recipes/public.rb +9 -0
  15. data/lib/generators/{recipes → wheels/recipes}/recipes.rb +0 -0
  16. data/lib/generators/{recipes → wheels/recipes}/remarkable.rb +0 -0
  17. data/lib/generators/{recipes → wheels/recipes}/rspec.rb +0 -0
  18. data/lib/generators/{recipes → wheels/recipes}/wheels.rb +0 -0
  19. data/lib/generators/{snippets → wheels/snippets}/cucumber/database_config +0 -0
  20. data/lib/generators/{templates → wheels/templates}/cancan/ability.rb +0 -0
  21. data/lib/generators/{templates → wheels/templates}/database/postgresql.yml +0 -0
  22. data/lib/generators/{templates → wheels/templates}/git/gitignore +0 -0
  23. data/lib/generators/{templates → wheels/templates}/haml/app/views/layouts/application.html.haml +0 -0
  24. data/lib/generators/{templates → wheels/templates}/mongoid/features/step_definitions/mongoid_steps.rb +0 -0
  25. data/lib/generators/{templates → wheels/templates}/mongoid/features/support/hooks.rb +0 -0
  26. data/lib/generators/wheels/wheels_generator.rb +0 -2
  27. data/lib/generators/wheels_update/core_extensions.3.rb +64 -0
  28. data/lib/generators/{recipes/wheels_update.rb → wheels_update/recipes/wheels.rb} +0 -0
  29. data/lib/generators/wheels_update/wheels_update_generator.rb +1 -1
  30. data/lib/wheels/base.rb +7 -0
  31. data/lib/wheels/routes.rb +2 -13
  32. data/test/functional/access_control_entries_controller_test.rb +49 -0
  33. data/test/functional/app_configs_controller_test.rb +49 -0
  34. data/test/functional/discussions_controller_test.rb +49 -0
  35. data/test/functional/external_links_controller_test.rb +49 -0
  36. data/test/functional/feedback_mailer_test.rb +8 -0
  37. data/test/functional/feedbacks_controller_test.rb +49 -0
  38. data/test/functional/forums_controller_test.rb +49 -0
  39. data/test/functional/layouts_controller_test.rb +49 -0
  40. data/test/functional/member_pages_controller_test.rb +49 -0
  41. data/test/functional/members_controller_test.rb +8 -0
  42. data/test/functional/menus_controller_test.rb +49 -0
  43. data/test/functional/pages_controller_test.rb +49 -0
  44. data/test/functional/product_revisions_controller_test.rb +49 -0
  45. data/test/performance/browsing_test.rb +9 -0
  46. data/test/test_helper.rb +13 -0
  47. data/test/unit/access_control_entry_test.rb +8 -0
  48. data/test/unit/app_config_test.rb +8 -0
  49. data/test/unit/attachment_test.rb +8 -0
  50. data/test/unit/discussion_test.rb +8 -0
  51. data/test/unit/external_link_test.rb +8 -0
  52. data/test/unit/feedback_test.rb +8 -0
  53. data/test/unit/forum_message_test.rb +8 -0
  54. data/test/unit/forum_test.rb +8 -0
  55. data/test/unit/helpers/access_control_entries_helper_test.rb +4 -0
  56. data/test/unit/helpers/app_configs_helper_test.rb +4 -0
  57. data/test/unit/helpers/discussions_helper_test.rb +4 -0
  58. data/test/unit/helpers/external_links_helper_test.rb +4 -0
  59. data/test/unit/helpers/feedbacks_helper_test.rb +4 -0
  60. data/test/unit/helpers/forums_helper_test.rb +4 -0
  61. data/test/unit/helpers/layouts_helper_test.rb +4 -0
  62. data/test/unit/helpers/member_pages_helper_test.rb +4 -0
  63. data/test/unit/helpers/members_helper_test.rb +4 -0
  64. data/test/unit/helpers/menus_helper_test.rb +4 -0
  65. data/test/unit/helpers/pages_helper_test.rb +4 -0
  66. data/test/unit/helpers/product_revisions_helper_test.rb +4 -0
  67. data/test/unit/layout_test.rb +8 -0
  68. data/test/unit/member_page_test.rb +8 -0
  69. data/test/unit/menu_test.rb +8 -0
  70. data/test/unit/page_revision_test.rb +8 -0
  71. data/test/unit/page_test.rb +8 -0
  72. data/test/unit/product_revision_test.rb +8 -0
  73. data/test/unit/settings_test.rb +8 -0
  74. data/test/unit/sitemap_test.rb +8 -0
  75. data/test/unit/user_test.rb +8 -0
  76. data/wheels.gemspec +122 -252
  77. metadata +124 -266
  78. data/LICENSE +0 -20
  79. data/README.rdoc +0 -17
  80. data/VERSION +0 -1
  81. data/app/controllers/access_control_entries_controller.rb +0 -20
  82. data/app/controllers/app_configs_controller.rb +0 -17
  83. data/app/controllers/application_controller.rb +0 -39
  84. data/app/controllers/attachments_controller.rb +0 -16
  85. data/app/controllers/blogs_controller.rb +0 -39
  86. data/app/controllers/discussions_controller.rb +0 -10
  87. data/app/controllers/external_links_controller.rb +0 -5
  88. data/app/controllers/feedbacks_controller.rb +0 -10
  89. data/app/controllers/forum_messages_controller.rb +0 -13
  90. data/app/controllers/forums_controller.rb +0 -2
  91. data/app/controllers/galleries_controller.rb +0 -60
  92. data/app/controllers/images_controller.rb +0 -30
  93. data/app/controllers/menus_controller.rb +0 -2
  94. data/app/controllers/pages_controller.rb +0 -71
  95. data/app/controllers/profiles_controller.rb +0 -16
  96. data/app/controllers/sitemaps_controller.rb +0 -135
  97. data/app/controllers/users_controller.rb +0 -28
  98. data/app/helpers/access_control_entries_helper.rb +0 -2
  99. data/app/helpers/app_configs_helper.rb +0 -2
  100. data/app/helpers/application_helper.rb +0 -36
  101. data/app/helpers/blogs_helper.rb +0 -10
  102. data/app/helpers/discussions_helper.rb +0 -2
  103. data/app/helpers/external_links_helper.rb +0 -2
  104. data/app/helpers/feedbacks_helper.rb +0 -2
  105. data/app/helpers/forums_helper.rb +0 -2
  106. data/app/helpers/menus_helper.rb +0 -2
  107. data/app/helpers/pages_helper.rb +0 -192
  108. data/app/helpers/sitemaps_helper.rb +0 -12
  109. data/app/mailers/feedback_mailer.rb +0 -10
  110. data/app/models/ability.rb +0 -43
  111. data/app/models/access_control_entry.rb +0 -100
  112. data/app/models/app_config.rb +0 -26
  113. data/app/models/attachment.rb +0 -10
  114. data/app/models/blog.rb +0 -10
  115. data/app/models/discussion.rb +0 -19
  116. data/app/models/external_link.rb +0 -4
  117. data/app/models/feedback.rb +0 -11
  118. data/app/models/forum.rb +0 -4
  119. data/app/models/forum_message.rb +0 -5
  120. data/app/models/gallery.rb +0 -5
  121. data/app/models/image.rb +0 -10
  122. data/app/models/menu.rb +0 -4
  123. data/app/models/page.rb +0 -7
  124. data/app/models/page_revision.rb +0 -2
  125. data/app/models/profile.rb +0 -12
  126. data/app/models/role.rb +0 -29
  127. data/app/models/s3_provider.rb +0 -84
  128. data/app/models/sitemap.rb +0 -171
  129. data/app/models/tagging.rb +0 -4
  130. data/app/models/user.rb +0 -69
  131. data/app/validators/email_validator.rb +0 -22
  132. data/app/views/access_control_entries/_form.html.haml +0 -33
  133. data/app/views/access_control_entries/_index.html.haml +0 -46
  134. data/app/views/access_control_entries/_show.html.haml +0 -12
  135. data/app/views/access_control_entries/create.js.haml +0 -3
  136. data/app/views/access_control_entries/destroy.js.haml +0 -3
  137. data/app/views/access_control_entries/edit.html.haml +0 -7
  138. data/app/views/access_control_entries/edit.js.haml +0 -3
  139. data/app/views/access_control_entries/index.html.haml +0 -2
  140. data/app/views/access_control_entries/index.js.haml +0 -3
  141. data/app/views/access_control_entries/new.html.haml +0 -5
  142. data/app/views/access_control_entries/new.js.haml +0 -3
  143. data/app/views/access_control_entries/show.html.haml +0 -2
  144. data/app/views/access_control_entries/show.js.haml +0 -4
  145. data/app/views/access_control_entries/update.js.haml +0 -3
  146. data/app/views/app_configs/_form.html.haml +0 -11
  147. data/app/views/app_configs/_index.html.haml +0 -6
  148. data/app/views/app_configs/_show.html.haml +0 -4
  149. data/app/views/app_configs/create.js.haml +0 -3
  150. data/app/views/app_configs/css.css.haml +0 -2
  151. data/app/views/app_configs/destroy.js.haml +0 -3
  152. data/app/views/app_configs/edit.html.haml +0 -2
  153. data/app/views/app_configs/edit.js.haml +0 -3
  154. data/app/views/app_configs/index.html.haml +0 -2
  155. data/app/views/app_configs/index.js.haml +0 -3
  156. data/app/views/app_configs/new.html.haml +0 -2
  157. data/app/views/app_configs/new.js.haml +0 -3
  158. data/app/views/app_configs/show.html.haml +0 -2
  159. data/app/views/app_configs/show.js.haml +0 -3
  160. data/app/views/app_configs/update.js.haml +0 -3
  161. data/app/views/attachments/_form.html.haml +0 -26
  162. data/app/views/attachments/_index.html.haml +0 -9
  163. data/app/views/attachments/_show.html.haml +0 -6
  164. data/app/views/attachments/_uploadify.html.erb +0 -12
  165. data/app/views/attachments/create.js.haml +0 -3
  166. data/app/views/attachments/destroy.js.haml +0 -3
  167. data/app/views/attachments/edit.js.haml +0 -3
  168. data/app/views/attachments/index.html.haml +0 -2
  169. data/app/views/attachments/index.js.haml +0 -3
  170. data/app/views/attachments/new.html.haml +0 -3
  171. data/app/views/attachments/new.js.haml +0 -3
  172. data/app/views/attachments/show.html.haml +0 -2
  173. data/app/views/attachments/show.js.haml +0 -3
  174. data/app/views/attachments/update.js.haml +0 -3
  175. data/app/views/blogs/_form.html.haml +0 -22
  176. data/app/views/blogs/edit.html.haml +0 -8
  177. data/app/views/blogs/index.html.haml +0 -21
  178. data/app/views/blogs/index.xml.builder +0 -27
  179. data/app/views/blogs/new.html.haml +0 -6
  180. data/app/views/blogs/show.html.haml +0 -25
  181. data/app/views/discussions/_form.html.haml +0 -16
  182. data/app/views/discussions/edit.html.haml +0 -7
  183. data/app/views/discussions/index.html.haml +0 -10
  184. data/app/views/discussions/new.html.haml +0 -25
  185. data/app/views/discussions/show.html.haml +0 -16
  186. data/app/views/external_links/_fields_for.html.haml +0 -2
  187. data/app/views/external_links/_form.html.haml +0 -18
  188. data/app/views/external_links/_show.html.haml +0 -7
  189. data/app/views/external_links/create.js.haml +0 -3
  190. data/app/views/external_links/destroy.js.haml +0 -3
  191. data/app/views/external_links/edit.html.haml +0 -7
  192. data/app/views/external_links/edit.js.haml +0 -3
  193. data/app/views/external_links/index.html.haml +0 -23
  194. data/app/views/external_links/index.js.haml +0 -3
  195. data/app/views/external_links/new.html.haml +0 -5
  196. data/app/views/external_links/new.js.haml +0 -3
  197. data/app/views/external_links/show.html.haml +0 -2
  198. data/app/views/external_links/show.js.haml +0 -3
  199. data/app/views/external_links/update.js.haml +0 -3
  200. data/app/views/feedback_mailer/submit_feedback.html.haml +0 -22
  201. data/app/views/feedbacks/_form.html.haml +0 -37
  202. data/app/views/feedbacks/index.html.haml +0 -27
  203. data/app/views/feedbacks/new.html.haml +0 -6
  204. data/app/views/feedbacks/show.html.haml +0 -19
  205. data/app/views/forum_messages/_form.html.haml +0 -6
  206. data/app/views/forum_messages/index.html.haml +0 -11
  207. data/app/views/forum_messages/new.html.haml +0 -5
  208. data/app/views/forums/_form.html.haml +0 -13
  209. data/app/views/forums/edit.html.haml +0 -7
  210. data/app/views/forums/index.html.haml +0 -23
  211. data/app/views/forums/new.html.haml +0 -5
  212. data/app/views/forums/show.html.haml +0 -20
  213. data/app/views/galleries/_form.html.haml +0 -30
  214. data/app/views/galleries/_show.html.haml +0 -21
  215. data/app/views/galleries/edit.html.haml +0 -7
  216. data/app/views/galleries/index.html.haml +0 -15
  217. data/app/views/galleries/new.html.haml +0 -5
  218. data/app/views/galleries/show.html.haml +0 -4
  219. data/app/views/images/_form.html.haml +0 -10
  220. data/app/views/images/create.js.haml +0 -3
  221. data/app/views/images/destroy.js.haml +0 -3
  222. data/app/views/images/edit.html.haml +0 -7
  223. data/app/views/images/edit.js.haml +0 -3
  224. data/app/views/images/index.html.haml +0 -17
  225. data/app/views/images/index.js.haml +0 -3
  226. data/app/views/images/new.html.haml +0 -5
  227. data/app/views/images/new.js.haml +0 -3
  228. data/app/views/images/show.html.haml +0 -5
  229. data/app/views/images/show.js.haml +0 -3
  230. data/app/views/images/update.js.haml +0 -3
  231. data/app/views/layouts/application.html.haml +0 -59
  232. data/app/views/layouts/bare.html.haml +0 -2
  233. data/app/views/layouts/image_dialog.html.haml +0 -18
  234. data/app/views/loadbehind/_destroy.js.haml +0 -3
  235. data/app/views/loadbehind/_edit.js.haml +0 -4
  236. data/app/views/loadbehind/_errors.html.haml +0 -5
  237. data/app/views/loadbehind/_growl_template.html.haml +0 -65
  238. data/app/views/loadbehind/_show_box.html.haml +0 -9
  239. data/app/views/loadbehind/_view.js.haml +0 -4
  240. data/app/views/loadbehind/growl.js.haml +0 -4
  241. data/app/views/loadbehind/index.js.haml +0 -4
  242. data/app/views/menus/_form.html.haml +0 -13
  243. data/app/views/menus/edit.html.haml +0 -7
  244. data/app/views/menus/index.html.haml +0 -19
  245. data/app/views/menus/new.html.haml +0 -5
  246. data/app/views/menus/show.html.haml +0 -7
  247. data/app/views/pages/_child_pages_links.html.haml +0 -5
  248. data/app/views/pages/_control_panel.html.haml +0 -15
  249. data/app/views/pages/_form.html.haml +0 -27
  250. data/app/views/pages/_form_fields.html.haml +0 -23
  251. data/app/views/pages/_show.html.haml +0 -4
  252. data/app/views/pages/_show_attachment.html.haml +0 -6
  253. data/app/views/pages/_show_small.html.haml +0 -2
  254. data/app/views/pages/create.js.haml +0 -3
  255. data/app/views/pages/destroy.js.haml +0 -3
  256. data/app/views/pages/edit.html.haml +0 -16
  257. data/app/views/pages/edit.js.haml +0 -4
  258. data/app/views/pages/index.html.haml +0 -19
  259. data/app/views/pages/index.js.haml +0 -3
  260. data/app/views/pages/new.html.haml +0 -5
  261. data/app/views/pages/new.js.haml +0 -3
  262. data/app/views/pages/show.html.haml +0 -20
  263. data/app/views/pages/show.js.haml +0 -3
  264. data/app/views/pages/update.js.haml +0 -3
  265. data/app/views/profiles/_form.html.haml +0 -26
  266. data/app/views/profiles/edit.html.haml +0 -7
  267. data/app/views/profiles/index.html.haml +0 -25
  268. data/app/views/profiles/new.html.haml +0 -5
  269. data/app/views/profiles/show.html.haml +0 -21
  270. data/app/views/sitemaps/edit.html.haml +0 -12
  271. data/app/views/sitemaps/edit.js.erb +0 -0
  272. data/app/views/sitemaps/index.html.haml +0 -83
  273. data/app/views/sitemaps/index.json.erb +0 -23
  274. data/app/views/sitemaps/new.html.haml +0 -8
  275. data/app/views/sitemaps/new.js.erb +0 -0
  276. data/app/views/users/edit.html.haml +0 -45
  277. data/app/views/users/index.html.haml +0 -19
  278. data/config/amazon_s3.yml +0 -15
  279. data/db/migrate/0000_devise_create_users.rb +0 -26
  280. data/db/migrate/0010_add_fields_to_users.rb +0 -28
  281. data/db/migrate/0020_create_blogs.rb +0 -16
  282. data/db/migrate/0030_create_galleries.rb +0 -15
  283. data/db/migrate/0040_create_images.rb +0 -17
  284. data/db/migrate/0050_create_profiles.rb +0 -24
  285. data/db/migrate/0060_insert_admin_user_and_roles.rb +0 -24
  286. data/db/migrate/0070_create_pages.rb +0 -16
  287. data/db/migrate/0080_create_forums.rb +0 -13
  288. data/db/migrate/0090_create_discussions.rb +0 -14
  289. data/db/migrate/0100_create_forum_messages.rb +0 -15
  290. data/db/migrate/0110_create_access_control_entries.rb +0 -23
  291. data/db/migrate/0120_create_attachments.rb +0 -17
  292. data/db/migrate/0130_create_roles.rb +0 -13
  293. data/db/migrate/0140_create_feedbacks.rb +0 -20
  294. data/db/migrate/0150_create_external_links.rb +0 -14
  295. data/db/migrate/0160_create_sitemaps.rb +0 -17
  296. data/db/migrate/0170_create_menus.rb +0 -14
  297. data/db/migrate/0180_acts_as_taggable_on_migration.rb +0 -28
  298. data/init.rb +0 -2
@@ -1,60 +0,0 @@
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
-
@@ -1,30 +0,0 @@
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
-
@@ -1,2 +0,0 @@
1
- class MenusController < InheritedResources::Base
2
- end
@@ -1,71 +0,0 @@
1
- class PagesController < InheritedResources::Base
2
- respond_to :js, :html
3
- ajax_loading
4
- before_filter :set_collection_name
5
- before_filter :parse_request_url, :only=>:show
6
-
7
- def set_collection_name
8
- if params[:page_id]
9
- self.resources_configuration[:self][:collection_name] = :children
10
- end
11
- end
12
-
13
- def parse_request_url
14
- if params["level1"]
15
- @sitemap = Sitemap.find_by_path(*[1,2,3,4].map{|i|params["level#{i}"]})
16
- @page = @sitemap.resource
17
- end
18
- end
19
-
20
- before_filter :authenticate_user!, :except=>[:show]
21
- before_filter :maybe_authenticate, :only=>[:show]
22
- before_filter :resource, :only=>[:update, :show, :destroy, :edit]
23
- authorize_resource
24
-
25
- has_scope :tagged_with, :as => :tag
26
- has_scope :accessible_by, :type=>:boolean, :default=>true do |c,s|
27
- s.accessible_by(c.current_ability)
28
- end
29
-
30
- def resource
31
- unless @page
32
- page_id = params[:id]
33
- if page_id.is_numeric?
34
- @page ||= Page.find(page_id)
35
- else
36
- @page ||= Page.where(["lower(pages.title) = ?", page_id.downcase.gsub(/[_]/, ' ')]).first
37
- end
38
- @attachments ||= @page.attachments
39
- end
40
- @page
41
- end
42
-
43
- def maybe_authenticate
44
- unless user_signed_in?
45
- authenticate_user! unless current_ability.can? :read, resource
46
- end
47
- end
48
-
49
- def edit
50
- edit! do |format|
51
- @attachment = Attachment.new(:page=>@page)
52
- @s3provider = S3Provider.new(:key=>"attachments/#{current_user.id}")
53
- end
54
- end
55
-
56
- def create
57
- create! { (@parent_page ? page_child_path(@parent_page, @page) : @page) }
58
- end
59
-
60
- def update
61
- update! do |format|
62
- if params[:child_id]
63
- @parent_page = @page
64
- @page = Page.find(params[:child_id])
65
- @page.parent = @parent_page
66
- @page.save
67
- end
68
- end
69
- end
70
- end
71
-
@@ -1,16 +0,0 @@
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
-
@@ -1,135 +0,0 @@
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
-
@@ -1,28 +0,0 @@
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
-
@@ -1,2 +0,0 @@
1
- module AccessControlEntriesHelper
2
- end
@@ -1,2 +0,0 @@
1
- module AppConfigsHelper
2
- end
@@ -1,36 +0,0 @@
1
- module ApplicationHelper
2
- def menu_node(name, url)
3
- content_tag(:li, content_tag(:a, content_tag(:span, name, :class=>name.underscore.gsub(/ /, '_')), :href=>url))
4
- end
5
-
6
- def sidebar_link(name, url, is_title = false)
7
- _class = name.underscore.gsub(/ /, '_')
8
- _class += "sidebar_title" if is_title
9
- content_tag(:li, content_tag(:a, content_tag(:span, name, :class=>name.underscore), :href=>url), :class=>_class)
10
- end
11
-
12
- def sidebar_content(&block)
13
- @sidebar = true
14
- content_for(:sidebar) do
15
- block.call
16
- end
17
- end
18
-
19
- def include_ckeditor
20
- content_for :head do
21
- javascript_include_tag('/ckeditor/ckeditor.js',
22
- '/ckeditor/adapters/jquery.js',
23
- "galleries/configure_ckeditor.js")
24
- end
25
- end
26
- def session_key_name
27
- Rails.application.config.session_options[:key]
28
- end
29
- def make_session_string
30
- arr = []
31
- request.env['HTTP_COOKIE'].each_char{|c| arr.push(c[0].to_s)}
32
- arr.join("x")
33
- end
34
-
35
- end
36
-
@@ -1,10 +0,0 @@
1
- module BlogsHelper
2
- def include_ckeditor
3
- content_for :head do
4
- javascript_include_tag('/ckeditor/ckeditor.js',
5
- '/ckeditor/adapters/jquery.js',
6
- "galleries/configure_ckeditor.js")
7
- end
8
- end
9
- end
10
-
@@ -1,2 +0,0 @@
1
- module DiscussionsHelper
2
- end
@@ -1,2 +0,0 @@
1
- module ExternalLinksHelper
2
- end
@@ -1,2 +0,0 @@
1
- module FeedbacksHelper
2
- end
@@ -1,2 +0,0 @@
1
- module ForumsHelper
2
- end
@@ -1,2 +0,0 @@
1
- module MenusHelper
2
- end
@@ -1,192 +0,0 @@
1
- module PagesHelper
2
- def form_url
3
- @parent_page ? page_children_path(@parent_page) : page_path(@page)
4
- end
5
- def form_object
6
- @parent_page ? [@parent_page, @page] : @page
7
- end
8
-
9
- def to_html_options(pages)
10
- pages.map{|p| [p.title, p.id]}
11
- end
12
-
13
- ######################################################
14
- ##
15
- ##
16
- ## Begin of uploadify_s3
17
- ##
18
- ##
19
- ######################################################
20
-
21
- def uploadify_s3(options = {})
22
- # stylesheet_link_tag('uploadify/uploadify') <<
23
- # javascript_include_tag('uploadify/jquery.uploadify.v2.1.0.min') <<
24
- # javascript_include_tag('uploadify/swfobject') <<
25
- javascript_uploadify_s3_tag(options)
26
- end
27
-
28
- protected
29
-
30
- def javascript_uploadify_s3_tag(options = {})
31
- options = default_options.merge(options)
32
- javascript_tag( %(
33
- $(document).ready(function() {
34
- $("#{options[:file_input_selector]}").uploadify({
35
- 'fileDataName' : 'file',
36
- 'uploader' : '/uploadify.swf',
37
- 'script' : '#{bucket_url}',
38
- 'cancelImg' : '/images/uploadify/cancel.png',
39
- 'folder' : 'attachments',
40
- 'auto' : true,
41
- 'multi' : true,
42
- 'buttonText' : 'Add File',
43
- 'sizeLimit' : '#{max_filesize}',
44
- 'fileDesc' : '#{options[:file_desc]}',
45
- 'fileExt' : '#{options[:file_ext]}',
46
- 'onSelect' : function(event, queueID, fileObj) {
47
- if (fileObj.size >= "#{max_filesize}") {
48
- $("#{options[:file_input_selector]}").uploadifyCancel(queueID);
49
- alert('Sorry the max file size is #{((max_filesize/1024)/1024)} MB');
50
- return false;
51
- }
52
-
53
- $('div.button_group').hide();
54
- return true;
55
- },
56
- 'onComplete' : function(event, queueID, fileObj, response) {
57
- $('div.button_group').show();
58
- fileInfo = {
59
- 'name' : fileObj.name,
60
- 'size' : fileObj.size,
61
- 'type' : fileObj.type,
62
- 'url' : '#{bucket_url}#{upload_path}/' + fileObj.name + '#{rangen}'
63
- };
64
- var onsucc = (#{options[:on_success]});
65
- onsucc(fileInfo);
66
- $('#{options[:file_input_selector]}').hide();
67
- return true;
68
- },
69
- 'onError' : function (a, b, c, d) {
70
- if (d.info == 201) {
71
- fileInfo = {
72
- 'name' : c.name,
73
- 'size' : c.size,
74
- 'type' : c.type,
75
- 'url' : '#{bucket_url}#{upload_path}/' + c.name + '#{rangen}'
76
- };
77
- var onsucc = (#{options[:on_success]});
78
- onsucc(fileInfo);
79
- $('#{options[:file_input_selector]}').hide();
80
- } else {
81
- var onerror = (#{options[:on_error]});
82
- if (onerror) {
83
- onerror(d.type, d.text);
84
- $('#file_uploaderQueue').hide();
85
- return false;
86
- }
87
- }
88
-
89
- return true;
90
- },
91
- 'scriptData' : {
92
- 'AWSAccessKeyId': '#{aws_access_key}',
93
- 'key': '#{key}',
94
- 'acl': '#{acl}',
95
- 'policy': '#{s3_policy}',
96
- 'success_action_status': '201',
97
- 'signature': encodeURIComponent(encodeURIComponent('#{s3_signature}')),
98
- 'Content-Type': ''
99
- }
100
- });
101
- });
102
- ))
103
- end
104
-
105
- def bucket_url
106
- "http://#{bucket}.s3.amazonaws.com/"
107
- end
108
-
109
- def key
110
- "#{upload_path}/${filename}#{rangen}"
111
- end
112
-
113
- def rangen
114
- @rangen ||= '' # rand(36 ** 8).to_s(36)
115
- end
116
-
117
- def policy_doc
118
- @policy ||= "{'expiration': '#{expiration_date}',
119
- 'conditions': [{'bucket': '#{bucket}'},
120
- ['starts-with', '$key', '#{upload_path}'],
121
- {'acl': '#{acl.to_s}'},
122
- ['content-length-range', 0, #{max_filesize}],
123
- {'success_action_status': '201'},
124
- ['starts-with','$folder',''],
125
- ['starts-with','$Filename',''],
126
- ['starts-with','$fileext',''],
127
- ]
128
- }"
129
- end
130
-
131
- def s3_policy
132
- Base64.encode64(policy_doc).gsub(/\n|\r/, '')
133
- end
134
-
135
- def s3_signature
136
- raise "Secret key should not be nil." if self.aws_secret_key.nil?
137
- b64_hmac_sha1(aws_secret_key, s3_policy)
138
- end
139
-
140
- def load_s3config
141
- a = YAML.load_file("#{Rails.root}/config/amazon_s3.yml")
142
- puts 'loading config from yaml file.'
143
- @s3config = a['development']
144
- puts @s3config.inspect
145
- end
146
-
147
- def s3config(name)
148
- load_s3config unless @s3config
149
- @s3config[name]
150
- end
151
-
152
- def aws_access_key
153
- s3config 'access_key_id'
154
- end
155
-
156
- def aws_secret_key
157
- s3config('secret_access_key')
158
- end
159
-
160
- def bucket
161
- s3config('bucket')
162
- end
163
-
164
- def acl
165
- s3config('default_acl') || "public-read"
166
- end
167
-
168
- def upload_path
169
- s3config('upload_path') || 'attachments'
170
- end
171
-
172
- def max_filesize
173
- s3config('max_file_size') || 1000.megabyte
174
- end
175
-
176
- def expiration_date
177
- 10.hours.from_now.utc.strftime('%Y-%m-%dT%H:%M:%S.000Z')
178
- end
179
-
180
- def default_options
181
- {
182
- :button_text => 'Add File',
183
- :button_img => '/images/uploadify/upload.png',
184
- :height => '20',
185
- :width => '30',
186
- :file_ext => '*.*',
187
- :file_input_selector => '#file_upload',
188
- :file_desc => 'Please choose your file'
189
- }
190
- end
191
- end
192
-
@@ -1,12 +0,0 @@
1
- module SitemapsHelper
2
- def authenticity_token_json
3
- unless protect_against_forgery?
4
- ''
5
- else
6
- %("#{request_forgery_protection_token.to_s}" : "#{form_authenticity_token}",\n)
7
- end
8
- end
9
-
10
-
11
- end
12
-
@@ -1,10 +0,0 @@
1
- class FeedbackMailer < ActionMailer::Base
2
- default :from => "mailer-no-reply@cagym.com"
3
-
4
- def submit_feedback(feedback)
5
- @feedback = feedback
6
- #attachments["rails.png"] = File.read("#{Rails.root}/public/images/rails.png")
7
- mail(:to => "hipkin@pacbell.net", :subject => %(CAGYM.com user feedback: #{feedback.subject}))
8
- end
9
- end
10
-
@@ -1,43 +0,0 @@
1
- class Ability
2
- include CanCan::Ability
3
- def self.initializers
4
- @initializers ||= []
5
- end
6
-
7
- def self.initializer(*method_names)
8
- method_names.each{|t| initializers << t}
9
- end
10
- initializer :init_wheels
11
-
12
- def initialize(user)
13
- user ||= User.nobody
14
- puts all_aces_for(user).map{|t| "#{t.resource_type} #{t.options.inspect}"}.join("\n")
15
- self.class.initializers.each{|t| self.send(t, user)}
16
- all_aces_for(user).each do |ace|
17
- ace.configure(self)
18
- end
19
- end
20
-
21
- def all_aces_for(user)
22
- (user.access_control_entries + user.role.access_control_entries)
23
- end
24
-
25
- def init_wheels(user)
26
- can :read, :all
27
- roles = Role.all
28
- def roles.find_by_name(name); self.select{|t| t.name==name}[0]; end;
29
- case user.role.id
30
- when roles.find_by_name("Super").id
31
- can :manage, :all
32
- when roles.find_by_name("Admin").id
33
- can :manage, :all
34
- when roles.find_by_name("User").id
35
- can :manage, Gallery, :user_id => user.id
36
- can :manage, Blog, :user_id => user.id
37
- can :edit, Profile, :user_id => user.id
38
- cannot :read, User
39
- can :manage, User, :id => user.id
40
- end
41
- end
42
- end
43
-