alchemy_cms 4.0.0.beta → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -7
  3. data/CHANGELOG.md +23 -0
  4. data/README.md +1 -1
  5. data/alchemy_cms.gemspec +1 -1
  6. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +2 -2
  7. data/app/assets/stylesheets/alchemy/_extends.scss +3 -5
  8. data/app/assets/stylesheets/alchemy/_mixins.scss +1 -1
  9. data/app/assets/stylesheets/alchemy/base.scss +2 -2
  10. data/app/assets/stylesheets/alchemy/buttons.scss +2 -2
  11. data/app/assets/stylesheets/alchemy/dialogs.scss +3 -3
  12. data/app/assets/stylesheets/alchemy/elements.scss +2 -2
  13. data/app/assets/stylesheets/alchemy/image_library.scss +10 -10
  14. data/app/assets/stylesheets/alchemy/jquery.datetimepicker.scss +2 -2
  15. data/app/assets/stylesheets/alchemy/lists.scss +2 -1
  16. data/app/assets/stylesheets/alchemy/sitemap.scss +1 -16
  17. data/app/assets/stylesheets/alchemy/tables.scss +1 -1
  18. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +4 -4
  19. data/app/controllers/alchemy/admin/attachments_controller.rb +10 -10
  20. data/app/controllers/alchemy/admin/base_controller.rb +10 -19
  21. data/app/controllers/alchemy/admin/clipboard_controller.rb +20 -7
  22. data/app/controllers/alchemy/admin/contents_controller.rb +5 -19
  23. data/app/controllers/alchemy/admin/dashboard_controller.rb +5 -3
  24. data/app/controllers/alchemy/admin/elements_controller.rb +7 -1
  25. data/app/controllers/alchemy/admin/essence_files_controller.rb +2 -2
  26. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +8 -13
  27. data/app/controllers/alchemy/admin/languages_controller.rb +2 -0
  28. data/app/controllers/alchemy/admin/layoutpages_controller.rb +2 -0
  29. data/app/controllers/alchemy/admin/legacy_page_urls_controller.rb +2 -0
  30. data/app/controllers/alchemy/admin/pages_controller.rb +3 -1
  31. data/app/controllers/alchemy/admin/pictures_controller.rb +11 -9
  32. data/app/controllers/alchemy/admin/resources_controller.rb +25 -4
  33. data/app/controllers/alchemy/admin/sites_controller.rb +2 -0
  34. data/app/controllers/alchemy/admin/tags_controller.rb +2 -0
  35. data/app/controllers/alchemy/admin/trash_controller.rb +2 -0
  36. data/app/controllers/alchemy/api/base_controller.rb +2 -0
  37. data/app/controllers/alchemy/api/contents_controller.rb +2 -0
  38. data/app/controllers/alchemy/api/elements_controller.rb +2 -0
  39. data/app/controllers/alchemy/api/pages_controller.rb +2 -0
  40. data/app/controllers/alchemy/attachments_controller.rb +2 -0
  41. data/app/controllers/alchemy/base_controller.rb +3 -1
  42. data/app/controllers/alchemy/elements_controller.rb +2 -0
  43. data/app/controllers/alchemy/messages_controller.rb +2 -0
  44. data/app/controllers/alchemy/pages_controller.rb +11 -2
  45. data/app/controllers/concerns/alchemy/admin/uploader_responses.rb +2 -0
  46. data/app/controllers/concerns/alchemy/legacy_page_redirects.rb +2 -0
  47. data/app/controllers/concerns/alchemy/locale_redirects.rb +2 -0
  48. data/app/controllers/concerns/alchemy/page_redirects.rb +2 -0
  49. data/app/controllers/concerns/alchemy/site_redirects.rb +2 -0
  50. data/app/helpers/alchemy/admin/attachments_helper.rb +2 -0
  51. data/app/helpers/alchemy/admin/base_helper.rb +2 -28
  52. data/app/helpers/alchemy/admin/contents_helper.rb +2 -0
  53. data/app/helpers/alchemy/admin/elements_helper.rb +2 -0
  54. data/app/helpers/alchemy/admin/essences_helper.rb +2 -0
  55. data/app/helpers/alchemy/admin/form_helper.rb +2 -0
  56. data/app/helpers/alchemy/admin/navigation_helper.rb +2 -0
  57. data/app/helpers/alchemy/admin/pages_helper.rb +2 -0
  58. data/app/helpers/alchemy/admin/pictures_helper.rb +2 -0
  59. data/app/helpers/alchemy/admin/tags_helper.rb +24 -76
  60. data/app/helpers/alchemy/base_helper.rb +2 -0
  61. data/app/helpers/alchemy/deprecated_pages_helper.rb +2 -0
  62. data/app/helpers/alchemy/elements_block_helper.rb +2 -0
  63. data/app/helpers/alchemy/elements_helper.rb +2 -0
  64. data/app/helpers/alchemy/essences_helper.rb +2 -0
  65. data/app/helpers/alchemy/pages_helper.rb +2 -0
  66. data/app/helpers/alchemy/url_helper.rb +2 -0
  67. data/app/mailers/alchemy/base_mailer.rb +2 -0
  68. data/app/mailers/alchemy/messages_mailer.rb +2 -0
  69. data/app/models/alchemy.rb +2 -0
  70. data/app/models/alchemy/attachment.rb +6 -4
  71. data/app/models/alchemy/cell.rb +4 -2
  72. data/app/models/alchemy/content.rb +7 -5
  73. data/app/models/alchemy/content/factory.rb +7 -7
  74. data/app/models/alchemy/element.rb +21 -28
  75. data/app/models/alchemy/element/definitions.rb +4 -2
  76. data/app/models/alchemy/element/element_contents.rb +3 -1
  77. data/app/models/alchemy/element/element_essences.rb +2 -0
  78. data/app/models/alchemy/element/presenters.rb +2 -0
  79. data/app/models/alchemy/element_to_page.rb +2 -0
  80. data/app/models/alchemy/essence_boolean.rb +2 -0
  81. data/app/models/alchemy/essence_date.rb +2 -0
  82. data/app/models/alchemy/essence_file.rb +2 -0
  83. data/app/models/alchemy/essence_html.rb +2 -0
  84. data/app/models/alchemy/essence_link.rb +6 -4
  85. data/app/models/alchemy/essence_picture.rb +13 -11
  86. data/app/models/alchemy/essence_picture_view.rb +2 -0
  87. data/app/models/alchemy/essence_richtext.rb +2 -0
  88. data/app/models/alchemy/essence_select.rb +3 -1
  89. data/app/models/alchemy/essence_text.rb +6 -4
  90. data/app/models/alchemy/folded_page.rb +4 -2
  91. data/app/models/alchemy/language.rb +9 -6
  92. data/app/models/alchemy/language/code.rb +2 -0
  93. data/app/models/alchemy/legacy_page_url.rb +3 -1
  94. data/app/models/alchemy/message.rb +2 -0
  95. data/app/models/alchemy/page.rb +3 -2
  96. data/app/models/alchemy/page/fixed_attributes.rb +2 -0
  97. data/app/models/alchemy/page/page_cells.rb +2 -0
  98. data/app/models/alchemy/page/page_elements.rb +3 -1
  99. data/app/models/alchemy/page/page_naming.rb +2 -0
  100. data/app/models/alchemy/page/page_natures.rb +2 -1
  101. data/app/models/alchemy/page/page_scopes.rb +2 -0
  102. data/app/models/alchemy/page/page_users.rb +2 -0
  103. data/app/models/alchemy/picture.rb +2 -0
  104. data/app/models/alchemy/picture/transformations.rb +2 -0
  105. data/app/models/alchemy/picture/url.rb +2 -0
  106. data/app/models/alchemy/site.rb +4 -2
  107. data/app/models/alchemy/site/layout.rb +2 -0
  108. data/app/models/alchemy/tag.rb +5 -2
  109. data/app/models/alchemy/tree_node.rb +2 -0
  110. data/app/serializers/alchemy/attachment_serializer.rb +2 -0
  111. data/app/serializers/alchemy/base_serializer.rb +2 -0
  112. data/app/serializers/alchemy/cell_serializer.rb +2 -0
  113. data/app/serializers/alchemy/content_serializer.rb +2 -0
  114. data/app/serializers/alchemy/element_serializer.rb +2 -0
  115. data/app/serializers/alchemy/essence_boolean_serializer.rb +2 -0
  116. data/app/serializers/alchemy/essence_date_serializer.rb +2 -0
  117. data/app/serializers/alchemy/essence_file_serializer.rb +2 -0
  118. data/app/serializers/alchemy/essence_html_serializer.rb +2 -0
  119. data/app/serializers/alchemy/essence_link_serializer.rb +2 -0
  120. data/app/serializers/alchemy/essence_picture_serializer.rb +2 -0
  121. data/app/serializers/alchemy/essence_richtext_serializer.rb +2 -0
  122. data/app/serializers/alchemy/essence_select_serializer.rb +2 -0
  123. data/app/serializers/alchemy/essence_text_serializer.rb +2 -0
  124. data/app/serializers/alchemy/legacy_element_serializer.rb +2 -0
  125. data/app/serializers/alchemy/page_serializer.rb +2 -0
  126. data/app/serializers/alchemy/page_tree_serializer.rb +2 -0
  127. data/app/serializers/alchemy/picture_serializer.rb +2 -0
  128. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +1 -1
  129. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +1 -1
  130. data/app/views/alchemy/admin/attachments/_filter_bar.html.erb +1 -3
  131. data/app/views/alchemy/admin/attachments/_tag_list.html.erb +1 -1
  132. data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
  133. data/app/views/alchemy/admin/contents/create.js.erb +9 -13
  134. data/app/views/alchemy/admin/contents/new.html.erb +1 -1
  135. data/app/views/alchemy/admin/elements/_picture_gallery_editor.html.erb +4 -4
  136. data/app/views/alchemy/admin/essence_files/assign.js.erb +1 -1
  137. data/app/views/alchemy/admin/essence_pictures/assign.js.erb +1 -1
  138. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -1
  139. data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +10 -7
  140. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +8 -6
  141. data/app/views/alchemy/admin/essence_pictures/update.js.erb +1 -1
  142. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +2 -2
  143. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +4 -4
  144. data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +1 -3
  145. data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +1 -1
  146. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  147. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +1 -1
  148. data/app/views/alchemy/admin/resources/_filter_bar.html.erb +1 -3
  149. data/app/views/alchemy/admin/resources/_tag_list.html.erb +1 -1
  150. data/app/views/alchemy/admin/uploader/_button.html.erb +1 -1
  151. data/app/views/alchemy/essences/_essence_file_editor.html.erb +2 -2
  152. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +2 -2
  153. data/app/views/alchemy/essences/shared/_essence_picture_tools.html.erb +3 -3
  154. data/app/views/alchemy/navigation/_renderer.html.erb +1 -2
  155. data/config/brakeman.ignore +65 -0
  156. data/db/migrate/20130827094554_alchemy_two_point_six.rb +1 -1
  157. data/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +1 -1
  158. data/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +1 -1
  159. data/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +1 -1
  160. data/db/migrate/20150608204610_add_parent_element_id_to_alchemy_elements.rb +1 -1
  161. data/db/migrate/20150729151825_add_link_text_to_alchemy_essence_files.rb +1 -1
  162. data/db/migrate/20150906195818_add_locale_to_alchemy_languages.rb +1 -1
  163. data/db/migrate/20160108174834_add_timebased_publishing_columns_to_pages.rb +1 -1
  164. data/db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb +1 -1
  165. data/db/migrate/20160617224938_change_alchemy_pages_locked_to_locked_at.rb +1 -1
  166. data/db/migrate/20160912223112_add_index_to_alchemy_pages_rgt.rb +1 -1
  167. data/db/migrate/20160927205604_add_foreign_key_indices_and_null_constraints.rb +1 -1
  168. data/db/migrate/20160928080104_add_foreign_keys.rb +1 -1
  169. data/lib/alchemy/ability_helper.rb +2 -0
  170. data/lib/alchemy/admin/locale.rb +2 -0
  171. data/lib/alchemy/auth_accessors.rb +2 -0
  172. data/lib/alchemy/cache_digests/template_tracker.rb +2 -0
  173. data/lib/alchemy/config.rb +2 -0
  174. data/lib/alchemy/configuration_methods.rb +2 -0
  175. data/lib/alchemy/controller_actions.rb +2 -0
  176. data/lib/alchemy/deprecation.rb +3 -0
  177. data/lib/alchemy/errors.rb +2 -0
  178. data/lib/alchemy/essence.rb +2 -0
  179. data/lib/alchemy/filetypes.rb +2 -0
  180. data/lib/alchemy/forms/builder.rb +2 -0
  181. data/lib/alchemy/hints.rb +2 -0
  182. data/lib/alchemy/i18n.rb +2 -0
  183. data/lib/alchemy/logger.rb +2 -0
  184. data/lib/alchemy/modules.rb +2 -0
  185. data/lib/alchemy/name_conversions.rb +2 -0
  186. data/lib/alchemy/on_page_layout.rb +2 -0
  187. data/lib/alchemy/on_page_layout/callbacks_runner.rb +2 -0
  188. data/lib/alchemy/page_layout.rb +3 -1
  189. data/lib/alchemy/paths.rb +2 -0
  190. data/lib/alchemy/permissions.rb +2 -0
  191. data/lib/alchemy/picture_attributes.rb +2 -0
  192. data/lib/alchemy/resource.rb +2 -0
  193. data/lib/alchemy/resources_helper.rb +14 -12
  194. data/lib/alchemy/routing_constraints.rb +2 -0
  195. data/lib/alchemy/ssl_protection.rb +2 -0
  196. data/lib/alchemy/test_support/controller_requests.rb +20 -0
  197. data/lib/alchemy/test_support/essence_shared_examples.rb +3 -21
  198. data/lib/alchemy/tinymce.rb +2 -0
  199. data/lib/alchemy/touching.rb +2 -0
  200. data/lib/alchemy/upgrader/three_point_four.rb +20 -3
  201. data/lib/alchemy/userstamp.rb +2 -0
  202. data/lib/alchemy/version.rb +3 -1
  203. data/lib/alchemy_cms.rb +1 -0
  204. data/lib/tasks/alchemy/upgrade.rake +5 -1
  205. metadata +7 -5
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  class ElementsController < Alchemy::BaseController
3
5
  load_and_authorize_resource
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  #
3
5
  # == Sending Messages:
