alchemy_cms 2.2.4 → 2.3.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. data/.gitignore +1 -1
  2. data/.travis.yml +3 -4
  3. data/Gemfile +1 -0
  4. data/README.md +10 -6
  5. data/alchemy_cms.gemspec +5 -2
  6. data/app/assets/images/alchemy/icons.png +0 -0
  7. data/app/assets/images/sassy-ie-overlay.png +0 -0
  8. data/app/assets/javascripts/alchemy/alchemy.base.js +50 -59
  9. data/app/assets/javascripts/alchemy/alchemy.buttons.js +14 -4
  10. data/app/assets/javascripts/alchemy/alchemy.datepicker.js +8 -2
  11. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +11 -3
  12. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +1 -1
  13. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +14 -1
  14. data/app/assets/javascripts/alchemy/alchemy.preview.js +1 -1
  15. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +12 -4
  16. data/app/assets/javascripts/alchemy/alchemy.uploader.js +4 -1
  17. data/app/assets/javascripts/alchemy/alchemy.windows.js +18 -8
  18. data/app/assets/stylesheets/alchemy/_defaults.scss +84 -120
  19. data/app/assets/stylesheets/alchemy/alchemy.css +2 -2
  20. data/app/assets/stylesheets/alchemy/archive.css.scss +288 -0
  21. data/app/assets/stylesheets/alchemy/base.css.scss +95 -390
  22. data/app/assets/stylesheets/alchemy/dashboard.css.scss +4 -4
  23. data/app/assets/stylesheets/alchemy/elements.css.scss +83 -118
  24. data/app/assets/stylesheets/alchemy/flash.css.scss +1 -1
  25. data/app/assets/stylesheets/alchemy/form_elements.css.scss +528 -0
  26. data/app/assets/stylesheets/alchemy/frame.css.scss +13 -39
  27. data/app/assets/stylesheets/alchemy/icons.css.scss +217 -228
  28. data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +48 -50
  29. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
  30. data/app/assets/stylesheets/alchemy/login.css.scss +1 -5
  31. data/app/assets/stylesheets/alchemy/menubar.css.scss +19 -29
  32. data/app/assets/stylesheets/alchemy/pagination.css.scss +3 -4
  33. data/app/assets/stylesheets/alchemy/sitemap.css.scss +81 -81
  34. data/app/assets/stylesheets/alchemy/tables.css.scss +63 -57
  35. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +57 -57
  36. data/app/assets/stylesheets/alchemy/upload.css.scss +6 -6
  37. data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +6 -10
  38. data/app/controllers/alchemy/admin/attachments_controller.rb +5 -4
  39. data/app/controllers/alchemy/admin/base_controller.rb +1 -9
  40. data/app/controllers/alchemy/admin/contents_controller.rb +4 -6
  41. data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
  42. data/app/controllers/alchemy/admin/pages_controller.rb +2 -2
  43. data/app/controllers/alchemy/admin/pictures_controller.rb +74 -15
  44. data/app/controllers/alchemy/attachments_controller.rb +8 -2
  45. data/app/controllers/alchemy/base_controller.rb +47 -5
  46. data/app/controllers/alchemy/elements_controller.rb +1 -1
  47. data/app/controllers/alchemy/messages_controller.rb +12 -12
  48. data/app/controllers/alchemy/pages_controller.rb +5 -1
  49. data/app/controllers/alchemy/pictures_controller.rb +9 -4
  50. data/app/controllers/alchemy/user_sessions_controller.rb +2 -4
  51. data/app/helpers/alchemy/admin/base_helper.rb +98 -19
  52. data/app/helpers/alchemy/admin/contents_helper.rb +2 -2
  53. data/app/helpers/alchemy/admin/elements_helper.rb +2 -3
  54. data/app/helpers/alchemy/base_helper.rb +6 -5
  55. data/app/helpers/alchemy/elements_helper.rb +2 -2
  56. data/app/helpers/alchemy/essences_helper.rb +4 -5
  57. data/app/helpers/alchemy/pages_helper.rb +15 -79
  58. data/app/helpers/alchemy/url_helper.rb +67 -0
  59. data/app/mailers/alchemy/messages.rb +1 -1
  60. data/app/mailers/alchemy/notifications.rb +1 -1
  61. data/app/models/alchemy/attachment.rb +11 -2
  62. data/app/models/alchemy/cell.rb +20 -10
  63. data/app/models/alchemy/content.rb +4 -3
  64. data/app/models/alchemy/element.rb +170 -178
  65. data/app/models/alchemy/language/code.rb +4 -1
  66. data/app/models/alchemy/message.rb +19 -3
  67. data/app/models/alchemy/page.rb +45 -40
  68. data/app/models/alchemy/picture.rb +24 -2
  69. data/app/models/alchemy/user.rb +2 -3
  70. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +12 -12
  71. data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
  72. data/app/views/alchemy/admin/attachments/create.js.erb +1 -0
  73. data/app/views/alchemy/admin/attachments/edit.html.erb +9 -3
  74. data/app/views/alchemy/admin/attachments/index.html.erb +3 -2
  75. data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
  76. data/app/views/alchemy/admin/contents/create.js.erb +54 -0
  77. data/app/views/alchemy/admin/contents/new.html.erb +9 -4
  78. data/app/views/alchemy/admin/elements/{_add_content.html.erb → _add_picture.html.erb} +4 -4
  79. data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -1
  80. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -1
  81. data/app/views/alchemy/admin/elements/{_picture_editor.html.erb → _picture_gallery_editor.html.erb} +7 -11
  82. data/app/views/alchemy/admin/elements/fold.js.erb +46 -0
  83. data/app/views/alchemy/admin/elements/index.html.erb +24 -24
  84. data/app/views/alchemy/admin/elements/list.js.erb +11 -9
  85. data/app/views/alchemy/admin/essence_files/assign.js.erb +3 -1
  86. data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +28 -0
  87. data/app/views/alchemy/admin/pages/_contactform_links.html.erb +8 -6
  88. data/app/views/alchemy/admin/pages/_external_link.html.erb +11 -9
  89. data/app/views/alchemy/admin/pages/_file_link.html.erb +10 -8
  90. data/app/views/alchemy/admin/pages/_internal_link.html.erb +14 -10
  91. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  92. data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
  93. data/app/views/alchemy/admin/pages/_page_for_links.html.erb +32 -21
  94. data/app/views/alchemy/admin/pages/configure.html.erb +2 -2
  95. data/app/views/alchemy/admin/pages/configure_external.html.erb +13 -13
  96. data/app/views/alchemy/admin/pages/edit.html.erb +2 -2
  97. data/app/views/alchemy/admin/pages/index.html.erb +26 -24
  98. data/app/views/alchemy/admin/pages/link.html.erb +2 -5
  99. data/app/views/alchemy/admin/partials/_upload_form.html.erb +28 -12
  100. data/app/views/alchemy/admin/pictures/_archive.html.erb +54 -0
  101. data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +10 -7
  102. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +21 -22
  103. data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +31 -0
  104. data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +9 -0
  105. data/app/views/alchemy/admin/pictures/_picture.html.erb +36 -6
  106. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -0
  107. data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
  108. data/app/views/alchemy/admin/pictures/create.js.erb +4 -5
  109. data/app/views/alchemy/admin/pictures/edit.html.erb +26 -0
  110. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +39 -0
  111. data/app/views/alchemy/admin/pictures/index.html.erb +81 -70
  112. data/app/views/alchemy/admin/pictures/index.js.erb +3 -0
  113. data/app/views/alchemy/admin/pictures/new.html.erb +1 -0
  114. data/app/views/alchemy/admin/resources/index.html.erb +3 -1
  115. data/app/views/alchemy/admin/users/_table.html.erb +1 -1
  116. data/app/views/alchemy/admin/users/index.html.erb +27 -23
  117. data/app/views/alchemy/elements/_article_editor.html.erb +7 -2
  118. data/app/views/alchemy/elements/_bild_editor.html.erb +1 -1
  119. data/app/views/alchemy/elements/_bild_text_editor.html.erb +6 -1
  120. data/app/views/alchemy/elements/_bild_text_view.html.erb +3 -3
  121. data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +1 -1
  122. data/app/views/alchemy/elements/_image_mosaic_view.html.erb +2 -2
  123. data/app/views/alchemy/elements/_intro_image_text_view.html.erb +4 -4
  124. data/app/views/alchemy/elements/_searchresult_editor.html.erb +4 -1
  125. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +1 -1
  126. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +2 -3
  127. data/app/views/alchemy/essences/_essence_picture_tools.html.erb +1 -1
  128. data/app/views/alchemy/search/_form.html.erb +8 -0
  129. data/app/views/alchemy/search/_result.html.erb +3 -2
  130. data/app/views/alchemy/search/_results.html.erb +28 -0
  131. data/app/views/alchemy/user_sessions/leave.html.erb +4 -4
  132. data/app/views/alchemy/user_sessions/login.html.erb +1 -2
  133. data/app/views/layouts/alchemy/admin.html.erb +30 -10
  134. data/app/views/layouts/alchemy/login.html.erb +2 -39
  135. data/config/alchemy/elements.yml +1 -2
  136. data/config/alchemy/page_layouts.yml +8 -5
  137. data/config/authorization_rules.rb +27 -18
  138. data/config/initializers/localeapp.rb +9 -0
  139. data/config/locales/alchemy.de.yml +93 -56
  140. data/config/locales/alchemy.en.yml +73 -50
  141. data/config/routes.rb +3 -1
  142. data/db/migrate/20120704181529_add_upload_hash_to_alchemy_picture.rb +5 -0
  143. data/db/migrate/20120705214247_acts_as_taggable_on_migration.rb +28 -0
  144. data/db/migrate/20120728185830_add_cached_tag_list_to_alchemy_pictures.rb +5 -0
  145. data/db/migrate/20120831135441_set_alchemy_languages_country_code_default_to_empty_string.rb +9 -0
  146. data/lib/alchemy/capistrano.rb +2 -2
  147. data/lib/alchemy/essence.rb +14 -0
  148. data/lib/alchemy/page_layout.rb +0 -6
  149. data/lib/alchemy/resource.rb +9 -15
  150. data/lib/alchemy/upgrader.rb +18 -3
  151. data/lib/alchemy/version.rb +5 -1
  152. data/lib/alchemy_cms.rb +4 -1
  153. data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +16 -6
  154. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +17 -3
  155. data/lib/rails/generators/alchemy/elements/elements_generator.rb +6 -1
  156. data/lib/rails/generators/alchemy/elements/templates/editor.html.erb +10 -1
  157. data/lib/rails/generators/alchemy/elements/templates/view.html.erb +17 -18
  158. data/lib/rails/generators/alchemy/scaffold/files/pages.html.erb +4 -2
  159. data/lib/tasks/fleximage.rake +2 -2
  160. data/spec/controllers/admin/contents_controller_spec.rb +2 -2
  161. data/spec/controllers/admin/elements_controller_spec.rb +30 -1
  162. data/spec/controllers/admin/pages_controller_spec.rb +35 -18
  163. data/spec/controllers/admin/trash_controller_spec.rb +40 -16
  164. data/spec/controllers/attachments_controller_spec.rb +62 -0
  165. data/spec/controllers/base_controller_spec.rb +43 -42
  166. data/spec/controllers/elements_controller_spec.rb +30 -0
  167. data/spec/controllers/pages_controller_spec.rb +22 -5
  168. data/spec/controllers/pictures_controller_spec.rb +82 -0
  169. data/spec/dummy/app/models/event.rb +2 -1
  170. data/spec/dummy/config/database.yml +3 -2
  171. data/spec/dummy/db/schema.rb +51 -27
  172. data/spec/factories.rb +29 -8
  173. data/spec/helpers/admin/base_helper_spec.rb +134 -21
  174. data/spec/helpers/admin/contents_helper_spec.rb +2 -2
  175. data/spec/helpers/admin/elements_helper_spec.rb +17 -9
  176. data/spec/helpers/admin/essences_helper_spec.rb +7 -6
  177. data/spec/helpers/essences_helper_spec.rb +8 -7
  178. data/spec/helpers/pages_helper_spec.rb +208 -325
  179. data/spec/helpers/url_helper_spec.rb +171 -0
  180. data/spec/integration/admin/link_overlay_spec.rb +53 -0
  181. data/spec/integration/admin/modules_integration_spec.rb +22 -26
  182. data/spec/integration/admin/pages_controller_spec.rb +10 -19
  183. data/spec/integration/admin/picture_library_integration_spec.rb +52 -0
  184. data/spec/integration/admin/resources_integration_spec.rb +68 -75
  185. data/spec/integration/pages_controller_spec.rb +70 -61
  186. data/spec/integration/security_spec.rb +3 -5
  187. data/spec/integration/translation_integration_spec.rb +56 -0
  188. data/spec/libraries/essence_spec.rb +18 -0
  189. data/spec/libraries/resource_spec.rb +101 -79
  190. data/spec/libraries/resources_helper_spec.rb +3 -0
  191. data/spec/models/content_spec.rb +63 -60
  192. data/spec/models/element_spec.rb +203 -93
  193. data/spec/models/language_spec.rb +90 -65
  194. data/spec/models/page_layout_spec.rb +37 -0
  195. data/spec/models/page_spec.rb +181 -113
  196. data/spec/models/picture_spec.rb +73 -26
  197. data/spec/models/resource_spec.rb +52 -23
  198. data/spec/support/alchemy/specs_helpers.rb +2 -0
  199. data/spec/support/image.png +0 -0
  200. data/spec/{helpers/url_helpers_spec.rb → url_helpers_spec.rb} +0 -0
  201. data/vendor/assets/javascripts/jquery_plugins/jquery.selectBoxIt.js +1909 -0
  202. data/vendor/assets/javascripts/jquery_plugins/preloadCssImages.jQuery_v5.js +152 -0
  203. metadata +106 -33
  204. data/app/assets/stylesheets/alchemy/buttons.css.scss +0 -361
  205. data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +0 -260
  206. data/app/views/alchemy/admin/contents/create.js.coffee +0 -49
  207. data/app/views/alchemy/admin/elements/fold.js.coffee +0 -37
  208. data/app/views/alchemy/admin/essence_pictures/destroy.js.coffee +0 -19
  209. data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +0 -16
  210. data/app/views/alchemy/admin/pictures/update.js.erb +0 -3
  211. data/spec/dummy/config/locales/en.yml +0 -5
  212. data/spec/dummy/config/locales/fo.yml +0 -5
  213. data/spec/page_layout_spec.rb +0 -35
  214. data/vendor/assets/javascripts/jquery_plugins/jquery.in-place-edit.js +0 -172
  215. data/vendor/assets/javascripts/jquery_plugins/jquery.sb.min.js +0 -14
