gluttonberg-core 2.6.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (613) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +29 -3
  3. data/Rakefile +32 -15
  4. data/app/assets/images/chosen-sprite-2x.png +0 -0
  5. data/app/assets/images/chosen-sprite.png +0 -0
  6. data/app/assets/images/{library/gb_sort_by_asc.png → gb_sort_by_asc.png} +0 -0
  7. data/app/assets/images/{library/gb_sort_by_desc.png → gb_sort_by_desc.png} +0 -0
  8. data/app/assets/javascripts/chosen-jquery-min.js +2 -0
  9. data/app/assets/javascripts/gb_360player.js +676 -0
  10. data/app/assets/javascripts/gb_application.js +708 -463
  11. data/app/assets/javascripts/gb_html5.js +9 -0
  12. data/app/assets/javascripts/gb_jeditable.js +356 -356
  13. data/app/assets/javascripts/gb_jquery-nestable.js +490 -0
  14. data/app/assets/javascripts/gb_utils.js +1808 -0
  15. data/app/assets/javascripts/gluttonberg.js +26 -0
  16. data/app/assets/javascripts/jcrop/css/gb_jquery-Jcrop.css +163 -31
  17. data/app/assets/javascripts/jcrop/js/jquery-Jcrop-min.js +19 -243
  18. data/app/assets/javascripts/jquery-1-10-1.js +6 -0
  19. data/app/assets/javascripts/jquery-ui-1-10-3.custom-min.js +6 -0
  20. data/app/assets/javascripts/jquery-validate.js +652 -718
  21. data/app/assets/javascripts/rails.js +372 -106
  22. data/app/assets/javascripts/redactormin.js +7348 -0
  23. data/app/assets/stylesheets/chosen.css +430 -0
  24. data/app/assets/stylesheets/gb_360player.css +2 -10
  25. data/app/assets/stylesheets/gb_admin-override.sass +466 -22
  26. data/app/assets/stylesheets/gb_bootstrap.css +7 -1
  27. data/app/assets/stylesheets/gluttonberg.css +17 -0
  28. data/app/assets/stylesheets/redactor.css +864 -0
  29. data/app/assets/stylesheets/user-styles.sass +0 -3
  30. data/app/controllers/gluttonberg/admin/asset_library/assets_ajax_controller.rb +65 -0
  31. data/app/controllers/gluttonberg/admin/asset_library/assets_bulk_controller.rb +47 -0
  32. data/app/controllers/gluttonberg/admin/asset_library/assets_controller.rb +43 -266
  33. data/app/controllers/gluttonberg/admin/asset_library/base_controller.rb +29 -0
  34. data/app/controllers/gluttonberg/admin/asset_library/collections_controller.rb +11 -37
  35. data/app/controllers/gluttonberg/admin/base_controller.rb +117 -178
  36. data/app/controllers/gluttonberg/admin/content/auto_save_controller.rb +63 -0
  37. data/app/controllers/gluttonberg/admin/content/flag_controller.rb +6 -6
  38. data/app/controllers/gluttonberg/admin/content/galleries_controller.rb +29 -37
  39. data/app/controllers/gluttonberg/admin/content/page_localizations_controller.rb +82 -49
  40. data/app/controllers/gluttonberg/admin/content/pages_controller.rb +59 -32
  41. data/app/controllers/gluttonberg/admin/main_controller.rb +77 -7
  42. data/app/controllers/gluttonberg/admin/membership/base_controller.rb +2 -1
  43. data/app/controllers/gluttonberg/admin/membership/groups_controller.rb +27 -33
  44. data/app/controllers/gluttonberg/admin/membership/main_controller.rb +3 -2
  45. data/app/controllers/gluttonberg/admin/membership/members_controller.rb +37 -42
  46. data/app/controllers/gluttonberg/admin/password_resets_controller.rb +16 -28
  47. data/app/controllers/gluttonberg/admin/settings/configurations_controller.rb +101 -0
  48. data/app/controllers/gluttonberg/admin/settings/embeds_controller.rb +79 -0
  49. data/app/controllers/gluttonberg/admin/settings/locales_controller.rb +22 -28
  50. data/app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb +31 -36
  51. data/app/controllers/gluttonberg/admin/settings/users_controller.rb +45 -40
  52. data/app/controllers/gluttonberg/base_controller.rb +95 -0
  53. data/app/controllers/gluttonberg/public/base_controller.rb +104 -157
  54. data/app/controllers/gluttonberg/public/flag_controller.rb +2 -7
  55. data/app/controllers/gluttonberg/public/gallery_controller.rb +1 -0
  56. data/app/controllers/gluttonberg/public/member_password_resets_controller.rb +5 -17
  57. data/app/controllers/gluttonberg/public/members_controller.rb +5 -15
  58. data/app/controllers/gluttonberg/public/pages_controller.rb +25 -14
  59. data/app/controllers/gluttonberg/public/public_assets_controller.rb +4 -2
  60. data/app/helpers/gluttonberg/admin.rb +86 -368
  61. data/app/helpers/gluttonberg/admin/assets.rb +84 -0
  62. data/app/helpers/gluttonberg/admin/form.rb +159 -0
  63. data/app/helpers/gluttonberg/admin/messages.rb +32 -0
  64. data/app/helpers/gluttonberg/admin/versioning.rb +196 -0
  65. data/app/helpers/gluttonberg/application_helper.rb +34 -7
  66. data/app/helpers/gluttonberg/asset_library.rb +29 -254
  67. data/app/helpers/gluttonberg/content_helpers.rb +17 -69
  68. data/app/helpers/gluttonberg/deprecated.rb +24 -0
  69. data/app/helpers/gluttonberg/public.rb +51 -244
  70. data/app/helpers/gluttonberg/public/assets.rb +31 -0
  71. data/app/helpers/gluttonberg/public/cms_stylesheets.rb +35 -0
  72. data/app/helpers/gluttonberg/public/html_truncate.rb +74 -0
  73. data/app/helpers/gluttonberg/public/meta_tags.rb +27 -0
  74. data/app/helpers/gluttonberg/public/nav_tree.rb +99 -0
  75. data/app/helpers/gluttonberg/public/page_info.rb +168 -0
  76. data/app/mailer/gluttonberg/base_notifier.rb +25 -0
  77. data/app/mailer/member_notifier.rb +8 -20
  78. data/app/mailer/notifier.rb +14 -39
  79. data/app/models/ability.rb +48 -34
  80. data/app/models/flag.rb +7 -7
  81. data/app/models/gluttonberg/asset.rb +115 -166
  82. data/app/models/gluttonberg/asset_bulk_import.rb +70 -0
  83. data/app/models/gluttonberg/asset_category.rb +75 -29
  84. data/app/models/gluttonberg/asset_collection.rb +65 -12
  85. data/app/models/gluttonberg/asset_mime_type.rb +5 -0
  86. data/app/models/gluttonberg/asset_thumbnail.rb +6 -1
  87. data/app/models/gluttonberg/asset_type.rb +49 -38
  88. data/app/models/gluttonberg/audio_asset_attribute.rb +7 -3
  89. data/app/models/gluttonberg/authorization.rb +10 -0
  90. data/app/models/gluttonberg/auto_save.rb +32 -0
  91. data/app/models/gluttonberg/collapsed_page.rb +13 -0
  92. data/app/models/gluttonberg/embed.rb +13 -0
  93. data/app/models/gluttonberg/feed.rb +14 -5
  94. data/app/models/gluttonberg/gallery.rb +35 -9
  95. data/app/models/gluttonberg/gallery_image.rb +9 -2
  96. data/app/models/gluttonberg/group.rb +18 -2
  97. data/app/models/gluttonberg/html_content.rb +5 -1
  98. data/app/models/gluttonberg/image_content.rb +5 -1
  99. data/app/models/gluttonberg/locale.rb +28 -9
  100. data/app/models/gluttonberg/member.rb +48 -197
  101. data/app/models/gluttonberg/page.rb +78 -288
  102. data/app/models/gluttonberg/page_localization.rb +63 -66
  103. data/app/models/gluttonberg/plain_text_content.rb +6 -0
  104. data/app/models/gluttonberg/repeater.rb +30 -0
  105. data/app/models/gluttonberg/search.rb +96 -72
  106. data/app/models/gluttonberg/select_content.rb +12 -0
  107. data/app/models/gluttonberg/setting.rb +79 -29
  108. data/app/models/gluttonberg/sitemap.rb +1 -0
  109. data/app/models/gluttonberg/stylesheet.rb +12 -6
  110. data/app/models/gluttonberg/textarea_content.rb +14 -0
  111. data/app/models/gluttonberg/version.rb +9 -0
  112. data/app/models/user.rb +137 -13
  113. data/app/observers/gluttonberg/locale_observer.rb +33 -22
  114. data/app/observers/gluttonberg/page_localization_observer.rb +22 -12
  115. data/app/observers/gluttonberg/page_observer.rb +50 -35
  116. data/app/views/{gluttonberg/public/exceptions → exceptions}/access_denied.html.haml +0 -0
  117. data/app/views/{gluttonberg/public/exceptions → exceptions}/not_found.html.haml +0 -0
  118. data/app/views/gluttonberg/admin/asset_library/assets/_browser_root.html.haml +17 -12
  119. data/app/views/gluttonberg/admin/asset_library/assets/_form.html.haml +5 -7
  120. data/app/views/gluttonberg/admin/asset_library/assets/browser.html.haml +5 -5
  121. data/app/views/gluttonberg/admin/asset_library/assets/show.html.haml +13 -7
  122. data/app/views/gluttonberg/admin/asset_library/assets/show.json.rabl +3 -0
  123. data/app/views/gluttonberg/admin/asset_library/{assets → assets_ajax}/browser_collection.json.haml +0 -0
  124. data/app/views/gluttonberg/admin/asset_library/{assets → assets_bulk}/add_assets_in_bulk.html.haml +6 -20
  125. data/app/views/gluttonberg/admin/asset_library/{assets → assets_bulk}/create_assets_in_bulk.html.haml +0 -0
  126. data/app/views/gluttonberg/admin/asset_library/collections/_form.html.haml +8 -5
  127. data/app/views/gluttonberg/admin/asset_library/shared/_asset_browser.html.haml +34 -0
  128. data/app/views/gluttonberg/admin/asset_library/shared/_asset_panels.html.haml +15 -11
  129. data/app/views/gluttonberg/admin/content/editors/_html_content.html.haml +2 -2
  130. data/app/views/gluttonberg/admin/content/editors/_select_content.html.haml +7 -0
  131. data/app/views/gluttonberg/admin/content/editors/_textarea_content.html.haml +6 -0
  132. data/app/views/gluttonberg/admin/content/flag/index.html.haml +48 -39
  133. data/app/views/gluttonberg/admin/content/galleries/_form.html.haml +46 -9
  134. data/app/views/gluttonberg/admin/content/galleries/_image_repeater.html.haml +30 -0
  135. data/app/views/gluttonberg/admin/content/galleries/edit.html.haml +1 -12
  136. data/app/views/gluttonberg/admin/content/galleries/index.html.haml +18 -9
  137. data/app/views/gluttonberg/admin/content/galleries/new.html.haml +1 -1
  138. data/app/views/gluttonberg/admin/content/main/_sidebar.html.haml +28 -16
  139. data/app/views/gluttonberg/admin/content/page_localizations/_form.html.haml +11 -20
  140. data/app/views/gluttonberg/admin/content/page_localizations/edit.html.haml +7 -0
  141. data/app/views/gluttonberg/admin/content/pages/_form.html.haml +11 -4
  142. data/app/views/gluttonberg/admin/content/pages/_page_settings.html.haml +4 -7
  143. data/app/views/gluttonberg/admin/content/pages/_row.html.haml +38 -30
  144. data/app/views/gluttonberg/admin/content/pages/index.html.haml +23 -15
  145. data/app/views/gluttonberg/admin/content/pages/pages_list_for_tinymce.html.haml +14 -3
  146. data/app/views/gluttonberg/admin/content/pages/show.html.haml +1 -1
  147. data/app/views/gluttonberg/admin/main/index.html.haml +13 -12
  148. data/app/views/gluttonberg/admin/main/waiting_for_approval.html.haml +33 -0
  149. data/app/views/gluttonberg/admin/membership/groups/index.html.haml +5 -5
  150. data/app/views/gluttonberg/admin/membership/members/_form.html.haml +3 -1
  151. data/app/views/gluttonberg/admin/membership/members/edit.html.haml +1 -0
  152. data/app/views/gluttonberg/admin/membership/members/index.html.haml +1 -1
  153. data/app/views/gluttonberg/admin/password_resets/edit.html.haml +36 -16
  154. data/app/views/gluttonberg/admin/password_resets/new.html.haml +19 -11
  155. data/app/views/gluttonberg/admin/settings/configurations/_form.html.haml +28 -0
  156. data/app/views/gluttonberg/admin/settings/configurations/_settings_table.html.haml +42 -0
  157. data/app/views/gluttonberg/admin/settings/{generic_settings → configurations}/_value_tag.html.haml +0 -0
  158. data/app/views/gluttonberg/admin/settings/configurations/edit.html.haml +4 -0
  159. data/app/views/gluttonberg/admin/settings/configurations/index.html.haml +31 -0
  160. data/app/views/gluttonberg/admin/settings/{generic_settings → configurations}/new.html.haml +2 -2
  161. data/app/views/gluttonberg/admin/settings/embeds/_form.html.haml +19 -0
  162. data/app/views/gluttonberg/admin/settings/embeds/edit.html.haml +12 -0
  163. data/app/views/gluttonberg/admin/settings/embeds/index.html.haml +36 -0
  164. data/app/views/gluttonberg/admin/settings/embeds/list_for_redactor.html.haml +29 -0
  165. data/app/views/gluttonberg/admin/settings/embeds/new.html.haml +12 -0
  166. data/app/views/gluttonberg/admin/settings/locales/edit.html.haml +9 -1
  167. data/app/views/gluttonberg/admin/settings/locales/index.html.haml +2 -1
  168. data/app/views/gluttonberg/admin/settings/locales/new.html.haml +10 -1
  169. data/app/views/gluttonberg/admin/settings/main/_sidebar.html.haml +9 -7
  170. data/app/views/gluttonberg/admin/settings/stylesheets/_form.html.haml +11 -9
  171. data/app/views/gluttonberg/admin/settings/stylesheets/edit.html.haml +11 -2
  172. data/app/views/gluttonberg/admin/settings/stylesheets/index.html.haml +45 -36
  173. data/app/views/gluttonberg/admin/settings/stylesheets/new.html.haml +11 -2
  174. data/app/views/gluttonberg/admin/settings/users/_form.html.haml +29 -18
  175. data/app/views/gluttonberg/admin/settings/users/index.html.haml +1 -1
  176. data/app/views/gluttonberg/admin/shared/_asset_panel.html.haml +19 -4
  177. data/app/views/gluttonberg/admin/shared/_auto_save_version.html.haml +12 -0
  178. data/app/views/gluttonberg/admin/shared/_datetime_field.html.haml +19 -0
  179. data/app/views/gluttonberg/admin/shared/_previous_version_warning.html.haml +5 -0
  180. data/app/views/gluttonberg/admin/shared/_version_alerts.html.haml +34 -0
  181. data/app/views/gluttonberg/admin/shared/_version_dashboard_notifications.html.haml +11 -0
  182. data/app/views/gluttonberg/admin/shared/_version_listing.html.haml +23 -0
  183. data/app/views/gluttonberg/admin/shared/delete.html.haml +21 -48
  184. data/app/views/gluttonberg/admin/shared/generic.html.haml +20 -19
  185. data/app/views/gluttonberg/admin/user_sessions/new.html.haml +14 -9
  186. data/app/views/gluttonberg/public/member_password_resets/edit.html.haml +2 -0
  187. data/app/views/gluttonberg/public/member_password_resets/new.html.haml +3 -0
  188. data/app/views/gluttonberg/public/members/_form.html.haml +3 -0
  189. data/app/views/gluttonberg/public/members/edit.html.haml +7 -9
  190. data/app/views/gluttonberg/public/members/show.html.haml +1 -3
  191. data/app/views/gluttonberg/public/pages/restrict_site_access.html.haml +3 -4
  192. data/app/views/gluttonberg/public/shared/_gallery_images_lis.html.haml +9 -0
  193. data/app/views/layouts/_flash_messages.html.haml +5 -3
  194. data/app/views/layouts/bare.html.haml +8 -17
  195. data/app/views/layouts/gluttonberg.html.haml +37 -44
  196. data/app/views/notifier/version_declined.html.haml +21 -0
  197. data/config/locales/en_au.yml +1 -1
  198. data/config/locales/en_gb.yml +2 -1
  199. data/config/routes.rb +70 -85
  200. data/db/migrate/20130801050257_create_repeater.rb +14 -0
  201. data/lib/audio_job.rb +11 -9
  202. data/lib/engine.rb +115 -72
  203. data/lib/generators/gluttonberg/resource/resource_generator.rb +51 -41
  204. data/lib/generators/gluttonberg/resource/templates/admin_controller.rb +16 -11
  205. data/lib/generators/gluttonberg/resource/templates/backend_view_edit.html.haml +7 -2
  206. data/lib/generators/gluttonberg/resource/templates/backend_view_form.html.haml +3 -14
  207. data/lib/generators/gluttonberg/resource/templates/backend_view_import.html.haml +10 -7
  208. data/lib/generators/gluttonberg/resource/templates/backend_view_index.html.haml +6 -5
  209. data/lib/generators/gluttonberg/resource/templates/backend_view_show.html.haml +2 -2
  210. data/lib/generators/gluttonberg/resource/templates/migration.rb +12 -1
  211. data/lib/generators/gluttonberg/resource/templates/model.rb +18 -1
  212. data/lib/generators/gluttonberg/resource/templates/public_view_index.html.haml +27 -10
  213. data/lib/generators/gluttonberg/resource/templates/public_view_show.html.haml +10 -4
  214. data/lib/gluttonberg.rb +68 -37
  215. data/lib/gluttonberg/can_flag.rb +64 -76
  216. data/lib/gluttonberg/components.rb +47 -24
  217. data/lib/gluttonberg/content.rb +15 -0
  218. data/lib/gluttonberg/content/block.rb +99 -85
  219. data/lib/gluttonberg/content/block_localization.rb +11 -8
  220. data/lib/gluttonberg/content/clean_html.rb +12 -15
  221. data/lib/gluttonberg/content/default_template_file.rb +44 -0
  222. data/lib/gluttonberg/content/despamilator/filter/naughty_words.rb +4 -2
  223. data/lib/gluttonberg/content/home_page_info.rb +39 -0
  224. data/lib/gluttonberg/content/import_export_csv.rb +243 -130
  225. data/lib/gluttonberg/content/localization.rb +137 -148
  226. data/lib/gluttonberg/content/page_children.rb +36 -0
  227. data/lib/gluttonberg/content/page_components.rb +23 -0
  228. data/lib/gluttonberg/content/page_description_info.rb +55 -0
  229. data/lib/gluttonberg/content/page_duplicate.rb +68 -0
  230. data/lib/gluttonberg/content/page_finder.rb +63 -0
  231. data/lib/gluttonberg/content/page_localization_slug.rb +89 -0
  232. data/lib/gluttonberg/content/page_repairer.rb +117 -0
  233. data/lib/gluttonberg/content/publishable.rb +77 -71
  234. data/lib/gluttonberg/content/slug_management.rb +74 -26
  235. data/lib/gluttonberg/content/validations.rb +58 -0
  236. data/lib/gluttonberg/content/versioning.rb +40 -22
  237. data/lib/gluttonberg/drag_tree.rb +0 -1
  238. data/lib/gluttonberg/drag_tree/action_controller.rb +49 -37
  239. data/lib/gluttonberg/drag_tree/action_view.rb +0 -6
  240. data/lib/gluttonberg/drag_tree/active_record.rb +49 -49
  241. data/lib/gluttonberg/extensions.rb +1 -0
  242. data/lib/gluttonberg/extensions/string.rb +20 -0
  243. data/lib/gluttonberg/gb_file.rb +30 -0
  244. data/lib/gluttonberg/helpers/form_builder.rb +91 -38
  245. data/lib/gluttonberg/library.rb +9 -90
  246. data/lib/gluttonberg/library/attachment_mixin.rb +88 -98
  247. data/lib/gluttonberg/library/config/image_sizes.rb +22 -19
  248. data/lib/gluttonberg/library/default_asset_types.rb +104 -0
  249. data/lib/gluttonberg/library/processor/audio.rb +32 -16
  250. data/lib/gluttonberg/library/processor/image.rb +78 -69
  251. data/lib/gluttonberg/library/quick_magick/image.rb +72 -319
  252. data/lib/gluttonberg/library/quick_magick/image/draw.rb +133 -0
  253. data/lib/gluttonberg/library/quick_magick/image/operators_and_settings.rb +78 -0
  254. data/lib/gluttonberg/library/quick_magick/image/serialization.rb +79 -0
  255. data/lib/gluttonberg/library/quick_magick/image_list.rb +0 -1
  256. data/lib/gluttonberg/library/storage/filesystem.rb +45 -46
  257. data/lib/gluttonberg/library/storage/s3.rb +123 -119
  258. data/lib/gluttonberg/membership.rb +9 -0
  259. data/lib/gluttonberg/membership/export.rb +82 -0
  260. data/lib/gluttonberg/membership/import.rb +179 -0
  261. data/lib/gluttonberg/middleware/honeypot.rb +1 -2
  262. data/lib/gluttonberg/middleware/locales.rb +69 -18
  263. data/lib/gluttonberg/middleware/rewriter.rb +57 -16
  264. data/lib/gluttonberg/mixin_manager.rb +19 -0
  265. data/lib/gluttonberg/page_description.rb +82 -112
  266. data/lib/gluttonberg/random_string_generator.rb +31 -0
  267. data/lib/gluttonberg/record_history.rb +5 -7
  268. data/lib/gluttonberg/tasks/asset.rake +19 -8
  269. data/lib/gluttonberg/tasks/gluttonberg.rake +167 -13
  270. data/lib/gluttonberg/templates.rb +1 -3
  271. data/lib/gluttonberg/version.rb +1 -1
  272. data/lib/photo_job.rb +16 -0
  273. data/spec/controllers/auto_save_controller_spec.rb +57 -0
  274. data/spec/controllers/record_history_spec.rb +75 -0
  275. data/spec/dummy/README.rdoc +261 -0
  276. data/spec/dummy/Rakefile +7 -0
  277. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  278. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  279. data/spec/dummy/app/controllers/admin/staff_profiles_controller.rb +56 -0
  280. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  281. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  282. data/spec/dummy/app/models/staff_profile.rb +20 -0
  283. data/spec/dummy/app/models/vendor_mixin.rb +14 -0
  284. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  285. data/spec/dummy/config.ru +4 -0
  286. data/spec/dummy/config/application.rb +18 -0
  287. data/spec/dummy/config/boot.rb +10 -0
  288. data/spec/dummy/config/database.yml +8 -0
  289. data/spec/dummy/config/environment.rb +5 -0
  290. data/spec/dummy/config/environments/development.rb +37 -0
  291. data/spec/dummy/config/environments/production.rb +67 -0
  292. data/spec/dummy/config/environments/test.rb +37 -0
  293. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  294. data/spec/dummy/config/initializers/gluttonberg_advance_settings.rb +73 -0
  295. data/spec/dummy/config/initializers/gluttonberg_basic_settings.rb +65 -0
  296. data/spec/dummy/config/initializers/gluttonberg_menu_settings.rb +1 -0
  297. data/spec/dummy/config/initializers/inflections.rb +15 -0
  298. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  299. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  300. data/spec/dummy/config/initializers/session_store.rb +8 -0
  301. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  302. data/spec/dummy/config/locales/en.yml +5 -0
  303. data/{lib/generators/gluttonberg/installer/templates → spec/dummy/config}/page_descriptions.rb +103 -65
  304. data/spec/dummy/config/routes.rb +10 -0
  305. data/spec/dummy/db/20130625060411_create_staff_profile.rb +35 -0
  306. data/spec/dummy/db/schema.rb +474 -0
  307. data/spec/dummy/public/404.html +26 -0
  308. data/spec/dummy/public/422.html +26 -0
  309. data/spec/dummy/public/500.html +25 -0
  310. data/spec/dummy/public/favicon.ico +0 -0
  311. data/spec/dummy/script/rails +6 -0
  312. data/spec/dummy/tmp/cache/041/891/setting_library_number_of_recent_assets +0 -0
  313. data/spec/dummy/tmp/cache/08E/741/setting_comment_number_of_emails_allowed +0 -0
  314. data/spec/dummy/tmp/cache/580/D10/setting_title +0 -0
  315. data/spec/dummy/tmp/cache/62E/160/setting_fb_icon +0 -0
  316. data/spec/dummy/tmp/cache/6D6/FB0/setting_keywords +0 -0
  317. data/spec/dummy/tmp/cache/6D8/B60/setting_s3_key_id +0 -0
  318. data/spec/dummy/tmp/cache/6E1/A40/setting_s3_bucket +0 -0
  319. data/spec/dummy/tmp/cache/779/DF0/setting_from_email +0 -0
  320. data/spec/dummy/tmp/cache/7C5/450/setting_title_site1 +0 -0
  321. data/spec/dummy/tmp/cache/7C6/460/setting_title_site2 +0 -0
  322. data/spec/dummy/tmp/cache/802/000/setting_description +0 -0
  323. data/spec/dummy/tmp/cache/836/DD0/setting_backend_logo +0 -0
  324. data/spec/dummy/tmp/cache/862/FA0/setting_audio_assets +1 -0
  325. data/spec/dummy/tmp/cache/867/4E0/setting_video_assets +0 -0
  326. data/spec/dummy/tmp/cache/867/710/setting_enable_WYSIWYG +0 -0
  327. data/spec/dummy/tmp/cache/873/9E0/setting_fb_icon_site1 +0 -0
  328. data/spec/dummy/tmp/cache/874/9F0/setting_fb_icon_site2 +0 -0
  329. data/spec/dummy/tmp/cache/87D/A10/setting_s3_access_key +0 -0
  330. data/spec/dummy/tmp/cache/8AC/280/setting_s3_server_url +0 -0
  331. data/spec/dummy/tmp/cache/91B/730/setting_keywords_site1 +0 -0
  332. data/spec/dummy/tmp/cache/91C/740/setting_keywords_site2 +0 -0
  333. data/spec/dummy/tmp/cache/933/980/setting_auto_save_time +0 -0
  334. data/spec/dummy/tmp/cache/9BE/290/setting_from_email_site1 +0 -0
  335. data/spec/dummy/tmp/cache/9BF/2A0/setting_from_email_site2 +0 -0
  336. data/spec/dummy/tmp/cache/A02/5E0/setting_google_analytics +0 -0
  337. data/spec/dummy/tmp/cache/A47/800/setting_description_site1 +0 -0
  338. data/spec/dummy/tmp/cache/A48/810/setting_description_site2 +0 -0
  339. data/spec/dummy/tmp/cache/A69/B60/setting_comment_blacklist +0 -0
  340. data/spec/dummy/tmp/cache/B5C/D40/setting_number_of_revisions +0 -0
  341. data/spec/dummy/tmp/cache/BB3/350/setting_restrict_site_access +0 -0
  342. data/spec/dummy/tmp/cache/BB7/620/setting_comment_notification +0 -0
  343. data/spec/dummy/tmp/cache/BFB/140/setting_comment_email_as_spam +0 -0
  344. data/spec/dummy/tmp/cache/C47/DE0/setting_google_analytics_site1 +0 -0
  345. data/spec/dummy/tmp/cache/C48/DF0/setting_google_analytics_site2 +0 -0
  346. data/spec/dummy/tmp/cache/D3E/E20/setting_number_of_per_page_items +0 -0
  347. data/spec/dummy/tmp/cache/DF8/DB0/setting_restrict_site_access_site1 +0 -0
  348. data/spec/dummy/tmp/cache/DF9/DC0/setting_restrict_site_access_site2 +0 -0
  349. data/spec/dummy/tmp/cache/DFC/200/setting_comment_notification_site1 +0 -0
  350. data/spec/dummy/tmp/cache/DFD/210/setting_comment_notification_site2 +0 -0
  351. data/spec/dummy/tmp/cache/FD9/200/setting_comment_number_of_urls_allowed +0 -0
  352. data/spec/fixtures/assets/assets_import.zip +0 -0
  353. data/spec/fixtures/assets/audio.mp3 +0 -0
  354. data/spec/fixtures/assets/c3-add-interactive.mov +0 -0
  355. data/spec/fixtures/assets/gb_banner.jpg +0 -0
  356. data/spec/fixtures/assets/gb_logo.png +0 -0
  357. data/spec/fixtures/assets/high_res_photo.jpg +0 -0
  358. data/spec/fixtures/assets/untitled +0 -0
  359. data/spec/fixtures/members.csv +5 -0
  360. data/spec/fixtures/staff_profiles.csv +4 -0
  361. data/spec/helpers/public/assets_spec.rb +73 -0
  362. data/spec/helpers/public/content_helpers_spec.rb +71 -0
  363. data/spec/helpers/public/html_truncate_spec.rb +37 -0
  364. data/spec/helpers/public/meta_tags_spec.rb +29 -0
  365. data/spec/helpers/public/page_info_spec.rb +233 -0
  366. data/spec/helpers/public_spec.rb +114 -0
  367. data/spec/lib/content/import_export_csv_spec.rb +177 -0
  368. data/spec/lib/content/localization_spec.rb +107 -0
  369. data/spec/lib/content/page_finder_spec.rb +71 -0
  370. data/spec/lib/content/page_repairer_spec.rb +151 -0
  371. data/spec/lib/content/publishable_spec.rb +54 -0
  372. data/spec/lib/content/validations_spec.rb +88 -0
  373. data/spec/lib/drag_tree/action_controller_spec.rb +137 -0
  374. data/spec/lib/drag_tree/active_record_spec.rb +86 -0
  375. data/spec/lib/library/s3_rspec.rb +78 -0
  376. data/spec/lib/membership/export_spec.rb +89 -0
  377. data/spec/lib/membership/import_spec.rb +68 -0
  378. data/spec/lib/middleware/locales_spec.rb +192 -0
  379. data/spec/lib/middleware/rewriter_spec.rb +186 -0
  380. data/spec/lib/page_description_spec.rb +68 -0
  381. data/spec/mailers/member_notifier_spec.rb +140 -0
  382. data/spec/mailers/notifier_spec.rb +86 -0
  383. data/spec/models/asset_bulk_import_spec.rb +43 -0
  384. data/spec/models/asset_category_spec.rb +77 -0
  385. data/spec/models/asset_collection_spec.rb +72 -0
  386. data/spec/models/asset_spec.rb +278 -0
  387. data/spec/models/asset_type_spec.rb +109 -0
  388. data/spec/models/member_spec.rb +128 -0
  389. data/spec/models/page_localization_spec.rb +81 -0
  390. data/spec/models/page_spec.rb +221 -0
  391. data/spec/models/setting_spec.rb +49 -0
  392. data/spec/models/user_spec.rb +385 -0
  393. data/spec/observers/locale_observer_spec.rb +79 -0
  394. data/spec/observers/page_localization_observer_spec.rb +87 -0
  395. data/spec/observers/page_observer_spec.rb +130 -0
  396. data/spec/spec_helper.rb +90 -0
  397. metadata +508 -331
  398. data/app/assets/images/gb_360-button-pause-light.gif +0 -0
  399. data/app/assets/images/gb_360-button-pause-light.png +0 -0
  400. data/app/assets/images/gb_360-button-pause.gif +0 -0
  401. data/app/assets/images/gb_360-button-pause.png +0 -0
  402. data/app/assets/images/gb_360-button-play-light.gif +0 -0
  403. data/app/assets/images/gb_360-button-play-light.png +0 -0
  404. data/app/assets/images/gb_360-button-play.gif +0 -0
  405. data/app/assets/images/gb_360-button-play.png +0 -0
  406. data/app/assets/images/gb_360-button-vis-pause-light.gif +0 -0
  407. data/app/assets/images/gb_360-button-vis-pause-light.png +0 -0
  408. data/app/assets/images/gb_360-button-vis-pause.gif +0 -0
  409. data/app/assets/images/gb_360-button-vis-pause.png +0 -0
  410. data/app/assets/images/gb_360-button-vis-play-light.gif +0 -0
  411. data/app/assets/images/gb_360-button-vis-play-light.png +0 -0
  412. data/app/assets/images/gb_360-button-vis-play.gif +0 -0
  413. data/app/assets/images/gb_360-button-vis-play.png +0 -0
  414. data/app/assets/images/gb_button_bkg_grey.gif +0 -0
  415. data/app/assets/images/gb_icon_content_2.png +0 -0
  416. data/app/assets/images/gb_icon_dash.png +0 -0
  417. data/app/assets/images/gb_icon_library_2.png +0 -0
  418. data/app/assets/images/gb_page_content_fillin.gif +0 -0
  419. data/app/assets/images/gb_spinner_for_dialouge.gif +0 -0
  420. data/app/assets/images/gb_sub_nav_back_bkg.gif +0 -0
  421. data/app/assets/images/gb_subnav_bkg.gif +0 -0
  422. data/app/assets/images/gb_table_head_bkg.gif +0 -0
  423. data/app/assets/images/gb_wrapper_bkg.png +0 -0
  424. data/app/assets/images/gb_wysiwyg.png +0 -0
  425. data/app/assets/images/help/gb_help.jpg +0 -0
  426. data/app/assets/images/icons/gb_collapsed.png +0 -0
  427. data/app/assets/images/icons/gb_expanded.png +0 -0
  428. data/app/assets/images/library/gb_back.gif +0 -0
  429. data/app/assets/images/library/gb_dialog_overlay.png +0 -0
  430. data/app/assets/images/library/gb_inactive_tab.jpg +0 -0
  431. data/app/assets/images/library/gb_search_icon.gif +0 -0
  432. data/app/assets/images/library/gb_wysiwyg_pic.png +0 -0
  433. data/app/assets/javascripts/gb_ajaxfileupload.js +0 -205
  434. data/app/assets/javascripts/gb_berniecode-animator.js +0 -674
  435. data/app/assets/javascripts/gb_bootstrap-datepicker.js +0 -501
  436. data/app/assets/javascripts/gb_expander.js +0 -81
  437. data/app/assets/javascripts/gb_jquery-dragTree.js +0 -525
  438. data/app/assets/javascripts/gb_jquery-tagarea.js +0 -404
  439. data/app/assets/javascripts/gb_login.js +0 -33
  440. data/app/assets/javascripts/gb_tags.js +0 -177
  441. data/app/assets/javascripts/jquery-1-7-1.js +0 -9267
  442. data/app/assets/javascripts/jquery-dimensions-min.js +0 -12
  443. data/app/assets/javascripts/jquery-ui-1-8-23-custom-min.js +0 -85
  444. data/app/assets/javascripts/tiny_mce/jquery.tinymce.js +0 -1
  445. data/app/assets/javascripts/tiny_mce/langs/en.js +0 -223
  446. data/app/assets/javascripts/tiny_mce/plugins/advhr/css/advhr.css +0 -5
  447. data/app/assets/javascripts/tiny_mce/plugins/advhr/editor_plugin.js +0 -1
  448. data/app/assets/javascripts/tiny_mce/plugins/advhr/js/rule.js +0 -43
  449. data/app/assets/javascripts/tiny_mce/plugins/advhr/langs/en_dlg.js +0 -7
  450. data/app/assets/javascripts/tiny_mce/plugins/advhr/rule.htm +0 -58
  451. data/app/assets/javascripts/tiny_mce/plugins/advlink/css/advlink.css +0 -8
  452. data/app/assets/javascripts/tiny_mce/plugins/advlink/editor_plugin.js +0 -61
  453. data/app/assets/javascripts/tiny_mce/plugins/advlink/js/advlink.js +0 -564
  454. data/app/assets/javascripts/tiny_mce/plugins/advlink/langs/en_dlg.js +0 -54
  455. data/app/assets/javascripts/tiny_mce/plugins/advlink/link.htm +0 -355
  456. data/app/assets/javascripts/tiny_mce/plugins/advlist/editor_plugin.js +0 -1
  457. data/app/assets/javascripts/tiny_mce/plugins/autolink/editor_plugin.js +0 -1
  458. data/app/assets/javascripts/tiny_mce/plugins/fullscreen/editor_plugin.js +0 -1
  459. data/app/assets/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm +0 -109
  460. data/app/assets/javascripts/tiny_mce/plugins/gb_assets/editor_plugin.js +0 -47
  461. data/app/assets/javascripts/tiny_mce/plugins/gb_assets/editor_plugin_src.js +0 -43
  462. data/app/assets/javascripts/tiny_mce/plugins/gb_assets/emotions.htm +0 -41
  463. data/app/assets/javascripts/tiny_mce/plugins/gb_assets/js/emotions.js +0 -22
  464. data/app/assets/javascripts/tiny_mce/plugins/gb_assets/langs/en_dlg.js +0 -20
  465. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/editor_plugin.js +0 -1
  466. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif +0 -0
  467. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/button.gif +0 -0
  468. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif +0 -0
  469. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif +0 -0
  470. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif +0 -0
  471. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif +0 -0
  472. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif +0 -0
  473. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css +0 -90
  474. data/app/assets/javascripts/tiny_mce/plugins/inlinepopups/template.htm +0 -387
  475. data/app/assets/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin.js +0 -1
  476. data/app/assets/javascripts/tiny_mce/plugins/lists/editor_plugin.js +0 -1
  477. data/app/assets/javascripts/tiny_mce/plugins/paste/editor_plugin.js +0 -1
  478. data/app/assets/javascripts/tiny_mce/plugins/paste/js/pastetext.js +0 -36
  479. data/app/assets/javascripts/tiny_mce/plugins/paste/js/pasteword.js +0 -51
  480. data/app/assets/javascripts/tiny_mce/plugins/paste/langs/en_dlg.js +0 -5
  481. data/app/assets/javascripts/tiny_mce/plugins/paste/pastetext.htm +0 -27
  482. data/app/assets/javascripts/tiny_mce/plugins/paste/pasteword.htm +0 -21
  483. data/app/assets/javascripts/tiny_mce/plugins/preview/editor_plugin.js +0 -1
  484. data/app/assets/javascripts/tiny_mce/plugins/preview/jscripts/embed.js +0 -73
  485. data/app/assets/javascripts/tiny_mce/plugins/preview/preview.html +0 -18
  486. data/app/assets/javascripts/tiny_mce/plugins/style/css/props.css +0 -13
  487. data/app/assets/javascripts/tiny_mce/plugins/style/editor_plugin.js +0 -1
  488. data/app/assets/javascripts/tiny_mce/plugins/style/js/props.js +0 -635
  489. data/app/assets/javascripts/tiny_mce/plugins/style/langs/en_dlg.js +0 -70
  490. data/app/assets/javascripts/tiny_mce/plugins/style/props.htm +0 -838
  491. data/app/assets/javascripts/tiny_mce/plugins/table/cell.htm +0 -180
  492. data/app/assets/javascripts/tiny_mce/plugins/table/css/cell.css +0 -17
  493. data/app/assets/javascripts/tiny_mce/plugins/table/css/row.css +0 -25
  494. data/app/assets/javascripts/tiny_mce/plugins/table/css/table.css +0 -13
  495. data/app/assets/javascripts/tiny_mce/plugins/table/editor_plugin.js +0 -1
  496. data/app/assets/javascripts/tiny_mce/plugins/table/js/cell.js +0 -319
  497. data/app/assets/javascripts/tiny_mce/plugins/table/js/merge_cells.js +0 -27
  498. data/app/assets/javascripts/tiny_mce/plugins/table/js/row.js +0 -237
  499. data/app/assets/javascripts/tiny_mce/plugins/table/js/table.js +0 -450
  500. data/app/assets/javascripts/tiny_mce/plugins/table/langs/en_dlg.js +0 -75
  501. data/app/assets/javascripts/tiny_mce/plugins/table/merge_cells.htm +0 -32
  502. data/app/assets/javascripts/tiny_mce/plugins/table/row.htm +0 -158
  503. data/app/assets/javascripts/tiny_mce/plugins/table/table.htm +0 -188
  504. data/app/assets/javascripts/tiny_mce/plugins/wordcount/editor_plugin.js +0 -1
  505. data/app/assets/javascripts/tiny_mce/themes/advanced/anchor.htm +0 -26
  506. data/app/assets/javascripts/tiny_mce/themes/advanced/editor_template.js +0 -1
  507. data/app/assets/javascripts/tiny_mce/themes/advanced/editor_template_src.js +0 -1358
  508. data/app/assets/javascripts/tiny_mce/themes/advanced/img/icons.gif +0 -0
  509. data/app/assets/javascripts/tiny_mce/themes/advanced/img/trans.gif +0 -0
  510. data/app/assets/javascripts/tiny_mce/themes/advanced/js/anchor.js +0 -42
  511. data/app/assets/javascripts/tiny_mce/themes/advanced/js/link.js +0 -153
  512. data/app/assets/javascripts/tiny_mce/themes/advanced/js/source_editor.js +0 -56
  513. data/app/assets/javascripts/tiny_mce/themes/advanced/langs/en.js +0 -68
  514. data/app/assets/javascripts/tiny_mce/themes/advanced/langs/en_dlg.js +0 -54
  515. data/app/assets/javascripts/tiny_mce/themes/advanced/skins/default/content.css +0 -47
  516. data/app/assets/javascripts/tiny_mce/themes/advanced/skins/default/dialog.css +0 -117
  517. data/app/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
  518. data/app/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
  519. data/app/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
  520. data/app/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_check.gif +0 -0
  521. data/app/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/progress.gif +0 -0
  522. data/app/assets/javascripts/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
  523. data/app/assets/javascripts/tiny_mce/themes/advanced/skins/default/ui.css +0 -227
  524. data/app/assets/javascripts/tiny_mce/themes/advanced/source_editor.htm +0 -25
  525. data/app/assets/javascripts/tiny_mce/tiny_mce.js +0 -1
  526. data/app/assets/javascripts/tiny_mce/tiny_mce_popup.js +0 -5
  527. data/app/assets/javascripts/tiny_mce/utils/editable_selects.js +0 -70
  528. data/app/assets/javascripts/tiny_mce/utils/form_utils.js +0 -210
  529. data/app/assets/javascripts/tiny_mce/utils/mctabs.js +0 -162
  530. data/app/assets/javascripts/tiny_mce/utils/validate.js +0 -252
  531. data/app/controllers/gluttonberg/admin/content/articles_controller.rb +0 -139
  532. data/app/controllers/gluttonberg/admin/content/blogs_controller.rb +0 -101
  533. data/app/controllers/gluttonberg/admin/content/comments_controller.rb +0 -130
  534. data/app/controllers/gluttonberg/admin/content/main_controller.rb +0 -13
  535. data/app/controllers/gluttonberg/admin/help_controller.rb +0 -15
  536. data/app/controllers/gluttonberg/admin/settings/generic_settings_controller.rb +0 -90
  537. data/app/controllers/gluttonberg/admin/settings/main_controller.rb +0 -11
  538. data/app/controllers/gluttonberg/public/articles_controller.rb +0 -79
  539. data/app/controllers/gluttonberg/public/blogs_controller.rb +0 -44
  540. data/app/controllers/gluttonberg/public/comments_controller.rb +0 -46
  541. data/app/models/gluttonberg/article.rb +0 -73
  542. data/app/models/gluttonberg/article_localization.rb +0 -21
  543. data/app/models/gluttonberg/blog.rb +0 -19
  544. data/app/models/gluttonberg/comment.rb +0 -142
  545. data/app/models/gluttonberg/comment_subscription.rb +0 -28
  546. data/app/models/gluttonberg/help.rb +0 -48
  547. data/app/views/gluttonberg/admin/content/articles/_form.html.haml +0 -115
  548. data/app/views/gluttonberg/admin/content/articles/edit.html.haml +0 -11
  549. data/app/views/gluttonberg/admin/content/articles/index.html.haml +0 -71
  550. data/app/views/gluttonberg/admin/content/articles/new.html.haml +0 -11
  551. data/app/views/gluttonberg/admin/content/blogs/_form.html.haml +0 -56
  552. data/app/views/gluttonberg/admin/content/blogs/edit.html.haml +0 -3
  553. data/app/views/gluttonberg/admin/content/blogs/index.html.haml +0 -35
  554. data/app/views/gluttonberg/admin/content/blogs/new.html.haml +0 -10
  555. data/app/views/gluttonberg/admin/content/comments/index.html.haml +0 -66
  556. data/app/views/gluttonberg/admin/content/galleries/_images_list.html.haml +0 -21
  557. data/app/views/gluttonberg/admin/content/galleries/add_image.html.haml +0 -1
  558. data/app/views/gluttonberg/admin/content/main/index.html.haml +0 -20
  559. data/app/views/gluttonberg/admin/content/pages/edit_home.html.haml +0 -11
  560. data/app/views/gluttonberg/admin/exceptions/internal_server_error.html.haml +0 -11
  561. data/app/views/gluttonberg/admin/exceptions/not_acceptable.html.haml +0 -9
  562. data/app/views/gluttonberg/admin/membership/main/index.html.haml +0 -11
  563. data/app/views/gluttonberg/admin/settings/generic_settings/_form.html.haml +0 -26
  564. data/app/views/gluttonberg/admin/settings/generic_settings/edit.html.haml +0 -4
  565. data/app/views/gluttonberg/admin/settings/generic_settings/index.html.haml +0 -58
  566. data/app/views/gluttonberg/admin/settings/main/index.html.haml +0 -18
  567. data/app/views/gluttonberg/public/articles/index.rss.builder +0 -21
  568. data/app/views/gluttonberg/public/blogs/show.rss.builder +0 -21
  569. data/app/views/gluttonberg/public/exceptions/internal_server_error.html.haml +0 -11
  570. data/app/views/gluttonberg/public/exceptions/not_acceptable.html.haml +0 -9
  571. data/app/views/help/gluttonberg/admin/AssetLibrary/assets/add_assets_in_bulk.html.haml +0 -41
  572. data/app/views/help/gluttonberg/admin/AssetLibrary/assets/edit.html.haml +0 -61
  573. data/app/views/help/gluttonberg/admin/AssetLibrary/assets/index.html.haml +0 -16
  574. data/app/views/help/gluttonberg/admin/AssetLibrary/assets/new.html.haml +0 -57
  575. data/app/views/help/gluttonberg/admin/AssetLibrary/collections/edit.html.haml +0 -15
  576. data/app/views/help/gluttonberg/admin/AssetLibrary/collections/index.html.haml +0 -41
  577. data/app/views/help/gluttonberg/admin/AssetLibrary/collections/new.html.haml +0 -15
  578. data/app/views/help/gluttonberg/admin/AssetLibrary/main/index.html.haml +0 -34
  579. data/app/views/help/gluttonberg/admin/content/page_localizations/edit.html.haml +0 -89
  580. data/app/views/help/gluttonberg/admin/content/pages/_page_description_help.html.haml +0 -14
  581. data/app/views/help/gluttonberg/admin/content/pages/edit.html.haml +0 -62
  582. data/app/views/help/gluttonberg/admin/content/pages/index.html.haml +0 -111
  583. data/app/views/help/gluttonberg/admin/content/pages/new.html.haml +0 -61
  584. data/app/views/help/gluttonberg/admin/settings/dialects/edit.html.haml +0 -47
  585. data/app/views/help/gluttonberg/admin/settings/dialects/index.html.haml +0 -50
  586. data/app/views/help/gluttonberg/admin/settings/dialects/new.html.haml +0 -47
  587. data/app/views/help/gluttonberg/admin/settings/generic_settings/index.html.haml +0 -74
  588. data/app/views/help/gluttonberg/admin/settings/locales/edit.html.haml +0 -71
  589. data/app/views/help/gluttonberg/admin/settings/locales/index.html.haml +0 -57
  590. data/app/views/help/gluttonberg/admin/settings/locales/new.html.haml +0 -71
  591. data/app/views/help/gluttonberg/admin/settings/users/edit.html.haml +0 -63
  592. data/app/views/help/gluttonberg/admin/settings/users/index.html.haml +0 -60
  593. data/app/views/help/gluttonberg/admin/settings/users/new.html.haml +0 -69
  594. data/app/views/notifier/comment_notification.html.haml +0 -17
  595. data/app/views/notifier/comment_notification_for_admin.html.haml +0 -19
  596. data/db/migrate/20121106025800_add_artist_and_link_to_assets.rb +0 -6
  597. data/lib/acts_as_versioned.rb +0 -496
  598. data/lib/generators/gluttonberg/blog/blog_generator.rb +0 -46
  599. data/lib/generators/gluttonberg/blog/templates/articles_index.html.haml +0 -18
  600. data/lib/generators/gluttonberg/blog/templates/articles_show.html.haml +0 -63
  601. data/lib/generators/gluttonberg/blog/templates/articles_tag.html.haml +0 -24
  602. data/lib/generators/gluttonberg/blog/templates/blog_migration.rb +0 -90
  603. data/lib/generators/gluttonberg/blog/templates/blogs_index.html.haml +0 -15
  604. data/lib/generators/gluttonberg/blog/templates/blogs_show.html.haml +0 -25
  605. data/lib/generators/gluttonberg/installer/USAGE +0 -1
  606. data/lib/generators/gluttonberg/installer/installer_generator.rb +0 -106
  607. data/lib/generators/gluttonberg/installer/templates/delayed_job_script +0 -5
  608. data/lib/generators/gluttonberg/installer/templates/gluttonberg_migration.rb +0 -368
  609. data/lib/generators/gluttonberg/installer/templates/public.html.haml +0 -24
  610. data/lib/generators/gluttonberg/installer/templates/sitemap.rb +0 -70
  611. data/lib/gluttonberg/authorizable.rb +0 -51
  612. data/lib/gluttonberg/helpers.rb +0 -20
  613. data/lib/rails/railties/tasks.rake +0 -3
