alchemy_cms 2.5.3.1 → 2.6.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (331) hide show
  1. data/.gitignore +1 -1
  2. data/.travis.yml +5 -13
  3. data/Gemfile +6 -3
  4. data/README.md +3 -2
  5. data/alchemy_cms.gemspec +22 -22
  6. data/app/assets/fonts/alchemy-icons.eot +0 -0
  7. data/app/assets/fonts/alchemy-icons.svg +54 -0
  8. data/app/assets/fonts/alchemy-icons.ttf +0 -0
  9. data/app/assets/fonts/alchemy-icons.woff +0 -0
  10. data/app/assets/images/alchemy/icons.png +0 -0
  11. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +151 -0
  12. data/app/assets/javascripts/alchemy/alchemy.buttons.js.coffee +3 -2
  13. data/app/assets/javascripts/alchemy/alchemy.datepicker.js.coffee +31 -0
  14. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +1 -1
  15. data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +98 -0
  16. data/app/assets/javascripts/alchemy/alchemy.elements_window.js.coffee +23 -24
  17. data/app/assets/javascripts/alchemy/alchemy.growler.js.coffee +27 -0
  18. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +11 -8
  19. data/app/assets/javascripts/alchemy/alchemy.hotkeys.js.coffee +32 -0
  20. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee +46 -0
  21. data/app/assets/javascripts/alchemy/alchemy.js +8 -2
  22. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +5 -4
  23. data/app/assets/javascripts/alchemy/alchemy.list_filter.js.coffee +49 -0
  24. data/app/assets/javascripts/alchemy/alchemy.onload.js.coffee +3 -0
  25. data/app/assets/javascripts/alchemy/alchemy.preview_window.js.coffee +71 -0
  26. data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +61 -0
  27. data/app/assets/javascripts/alchemy/alchemy.spinner.js.coffee +35 -0
  28. data/app/assets/javascripts/alchemy/alchemy.string_extension.js.coffee +11 -0
  29. data/app/assets/javascripts/alchemy/alchemy.windows.js.coffee +278 -0
  30. data/app/assets/stylesheets/alchemy/admin.css.scss +2 -0
  31. data/app/assets/stylesheets/alchemy/archive.scss +109 -65
  32. data/app/assets/stylesheets/alchemy/base.scss +16 -188
  33. data/app/assets/stylesheets/alchemy/dashboard.scss +2 -2
  34. data/app/assets/stylesheets/alchemy/defaults.scss +2 -1
  35. data/app/assets/stylesheets/alchemy/elements.scss +58 -94
  36. data/app/assets/stylesheets/alchemy/errors.scss +2 -2
  37. data/app/assets/stylesheets/alchemy/{mixins.scss → extends.scss} +104 -80
  38. data/app/assets/stylesheets/alchemy/flash.scss +4 -6
  39. data/app/assets/stylesheets/alchemy/fonts.scss +46 -0
  40. data/app/assets/stylesheets/alchemy/form_elements.scss +46 -45
  41. data/app/assets/stylesheets/alchemy/frame.scss +20 -15
  42. data/app/assets/stylesheets/alchemy/icons.scss +22 -9
  43. data/app/assets/stylesheets/alchemy/jquery-ui.scss +476 -399
  44. data/app/assets/stylesheets/alchemy/login.scss +1 -1
  45. data/app/assets/stylesheets/alchemy/menubar.css.scss +1 -1
  46. data/app/assets/stylesheets/alchemy/notices.scss +5 -5
  47. data/app/assets/stylesheets/alchemy/pagination.scss +25 -13
  48. data/app/assets/stylesheets/alchemy/search.scss +29 -17
  49. data/app/assets/stylesheets/alchemy/sitemap.scss +41 -36
  50. data/app/assets/stylesheets/alchemy/tables.scss +102 -50
  51. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +18 -16
  52. data/app/assets/stylesheets/alchemy/toolbar.scss +84 -24
  53. data/app/assets/stylesheets/alchemy/upload.scss +14 -9
  54. data/app/assets/stylesheets/alchemy/variables.scss +1 -0
  55. data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +18 -21
  56. data/app/controllers/alchemy/admin/attachments_controller.rb +29 -39
  57. data/app/controllers/alchemy/admin/base_controller.rb +3 -9
  58. data/app/controllers/alchemy/admin/clipboard_controller.rb +1 -1
  59. data/app/controllers/alchemy/admin/contents_controller.rb +1 -1
  60. data/app/controllers/alchemy/admin/dashboard_controller.rb +1 -1
  61. data/app/controllers/alchemy/admin/elements_controller.rb +3 -3
  62. data/app/controllers/alchemy/admin/essence_files_controller.rb +1 -1
  63. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +5 -5
  64. data/app/controllers/alchemy/admin/languages_controller.rb +1 -1
  65. data/app/controllers/alchemy/admin/pages_controller.rb +18 -16
  66. data/app/controllers/alchemy/admin/pictures_controller.rb +11 -10
  67. data/app/controllers/alchemy/admin/resources_controller.rb +87 -14
  68. data/app/controllers/alchemy/admin/tags_controller.rb +3 -3
  69. data/app/controllers/alchemy/admin/trash_controller.rb +3 -3
  70. data/app/controllers/alchemy/admin/users_controller.rb +6 -11
  71. data/app/controllers/alchemy/attachments_controller.rb +8 -9
  72. data/app/controllers/alchemy/base_controller.rb +17 -10
  73. data/app/controllers/alchemy/pages_controller.rb +7 -19
  74. data/app/controllers/alchemy/passwords_controller.rb +15 -3
  75. data/app/controllers/alchemy/user_sessions_controller.rb +5 -4
  76. data/app/controllers/alchemy/users_controller.rb +1 -1
  77. data/app/helpers/alchemy/admin/attachments_helper.rb +2 -2
  78. data/app/helpers/alchemy/admin/base_helper.rb +62 -90
  79. data/app/helpers/alchemy/admin/elements_helper.rb +13 -5
  80. data/app/helpers/alchemy/admin/essences_helper.rb +3 -5
  81. data/app/helpers/alchemy/admin/pages_helper.rb +6 -3
  82. data/app/helpers/alchemy/admin/tags_helper.rb +60 -0
  83. data/app/helpers/alchemy/base_helper.rb +16 -20
  84. data/app/helpers/alchemy/elements_helper.rb +7 -11
  85. data/app/helpers/alchemy/essences_helper.rb +2 -2
  86. data/app/helpers/alchemy/pages_helper.rb +31 -69
  87. data/app/helpers/alchemy/url_helper.rb +11 -3
  88. data/app/models/alchemy/attachment.rb +73 -45
  89. data/app/models/alchemy/cell.rb +1 -1
  90. data/app/models/alchemy/content.rb +20 -9
  91. data/app/models/alchemy/element.rb +9 -7
  92. data/app/models/alchemy/page.rb +15 -248
  93. data/app/models/alchemy/page/cells.rb +71 -0
  94. data/app/models/alchemy/page/elements.rb +147 -0
  95. data/app/models/alchemy/page/naming.rb +90 -0
  96. data/app/models/alchemy/picture.rb +18 -13
  97. data/app/models/alchemy/tag.rb +1 -1
  98. data/app/models/alchemy/user.rb +38 -6
  99. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +14 -7
  100. data/app/views/alchemy/admin/attachments/_attachment.html.erb +17 -12
  101. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +3 -8
  102. data/app/views/alchemy/admin/attachments/_files_list.html.erb +20 -12
  103. data/app/views/alchemy/admin/attachments/_overlay_file_list.html.erb +11 -0
  104. data/app/views/alchemy/admin/attachments/_tag_list.html.erb +31 -0
  105. data/app/views/alchemy/admin/attachments/archive_overlay.js.erb +4 -0
  106. data/app/views/alchemy/admin/attachments/edit.html.erb +8 -7
  107. data/app/views/alchemy/admin/attachments/index.html.erb +19 -12
  108. data/app/views/alchemy/admin/attachments/new.html.erb +2 -2
  109. data/app/views/alchemy/admin/attachments/show.html.erb +3 -0
  110. data/app/views/alchemy/admin/contents/_missing.html.erb +4 -4
  111. data/app/views/alchemy/admin/contents/create.js.erb +1 -1
  112. data/app/views/alchemy/admin/contents/new.html.erb +6 -3
  113. data/app/views/alchemy/admin/dashboard/_locked_pages.html.erb +1 -1
  114. data/app/views/alchemy/admin/dashboard/_users.html.erb +1 -1
  115. data/app/views/alchemy/admin/dashboard/index.html.erb +3 -3
  116. data/app/views/alchemy/admin/dashboard/info.html.erb +16 -13
  117. data/app/views/alchemy/admin/elements/_add_picture.html.erb +1 -1
  118. data/app/views/alchemy/admin/elements/_element_foot.html.erb +4 -4
  119. data/app/views/alchemy/admin/elements/_element_head.html.erb +1 -7
  120. data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -2
  121. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +4 -4
  122. data/app/views/alchemy/admin/elements/_picture_gallery_editor.html.erb +1 -1
  123. data/app/views/alchemy/admin/elements/create.js.erb +2 -2
  124. data/app/views/alchemy/admin/elements/fold.js.erb +3 -6
  125. data/app/views/alchemy/admin/elements/new.html.erb +1 -1
  126. data/app/views/alchemy/admin/elements/order.js.erb +1 -1
  127. data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
  128. data/app/views/alchemy/admin/elements/update.js.erb +2 -2
  129. data/app/views/alchemy/admin/essence_files/edit.html.erb +4 -4
  130. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +17 -18
  131. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +2 -2
  132. data/app/views/alchemy/admin/essence_pictures/update.js.erb +1 -0
  133. data/app/views/alchemy/admin/languages/_form.html.erb +12 -10
  134. data/app/views/alchemy/admin/languages/_language.html.erb +2 -1
  135. data/app/views/alchemy/admin/languages/_table.html.erb +3 -3
  136. data/app/views/alchemy/admin/languages/index.html.erb +15 -15
  137. data/app/views/alchemy/admin/layoutpages/_layoutpage.html.erb +6 -6
  138. data/app/views/alchemy/admin/layoutpages/index.html.erb +41 -40
  139. data/app/views/alchemy/admin/pages/_contactform_links.html.erb +4 -4
  140. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +6 -6
  141. data/app/views/alchemy/admin/pages/_external_link.html.erb +2 -2
  142. data/app/views/alchemy/admin/pages/_file_link.html.erb +3 -3
  143. data/app/views/alchemy/admin/pages/_internal_link.html.erb +1 -1
  144. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  145. data/app/views/alchemy/admin/pages/_page.html.erb +13 -13
  146. data/app/views/alchemy/admin/pages/_page_for_links.html.erb +2 -4
  147. data/app/views/alchemy/admin/pages/_sitemap.html.erb +5 -0
  148. data/app/views/alchemy/admin/pages/configure.html.erb +7 -7
  149. data/app/views/alchemy/admin/pages/configure_external.html.erb +4 -4
  150. data/app/views/alchemy/admin/pages/edit.html.erb +23 -30
  151. data/app/views/alchemy/admin/pages/index.html.erb +34 -23
  152. data/app/views/alchemy/admin/pages/new.html.erb +1 -1
  153. data/app/views/alchemy/admin/pages/sort.js.erb +1 -1
  154. data/app/views/alchemy/admin/partials/_flash_upload.html.erb +2 -3
  155. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +2 -2
  156. data/app/views/alchemy/admin/partials/_search_form.html.erb +3 -3
  157. data/app/views/alchemy/admin/partials/_upload_form.html.erb +2 -2
  158. data/app/views/alchemy/admin/pictures/_archive.html.erb +7 -7
  159. data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +1 -1
  160. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +6 -6
  161. data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +4 -4
  162. data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +1 -1
  163. data/app/views/alchemy/admin/pictures/_picture.html.erb +3 -8
  164. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +9 -14
  165. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -25
  166. data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
  167. data/app/views/alchemy/admin/pictures/index.html.erb +49 -42
  168. data/app/views/alchemy/admin/pictures/new.html.erb +2 -2
  169. data/app/views/alchemy/admin/pictures/show.html.erb +11 -0
  170. data/app/views/alchemy/admin/resources/_boolean.html.erb +2 -2
  171. data/app/views/alchemy/admin/resources/_datetime.html.erb +2 -2
  172. data/app/views/alchemy/admin/resources/_form.html.erb +9 -8
  173. data/app/views/alchemy/admin/resources/_resource.html.erb +15 -21
  174. data/app/views/alchemy/admin/resources/_string.html.erb +2 -2
  175. data/app/views/alchemy/admin/resources/_table.html.erb +11 -13
  176. data/app/views/alchemy/admin/resources/_text.html.erb +2 -2
  177. data/app/views/alchemy/admin/resources/index.csv.erb +13 -0
  178. data/app/views/alchemy/admin/resources/index.html.erb +24 -15
  179. data/app/views/alchemy/admin/sites/index.html.erb +23 -0
  180. data/app/views/alchemy/admin/tags/_radio_tag.html.erb +1 -1
  181. data/app/views/alchemy/admin/tags/_tag.html.erb +2 -1
  182. data/app/views/alchemy/admin/tags/edit.html.erb +1 -1
  183. data/app/views/alchemy/admin/tags/index.html.erb +16 -11
  184. data/app/views/alchemy/admin/tags/new.html.erb +3 -3
  185. data/app/views/alchemy/admin/trash/clear.js.coffee +1 -1
  186. data/app/views/alchemy/admin/users/_table.html.erb +12 -5
  187. data/app/views/alchemy/admin/users/_user.html.erb +16 -16
  188. data/app/views/alchemy/admin/users/index.html.erb +28 -16
  189. data/app/views/alchemy/breadcrumb/_page.html.erb +15 -0
  190. data/app/views/alchemy/breadcrumb/_spacer.html.erb +1 -0
  191. data/app/views/alchemy/elements/_editor_not_found.html.erb +1 -1
  192. data/app/views/alchemy/essences/_essence_file_editor.html.erb +16 -16
  193. data/app/views/alchemy/essences/_essence_file_view.html.erb +8 -9
  194. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +3 -6
  195. data/app/views/alchemy/essences/_essence_picture_tools.html.erb +9 -8
  196. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +0 -5
  197. data/app/views/alchemy/essences/_linkable_essence_tools.html.erb +2 -2
  198. data/app/views/alchemy/navigation/_link.html.erb +7 -7
  199. data/app/views/alchemy/navigation/_renderer.html.erb +29 -36
  200. data/app/views/alchemy/notifications/admin_user_created.de.text.erb +5 -1
  201. data/app/views/alchemy/notifications/admin_user_created.en.text.erb +5 -1
  202. data/app/views/alchemy/notifications/registered_user_created.de.text.erb +13 -0
  203. data/app/views/alchemy/notifications/registered_user_created.en.text.erb +13 -0
  204. data/app/views/alchemy/search/_result.html.erb +4 -6
  205. data/app/views/alchemy/search/_results.html.erb +4 -5
  206. data/app/views/alchemy/user_sessions/leave.html.erb +1 -1
  207. data/app/views/alchemy/user_sessions/new.html.erb +2 -2
  208. data/app/views/kaminari/_first_page.html.erb +11 -0
  209. data/app/views/kaminari/_gap.html.erb +1 -1
  210. data/app/views/kaminari/_last_page.html.erb +11 -0
  211. data/app/views/kaminari/_next_page.html.erb +2 -2
  212. data/app/views/kaminari/_page.html.erb +1 -1
  213. data/app/views/kaminari/_paginator.html.erb +2 -0
  214. data/app/views/kaminari/_prev_page.html.erb +2 -2
  215. data/app/views/layouts/alchemy/admin.html.erb +4 -5
  216. data/config/alchemy/config.yml +8 -12
  217. data/config/authorization_rules.rb +4 -3
  218. data/config/initializers/dragonfly.rb +20 -12
  219. data/config/locales/alchemy.de.yml +20 -15
  220. data/config/locales/alchemy.en.yml +15 -10
  221. data/config/locales/devise.de.yml +1 -0
  222. data/config/routes.rb +3 -3
  223. data/{spec/dummy/db/migrate/20121118000000_alchemy_two_point_four.rb → db/migrate/20130214233001_alchemy_two_point_five.rb} +50 -36
  224. data/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +21 -0
  225. data/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +11 -0
  226. data/lib/alchemy/capistrano.rb +10 -8
  227. data/lib/alchemy/errors.rb +7 -0
  228. data/lib/alchemy/filetypes.rb +33 -0
  229. data/lib/alchemy/i18n.rb +9 -1
  230. data/lib/alchemy/name_conversions.rb +28 -0
  231. data/lib/alchemy/page_layout.rb +5 -3
  232. data/lib/alchemy/resource.rb +132 -29
  233. data/lib/alchemy/resources_helper.rb +81 -12
  234. data/lib/alchemy/upgrader.rb +14 -276
  235. data/lib/alchemy/version.rb +1 -1
  236. data/lib/alchemy_cms.rb +17 -2
  237. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +1 -1
  238. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +1 -1
  239. data/lib/tasks/alchemy/convert.rake +39 -0
  240. data/lib/tasks/alchemy/install.rake +4 -6
  241. data/lib/tasks/alchemy/upgrade.rake +18 -1
  242. data/spec/controllers/admin/clipboard_controller_spec.rb +4 -4
  243. data/spec/controllers/admin/elements_controller_spec.rb +23 -23
  244. data/spec/controllers/admin/pages_controller_spec.rb +15 -0
  245. data/spec/controllers/admin/resources_controller_spec.rb +1 -11
  246. data/spec/controllers/admin/trash_controller_spec.rb +9 -9
  247. data/spec/controllers/attachments_controller_spec.rb +3 -3
  248. data/spec/controllers/elements_controller_spec.rb +2 -2
  249. data/spec/controllers/pages_controller_spec.rb +160 -129
  250. data/spec/controllers/pictures_controller_spec.rb +2 -2
  251. data/spec/controllers/user_sessions_controller_spec.rb +3 -3
  252. data/spec/controllers/users_controller_spec.rb +2 -2
  253. data/spec/dummy/app/models/event.rb +2 -2
  254. data/spec/dummy/app/models/location.rb +4 -0
  255. data/spec/dummy/app/views/layouts/application.html.erb +6 -42
  256. data/spec/dummy/config/routes.rb +1 -1
  257. data/spec/dummy/db/migrate/20121026104128_create_events.rb +0 -1
  258. data/{db/migrate/20121118000000_alchemy_two_point_four.rb → spec/dummy/db/migrate/20130214233001_alchemy_two_point_five.rb} +50 -36
  259. data/spec/dummy/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +21 -0
  260. data/spec/dummy/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +11 -0
  261. data/spec/dummy/db/migrate/20130328101418_create_locations.rb +9 -0
  262. data/spec/dummy/db/schema.rb +15 -6
  263. data/spec/factories.rb +4 -4
  264. data/spec/{integration → features}/admin/link_overlay_spec.rb +0 -0
  265. data/spec/{integration → features}/admin/modules_integration_spec.rb +1 -1
  266. data/spec/{integration → features}/admin/pages_controller_spec.rb +9 -4
  267. data/spec/{integration → features}/admin/picture_library_integration_spec.rb +5 -5
  268. data/spec/{integration → features}/admin/resources_integration_spec.rb +1 -1
  269. data/spec/{integration → features}/navigation_spec.rb +0 -0
  270. data/spec/{integration → features}/pages_controller_spec.rb +42 -112
  271. data/spec/{integration → features}/picture_security_spec.rb +2 -2
  272. data/spec/{integration → features}/security_spec.rb +7 -7
  273. data/spec/{integration → features}/translation_integration_spec.rb +0 -0
  274. data/spec/helpers/admin/base_helper_spec.rb +0 -50
  275. data/spec/helpers/admin/tags_helper_spec.rb +53 -0
  276. data/spec/helpers/base_helper_spec.rb +19 -3
  277. data/spec/helpers/pages_helper_spec.rb +92 -44
  278. data/spec/{url_helpers_spec.rb → helpers/picture_url_helpers_spec.rb} +7 -7
  279. data/spec/helpers/url_helper_spec.rb +92 -72
  280. data/spec/{config_spec.rb → libraries/config_spec.rb} +0 -0
  281. data/spec/libraries/resource_spec.rb +215 -76
  282. data/spec/libraries/resources_helper_spec.rb +70 -28
  283. data/spec/models/attachment_spec.rb +75 -9
  284. data/spec/models/clipboard_spec.rb +1 -1
  285. data/spec/models/element_spec.rb +7 -0
  286. data/spec/models/page_spec.rb +144 -25
  287. data/spec/models/picture_spec.rb +5 -5
  288. data/spec/models/resource_spec.rb +47 -10
  289. data/spec/models/user_spec.rb +115 -3
  290. data/spec/{routing_spec.rb → routing/routing_spec.rb} +8 -20
  291. data/spec/spec_helper.rb +5 -6
  292. data/spec/support/alchemy/specs_helpers.rb +1 -1
  293. data/spec/support/ci/install_phantomjs +1 -1
  294. data/spec/support/image with spaces.png +0 -0
  295. data/vendor/assets/javascripts/jquery_plugins/jquery.Jcrop.min.js +18 -18
  296. data/vendor/assets/javascripts/jquery_plugins/{jquery.dialogextend.1_0_1.js → jquery.dialogextend.js} +25 -17
  297. data/vendor/assets/javascripts/jquery_plugins/jquery.scrollTo.min.js +7 -0
  298. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.tabspaging.js +7 -7
  299. data/vendor/assets/javascripts/keymage.min.js +6 -0
  300. data/vendor/assets/javascripts/spin.min.js +1 -0
  301. metadata +122 -124
  302. data/app/assets/images/alchemy/ajax_loader.gif +0 -0
  303. data/app/assets/images/alchemy/gui/toggle.png +0 -0
  304. data/app/assets/images/alchemy/image_loader.gif +0 -0
  305. data/app/assets/images/alchemy/shading.png +0 -0
  306. data/app/assets/images/alchemy/tabs.gif +0 -0
  307. data/app/assets/javascripts/alchemy/alchemy.base.js +0 -172
  308. data/app/assets/javascripts/alchemy/alchemy.datepicker.js +0 -47
  309. data/app/assets/javascripts/alchemy/alchemy.element_editor_selector.js +0 -91
  310. data/app/assets/javascripts/alchemy/alchemy.growler.js +0 -46
  311. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js +0 -60
  312. data/app/assets/javascripts/alchemy/alchemy.js_extensions.js +0 -15
  313. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +0 -97
  314. data/app/assets/javascripts/alchemy/alchemy.windows.js +0 -321
  315. data/app/models/alchemy/clipboard_spec.rb +0 -0
  316. data/app/views/alchemy/admin/pictures/show_in_window.html.erb +0 -8
  317. data/app/views/alchemy/notifications/registered_user_created.text.erb +0 -11
  318. data/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +0 -21
  319. data/db/migrate/20121205155004_create_alchemy_sites.rb +0 -14
  320. data/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +0 -6
  321. data/db/migrate/20121220102223_add_aliases_to_site.rb +0 -6
  322. data/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +0 -11
  323. data/db/migrate/20130121092645_migrate_to_devise.rb +0 -24
  324. data/spec/alchemy_spec.rb +0 -7
  325. data/spec/dummy/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +0 -21
  326. data/spec/dummy/db/migrate/20121205155004_create_alchemy_sites.rb +0 -14
  327. data/spec/dummy/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +0 -6
  328. data/spec/dummy/db/migrate/20121220102223_add_aliases_to_site.rb +0 -6
  329. data/spec/dummy/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +0 -11
  330. data/spec/dummy/db/migrate/20130121092645_migrate_to_devise.rb +0 -24
  331. data/vendor/assets/javascripts/jquery_plugins/jquery.scrollTo-1.4.2-min.js +0 -11