@@ -1,9 +1,10 @@
1
1
  module Alchemy
2
2
  class UserSessionsController < Alchemy::BaseController
3
3
 
4
+ before_filter :set_translation
4
5
  before_filter :check_user_count, :only => :login
5
6
 
6
- layout 'alchemy/login'
7
+ layout 'alchemy/admin'
7
8
 
8
9
  helper 'Alchemy::Admin::Base'
9
10
 
@@ -30,8 +31,6 @@ module Alchemy
30
31
  else
31
32
  if request.get?
32
33
  @user_session = UserSession.new()
33
- @user_roles = User::ROLES.map { |role| [User.human_rolename(role), role] }
34
- @user_genders = User.genders_for_select
35
34
  flash.now[:info] = params[:message] || t("welcome_please_identify_notice")
36
35
  else
37
36
  @user_session = UserSession.new(params[:alchemy_user_session])
@@ -51,7 +50,6 @@ module Alchemy
51
50
  end
52
51
 
53
52
  def leave
54
- ::I18n.locale = current_user.try(:language)
55
53
  render :layout => false
56
54
  end
57
55
 
@@ -23,12 +23,12 @@ module Alchemy
23
23
  # :overflow [Boolean] # Should the dialog have overlapping content. If not, it shows scrollbars. Good for select boxes. Default false.