@@ -1,5 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  class PagesController < Alchemy::BaseController
5
+ SHOW_PAGE_PARAMS_KEYS = [
6
+ 'action',
7
+ 'controller',
8
+ 'urlname',
9
+ 'locale'
10
+ ]
11
+
3
12
  include OnPageLayout::CallbacksRunner
4
13
 
5
14
  # Redirecting concerns. Order is important here!
@@ -124,8 +133,8 @@ module Alchemy
124
133
  # * locale
125
134
  #
126
135
  def additional_params
127
- params.symbolize_keys.delete_if do |key, _|
128
- [:action, :controller, :urlname, :locale].include?(key)
136
+ params.to_unsafe_hash.delete_if do |key, _|
137
+ SHOW_PAGE_PARAMS_KEYS.include?(key)
129
138
  end
130
139
  end
131
140
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  module UploaderResponses
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  # Handles Legacy page redirects
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  # Handles locale redirects
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  # Handles page redirect urls
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module SiteRedirects
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  module AttachmentsHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  # This module contains helper methods for rendering dialogs, toolbar buttons and confirmation windows.
@@ -378,34 +380,6 @@ module Alchemy
378
380
  method.to_sym, {type: "text", class: type, "data-datepicker-type" => type, value: value}.merge(html_options)
379
381
  end