@@ -1,7 +1,9 @@
1
1
  module Gluttonberg
2
2
  module Library
3
3
  module Config
4
+ # Mixin which provides image sizes functionality to asset model
4
5
  module ImageSizes
6
+ extend ActiveSupport::Concern
5
7
 
6
8
  # Default sizes used when thumbnailing an image.
7
9
  DEFAULT_THUMBNAILS = {
@@ -34,28 +36,29 @@ module Gluttonberg
34
36
 
35
37
  end #ClassMethods
36
38
 
37
- module InstanceMethods
38
- # Returns the URL for the specified image size.
39
- def url_for(name)
40
- if self.class.sizes.has_key? name
41
- filename = self.class.sizes[name][:filename]
42
- "#{asset_directory_public_url}/#{filename}.#{file_extension}"
43
- end
39
+ # InstanceMethods
40
+ # Returns the URL for the specified image size.
41
+ def url_for(name=nil)
42
+ if name.blank?
43
+ url
44
+ elsif self.class.sizes.has_key? name
45
+ filename = self.class.sizes[name.to_sym][:filename]
46
+ "#{asset_directory_public_url}/#{filename}.#{file_extension}"
44
47
  end
48
+ end
45
49
 
46
- # Returns the public URL to the asset’s small thumbnail — relative
47
- # to the domain.
48
- def thumb_small_url
49
- url_for(:small_thumb) if category.downcase == "image"
50
- end
50
+ # Returns the public URL to the asset’s small thumbnail — relative
51
+ # to the domain.
52
+ def thumb_small_url
53
+ url_for(:small_thumb) if category.downcase == "image"
54
+ end
51
55
 
52
- # Returns the public URL to the asset’s large thumbnail — relative
53
- # to the domain.
54
- def thumb_large_url
55
- url_for(:large_thumb) if category.downcase == "image"
56
- end
57
- end #InstanceMethods
56
+ # Returns the public URL to the asset’s large thumbnail — relative
57
+ # to the domain.
58
+ def thumb_large_url
59
+ url_for(:large_thumb) if category.downcase == "image"
60
+ end
58
61
  end
59
62
  end
60
63
  end
61
- end
64
+ end
@@ -0,0 +1,104 @@
1
+ module Gluttonberg
2
+ module Library
3
+ module DefaultAssetTypes
4
+ def self.build
5
+ self.build_unknown_types
6
+ self.build_image_types
7
+ self.build_audio_types
8
+ self.build_video_types
9
+ self.build_document_types
10
+ end
11
+
12
+ # Makes sure the specified type exists in the DB, if it doesn’t it creates
13
+ # a new record.
14
+ def self.ensure_type(name, mime_type, category)
15
+ asset_type = AssetType.where(:name => name).first
16
+ if asset_type then
17
+ asset_type.asset_category = category
18
+ else
19
+ asset_type = AssetType.new(:name => name, :asset_category => category)
20
+ end
21
+ mime_type.split(' ').each do |this_mime_type|
22
+ asset_mime_type = AssetMimeType.new(:mime_type => this_mime_type)
23
+ asset_type.asset_mime_types << asset_mime_type
24
+ asset_mime_type.save
25
+ end
26
+ asset_type.save
27
+ end
28
+
29
+ private
30
+ def self.build_unknown_types
31
+ ensure_type('Unknown Image', 'image', AssetCategory.image_category)
32
+ ensure_type('Unknown Video', 'video', AssetCategory.video_category)
33
+ ensure_type('Unknown Audio', 'audio', AssetCategory.audio_category)
34
+ ensure_type('Unknown File', 'multi-part model message unknown', AssetCategory.uncategorised_category)
35
+ end
36
+
37
+ def self.build_image_types
38
+ ensure_type('Jpeg Image', 'image/jpeg image/pjpeg', AssetCategory.image_category)
39
+ ensure_type('Gif Image', 'image/gif', AssetCategory.image_category)
40
+ ensure_type('Png Image', 'image/png', AssetCategory.image_category)
41
+ ensure_type('Tiff Image', 'image/tiff', AssetCategory.image_category)
42
+ ensure_type('Adobe Photoshop Image', 'image/vnd.adobe.photoshop', AssetCategory.image_category)
43
+ ensure_type('Autocad Image', 'image/vnd.dwg', AssetCategory.image_category)
44
+ ensure_type('Autocad Image', 'image/vnd.dxf', AssetCategory.image_category)
45
+ ensure_type('Icon Image', 'image/vnd.microsoft.icon', AssetCategory.image_category)
46
+ ensure_type('Bitmap Image', 'image/x-bmp image/bmp image/x-win-bmp', AssetCategory.image_category)
47
+ ensure_type('Paintshop Pro Image', 'image/x-paintshoppro', AssetCategory.image_category)
48
+ ensure_type('Mobile Image (plb,psb,pvb)', 'application/vnd.3gpp.pic-bw-large application/vnd.3gpp.pic-bw-small application/vnd.3gpp.pic-bw-var', AssetCategory.image_category)
49
+ end
50
+
51
+ def self.build_audio_types
52
+ ensure_type('Moile Audio (3gpp,3gpp2)', 'audio/3gpp audio/3gpp2', AssetCategory.audio_category)
53
+ ensure_type('Dolby Digital Audio (ac3)', 'audio/ac3', AssetCategory.audio_category)
54
+ ensure_type('Mpeg Audio (mpga,mp2,mp3,mp4,mpa)', 'audio/mpeg audio/mpeg4-generic audio/mp4 audio/mp3 audio/mpa-robust', AssetCategory.audio_category) # @mpga,mp2,mp3
55
+ ensure_type('Aiff Audio (aif,aifc,aiff)', 'audio/x-aiff', AssetCategory.audio_category)
56
+ ensure_type('Midi Audio (mid,midi,kar)', 'audio/x-midi', AssetCategory.audio_category)
57
+ ensure_type('Real Audio (rm,ram,ra)', 'audio/x-pn-realaudio audio/x-realaudio', AssetCategory.audio_category)
58
+ ensure_type('Wav Audio (wav)', 'audio/x-wav', AssetCategory.audio_category)
59
+ ensure_type('Ogg Vorbis Audio (ogg)', 'application/ogg', AssetCategory.audio_category)
60
+ end
61
+
62
+ def self.build_video_types
63
+ ensure_type('Mobile Video', 'video/3gpp video/3gpp-tt video/3gpp2', AssetCategory.video_category) # @3gp,3gpp 'RFC3839,DRAFT:draft-gellens-mime-bucket
64
+ ensure_type('Digital Video', 'video/DV', AssetCategory.video_category) # RFC3189
65
+ ensure_type('Compressed Video', 'application/mpeg4-iod-xmt application/mpeg4-iod application/mpeg4-generic video/mp4 application/mp4 video/MPV video/mpeg4-generic video/mpeg video/MP2T video/H261 video/H263 video/H263-1998 video/H263-2000 video/H264 video/MP1S video/MP2P', AssetCategory.video_category) # RFC3555
66
+ ensure_type('Jpeg Video', 'video/JPEG video/MJ2', AssetCategory.video_category) # RFC3555
67
+ ensure_type('Quicktime Video', 'video/quicktime', AssetCategory.video_category)
68
+ ensure_type('Uncompressed Video', 'video/raw', AssetCategory.video_category)
69
+ ensure_type('Mpeg Playlist (mxu,m4u)', 'video/vnd.mpegurl', AssetCategory.video_category)
70
+ ensure_type('Avi Video (avi)', 'video/x-msvideo', AssetCategory.video_category)
71
+ ensure_type('Flash Video', 'video/x-flv', AssetCategory.video_category)
72
+ ensure_type('M4v Video', 'video/x-m4v', AssetCategory.video_category)
73
+ end
74
+
75
+ def self.build_document_types
76
+ #document category
77
+ ensure_type('Generic Document', 'application/x-csh application/x-dvi application/oda application/pgp-encrypted application/pgp-keys application/pgp-signature', AssetCategory.document_category)
78
+ ensure_type('Calendar Document', 'text/calendar text/x-vcalendar', AssetCategory.document_category)
79
+ ensure_type('Comma Seperated Values Document (csv)', 'text/csv text/comma-separated-values', AssetCategory.document_category)
80
+ ensure_type('Tab Seperated Values Text Document', 'text/tab-separated-values', AssetCategory.document_category)
81
+ ensure_type('Web Document', 'text/html', AssetCategory.document_category)
82
+ ensure_type('Plain Text Document', 'text/plain', AssetCategory.document_category)
83
+ ensure_type('Rich Text Document', 'text/richtext text/rtf', AssetCategory.document_category)
84
+ ensure_type('Sgml Document', 'text/sgml', AssetCategory.document_category)
85
+ ensure_type('Wap Document', 'text/vnd.wap.wml text/vnd.wap.wmlscript', AssetCategory.document_category)
86
+ ensure_type('XML Document', 'text/xml text/xml-external-parsed-entity', AssetCategory.document_category)
87
+ ensure_type('V-Card Document (vcf)', 'text/x-vcard', AssetCategory.document_category)
88
+ ensure_type('Apple Macintosh Document (hqx)', 'application/mac-binhex40', AssetCategory.document_category)
89
+ ensure_type('Adobe Acrobat Document (pdf)', 'application/pdf', AssetCategory.document_category)
90
+ self.buid_microsoft_office_types
91
+ end
92
+
93
+ def self.buid_microsoft_office_types
94
+ ensure_type('Microsoft Word Document (doc,dot,docx)', 'application/msword application/word', AssetCategory.document_category)
95
+ ensure_type('Microsoft Powerpoint Document (ppt,pps,pot,pptx)', 'application/vnd.ms-powerpoint application/powerpoint', AssetCategory.document_category)
96
+ ensure_type('Microsoft Excel Document (xls,xlt,xlsx)', 'application/vnd.ms-excel application/excel', AssetCategory.document_category)
97
+ ensure_type('Microsoft Works Document', 'application/vnd.ms-works', AssetCategory.document_category)
98
+ ensure_type('Microsoft Project Document (mpp)', 'application/vnd.ms-project', AssetCategory.document_category)
99
+ ensure_type('Microsoft Visio Document (vsd,vst,vsw,vss)', 'application/vnd.visio', AssetCategory.document_category)
100
+ ensure_type('HTML Help Document (chm)', 'application/x-chm', AssetCategory.document_category)
101
+ end
102
+ end
103
+ end
104
+ end
@@ -13,30 +13,46 @@ module Gluttonberg
13
13
 
14
14
  # Collect mp3 files info using Mp3Info gem
15
15
  def self.collect_mp3_info(asset)
16
- audio = AudioAssetAttribute.find( :first , :conditions => {:asset_id => asset.id})
17
-
18
16
  begin
19
17
  #open mp3 file
20
- Mp3Info.open(location_on_disk) do |mp3|
21
- if audio.blank?
22
- AudioAssetAttribute.create( :asset_id => asset.id , :length => mp3.length , :title => mp3.tag.title , :artist => mp3.tag.artist , :album => mp3.tag.album , :tracknum => mp3.tag.tracknum)
23
- else
24
- audio.update_attributes( {:length => mp3.length, :genre =>"" , :title => mp3.tag.title , :artist => mp3.tag.artist , :album => mp3.tag.album , :tracknum => mp3.tag.tracknum })
25
- end
26
- end
27
- if Gluttonberg::Setting.get_setting("audio_assets") == "Enable"
28
- Delayed::Job.enqueue AudioJob.new(asset.id)
18
+ Mp3Info.open(asset.location_on_disk) do |mp3|
19
+ self.update_audio_attributes(asset, mp3)
29
20
  end
21
+ self.enqueue_job(asset)
30
22
  rescue => detail
31
- # if exception occurs and asset has some attributes, then remove them.
32
- unless audio.blank?
33
- audio.update_attributes( {:length => nil , :title => nil , :artist => nil , :album => nil , :tracknum => nil })
34
- end
23
+ # if exception occurs and asset has some attributes,
24
+ # then remove them.
25
+ AudioAssetAttribute.where(:asset_id => asset.id).delete_all
35
26
  end
36
27
 
37
28
  end #collect_mp3_info
38
29
 
30
+ private
31
+ def self.enqueue_job(asset)
32
+ if Gluttonberg::Setting.get_setting("audio_assets") == "Enable"
33
+ AudioJob.perform_async(asset.id)
34
+ end
35
+ end
36
+
37
+ def self.update_audio_attributes(asset, mp3)
38
+ audio = asset.audio_asset_attribute
39
+ audio_attrs = {
40
+ :asset_id => asset.id,
41
+ :length => mp3.length ,
42
+ :title => mp3.tag.title,
43
+ :artist => mp3.tag.artist,
44
+ :album => mp3.tag.album,
45
+ :tracknum => mp3.tag.tracknum,
46
+ :genre =>""
47
+ }
48
+ if audio.blank?
49
+ AudioAssetAttribute.create(audio_attrs)
50
+ else
51
+ audio.update_attributes(audio_attrs)
52
+ end
53
+ end
54
+
39
55
  end
40
56
  end
41
57
  end
42
- end
58
+ end
@@ -3,12 +3,13 @@ module Gluttonberg
3
3
  module Processor
4
4
  class Image
5
5
 
6
- attr_accessor :asset
6
+ attr_accessor :asset, :replace_backup
7
7
 
8
- def self.process(asset_obj)
8
+ def self.process(asset_obj, replace_backup=true)
9
9
  if asset_obj.asset_type.asset_category.name == "image"
10
10
  processor = self.new
11
11
  processor.asset = asset_obj
12
+ processor.replace_backup = replace_backup
12
13
  processor.generate_thumb_and_proper_resolution
13
14
  end
14
15
  end
@@ -16,13 +17,18 @@ module Gluttonberg
16
17
  # Generates thumbnails for images, but also additionally checks to see
17
18
  # if the uploaded image exceeds the specified maximum, in which case it will resize it down.
18
19
  def generate_thumb_and_proper_resolution
19
- generate_proper_resolution
20
- generate_image_thumb
20
+ begin
21
+ if File.exist?(asset.tmp_location_on_disk)
22
+ generate_proper_resolution
23
+ generate_image_thumbnails
24
+ end
25
+ rescue => e
26
+ puts e
27
+ end
21
28
  end
22
29
 
23
30
  def suggested_measures(object , required_geometry)
24
- required_geometry = required_geometry.delete("#")
25
- required_geometry_tokens = required_geometry.split("x")
31
+ required_geometry_tokens = required_geometry.delete("#").split("x")
26
32
  actual_width = object.width.to_i
27
33
  actual_height = object.height.to_i
28
34
  required_width = required_geometry_tokens.first.to_i
@@ -49,86 +55,89 @@ module Gluttonberg
49
55
  end
50
56
 
51
57
  def generate_cropped_image(x , y , w , h, image_type)
52
- asset_thumb = asset.asset_thumbnails.find(:first , :conditions => {:thumbnail_type => image_type.to_s })
53
- if asset_thumb.blank?
54
- asset_thumb = asset.asset_thumbnails.create({:thumbnail_type => image_type.to_s , :user_generated => true })
55
- else
56
- asset_thumb.update_attributes(:user_generated => true)
57
- end
58
-
59
- file_name = "#{asset.class.sizes[image_type.to_sym][:filename]}.#{asset.file_extension}"
60
- begin
61
- image = QuickMagick::Image.read(asset.tmp_original_file_on_disk).first
62
- rescue
63
- image = QuickMagick::Image.read(asset.tmp_original_file_on_disk).first
64
- end
65
- thumb_defined_width = asset.class.sizes[image_type.to_sym][:geometry].split('x').first#.to_i
66
- scaling_percent = (thumb_defined_width.to_i/(w.to_i*1.0))*100
67
- image.arguments << " -crop #{w}x#{h}+#{x}+#{y} +repage"
68
- if scaling_percent != 1.0
69
- image.arguments << " -resize #{scaling_percent}%"
70
- end
71
- image.save File.join(asset.tmp_directory, file_name)
72
- asset.move_tmp_file_to_actual_directory(file_name , true)
58
+ asset_thumb = asset.asset_thumbnails.find_or_initialize_by_thumbnail_type(image_type.to_s)
59
+ asset_thumb.user_generated = true
60
+ asset_thumb.save
61
+ config = asset.class.sizes[image_type.to_sym]
62
+ file_name = "#{config[:filename]}.#{asset.file_extension}"
63
+ image = read_image_file(asset)
64
+ aurgments_str = _prepare_image_crop_arguments(x , y , w , h, config)
65
+ _resize_and_save(asset, image, nil, aurgments_str, file_name)
73
66
  end
74
67
 
75
68
  # Create thumbnailed versions of image attachements.
76
- # TODO: generate thumbnails with the correct extension
77
- def generate_image_thumb
69
+ def generate_image_thumbnails
78
70
  asset.class.sizes.each_pair do |name, config|
79
- asset_thumb = asset.asset_thumbnails.find(:first , :conditions => {:thumbnail_type => name.to_s, :user_generated => true })
80
- if asset_thumb.blank?
81
- begin
82
- image = QuickMagick::Image.read(asset.tmp_original_file_on_disk).first
83
- rescue
84
- image = QuickMagick::Image.read(asset.tmp_location_on_disk).first
85
- end
86
-
87
- file_name = "#{config[:filename]}.#{asset.file_extension}"
88
-
89
- if config[:geometry].include?("#")
90
- #todo
91
- begin
92
- image.resize(suggested_measures(image, config[:geometry]))
93
- image.arguments << " -gravity Center -crop #{config[:geometry].delete("#")}+0+0 +repage #{config[:grayscale] && config[:grayscale] == true ? "-colorspace Gray":""}"
94
- rescue => e
95
- puts e
96
- end
97
- else
98
- image.resize config[:geometry]
99
- image.arguments << "-colorspace Gray" if config[:grayscale] && config[:grayscale] == true
100
- end
101
- image.save File.join(asset.tmp_directory, file_name)
102
- asset.move_tmp_file_to_actual_directory(file_name, true)
103
- end # asset_thumb.blank?
71
+ asset_thumb = asset.asset_thumbnails.where({
72
+ :thumbnail_type => name.to_s,
73
+ :user_generated => true
74
+ }).first
75
+ _generate_image_thumbnail(name, config) if asset_thumb.blank?
104
76
  end # sizes loop
105
77
 
106
78
  asset.update_attribute(:custom_thumbnail , true)
107
79
  end
108
80
 
81
+
82
+
109
83
  def generate_proper_resolution
110
- asset.make_backup
111
- begin
112
- image = QuickMagick::Image.read(asset.tmp_original_file_on_disk).first
113
- rescue => e
114
- image = QuickMagick::Image.read(asset.tmp_location_on_disk).first
84
+ asset.make_backup(replace_backup)
85
+ image = read_image_file(asset)
86
+ asset.update_attributes( :width => image.width.to_i, :height => image.height.to_i)
87
+ _resize_and_save(asset, image, asset.class.max_image_size, nil, asset.file_name)
88
+ clean_audio_attributes_for_images(asset)
89
+ end
90
+
91
+ private
92
+ def _prepare_image_crop_arguments(x , y , w , h, config)
93
+ thumb_defined_width = config[:geometry].split('x').first
94
+ scaling_percent = (thumb_defined_width.to_i/(w.to_i*1.0))*100
95
+ aurgments_str = " -crop #{w}x#{h}+#{x}+#{y} +repage"
96
+ aurgments_str << " -resize #{scaling_percent}%" if scaling_percent != 1.0
97
+ aurgments_str
115
98
  end
116
99
 
117
- actual_width = image.width.to_i
118
- actual_height = image.height.to_i
100
+ def _generate_image_thumbnail(name, config)
101
+ image = read_image_file(asset)
102
+ file_name = "#{config[:filename]}.#{asset.file_extension}"
103
+ _resize_image_thumbnail(name, config, image, asset, file_name)
104
+ end
119
105
 
120
- asset.update_attributes( :width => actual_width ,:height => actual_height)
106
+ def _resize_image_thumbnail(name, config, image, asset, file_name)
107
+ aurgments_str = (config[:grayscale] == true ? "-colorspace Gray" : "" )
108
+ resize_str = config[:geometry]
121
109
 
122
- image.resize asset.class.max_image_size
123
- image.save File.join(asset.tmp_directory, asset.file_name)
124
- asset.move_tmp_file_to_actual_directory(asset.file_name , true)
125
- # remove mp3 info if any image have. it may happen in the case of updating asset from mp3 to image
126
- audio = AudioAssetAttribute.find( :first , :conditions => {:asset_id => asset.id})
127
- audio.destroy unless audio.blank?
128
- end
110
+ aurgments_str << " -quality #{config[:quality]} " unless config[:quality].blank?
129
111
 
112
+ #fixed size thumbnail
113
+ if config[:geometry].include?("#")
114
+ resize_str = suggested_measures(image, config[:geometry])
115
+ aurgments_str << " -gravity Center -crop #{config[:geometry].delete("#")}+0+0 +repage"
116
+ end
117
+ _resize_and_save(asset, image, resize_str, aurgments_str, file_name)
118
+ end
130
119
 
120
+ def read_image_file(asset)
121
+ begin
122
+ image = QuickMagick::Image.read(asset.tmp_original_file_on_disk).first
123
+ rescue => e
124
+ image = QuickMagick::Image.read(asset.tmp_location_on_disk).first
125
+ end
126
+ image
127
+ end
131
128
 
129
+ def _resize_and_save(asset, image, resize_str, aurgments_str, file_name)
130
+ image.resize resize_str unless resize_str.blank?
131
+ image.arguments << aurgments_str unless aurgments_str.blank?
132
+ image.save File.join(asset.tmp_directory, file_name)
133
+ asset.move_tmp_file_to_actual_directory(file_name , true)
134
+ end
135
+
136
+ def clean_audio_attributes_for_images(asset)
137
+ # remove mp3 info if any image have.
138
+ # it may happen in the case of updating asset from mp3 to image
139
+ AudioAssetAttribute.where(:asset_id => asset.id).delete_all
140
+ end
132
141
  end
133
142
  end
134
143
  end
@@ -1,100 +1,70 @@
1
1
  require "tempfile"
2
+ image = Pathname(__FILE__).dirname.expand_path
3
+ require File.join(image, "image", "draw")
4
+ require File.join(image, "image", "operators_and_settings")
5
+ require File.join(image, "image", "serialization")
2
6
 
3
7
  module Gluttonberg
4
8
  module Library
5
-
6
9
  module QuickMagick
7
-
8
10
  class Image
9
- class << self
10
-
11
- # create an array of images from the given blob data
12
- def from_blob(blob, &proc)
13
- file = Tempfile.new(QuickMagick::random_string)
14
- file.binmode
15
- file.write(blob)
16
- file.close
17
- self.read(file.path, &proc)
18
- end
19
-
20
- # create an array of images from the given file
21
- def read(filename, &proc)
22
- info = identify(%Q<"#{filename}">)
23
- info_lines = info.split(/[\r\n]/)
24
- images = []
25
- info_lines.each_with_index do |info_line, i|
26
- images << Image.new("#{filename}", i, info_line)
27
- end
28
- images.each(&proc) if block_given?
29
- return images
30
- end
31
-
32
- alias open read
33
-
34
- # Creates a new image initially set to gradient
35
- # Default gradient is linear gradient from black to white
36
- def gradient(width, height, type=QuickMagick::LinearGradient, color1=nil, color2=nil)
37
- template_name = type + ":"
38
- template_name << color1.to_s if color1
39
- template_name << '-' << color2.to_s if color2
40
- i = self.new(template_name, 0, nil, true)
41
- i.size = QuickMagick::geometry(width, height)
42
- yield(i) if block_given?
43
- i
44
- end
45
-
46
- # Creates an image with solid color
47
- def solid(width, height, color=nil)
48
- template_name = QuickMagick::SolidColor+":"
49
- template_name << color.to_s if color
50
- i = self.new(template_name, 0, nil, true)
51
- i.size = QuickMagick::geometry(width, height)
52
- yield(i) if block_given?
53
- i
54
- end
55
-
56
- # Creates an image from pattern
57
- def pattern(width, height, pattern)
58
- raise QuickMagick::QuickMagickError, "Invalid pattern '#{pattern.to_s}'" unless QuickMagick::Patterns.include?(pattern.to_s)
59
- template_name = "pattern:#{pattern.to_s}"
60
- i = self.new(template_name, 0, nil, true)
61
- i.size = QuickMagick::geometry(width, height)
62
- yield(i) if block_given?
63
- i
64
- end
11
+ include Draw
12
+ include OperatorsAndSettings
13
+ include Serialization
65
14
 
66
- # returns info for an image using <code>identify</code> command
67
- def identify(filename)
68
- QuickMagick.exec3 "identify #{QuickMagick.c filename}"
69
- end
15
+ # Creates a new image initially set to gradient
16
+ # Default gradient is linear gradient from black to white
17
+ def self.gradient(width, height, type=QuickMagick::LinearGradient, color1=nil, color2=nil)
18
+ template_name = type + ":"
19
+ template_name << color1.to_s if color1
20
+ template_name << '-' << color2.to_s if color2
21
+ i = self.new(template_name, 0, nil, true)
22
+ i.size = QuickMagick::geometry(width, height)
23
+ yield(i) if block_given?
24
+ i
25
+ end
26
+
27
+ # Creates an image with solid color
28
+ def self.solid(width, height, color=nil)
29
+ template_name = QuickMagick::SolidColor+":"
30
+ template_name << color.to_s if color
31
+ i = self.new(template_name, 0, nil, true)
32
+ i.size = QuickMagick::geometry(width, height)
33
+ yield(i) if block_given?
34
+ i
35
+ end
36
+
37
+ # Creates an image from pattern
38
+ def self.pattern(width, height, pattern)
39
+ raise QuickMagick::QuickMagickError, "Invalid pattern '#{pattern.to_s}'" unless QuickMagick::Patterns.include?(pattern.to_s)
40
+ template_name = "pattern:#{pattern.to_s}"
41
+ i = self.new(template_name, 0, nil, true)
42
+ i.size = QuickMagick::geometry(width, height)
43
+ yield(i) if block_given?
44
+ i
45
+ end
70
46
 
47
+ # returns info for an image using <code>identify</code> command
48
+ def self.identify(filename)
49
+ QuickMagick.exec3 "identify #{QuickMagick.c filename}"
71
50
  end
72
51
 
52
+ # ClassMethods
53
+
54
+ #instance methods
55
+
73
56
  # append the given option, value pair to the settings of the current image
74
57
  def append_to_settings(arg, value=nil)
75
58
  @arguments << "-#{arg} #{QuickMagick.c value} "
76
59
  @last_is_draw = false
77
60
  self
78
61
  end
79
-
62
+
80
63
  # append the given string as is. Used to append special arguments like +antialias or +debug
81
64
  def append_basic(arg)
82
65
  @arguments << arg << ' '
83
66
  end
84
67
 
85
- # Image settings supported by ImageMagick
86
- IMAGE_SETTINGS_METHODS = %w{
87
- adjoin affine alpha authenticate attenuate background bias black-point-compensation
88
- blue-primary bordercolor caption channel colors colorspace comment compose compress define
89
- delay depth display dispose dither encoding endian family fill filter font format fuzz gravity
90
- green-primary intent interlace interpolate interword-spacing kerning label limit loop mask
91
- mattecolor monitor orient ping pointsize preview quality quiet red-primary regard-warnings
92
- remap respect-parentheses scene seed stretch stroke strokewidth style taint texture treedepth
93
- transparent-color undercolor units verbose view virtual-pixel weight white-point
94
-
95
- density page sampling-factor size tile-offset
96
- }
97
-
98
68
  # append the given option, value pair to the args for the current image
99
69
  def append_to_operators(arg, value=nil)
100
70
  is_draw = (arg == 'draw')
@@ -106,7 +76,7 @@ module Gluttonberg
106
76
  @last_is_draw = is_draw
107
77
  self
108
78
  end
109
-
79
+
110
80
  # Reverts this image to its last saved state.
111
81
  # Note that you cannot revert an image created from scratch.
112
82
  def revert!
@@ -114,91 +84,20 @@ module Gluttonberg
114
84
  @arguments = ""
115
85
  end
116
86
 
117
- # Image operators supported by ImageMagick
118
- IMAGE_OPERATORS_METHODS = %w{
119
- alpha auto-orient bench black-threshold bordercolor charcoal clip clip-mask clip-path colorize
120
- contrast convolve cycle decipher deskew despeckle distort edge encipher emboss enhance equalize
121
- evaluate flip flop function gamma identify implode layers level level-colors median modulate monochrome
122
- negate noise normalize opaque ordered-dither NxN paint polaroid posterize print profile quantize
123
- radial-blur Raise random-threshold recolor render rotate segment sepia-tone set shade solarize
124
- sparse-color spread strip swirl threshold tile tint transform transparent transpose transverse trim
125
- type unique-colors white-threshold
126
-
127
- adaptive-blur adaptive-resize adaptive-sharpen annotate blur border chop contrast-stretch extent
128
- extract frame gaussian-blur geometry lat linear-stretch liquid-rescale motion-blur region repage
129
- resample resize roll sample scale selective-blur shadow sharpen shave shear sigmoidal-contrast
130
- sketch splice thumbnail unsharp vignette wave
131
-
132
- append average clut coalesce combine composite deconstruct flatten fx hald-clut morph mosaic process reverse separate write
133
- crop
134
- }
135
-
136
- # methods that are called with (=)
137
- WITH_EQUAL_METHODS =
138
- %w{alpha background bias black-point-compensation blue-primary border bordercolor caption
139
- cahnnel colors colorspace comment compose compress depth density encoding endian family fill filter
140
- font format frame fuzz geometry gravity label mattecolor page pointsize quality stroke strokewidth
141
- undercolor units weight
142
- brodercolor transparent type size}
143
-
144
- # methods that takes geometry options
145
- WITH_GEOMETRY_METHODS =
146
- %w{density page sampling-factor size tile-offset adaptive-blur adaptive-resize adaptive-sharpen
147
- annotate blur border chop contrast-stretch extent extract frame gaussian-blur
148
- geometry lat linear-stretch liquid-rescale motion-blur region repage resample resize roll
149
- sample scale selective-blur shadow sharpen shave shear sigmoidal-contrast sketch
150
- splice thumbnail unsharp vignette wave crop}
151
-
152
- # Methods that need special treatment. This array is used just to keep track of them.
153
- SPECIAL_COMMANDS =
154
- %w{floodfill antialias draw}
155
-
156
- IMAGE_SETTINGS_METHODS.each do |method|
157
- if WITH_EQUAL_METHODS.include?(method)
158
- define_method((method+'=').to_sym) do |arg|
159
- append_to_settings(method, arg)
160
- end
161
- elsif WITH_GEOMETRY_METHODS.include?(method)
162
- define_method((method).to_sym) do |*args|
163
- append_to_settings(method, QuickMagick::geometry(*args) )
164
- end
165
- else
166
- define_method(method.to_sym) do |*args|
167
- append_to_settings(method, args.join(" "))
168
- end
169
- end
170
- end
171
-
172
- IMAGE_OPERATORS_METHODS.each do |method|
173
- if WITH_EQUAL_METHODS.include?(method)
174
- define_method((method+'=').to_sym) do |arg|
175
- append_to_operators(method, arg )
176
- end
177
- elsif WITH_GEOMETRY_METHODS.include?(method)
178
- define_method((method).to_sym) do |*args|
179
- append_to_operators(method, QuickMagick::geometry(*args) )
180
- end
181
- else
182
- define_method(method.to_sym) do |*args|
183
- append_to_operators(method, args.join(" "))
184
- end
185
- end
186
- end
187
-
188
87
  # Fills a rectangle with a solid color
189
88
  def floodfill(width, height=nil, x=nil, y=nil, flag=nil, color=nil)
190
89
  append_to_operators "floodfill", QuickMagick::geometry(width, height, x, y, flag), color
191
90
  end
192
-
91
+
193
92
  # Enables/Disables flood fill. Pass a boolean argument.
194
93
  def antialias=(flag)
195
- append_basic flag ? '-antialias' : '+antialias'
94
+ append_basic flag ? '-antialias' : '+antialias'
196
95
  end
197
-
96
+
198
97
  # define attribute readers (getters)
199
98
  attr_reader :image_filename
200
99
  alias original_filename image_filename
201
-
100
+
202
101
  # constructor
203
102
  def initialize(filename, index=0, info_line=nil, pseudo_image=false)
204
103
  @image_filename = filename
@@ -206,22 +105,24 @@ module Gluttonberg
206
105
  @pseudo_image = pseudo_image
207
106
  if info_line
208
107
  @image_infoline = info_line.split
209
- @image_infoline[0..1] = @image_infoline[0..1].join(' ') while @image_infoline.size > 1 && !@image_infoline[0].start_with?(image_filename)
108
+ process_info_line
109
+ #@image_infoline[0..1] = @image_infoline[0..1].join(' ') while @image_infoline.size > 1 && !@image_infoline[0].start_with?(image_filename)
210
110
  end
211
111
  @arguments = ""
212
112
  end
213
-
113
+
214
114
  # The command line so far that will be used to convert or save the image
215
115
  def command_line
216
116
  %Q< "(" #{@arguments} #{QuickMagick.c(image_filename + (@pseudo_image ? "" : "[#{@index}]"))} ")" >
217
117
  end
218
-
118
+
219
119
  # An information line about the image obtained using 'identify' command line
220
120
  def image_infoline
221
121
  return nil if @pseudo_image
222
122
  unless @image_infoline
223
123
  @image_infoline = QuickMagick::Image::identify(command_line).split
224
- @image_infoline[0..1] = @image_infoline[0..1].join(' ') while @image_infoline.size > 1 && !@image_infoline[0].start_with?(image_filename)
124
+ process_info_line
125
+ #@image_infoline[0..1] = @image_infoline[0..1].join(' ') while @image_infoline.size > 1 && !@image_infoline[0].start_with?(image_filename)
225
126
  end
226
127
  @image_infoline
227
128
  end
@@ -257,159 +158,6 @@ module Gluttonberg
257
158
  points_str
258
159
  end
259
160
 
260
- # The shape primitives are drawn in the color specified by the preceding -fill setting.
261
- # For unfilled shapes, use -fill none.
262
- # You can optionally control the stroke (the "outline" of a shape) with the -stroke and -strokewidth settings.
263
-
264
- # draws a point at the given location in pixels
265
- # A point primitive is specified by a single point in the pixel plane, that is, by an ordered pair
266
- # of integer coordinates, x,y.
267
- # (As it involves only a single pixel, a point primitive is not affected by -stroke or -strokewidth.)
268
- def draw_point(x, y, options={})
269
- append_to_operators("draw", "#{options_to_str(options)} point #{x},#{y}")
270
- end
271
-
272
- # draws a line between the given two points
273
- # A line primitive requires a start point and end point.
274
- def draw_line(x0, y0, x1, y1, options={})
275
- append_to_operators("draw", "#{options_to_str(options)} line #{x0},#{y0} #{x1},#{y1}")
276
- end
277
-
278
- # draw a rectangle with the given two corners
279
- # A rectangle primitive is specified by the pair of points at the upper left and lower right corners.
280
- def draw_rectangle(x0, y0, x1, y1, options={})
281
- append_to_operators("draw", "#{options_to_str(options)} rectangle #{x0},#{y0} #{x1},#{y1}")
282
- end
283
-
284
- # draw a rounded rectangle with the given two corners
285
- # wc and hc are the width and height of the arc
286
- # A roundRectangle primitive takes the same corner points as a rectangle
287
- # followed by the width and height of the rounded corners to be removed.
288
- def draw_round_rectangle(x0, y0, x1, y1, wc, hc, options={})
289
- append_to_operators("draw", "#{options_to_str(options)} roundRectangle #{x0},#{y0} #{x1},#{y1} #{wc},#{hc}")
290
- end
291
-
292
- # The arc primitive is used to inscribe an elliptical segment in to a given rectangle.
293
- # An arc requires the two corners used for rectangle (see above) followed by
294
- # the start and end angles of the arc of the segment segment (e.g. 130,30 200,100 45,90).
295
- # The start and end points produced are then joined with a line segment and the resulting segment of an ellipse is filled.
296
- def draw_arc(x0, y0, x1, y1, a0, a1, options={})
297
- append_to_operators("draw", "#{options_to_str(options)} arc #{x0},#{y0} #{x1},#{y1} #{a0},#{a1}")
298
- end
299
-
300
- # Use ellipse to draw a partial (or whole) ellipse.
301
- # Give the center point, the horizontal and vertical "radii"
302
- # (the semi-axes of the ellipse) and start and end angles in degrees (e.g. 100,100 100,150 0,360).
303
- def draw_ellipse(x0, y0, rx, ry, a0, a1, options={})
304
- append_to_operators("draw", "#{options_to_str(options)} ellipse #{x0},#{y0} #{rx},#{ry} #{a0},#{a1}")
305
- end
306
-
307
- # The circle primitive makes a disk (filled) or circle (unfilled). Give the center and any point on the perimeter (boundary).
308
- def draw_circle(x0, y0, x1, y1, options={})
309
- append_to_operators("draw", "#{options_to_str(options)} circle #{x0},#{y0} #{x1},#{y1}")
310
- end
311
-
312
- # The polyline primitive requires three or more points to define their perimeters.
313
- # A polyline is simply a polygon in which the final point is not stroked to the start point.
314
- # When unfilled, this is a polygonal line. If the -stroke setting is none (the default), then a polyline is identical to a polygon.
315
- # points - A single array with each pair forming a coordinate in the form (x, y).
316
- # e.g. [0,0,100,100,100,0] will draw a polyline between points (0,0)-(100,100)-(100,0)
317
- def draw_polyline(points, options={})
318
- append_to_operators("draw", "#{options_to_str(options)} polyline #{points_to_str(points)}")
319
- end
320
-
321
- # The polygon primitive requires three or more points to define their perimeters.
322
- # A polyline is simply a polygon in which the final point is not stroked to the start point.
323
- # When unfilled, this is a polygonal line. If the -stroke setting is none (the default), then a polyline is identical to a polygon.
324
- # points - A single array with each pair forming a coordinate in the form (x, y).
325
- # e.g. [0,0,100,100,100,0] will draw a polygon between points (0,0)-(100,100)-(100,0)
326
- def draw_polygon(points, options={})
327
- append_to_operators("draw", "#{options_to_str(options)} polygon #{points_to_str(points)}")
328
- end
329
-
330
- # The Bezier primitive creates a spline curve and requires three or points to define its shape.
331
- # The first and last points are the knots and these points are attained by the curve,
332
- # while any intermediate coordinates are control points.
333
- # If two control points are specified, the line between each end knot and its sequentially
334
- # respective control point determines the tangent direction of the curve at that end.
335
- # If one control point is specified, the lines from the end knots to the one control point
336
- # determines the tangent directions of the curve at each end.
337
- # If more than two control points are specified, then the additional control points
338
- # act in combination to determine the intermediate shape of the curve.
339
- # In order to draw complex curves, it is highly recommended either to use the path primitive
340
- # or to draw multiple four-point bezier segments with the start and end knots of each successive segment repeated.
341
- def draw_bezier(points, options={})
342
- append_to_operators("draw", "#{options_to_str(options)} bezier #{points_to_str(points)}")
343
- end
344
-
345
- # A path represents an outline of an object, defined in terms of moveto
346
- # (set a new current point), lineto (draw a straight line), curveto (draw a Bezier curve),
347
- # arc (elliptical or circular arc) and closepath (close the current shape by drawing a
348
- # line to the last moveto) elements.
349
- # Compound paths (i.e., a path with subpaths, each consisting of a single moveto followed by
350
- # one or more line or curve operations) are possible to allow effects such as donut holes in objects.
351
- # (See http://www.w3.org/TR/SVG/paths.html)
352
- def draw_path(path_spec, options={})
353
- append_to_operators("draw", "#{options_to_str(options)} path #{path_spec}")
354
- end
355
-
356
- # Use image to composite an image with another image. Follow the image keyword
357
- # with the composite operator, image location, image size, and filename
358
- # You can use 0,0 for the image size, which means to use the actual dimensions found in the image header.
359
- # Otherwise, it is scaled to the given dimensions. See -compose for a description of the composite operators.
360
- def draw_image(operator, x0, y0, w, h, image_filename, options={})
361
- append_to_operators("draw", "#{options_to_str(options)} image #{operator} #{x0},#{y0} #{w},#{h} \"#{image_filename}\"")
362
- end
363
-
364
- # Use text to annotate an image with text. Follow the text coordinates with a string.
365
- def draw_text(x0, y0, text, options={})
366
- append_to_operators("draw", "#{options_to_str(options)} text #{x0},#{y0} '#{text}'")
367
- end
368
-
369
- # saves the current image to the given filename
370
- def save(output_filename)
371
- result = QuickMagick.exec3 "convert #{command_line} #{QuickMagick.c output_filename} "#-quality 92"
372
- if @pseudo_image
373
- # since it's been saved, convert it to normal image (not pseudo)
374
- initialize(output_filename)
375
- revert!
376
- end
377
- return result
378
- end
379
-
380
- alias write save
381
- alias convert save
382
-
383
- # saves the current image overwriting the original image file
384
- def save!
385
- raise QuickMagick::QuickMagickError, "Cannot mogrify a pseudo image" if @pseudo_image
386
- result = QuickMagick.exec3 "mogrify #{command_line}"
387
- # remove all operations to avoid duplicate operations
388
- revert!
389
- return result
390
- end
391
-
392
- alias write! save!
393
- alias mogrify! save!
394
-
395
- def to_blob
396
- tmp_file = Tempfile.new(QuickMagick::random_string)
397
- if command_line =~ /-format\s(\S+)\s/
398
- # use format set up by user
399
- blob_format = $1
400
- elsif !@pseudo_image
401
- # use original image format
402
- blob_format = self.format
403
- else
404
- # default format is jpg
405
- blob_format = 'jpg'
406
- end
407
- save "#{blob_format}:#{tmp_file.path}"
408
- blob = nil
409
- File.open(tmp_file.path, 'rb') { |f| blob = f.read}
410
- blob
411
- end
412
-
413
161
  def arguments
414
162
  @arguments
415
163
  end
@@ -417,36 +165,36 @@ module Gluttonberg
417
165
  def format
418
166
  image_infoline[1]
419
167
  end
420
-
168
+
421
169
  # columns of image in pixels
422
170
  def columns
423
171
  image_infoline[2].split('x').first.to_i
424
172
  end
425
-
173
+
426
174
  alias width columns
427
-
175
+
428
176
  # rows of image in pixels
429
177
  def rows
430
178
  image_infoline[2].split('x').last.to_i
431
179
  end
432
-
180
+
433
181
  alias height rows
434
-
182
+
435
183
  # Bit depth
436
184
  def bit_depth
437
185
  image_infoline[4].to_i
438
186
  end
439
-
187
+
440
188
  # Number of different colors used in this image
441
189
  def colors
442
190
  image_infoline[6].to_i
443
191
  end
444
-
192
+
445
193
  # returns size of image in bytes
446
194
  def size
447
195
  File.size?(image_filename)
448
196
  end
449
-
197
+
450
198
  # Reads a pixel from the image.
451
199
  # WARNING: This is done through command line which is very slow.
452
200
  # It is not recommended at all to use this method for image processing for example.
@@ -455,16 +203,21 @@ module Gluttonberg
455
203
  result =~ /Histogram:\s*\d+:\s*\(\s*(\d+),\s*(\d+),\s*(\d+)\)/
456
204
  return [$1.to_i, $2.to_i, $3.to_i]
457
205
  end
458
-
206
+
459
207
  # displays the current image as animated image
460
208
  def animate
461
209
  `animate #{command_line}`
462
210
  end
463
-
211
+
464
212
  # displays the current image to the x-windowing system
465
213
  def display
466
214
  `display #{command_line}`
467
215
  end
216
+
217
+ private
218
+ def process_info_line
219
+ @image_infoline[0..1] = @image_infoline[0..1].join(' ') while @image_infoline.size > 1 && !@image_infoline[0].start_with?(image_filename)
220
+ end
468
221
  end
469
222
  end
470
223
  end # Assetlibrary