24
24
  # :resizable [Boolean] # Is the dialog window resizable? Default false.
25
25
  # :modal [Boolean] # Show as modal window. Default true.
26
- # :overflow [Boolean] # Should the window show overflowing content? Default false.
26
+ # :overflow [Boolean] # Should the window show overflowing content? Default true.
27
27
  #
28
28
  def link_to_overlay_window(content, url, options={}, html_options={})
29
29
  default_options = {
30
30
  :modal => true,
31
- :overflow => false,
31
+ :overflow => true,
32
32
  :resizable => false
33
33
  }
34
34
  options = default_options.merge(options)
@@ -121,7 +121,7 @@ module Alchemy
121
121
  def link_to_confirmation_window(link_string = "", message = "", url = "", html_options = {})
122
122
  link_to(link_string, url,
123
123
  html_options.merge(
124
- 'data-alchemy-confirm' => {
124
+ 'data-alchemy-confirm-delete' => {
125
125
  :title => t("please_confirm"),
126
126
  :message => message,
127
127
  :ok_label => t("Yes"),
@@ -334,7 +334,7 @@ module Alchemy
334
334
  # :overlay_options [Hash] # Overlay options. See link_to_overlay_window helper.
335
335
  # :if_permitted_to [Array] # Check permission for button. [:action, :controller]. Exactly how you defined the permission in your +authorization_rules.rb+. Defaults to controller and action from button url.
336
336
  # :skip_permission_check [Boolean] # Skip the permission check. Default false. NOT RECOMMENDED!
337
- # :loading_indicator [Boolean] # Shows the please wait overlay while loading. Only for buttons not opening an overlay window. Default true.
337
+ # :loading_indicator [Boolean] # Shows the please wait overlay while loading. Default false.
338
338
  #
339
339
  def toolbar_button(options = {})
340
340
  options.symbolize_keys!
@@ -344,25 +344,25 @@ module Alchemy
344
344
  :active => false,
345
345
  :link_options => {},
346
346
  :overlay_options => {},
347
- :loading_indicator => true
347
+ :loading_indicator => false
348
348
  }
349
349
  options = defaults.merge(options)
350
350
  button = content_tag('div', :class => 'button_with_label' + (options[:active] ? ' active' : '')) do
351
351
  link = if options[:overlay]
352
- link_to_overlay_window(
353
- render_icon(options[:icon]),
354
- options[:url],
355
- options[:overlay_options],
356
- {
357
- :class => 'icon_button',
358
- :title => options[:title]
359
- }
360
- )
361
- else
362
- link_to options[:url], {:class => "icon_button#{options[:loading_indicator] ? ' please_wait' : nil}", :title => options[:title]}.merge(options[:link_options]) do
363
- render_icon(options[:icon])
364
- end
365
- end
352
+ link_to_overlay_window(
353
+ render_icon(options[:icon]),
354
+ options[:url],
355
+ options[:overlay_options],
356
+ {
357
+ :class => 'icon_button',
358
+ :title => options[:title]
359
+ }
360
+ )
361
+ else
362
+ link_to options[:url], {:class => "icon_button#{options[:loading_indicator] ? nil : ' please_wait'}", :title => options[:title]}.merge(options[:link_options]) do
363
+ render_icon(options[:icon])
364
+ end
365
+ end
366
366
  link += content_tag('label', options[:label])
367
367
  end
368
368
  if options[:skip_permission_check]
@@ -454,6 +454,85 @@ module Alchemy
454
454
  }.merge(html_options))
455
455
  end
456
456
 
457
+ # Merges the params-hash with the given hash
458
+ def merge_params(p={})
459
+ params.merge(p).delete_if { |k, v| v.blank? }
460
+ end
461
+
462
+ # Deletes one or several params from the params-hash and merges some new params in
463
+ def merge_params_without(excludes, p={})
464
+ current_params = params.clone.symbolize_keys
465
+ if excludes.is_a?(Array)
466
+ excludes.map { |i| current_params.delete(i.to_sym) }
467
+ else
468
+ current_params.delete(excludes.to_sym)
469
+ end
470
+ current_params.merge(p).delete_if { |k, v| v.blank? }
471
+ end
472
+
473
+ # Deletes all params from the params-hash except the given ones and merges some new params in
474
+ def merge_params_only(includes, p={})
475
+ current_params = params.clone.symbolize_keys
476
+ if includes.is_a?(Array)
477
+ symbolized_includes = includes.map(&:to_sym)
478
+ current_params.delete_if { |k, v| !symbolized_includes.include?(k) }
479
+ else
480
+ current_params.delete_if { |k, v| k != includes.to_sym }
481
+ end
482
+ current_params.merge(p).delete_if { |k, v| v.blank? }
483
+ end
484
+
485
+ # Checks if the pictures tag-filter contains the given tag
486
+ def pictures_filtered_by_tag?(tag)
487
+ if params[:tagged_with].present?
488
+ tags = params[:tagged_with].split(',')
489
+ tags.include?(tag.name)
490
+ else
491
+ false
492
+ end
493
+ end
494
+
495
+ # Adds the given tag to the pictures tag-filter
496
+ def add_to_picture_tag_filter(tag)
497
+ if params[:tagged_with].present?
498
+ tags = params[:tagged_with].split(',')
499
+ tags << tag.name
500
+ else
501
+ [tag.name]
502
+ end
503
+ end
504
+
505
+ # Removes the given tag from the pictures tag-filter
506
+ def remove_from_picture_tag_filter(tag)
507
+ if params[:tagged_with].present?
508
+ tags = params[:tagged_with].split(',')
509
+ tags.delete_if { |t| t == tag.name }
510
+ else
511
+ []
512
+ end
513
+ end
514
+
515
+ # Returns the picture tag-filter from params.
516
+ # A tag can be added to the filter.
517
+ # A tag can also be removed.
518
+ #
519
+ # Options are:
520
+ # * options (Hash):
521
+ # ** :add (ActsAsTaggableOn::Tag) - The tag that should be added to the tag-filter
522
+ # ** :remove (ActsAsTaggableOn::Tag) - The tag that should be removed from the tag-filter
523
+ def picture_tag_filter(options={})
524
+ case
525
+ when options[:add]
526
+ taglist = add_to_picture_tag_filter(options[:add]) if options[:add]
527
+ when options[:remove]
528
+ taglist = remove_from_picture_tag_filter(options[:remove]) if options[:remove]
529
+ else
530
+ return params[:tagged_with]
531
+ end
532
+ return nil if taglist.blank?
533
+ taglist.uniq.join(',')
534
+ end
535
+
457
536
  end
458
537
  end
459
538
  end
@@ -41,7 +41,7 @@ module Alchemy
41
41
  render_icon(:create) + t('add new content'),
42
42
  alchemy.new_admin_element_content_path(element),
43
43
  {
44
- :size => '335x70',
44
+ :size => '310x115',
45
45
  :title => t('Select an content'),
46
46
  :overflow => true
47
47
  },
@@ -90,7 +90,7 @@ module Alchemy
90
90
  :method => :post,
91
91
  :remote => true,
92
92
  :id => "add_content_for_element_#{element.id}",
93
- :class => 'button new_content_link'
93
+ :class => 'button with_icon new_content_link'
94
94
  )