380
382
 
381
- # Merges the params-hash with the given hash
382
- def merge_params(p = {})
383
- params.merge(p).delete_if { |_k, v| v.blank? }
384
- end
385
-
386
- # Deletes one or several params from the params-hash and merges some new params in
387
- def merge_params_without(excludes, p = {})
388
- current_params = params.clone.symbolize_keys
389
- if excludes.is_a?(Array)
390
- excludes.map { |i| current_params.delete(i.to_sym) }
391
- else
392
- current_params.delete(excludes.to_sym)
393
- end
394
- current_params.merge(p).delete_if { |_k, v| v.blank? }
395
- end
396
-
397
- # Deletes all params from the params-hash except the given ones and merges some new params in
398
- def merge_params_only(includes, p = {})
399
- current_params = params.clone.symbolize_keys
400
- if includes.is_a?(Array)
401
- symbolized_includes = includes.map(&:to_sym)
402
- current_params.delete_if { |k, _v| !symbolized_includes.include?(k) }
403
- else
404
- current_params.delete_if { |k, _v| k != includes.to_sym }
405
- end
406
- current_params.merge(p).delete_if { |_k, v| v.blank? }
407
- end
408
-
409
383
  # Render a hint icon with tooltip for given object.
410
384
  # The model class needs to include the hints module