@@ -64,12 +64,20 @@ module Alchemy
64
64
  end
65
65
  alias_method :render_picture_editor, :render_picture_gallery_editor
66
66
 
67
- # Returns all elements that could be placed on that page because of the pages layout.
68
- # The elements are returned as an array to be used in alchemy_selectbox form builder.
67
+ # Returns a elements options string for select helper.
68
+ #
69
+ # @param [Array] elements descriptions
70
+ # @return [String]
71
+ #
69
72
  def elements_for_select(elements)
70
73
  return [] if elements.nil?
71
- options = elements.collect { |e| [_t(e['name'], :scope => :element_names), e["name"]] }
72
- return options_for_select(options)
74
+ options = elements.collect do |e|
75
+ [
76
+ _t(e['name'], scope: 'element_names', default: e['name'].to_s.humanize),
77
+ e['name']
78
+ ]
79
+ end
80
+ options_for_select(options)
73
81
  end
74
82
 
75
83
  # Returns all elements that could be placed on that page because of the pages layout.
@@ -106,7 +114,7 @@ module Alchemy
106
114
  ]
107
115
  else
108
116
  [
109
- Alchemy::I18n.t(e['name'], :scope => :element_names),
117
+ _t(e['name'], scope: :element_names, default: e['name'].to_s.humanize),
110
118
  e[object_method] + (cell ? "##{cell['name']}" : "")
111
119
  ]