95
95
  end
96
96
 
@@ -52,11 +52,10 @@ module Alchemy
52
52
  :grouped => true
53
53
  }
54
54
  options = default_options.merge(options)
55
- picture_contents = element.contents.where(:essence_type => "Alchemy::EssencePicture")
56
55
  render(
57
- :partial => "alchemy/admin/elements/picture_editor",
56
+ :partial => "alchemy/admin/elements/picture_gallery_editor",
58
57
  :locals => {
59
- :picture_contents => picture_contents,
58
+ :pictures => element.contents.gallery_pictures,
60
59
  :element => element,
61
60
  :options => options
62
61
  }
@@ -7,13 +7,14 @@ module Alchemy
7
7
  text.truncate(:length => length)
8
8
  end
9
9
 
10
- # Returns @current_language set in the action (e.g. Page.show)
10
+ # Returns @language set in the action (e.g. Page.show)
11
11
  def current_language
12
- if @current_language.nil?
13
- warning('@current_language is not set')
14
- return nil
12
+ ActiveSupport::Deprecation.warn('This Proxy-method is deprecated. Please use @language directly.')
13
+ if @language.nil?
14
+ warning('@language is not set')
15
+ nil
15
16
  else
16
- @current_language
17
+ @language
17
18
  end
18
19
  end
19
20
 
@@ -153,13 +153,13 @@ module Alchemy
153
153
  # Returns a string for the id attribute of a html element for the given element
154
154
  def element_dom_id(element)
155
155
  return "" if element.nil?
156
- "#{element.name}_#{element.id}".html_safe
156
+ "#{element.name}_#{element.id}"
157
157
  end
158
158
 
159
159
  # Renders the data-alchemy-element HTML attribut used for the preview window hover effect.
160
160
  def element_preview_code(element)
161
161
  return "" if element.nil?
162
- " data-alchemy-element='#{element.id}'".html_safe if @preview_mode && element.page == @page
162
+ " data-alchemy-element='#{element.id}'" if @preview_mode && element.page == @page
163
163
  end
164
164
 
165
165
  # Returns the full url containing host, page and anchor for the given element
@@ -129,15 +129,14 @@ module Alchemy
129
129
  # == Options:
130
130
  #
131
131
  # :image_size => "111x93" # Used by EssencePicture to render the image via RMagick to that size. [Default nil]
132
- # :date_format => "Am %d. %m. %Y, um %H:%Mh" # Espacially for EssenceDate. See Rubys Date.strftime for date formatting options. [Default nil]
133
- # :caption => true # Pass Boolean to enable/disable the EssencePicture.caption. [Default true]
134
- # :blank_value => "Not found" # Pass a String that gets rendered if the content.essence is blank. [Default nil]
132
+ # :date_format => "Am %d. %m. %Y, um %H:%Mh" # Especially for EssenceDate. See Rubys Date.strftime for date formatting options. [Default nil]
133
+ # :show_caption => true # Pass Boolean to show/hide the caption of an EssencePicture. [Default true]
135
134
  #
136
135
  def render_essence_view(content, options = {}, html_options = {})
137
136
  defaults = {
138
- :caption => true
137
+ :show_caption => true
139
138
  }
140
- render_essence(content, :view, {:for_view => options}, html_options)
139
+ render_essence(content, :view, {:for_view => defaults.update(options)}, html_options)
141
140
  end
142
141
 
143
142
  end
@@ -4,6 +4,7 @@ module Alchemy
4
4
  include Alchemy::BaseHelper
5
5
  include Alchemy::ElementsHelper
6
6
  include Alchemy::PicturesHelper
7
+ include Alchemy::UrlHelper
7
8
 
8
9
  def render_classes(classes=[])
9
10
  s = classes.uniq.delete_if { |x| x.blank? }.join(" ")
@@ -49,7 +50,7 @@ module Alchemy
49
50
  return nil if (pages.blank? || pages.length == 1)
50
51
  pages.each_with_index do |page, i|
51
52
  if (options[:link_to_page_with_layout] != nil)
52
- page_found_by_layout = Page.where(:page_layout => options[:link_to_page_with_layout].to_s, :language_id => page.language_id)
53
+ page_found_by_layout = Page.where(:page_layout => options[:link_to_page_with_layout].to_s, :language_id => page.language_id).first
53
54
  end
54
55
  page = page_found_by_layout || page
55
56
  page = (options[:link_to_public_child] ? (page.first_public_child.blank? ? nil : page.first_public_child) : nil) if !page.public?
@@ -91,7 +92,6 @@ module Alchemy
91
92
  nil
92
93
  end
93
94
  end
94
-
95
95
  alias_method :language_switches, :language_switcher
96
96
 
97
97
  # Renders the layout from @page.page_layout. File resists in /app/views/page_layouts/_LAYOUT-NAME.html.erb
@@ -256,7 +256,8 @@ module Alchemy
256
256
  :public_only => true,
257
257
  :visible_only => true,
258
258
  :restricted_only => false,
259
- :reverse => false
259
+ :reverse => false,
260
+ :link_active_page => false
260
261
  }