411
385
  def render_hint_for(element)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  module ContentsHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  module ElementsHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  module EssencesHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  module FormHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  # This module contains helper methods for rendering the admin navigation.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  module PagesHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  module PicturesHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module Admin
3
5
  module TagsHelper
@@ -11,102 +13,48 @@ module Alchemy
11
13
  #
12
14
  def render_tag_list(class_name)
13
15
  raise ArgumentError, 'Please provide a String as class_name' if class_name.nil?
14
- li_s = []
15
- class_name.constantize.tag_counts.sort { |x, y| x.name.downcase <=> y.name.downcase }.each do |tag|
16
- tags = filtered_by_tag?(tag) ? tag_filter(remove: tag) : tag_filter(add: tag)
17
- li_s << content_tag('li', name: tag.name, class: tag_list_tag_active?(tag) ? 'active' : nil) do
16
+ sorted_tags_from(class_name: class_name).map do |tag|
17
+ content_tag('li', name: tag.name, class: filtered_by_tag?(tag) ? 'active' : nil) do
18
18
  link_to(
19
19
  "#{tag.name} (#{tag.count})",
20
20
  url_for(
21
- tag_list_params.reject { |k, _v| k == "page" }.merge(
22
- action: 'index',
23
- tagged_with: tags
21
+ search_filter_params.except(:page, :tagged_with).merge(
22
+ tagged_with: tags_for_filter(current: tag).presence
24
23
  )
25
24
  ),
26
25
  remote: request.xhr?,
27
26
  class: 'please_wait'
28
27
  )
29
28
  end
30
- end
31
- li_s.join.html_safe
29
+ end.join.html_safe
32
30
  end
33
31
 
34
- # Returns true if the given tag is in +params[:tag_list]+
35
- #
36
- # @param tag [ActsAsTaggableOn::Tag]
37
- # the tag
38
- # @param params [Hash]
39
- # url params
40
- # @return [Boolean]
32
+ # Returns true if the given tag is in +params[:tagged_with]+
41
33
  #
42
- def tag_list_tag_active?(tag)
43
- tag_list_params[:tagged_with].to_s.split(',').include?(tag.name)
44
- end
45
-
46
- # Checks if the tagged_with param contains the given tag
47
34
  def filtered_by_tag?(tag)
48
- if tag_list_params[:tagged_with].present?
49
- tags = tag_list_params[:tagged_with].split(',')
50
- tags.include?(tag.name)
51
- else
52
- false
53
- end
35
+ tags_from_params.include?(tag.name)
54
36
  end
55
37
 
56
- # Adds the given tag to the tag filter.
57
- def add_to_tag_filter(tag)
58
- if tag_list_params[:tagged_with].present?
59
- tags = tag_list_params[:tagged_with].split(',')
60
- tags << tag.name
61
- else
62
- [tag.name]
63
- end
64
- end
65
-
66
- # Removes the given tag from the tag filter.
67
- def remove_from_tag_filter(tag)
68
- if tag_list_params[:tagged_with].present?
69
- tags = tag_list_params[:tagged_with].split(',')
70
- tags.delete_if { |t| t == tag.name }
38
+ # Returns the tags from params suitable for the tags filter.
39
+ #
40
+ # @param current [ActsAsTaggableOn::Tag] - The current tag that will be added or removed if already present
41
+ # @returns [String]
42
+ def tags_for_filter(current:)
43
+ if filtered_by_tag?(current)
44
+ tags_from_params - Array(current.name)
71
45
  else
72
- []
73
- end
46
+ tags_from_params.push(current.name)
47
+ end.uniq.join(',')
74
48
  end
75
49
 
76
- # Returns the tag filter from params.
77
- #
78
- # A tag can be added to the filter.
79
- # A tag can also be removed.
80
- #
81
- # Options are:
82
- # * options (Hash):
83
- # ** :add (ActsAsTaggableOn::Tag) - The tag that should be added to the tag-filter
84
- # ** :remove (ActsAsTaggableOn::Tag) - The tag that should be removed from the tag-filter
85
- #
86
- def tag_filter(options = {})
87
- if options[:add]
88
- taglist = add_to_tag_filter(options[:add])
89
- elsif options[:remove]
90
- taglist = remove_from_tag_filter(options[:remove])
91
- else
92
- return tag_list_params[:tagged_with]
93
- end
94
- return nil if taglist.blank?
95
- taglist.uniq.join(',')
50
+ # Returns tags from params
51
+ # @returns [Array]
52
+ def tags_from_params
53
+ search_filter_params[:tagged_with].to_s.split(',')
96
54
  end
97
55
 
98
- def tag_list_params
99
- params.permit(
100
- :controller,
101
- :content_id,
102
- :element_id,
103
- :options,
104
- :swap,
105
- :use_route,
106
- :tagged_with,
107
- :filter,
108
- q: params.fetch(:q, {}).keys
109
- )
56
+ def sorted_tags_from(class_name:)
57
+ class_name.constantize.tag_counts.sort { |x, y| x.name.downcase <=> y.name.downcase }
110
58
  end
111
59
  end
112
60
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module BaseHelper
3
5
  def _t(key, *args)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module DeprecatedPagesHelper
3
5
  # All these helper methods are deprecated.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  # Provides a collection of block-level helpers, allowing for a much more
3
5
  # concise way of writing element view/editor partials.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  # This helpers are useful to render elements from pages.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  # This helper contains methods to render the +essence+ from an +Element+ +Content+.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  module PagesHelper
3
5
  include Alchemy::BaseHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Alchemy url helpers
2
4
  #
3
5
  # This helper is included within alchemy/pages_helper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  begin
3
5
  base_class = Object.const_get('::ApplicationMailer')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  class MessagesMailer < BaseMailer
3
5
  def contact_form_mail(message, mail_to, mail_from, subject)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  def self.table_name_prefix
3
5
  'alchemy_'
@@ -1,18 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # == Schema Information
2
4
  #
3
5
  # Table name: alchemy_attachments
4
6
  #
5
7
  # id :integer not null, primary key
6
- # name :string(255)
7
- # file_name :string(255)
8
- # file_mime_type :string(255)
8
+ # name :string
9
+ # file_name :string
10
+ # file_mime_type :string
9
11
  # file_size :integer
10
12
  # creator_id :integer
11
13
  # updater_id :integer
12
14
  # created_at :datetime not null
13
15
  # updated_at :datetime not null
14
16
  # cached_tag_list :text
15
- # file_uid :string(255)
17
+ # file_uid :string
16
18
  #
17
19
 
18
20
  module Alchemy
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # == Schema Information
2
4
  #
3
5
  # Table name: alchemy_cells
4
6
  #
5
7
  # id :integer not null, primary key
6
- # page_id :integer
7
- # name :string(255)
8
+ # page_id :integer not null
9
+ # name :string
8
10
  # created_at :datetime not null
9
11
  # updated_at :datetime not null
10
12
  #
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # == Schema Information
2
4
  #
3
5
  # Table name: alchemy_contents
4
6
  #
5
7
  # id :integer not null, primary key
6
- # name :string(255)
7
- # essence_type :string(255)
8
- # essence_id :integer
9
- # element_id :integer
8
+ # name :string
9
+ # essence_type :string not null
10
+ # essence_id :integer not null
11
+ # element_id :integer not null
10
12
  # position :integer
11
13
  # created_at :datetime not null
12
14
  # updated_at :datetime not null
@@ -105,7 +107,7 @@ module Alchemy
105
107
  # Settings from the elements.yml definition
106
108
  def settings
107
109
  return {} if definition.blank?
108
- @settings ||= definition.fetch('settings', {}).symbolize_keys
110
+ @settings ||= definition.fetch(:settings, {})
109
111
  end
110
112
 
111
113
  # Fetches value from settings
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Alchemy
2
4
  # Holds everything concerning the building and creating of contents and the related essence object.
3
5
  #
@@ -31,9 +33,8 @@ module Alchemy
31
33
  # @return [Alchemy::Content]
32
34
  #
33
35
  def create_from_scratch(element, essence_hash)
34
- essence_hash.stringify_keys!
35
36
  if content = build(element, essence_hash)
36
- content.create_essence!(essence_hash['essence_type'])
37
+ content.create_essence!(essence_hash[:essence_type])
37
38
  end
38
39
  content
39
40
  end
@@ -49,7 +50,7 @@ module Alchemy
49
50
  #
50
51
  def copy(source, differences = {})
51
52
  new_content = Content.new(
52
- source.attributes.except(*SKIPPED_ATTRIBUTES_ON_COPY).merge(differences.stringify_keys)
53
+ source.attributes.except(*SKIPPED_ATTRIBUTES_ON_COPY).merge(differences)
53
54
  )
54
55
 
55
56
  new_essence = new_content.essence.class.create!(
@@ -66,12 +67,11 @@ module Alchemy
66
67
  # 2. It builds a definition hash from essence type, if the the name key is not present
67
68
  #
68
69
  def content_definition(element, essence_hash)
69
- essence_hash.stringify_keys!
70
70
  # No name given. We build the content from essence type.
71
- if essence_hash['name'].blank? && essence_hash['essence_type'].present?
72
- content_definition_from_essence_type(element, essence_hash['essence_type'])
71
+ if essence_hash[:name].blank? && essence_hash[:essence_type].present?
72
+ content_definition_from_essence_type(element, essence_hash[:essence_type])
73
73
  else
74
- element.content_definition_for(essence_hash['name'])
74
+ element.content_definition_for(essence_hash[:name])
75
75
  end
76
76
  end
77
77