112
120
  end
@@ -22,7 +22,7 @@ module Alchemy
22
22
  # * editor_options (Hash) - Will be passed to the render_essence_editor partial renderer
23
23
  #
24
24
  def render_essence_editor_by_type(element, essence_type, options = {}, editor_options = {})
25
- return warning('Element is nil', _t("no_element_given")) if element.blank?
25
+ return warning('Element is nil', _t(:no_element_given)) if element.blank?
26
26
  return warning('EssenceType is blank', _t("No EssenceType given")) if essence_type.blank?
27
27
  defaults = {
28
28
  :position => 1,
@@ -68,7 +68,7 @@ module Alchemy
68
68
  #
69
69
  def render_essence_editor_by_name(element, name, options = {}, html_options = {})
70
70
  if element.blank?
71
- return warning('Element is nil', _t("no_element_given"))
71
+ return warning('Element is nil', _t(:no_element_given))
72
72
  end
73
73
  content = element.content_by_name(name)
74
74
  if content.nil?
@@ -141,9 +141,7 @@ module Alchemy
141
141
  }.merge(image_options)),
142
142
  :alt => content.ingredient.name,
143
143
  :class => 'img_paddingtop',
144
- :title => _t("image_name") + ": #{content.ingredient.name}",
145
- :onload => "Alchemy.fadeImage(this, '##{content_dom_id(content)} .picture_content_spinner');",
146
- :style => "display: none;"
144
+ :title => _t(:image_name) + ": #{content.ingredient.name}"
147
145
  )