261
262
  options = default_options.merge(options)
262
263
  pages = breadcrumb(options[:page])
@@ -288,7 +289,11 @@ module Alchemy
288
289
  elsif page == pages.first
289
290
  css_class = css_class.blank? ? "first" : [css_class, "first"].join(" ")
290
291
  end
291
- bc << link_to(h(page.name), show_alchemy_page_path(page), :class => css_class, :title => page.title)
292
+ if !options[:link_active_page] && page.name == @page.name
293
+ bc << content_tag(:span, h(page.name), :class => css_class)
294
+ else
295
+ bc << link_to(h(page.name), show_alchemy_page_path(page), :class => css_class, :title => page.title)
296
+ end
292
297
  end
293
298
  bc.join(options[:seperator]).html_safe
294
299
  end
@@ -409,30 +414,6 @@ module Alchemy
409
414
  return meta_string.html_safe
410
415
  end
411
416
 
412
- # This helper returns a path for use inside a link_to helper.
413
- #
414
- # You may pass a page_layout or an urlname.
415
- # Any additional options are passed to the url_helper, so you can add arguments to your url.
416
- #
417
- # Example:
418
- #
419
- # <%= link_to '&raquo order now', page_path_for(:page_layout => 'orderform', :product_id => element.id) %>
420
- #
421
- def page_path_for(options={})
422
- return warning("No page_layout, or urlname given. I got #{options.inspect} ") if options[:page_layout].blank? && options[:urlname].blank?
423
- if options[:urlname].blank?
424
- page = Page.find_by_page_layout(options[:page_layout])
425
- if page.blank?
426
- warning("No page found for #{options.inspect} ")
427
- return
428
- end
429
- urlname = page.urlname
430
- else
431
- urlname = options[:urlname]
432
- end
433
- alchemy.show_page_path({:urlname => urlname, :lang => multi_language? ? session[:language_code] : nil}.merge(options.except(:page_layout, :urlname, :lang)))
434
- end
435
-
436
417
  # Renders the partial for the cell with the given name of the current page.