148
146
  end
149
147
 
@@ -19,12 +19,14 @@ module Alchemy
19
19
  Alchemy.Tinymce = {
20
20
  init : function(callback) {
21
21
  var init = { #{init} };
22
+ var spinner = Alchemy.Spinner.small();
23
+ $('.tinymce_container').prepend(spinner.spin().el);
22
24
  init.mode = 'specific_textareas';
23
25
  init.editor_selector = 'default_tinymce';
24
26
  init.plugins = '#{Alchemy::Tinymce.plugins.join(',')}';
25
27
  init.language = '#{::I18n.locale.to_s.split('-')[0].downcase }';
26
28
  init.init_instance_callback = function(inst) {
27
- $('#' + inst.editorId).prev('.essence_richtext_loader').hide();
29
+ $('#' + inst.editorId).prev('.spinner').remove();
28
30
  }
29
31
  if (callback)
30
32
  init.oninit = callback;
@@ -67,9 +69,10 @@ module Alchemy
67
69
  init.language = '#{::I18n.locale.to_s.split('-')[0].downcase }';
68
70
  init.init_instance_callback = function(inst) {
69
71
  var $this = $('#' + inst.editorId);
70
- $this.prev('.essence_richtext_loader').hide();
72
+ var parent = $this.parents('.element_editor');
73
+ parent.find('.spinner').remove();
71
74
  inst.onChange.add(function (ed, l) {
72
- Alchemy.setElementDirty($this.parents('.element_editor'));
75
+ Alchemy.setElementDirty(parent);
73
76
  });
74
77
  }
75
78
  tinymce.init(init);
@@ -0,0 +1,60 @@
1
+ module Alchemy
2
+ module Admin
3
+ module TagsHelper
4
+
5
+ # Checks if the tagged_with param contains the given tag
6
+ def filtered_by_tag?(tag)
7
+ if params[:tagged_with].present?
8
+ tags = params[:tagged_with].split(',')
9
+ tags.include?(tag.name)
10
+ else
11
+ false
12
+ end
13
+ end
14
+
15
+ # Adds the given tag to the tag filter.
16
+ def add_to_tag_filter(tag)
17
+ if params[:tagged_with].present?
18
+ tags = params[:tagged_with].split(',')
19
+ tags << tag.name
20
+ else
21
+ [tag.name]
22
+ end
23
+ end
24
+
25
+ # Removes the given tag from the tag filter.
26
+ def remove_from_tag_filter(tag)
27
+ if params[:tagged_with].present?
28
+ tags = params[:tagged_with].split(',')
29
+ tags.delete_if { |t| t == tag.name }
30
+ else
31
+ []
32
+ end
33
+ end
34
+
35
+ # Returns the tag filter from params.
36
+ #
37
+ # A tag can be added to the filter.
38
+ # A tag can also be removed.
39
+ #
40
+ # Options are:
41
+ # * options (Hash):
42
+ # ** :add (ActsAsTaggableOn::Tag) - The tag that should be added to the tag-filter
43
+ # ** :remove (ActsAsTaggableOn::Tag) - The tag that should be removed from the tag-filter
44
+ #
45
+ def tag_filter(options={})
46
+ case
47
+ when options[:add]
48
+ taglist = add_to_tag_filter(options[:add]) if options[:add]
49
+ when options[:remove]
50
+ taglist = remove_from_tag_filter(options[:remove]) if options[:remove]
51
+ else
52
+ return params[:tagged_with]
53
+ end
54
+ return nil if taglist.blank?
55
+ taglist.uniq.join(',')
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -69,26 +69,7 @@ module Alchemy
69
69
  # I.e. used to find the active page in navigation.
70
70
  def breadcrumb(current)
71
71
  return [] if current.nil?
72
- result = Array.new
73
- result << current
74
- while current = current.parent
75
- result << current
76
- end
77
- return result.reverse
78
- end
79
-
80
- # Returns a hash with urlname for each url level.
81
- # I.e.: +{:level1 => 'company', :level2 => 'history'}+
82
- def params_for_nested_url(page = nil)
83
- page ||= @page
84
- raise ArgumentError if page.nil?
85
- nested_urL_params = {}
86
- page_bread_crumb = breadcrumb(page)
87
- urlnames = page_bread_crumb[2..page_bread_crumb.length-2].collect(&:urlname)
88
- urlnames.each_with_index do |urlname, i|
89
- nested_urL_params["level#{i+1}"] = urlname
90
- end
91
- nested_urL_params.symbolize_keys
72
+ current.self_and_ancestors.where("parent_id IS NOT NULL")
92
73
  end
93
74
 
94
75
  # Returns the Alchemy configuration.
@@ -120,5 +101,20 @@ module Alchemy
120
101
  render('alchemy/admin/partials/flash', flash_type: style, message: notice)
121
102
  end
122
103
 
104
+ # Checks if the given argument is a String or a Page object.
105
+ # If a String is given, it tries to find the page via page_layout
106
+ # Logs a warning if no page is given.
107
+ def page_or_find(page)
108
+ if page.is_a?(String)
109
+ page = Page.where(page_layout: page, language_id: session[:language_id]).first
110
+ end
111
+ if page.blank?
112
+ warning("No Page found for #{page.inspect}")
113
+ return
114
+ else
115
+ page
116
+ end
117
+ end
118
+
123
119
  end
124
120
  end
@@ -11,9 +11,9 @@ module Alchemy
11
11
  #
12
12
  # :only => [] # A list of element names to be rendered only. Very useful if you want to render a specific element type in a special html part (e.g.. <div>) of your page and all other elements in another part.
13
13
  # :except => [] # A list of element names to be rendered. The opposite of the only option.
14
- # :from_page # The Alchemy::Page.page_layout string from which the elements are rendered from, or you even pass a Page object.
15
- # :from_cell # The Cell object from which the elements are rendered from.
16
- # :count # The amount of elements to be rendered (begins with first element found)
14
+ # :from_page => @page # The Alchemy::Page.page_layout string from which the elements are rendered from, or you even pass a Page object.
15
+ # :from_cell => nil # The Cell object from which the elements are rendered from.
16
+ # :count => nil # The amount of elements to be rendered (begins with first element found)
17
17
  # :fallback => { # You can use the fallback option as an override. So you can take elements from a glo´bal laout page and only if the user adds an element on current page the local one gets rendered.
18
18
  # :for => 'ELEMENT_NAME', # The name of the element the fallback is for
19
19
  # :with => 'ELEMENT_NAME', # (OPTIONAL) the name of element to fallback with
@@ -30,7 +30,7 @@ module Alchemy
30
30
  default_options = {
31
31
  :except => [],
32
32
  :only => [],
33
- :from_page => "",
33
+ :from_page => @page,
34
34
  :from_cell => nil,
35
35
  :count => nil,
36
36
  :offset => nil,
@@ -39,14 +39,10 @@ module Alchemy
39
39
  :fallback => nil
40
40
  }
41
41
  options = default_options.merge(options)
42
- if options[:from_page].blank?
43
- page = @page
42
+ if options[:from_page].class == Page
43
+ page = options[:from_page]
44
44
  else
45
- if options[:from_page].class == Page
46
- page = options[:from_page]
47
- else
48
- page = Page.where(:page_layout => options[:from_page]).with_language(session[:language_id]).all
49
- end
45
+ page = Page.where(:page_layout => options[:from_page]).with_language(session[:language_id]).all
50
46
  end
51
47
  if page.blank?
52
48
  warning('Page is nil')
@@ -110,9 +110,9 @@ module Alchemy
110
110
  def render_essence(content, part = :view, options = {}, html_options = {})
111
111
  options = {:for_view => {}, :for_editor => {}}.update(options)
112
112
  if content.nil?
113
- return part == :view ? "" : warning('Content is nil', _t("content_not_found"))
113
+ return part == :view ? "" : warning('Content is nil', _t(:content_not_found))
114
114
  elsif content.essence.nil?
115
- return part == :view ? "" : warning('Essence is nil', _t("content_essence_not_found"))
115
+ return part == :view ? "" : warning('Essence is nil', _t(:content_essence_not_found))
116
116
  end
117
117
  render(
118
118
  :partial => "alchemy/essences/#{content.essence_partial_name}_#{part.to_s}",
@@ -131,57 +131,45 @@ module Alchemy
131
131
  # :submenu => false # Do you want a nested <ul> <li> structure for the deeper levels of your navigation, or not? Used to display the subnavigation within the mainnaviagtion. E.g. for dropdown menues.
132
132
  # :all_sub_menues => false # Renders the whole page tree.
133
133
  # :from_page => @root_page # Do you want to render a navigation from a different page then the current page? Then pass an Page instance or a Alchemy::PageLayout name as string.
134
- # :spacer => "" # Yeah even a spacer for the entries can be passed. Simple string, or even a complex html structure. E.g: "<span class='spacer'>|</spacer>". Only your imagination is the limit. And the W3C of course :)
135
- # :navigation_partial => "navigation/renderer" # Pass a different partial to be taken for the navigation rendering. CAUTION: Only for the advanced Alchemy webdevelopers. The standard partial takes care of nearly everything. But maybe you are an adventures one ^_^
134
+ # :spacer => nil # A spacer for the entries can be passed. Simple string, or even a complex html structure. E.g: "<span class='spacer'>|</spacer>".
135
+ # :navigation_partial => "navigation/renderer" # Pass a different partial to be taken for the navigation rendering.
136
136
  # :navigation_link_partial => "navigation/link" # Alchemy places an <a> html link in <li> tags. The tag automatically has an active css class if necessary. So styling is everything. But maybe you don't want this. So feel free to make you own partial and pass the filename here.
137
137
  # :show_nonactive => false # Commonly Alchemy only displays the submenu of the active page (if :submenu => true). If you want to display all child pages then pass true (together with :submenu => true of course). E.g. for the popular css-driven dropdownmenues these days.
138
138
  # :show_title => true # For our beloved SEOs :). Appends a title attribute to all links and places the page.title content into it.
139
- # :restricted_only => nil # Render only restricted pages.
139
+ # :restricted_only => false # Render only restricted pages. I.E for members only navigations.
140
140
  # :show_title => true # Show a title on navigation links. Title attribute from page.
141
141
  # :reverse => false # Reverse the navigation
142
142
  # :reverse_children => false # Reverse the nested children
143
+ # :deepness => nil # Show only pages up to this depth.
143
144
  #
144
145
  # === Passing HTML classes and ids to the renderer
145
146
  #
146
- # A second hash will be passed as html_options to the navigation renderer partial.
147
+ # A second hash can be passed as html_options to the navigation renderer partial.
147
148
  #
148
149
  # ==== Example:
149
150
  #
150
151
  # <%= render_navigation({from_page => 'subnavi'}, {:class => 'navigation', :id => 'subnavigation'}) %>
151
152
  #
152
153
  def render_navigation(options = {}, html_options = {})
153
- default_options = {
154
+ options = {
154
155
  :submenu => false,
155
156
  :all_sub_menues => false,
156
157
  :from_page => @root_page || Page.language_root_for(session[:language_id]),
157
- :spacer => "",
158
+ :spacer => nil,
158
159
  :navigation_partial => "alchemy/navigation/renderer",
159
160
  :navigation_link_partial => "alchemy/navigation/link",
160
161
  :show_nonactive => false,
161
- :restricted_only => nil,
162
+ :restricted_only => false,
162
163
  :show_title => true,
163
164
  :reverse => false,
164
165
  :reverse_children => false
165
- }
166
- options = default_options.merge(options)
167
- if options[:from_page].is_a?(String)
168
- page = Page.find_by_page_layout_and_language_id(options[:from_page], session[:language_id])
169
- else
170
- page = options[:from_page]
166
+ }.merge(options)
167
+ page = page_or_find(options[:from_page])
168
+ pages = page.children.visible.with_permissions_to(:show, :context => :alchemy_pages)
169
+ pages = pages.restricted if options.delete(:restricted_only)
170
+ if depth = options[:deepness]
171
+ pages = pages.where("#{Page.table_name}.depth <= #{depth}")
171
172
  end
172
- if page.blank?
173
- warning("No Page found for #{options[:from_page]}")
174
- return ""
175
- end
176
- conditions = {
177
- :parent_id => page.id,
178
- :restricted => options[:restricted_only] || false,
179
- :visible => true
180
- }
181
- if options[:restricted_only].nil?
182
- conditions.delete(:restricted)
183
- end
184
- pages = Page.where(conditions).order("lft ASC")
185
173
  if options[:reverse]
186
174
  pages.reverse!
187
175
  end
@@ -240,60 +228,34 @@ module Alchemy
240
228
  #
241
229
  # :seperator => %(<span class="seperator">></span>) # Maybe you don't want this seperator. Pass another one.
242
230
  # :page => @page # Pass a different Page instead of the default (@page).
243
- # :without => nil # Pass Pageobject or array of Pages that must not be displayed.
244
- # :public_only => false # Pass boolean for displaying published pages only.
245
- # :visible_only => true # Pass boolean for displaying (in navigation) visible pages only.
231
+ # :without => nil # Pass Page object or array of Pages that must not be displayed.
246
232
  # :restricted_only => false # Pass boolean for displaying restricted pages only.
247
- # :reverse => false # Pass boolean for displaying reversed breadcrumb.
233
+ # :reverse => false # Pass boolean for displaying breadcrumb in reversed reversed.
248
234
  #
249
235
  def render_breadcrumb(options={})
250
- default_options = {
236
+ options = {
251
237
  :seperator => %(<span class="seperator">&gt;</span>),
252
238
  :page => @page,
253
- :without => nil,
254
- :public_only => true,
255
- :visible_only => true,
256
239
  :restricted_only => false,
257
240
  :reverse => false,
258
241
  :link_active_page => false
259
- }
260
- options = default_options.merge(options)
261
- pages = breadcrumb(options[:page])
262
- pages.delete(Page.root)
263
- unless options[:without].nil?
264
- unless options[:without].class == Array
265
- pages.delete(options[:without])
242
+ }.merge(options)
243
+ pages = breadcrumb(options[:page]).published.visible.with_permissions_to(:show, :context => :alchemy_pages)
244
+ pages = pages.restricted if options.delete(:restricted_only)
245
+ pages.to_a.reverse! if options[:reverse]
246
+ if options[:without].present?
247
+ if options[:without].class == Array
248
+ pages = pages.to_a - options[:without]
266
249
  else
267
- pages = pages - options[:without]
250
+ pages.to_a.delete(options[:without])
268
251
  end
269
252
  end
270
- if options[:visible_only]
271
- pages.reject! { |p| !p.visible? }
272
- end
273
- if options[:public_only]
274
- pages.reject! { |p| !p.public? }
275
- end
276
- if options[:restricted_only]
277
- pages.reject! { |p| !p.restricted? }
278
- end
279
- if options[:reverse]
280
- pages.reverse!
281
- end
282
- bc = []
283
- pages.each do |page|
284
- css_class = page.name == @page.name ? "active" : nil
285
- if page == pages.last
286
- css_class = css_class.blank? ? "last" : [css_class, "last"].join(" ")
287
- elsif page == pages.first
288
- css_class = css_class.blank? ? "first" : [css_class, "first"].join(" ")
289
- end
290
- if !options[:link_active_page] && page.name == @page.name
291
- bc << content_tag(:span, h(page.name), :class => css_class)
292
- else
293
- bc << link_to(h(page.name), show_alchemy_page_path(page), :class => css_class, :title => page.title)
294
- end
295
- end
296
- bc.join(options[:seperator]).html_safe
253
+ render(
254
+ partial: 'alchemy/breadcrumb/page',
255
+ collection: pages,
256
+ spacer_template: 'alchemy/breadcrumb/spacer',
257
+ locals: {pages: pages, options: options}
258
+ )
297
259
  end
298
260
 
299
261
  # Returns current page title
@@ -77,11 +77,19 @@ module Alchemy
77
77
  # Returns the correct params-hash for passing to show_page_path
78
78
  def show_page_path_params(page, optional_params={})
79
79
  raise ArgumentError, 'Page is nil' if page.nil?
80
- url_params = {:level1 => nil, :level2 => nil, :level3 => nil, :urlname => page.urlname}
81
- url_params.update(optional_params)
82
- url_params.update(params_for_nested_url(page)) if configuration(:url_nesting)
80
+ url_params = {:urlname => page.urlname}.update(optional_params)
83
81
  multi_language? ? url_params.update(:lang => page.language_code) : url_params
84
82
  end
85
83
 
84
+ # Returns the path for downloading an alchemy attachment
85
+ def download_alchemy_attachment_path(attachment)
86
+ alchemy.download_attachment_path(attachment, attachment.urlname)
87
+ end
88
+
89
+ # Returns the url for downloading an alchemy attachment
90
+ def download_alchemy_attachment_url(attachment)
91
+ alchemy.download_attachment_url(attachment, attachment.urlname)
92
+ end
93
+
86
94
  end
87
95
  end
@@ -1,33 +1,52 @@
1
1
  module Alchemy
2
2
  class Attachment < ActiveRecord::Base
3
+ include Filetypes
4
+ include NameConversions
5
+
6
+ acts_as_taggable
7
+ file_accessor :file
8
+ stampable :stamper_class_name => 'Alchemy::User'
9
+
10
+ attr_accessible :file, :name, :file_name, :tag_list
3
11
 
4
12
  has_many :essence_files, :class_name => 'Alchemy::EssenceFile', :foreign_key => 'attachment_id'
5
13
  has_many :contents, :through => :essence_files
6
14
  has_many :elements, :through => :contents
7
15
  has_many :pages, :through => :elements
8
16
 
9
- attr_accessible :uploaded_data, :name, :filename, :tag_list
17
+ validates_presence_of :file
18
+ validates_format_of :file_name, :with => /^[A-Za-z0-9\.\-_]+$/, :on => :update
19
+ validates_size_of :file, :maximum => Config.get(:uploader)['file_size_limit'].megabytes
20
+ validates_property(
21
+ :format,
22
+ :of => :file,
23
+ :in => Config.get(:uploader)['allowed_filetypes']['attachments'],
24
+ :case_sensitive => false,
25
+ :message => I18n.t("not a valid file"),
26
+ :unless => proc { Config.get(:uploader)['allowed_filetypes']['attachments'].include?('*') }
27
+ )
28
+
29
+ before_create do
30
+ write_attribute(:name, convert_to_humanized_name(self.file_name, self.file.ext))
31
+ write_attribute(:file_name, sanitized_filename)
32
+ end
10
33
 
11
- stampable(:stamper_class_name => 'Alchemy::User')
34
+ # Class methods
12
35
 
13
- acts_as_taggable
14
- has_attachment(
15
- :storage => :file_system,
16
- :file_system_path => 'uploads/attachments',
17
- :size => 0.kilobytes..1000.megabytes
18
- )
19
- validates_as_attachment
36
+ class << self
37
+
38
+ def find_paginated(params, per_page, order)
39
+ attachments = Attachment.arel_table
40
+ cond = attachments[:name].matches("%#{params[:query]}%").or(attachments[:file_name].matches("%#{params[:query]}%"))
41
+ self.where(cond).page(params[:page] || 1).per(per_page).order(order)
42
+ end
20
43
 
21
- def self.find_paginated(params, per_page)
22
- attachments = Attachment.arel_table
23
- cond = attachments[:name].matches("%#{params[:query]}%").or(attachments[:filename].matches("%#{params[:query]}%"))
24
- self.where(cond).page(params[:page] || 1).per(per_page).order(:name)
25
44
  end
26
45
 
46
+ # Instance methods
47
+
27
48
  def urlname
28
- parts = filename.split('.')
29
- sfx = parts.pop
30
- "#{parts.join('-')}.#{sfx}"
49
+ read_attribute :file_name
31
50
  end
32
51
 
33
52
  # Checks if the attachment is restricted, because it is attached on restricted pages only
@@ -36,41 +55,50 @@ module Alchemy
36
55
  end
37
56
 
38
57
  def extension
39
- filename.split(".").last
58
+ file_name.split(".").last
40
59
  end
41
60
  alias_method :suffix, :extension
42
61
 
62
+ # Returns a css class name for kind of file
63
+ #
43
64
  def icon_css_class
44
- case content_type
45
- when "application/x-flash-video" then "video"
46
- when "video/x-flv" then "video"
47
- when "video/mp4" then "video"
48
- when "video/mpeg" then "video"
49
- when "video/quicktime" then "video"
50
- when "video/x-msvideo" then "video"
51
- when "video/x-ms-wmv" then "video"
52
- when "application/zip" then "archive"
53
- when "application/x-rar" then "archive"
54
- when "audio/mpeg" then "audio"
55
- when "audio/mp4" then "audio"
56
- when "audio/wav" then "audio"
57
- when "audio/x-wav" then "audio"
58
- when "application/x-shockwave-flash" then "flash"
59
- when "image/gif" then "image"
60
- when "image/jpeg" then "image"
61
- when "image/png" then "image"
62
- when "image/tiff" then "image"
63
- when "image/x-psd" then "psd"
64
- when "text/plain" then "text"
65
- when "application/rtf" then "rtf"
66
- when "application/pdf" then "pdf"
67
- when "application/msword" then "word"
68
- when "application/vnd.ms-excel" then "excel"
69
- when "text/x-vcard" then "vcard"
70
- when "application/vcard" then "vcard"
71
- else "file"
65
+ case file_mime_type
66
+ when *ARCHIVE_FILE_TYPES
67
+ then "archive"
68
+ when *AUDIO_FILE_TYPES
69
+ then "audio"
70
+ when *IMAGE_FILE_TYPES
71
+ then "image"
72
+ when *VIDEO_FILE_TYPES
73
+ then "video"
74
+ when "application/x-shockwave-flash"
75
+ then "flash"
76
+ when "image/x-psd"
77
+ then "psd"
78
+ when "text/plain"
79
+ then "text"
80
+ when "application/rtf"
81
+ then "rtf"
82
+ when "application/pdf"
83
+ then "pdf"
84
+ when "application/msword"
85
+ then "word"
86
+ when "application/vnd.ms-excel"
87
+ then "excel"
88
+ when *VCARD_FILE_TYPES
89
+ then "vcard"
90
+ else "file"
72
91
  end
73
92
  end
74
93
 
94
+ private
95
+
96
+ def sanitized_filename
97
+ parts = self.file_name.split('.')
98
+ sfx = parts.pop
99
+ name = convert_to_urlname(parts.join('-'))
100
+ "#{name}.#{sfx}"
101
+ end
102
+
75
103
  end
76
104
  end