437
418
  # Cell partials are located in +app/views/cells/+ of your project.
438
419
  #
@@ -467,68 +448,23 @@ module Alchemy
467
448
  # Renders the search form
468
449
  def render_search_form(options={})
469
450
  default_options = {
470
- :page => @search_result_page,
471
- :html5 => false,
472
- :button_value => t("search"),
473
- :button_class => nil
451
+ :html5 => false
474
452
  }
475
- options = default_options.merge(options)
476
- if options[:page].class.name != "Alchemy::Page"
477
- warning("No page found for #{options[:page].inspect}")
453
+ if @search_result_page.blank?
454
+ warning("No search result page found")
478
455
  return
479
456
  end
480
- form_tag(show_alchemy_page_path(options[:page]), :method => :get, :class => 'fulltext_search') do
481
- if options[:html5]
482
- search_field_tag(:query, params[:query])
483
- else
484
- text_field_tag(:query, params[:query]) + submit_tag(options[:button_value], :class => options[:button_class], :name => nil)
485
- end
486
- end
457
+ render :partial => 'alchemy/search/form', :locals => {:options => default_options.merge(options)}
487
458
  end
488
459
 
489
- # Renders the search-results
460
+ # Renders the search +results+ partial from +app/views/alchemy/search/+
490
461
  def render_search_results(options={})
491
462
  default_options = {
492
- :partial => 'alchemy/search/result',
493
463
  :show_language => true,
494
464
  :show_result_count => true,
495
465
  :show_heading => true
496
466
  }
497
- options = default_options.merge(options)
498
- return content_tag :h2, t('search_result_page.no_results'), :class => 'no_search_results' if @search_results.blank?
499
- results = ""
500
- @search_results.each do |essence|
501
- result = essence.highlight(
502
- "*#{params[:query]}*", {
503
- :field => (essence.class.name == "Alchemy::EssenceRichtext" ? :stripped_body : :body)
504
- })
505
- results << render(:partial => options[:partial], :locals => {:result => result, :options => options, :page => essence.page}) if essence.page
506
- end
507
- output = ""
508
- output << content_tag(:h1, t("search_result_page.result_heading", :query => h(params[:query])), :class => 'search_results_heading') if options[:show_heading]
509
- output << content_tag(:h2, t("search_result_page.result_count", :count => @search_results.length), :class => 'search_result_count') if options[:show_result_count]
510
- output << content_tag(:ul, results.html_safe, :class => 'search_result_list')
511
- content_tag :div, :class => 'search_results' do
512
- output.html_safe
513
- end
514
- end
515
-
516
- # Returns the correct params-hash for passing to show_page_path
517
- def show_page_path_params(page, optional_params={})
518
- url_params = {:level1 => nil, :level2 => nil, :level3 => nil, :urlname => page.urlname}
519
- url_params.update(optional_params)
520
- url_params.update(params_for_nested_url(page)) if configuration(:url_nesting)
521
- return multi_language? ? url_params.update(:lang => page.language_code) : url_params
522
- end
523
-
524
- #
525
- def show_alchemy_page_path(page, optional_params={})
526
- alchemy.show_page_path(show_page_path_params(page, optional_params))
527
- end
528
-
529
- #
530
- def show_alchemy_page_url(page, optional_params={})
531
- alchemy.show_page_url(show_page_path_params(page, optional_params))
467
+ render 'alchemy/search/results', :options => default_options.merge(options)
532
468
  end
533
469
 
534
470
  # Renders a menubar for logged in users that are visiting a page.
@@ -0,0 +1,67 @@
1
+ # Alchemy url helpers
2
+ #
3
+ # This helper is included within alchemy/pages_helper
4
+ #
5
+ module Alchemy
6
+ module UrlHelper
7
+
8
+ # Returns the correct params-hash for passing to show_page_path
9
+ def show_page_path_params(page, optional_params={})
10
+ url_params = {:level1 => nil, :level2 => nil, :level3 => nil, :urlname => page.urlname}
11
+ url_params.update(optional_params)
12
+ url_params.update(params_for_nested_url(page)) if configuration(:url_nesting)
13
+ multi_language? ? url_params.update(:lang => page.language_code) : url_params
14
+ end
15
+
16
+ # Returns the path for rendering an alchemy page
17
+ def show_alchemy_page_path(page, optional_params={})
18
+ alchemy.show_page_path(show_page_path_params(page, optional_params))
19
+ end
20
+
21
+ # Returns the url for rendering an alchemy page
22
+ def show_alchemy_page_url(page, optional_params={})
23
+ alchemy.show_page_url(show_page_path_params(page, optional_params))
24
+ end
25
+
26
+ # Returns the correct params-hash for passing to show_picture_path
27
+ def show_picture_path_params(picture, optional_params={})
28
+ url_params = {:id => picture.id, :name => picture.urlname, :format => configuration(:image_output_format)}
29
+ url_params.update(optional_params.update({:crop => optional_params[:crop] ? 'crop' : nil}))
30
+ end
31
+
32
+ # Returns the path for rendering an alchemy picture
33
+ def show_alchemy_picture_path(picture, optional_params={})
34
+ alchemy.show_picture_path(show_picture_path_params(picture, optional_params))
35
+ end
36
+
37
+ # Returns the url for rendering an alchemy picture
38
+ def show_alchemy_picture_url(picture, optional_params={})
39
+ alchemy.show_picture_url(show_picture_path_params(picture, optional_params))
40
+ end
41
+
42
+ # This helper returns a path for use inside a link_to helper.
43
+ #
44
+ # You may pass a page_layout or an urlname.
45
+ # Any additional options are passed to the url_helper, so you can add arguments to your url.
46
+ #
47
+ # Example:
48
+ #
49
+ # <%= link_to '&raquo order now', page_path_for(:page_layout => 'orderform', :product_id => element.id) %>
50
+ #
51
+ def page_path_for(options={})
52
+ return warning("No page_layout, or urlname given. I got #{options.inspect} ") if options[:page_layout].blank? && options[:urlname].blank?
53
+ if options[:urlname].blank?
54
+ page = Page.find_by_page_layout(options[:page_layout])
55
+ if page.blank?
56
+ warning("No page found for #{options.inspect} ")
57
+ return
58
+ end
59
+ urlname = page.urlname
60
+ else
61
+ urlname = options[:urlname]
62
+ end
63
+ alchemy.show_page_path({:urlname => urlname, :lang => multi_language? ? session[:language_code] : nil}.merge(options.except(:page_layout, :urlname, :lang)))
64
+ end
65
+
66
+ end
67
+ end