alchemy_cms 5.1.2 → 5.2.0.b1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of alchemy_cms might be problematic. Click here for more details.

@@ -130,31 +130,45 @@ en:
130
130
  # == Mime Types translations
131
131
  # These are human readable mime types used for the document-type row in archive files.
132
132
  mime_types:
133
- audio/mp4: 'MP4-Audio'
134
- application/msword: 'Word-Document'
135
- application/rtf: 'RTF-Document'
136
- audio/mpeg: 'MP3-Audio'
137
- text/plain: 'Text-Document'
138
- video/mp4: 'MP4-Video'
139
- video/mpeg: 'MPEG-Video'
140
- application/pdf: 'PDF-Document'
141
- application/x-flash-video: 'Flash-Video'
142
- video/x-flv: 'Flash-Video'
143
- application/x-shockwave-flash: 'Flash-Movie'
144
- application/zip: 'ZIP-Archive'
145
- application/x-rar: 'RAR-Archive'
133
+ application/msexcel: Excel Spreadsheet
134
+ application/mspowerpoint: PowerPoint Presentation
135
+ application/msword: Word Document
136
+ application/pdf: PDF Document
137
+ application/rtf: RTF Document
138
+ application/vcard: vCard
146
139
  application/vnd:
147
- ms-excel: 'Excel-Document'
148
- video/quicktime: 'Quicktime-Video'
149
- image/x-psd: 'Photoshop-File'
150
- image/gif: 'GIF-Image'
151
- image/png: 'PNG-Image'
152
- image/jpeg: 'JPG-Image'
153
- video/x-msvideo: 'AVI-Video'
154
- video/x-ms-wmv: 'Windows Media Video'
155
- image/tiff: 'TIFF-Image'
156
- 'text/x-vcard': 'vCard'
157
- application/vcard: 'vCard'
140
+ ms-excel: Excel Spreadsheet
141
+ ms-powerpoint: PowerPoint Presentation
142
+ ms-word: Word Document
143
+ openxmlformats-officedocument:
144
+ presentationml:
145
+ presentation: PowerPoint 2007 Presentation
146
+ spreadsheetml:
147
+ sheet: Excel 2007 Spreadsheet
148
+ wordprocessingml:
149
+ document: Word 2007 Document
150
+ application/x-flash-video: Flash Video
151
+ application/x-rar: RAR Archive
152
+ application/x-shockwave-flash: Flash Movie
153
+ application/zip: ZIP Archive
154
+ audio/mp4: MPEG-4 Audio
155
+ audio/mpeg: MP3 Audio
156
+ audio/wav: WAV Audio
157
+ audio/x-wav: WAV Audio
158
+ image/gif: GIF Image
159
+ image/jpeg: JPG Image
160
+ image/png: PNG Image
161
+ image/tiff: TIFF Image
162
+ image/x-psd: Photoshop File
163
+ image/svg+xml: SVG Image
164
+ text/plain: Plain Text Document
165
+ text/x-vcard: vCard
166
+ video/mp4: MPEG-4 Video
167
+ video/mpeg: MPEG Video
168
+ video/quicktime: Quicktime Video
169
+ video/x-flv: Flash Video
170
+ video/x-ms-wmv: Windows Media Video
171
+ video/x-msvideo: AVI Video
158
172
 
159
173
  link_target_options:
160
174
  default: Same Window
@@ -295,7 +309,9 @@ en:
295
309
  "Visit page": "Visit page"
296
310
  "Warning!": "Warning!"
297
311
  content_definition_missing: "Warning: Content is missing its definition. Please check the elements.yml"
312
+ content_deprecated: "WARNING! This content is deprecated and will be removed soon. Please do not use it anymore."
298
313
  element_definition_missing: "WARNING! Missing element definition. Please check your elements.yml file."
314
+ element_deprecated: "WARNING! This element is deprecated and will be removed soon. Please do not use it anymore."
299
315
  page_definition_missing: "WARNING! Missing page layout definition. Please check your page_layouts.yml file."
300
316
  "Welcome to Alchemy": "Welcome to Alchemy"
301
317
  "Who else is online": "Who else is online"
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Alchemy
3
- Deprecation = ActiveSupport::Deprecation.new("5.1", "Alchemy")
3
+ Deprecation = ActiveSupport::Deprecation.new("6.0", "Alchemy")
4
4
  end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ class ElementDefinition
5
+ class << self
6
+ # Returns the definitions from elements.yml file.
7
+ #
8
+ # Place a +elements.yml+ file inside your apps +config/alchemy+ folder to define
9
+ # your own set of elements
10
+ #
11
+ def all
12
+ @definitions ||= read_definitions_file.map(&:with_indifferent_access)
13
+ end
14
+
15
+ # Add additional page definitions to collection.
16
+ #
17
+ # Useful for extending the elements from an Alchemy module.
18
+ #
19
+ # === Usage Example
20
+ #
21
+ # Call +Alchemy::ElementDefinition.add(your_definition)+ in your engine.rb file.
22
+ #
23
+ # @param [Array || Hash]
24
+ # You can pass a single element definition as Hash, or a collection of elements as Array.
25
+ #
26
+ def add(element)
27
+ all
28
+ if element.is_a?(Array)
29
+ @definitions += element
30
+ elsif element.is_a?(Hash)
31
+ @definitions << element
32
+ else
33
+ raise TypeError
34
+ end
35
+ end
36
+
37
+ # Returns one element definition by given name.
38
+ #
39
+ def get(name)
40
+ return {} if name.blank?
41
+
42
+ all.detect { |a| a["name"] == name }
43
+ end
44
+
45
+ private
46
+
47
+ # Reads the element definitions from +config/alchemy/elements.yml+.
48
+ #
49
+ def read_definitions_file
50
+ if File.exist?(definitions_file_path)
51
+ YAML.safe_load(
52
+ ERB.new(File.read(definitions_file_path)).result,
53
+ YAML_WHITELIST_CLASSES,
54
+ [],
55
+ true
56
+ ) || []
57
+ else
58
+ raise LoadError,
59
+ "Could not find elements.yml file! Please run `rails generate alchemy:install`"
60
+ end
61
+ end
62
+
63
+ # Returns the elements.yml file path
64
+ #
65
+ def definitions_file_path
66
+ Rails.root.join "config/alchemy/elements.yml"
67
+ end
68
+ end
69
+ end
70
+ end
@@ -26,8 +26,6 @@ module Alchemy
26
26
  # Randomize the output of elements
27
27
  # @option options [Boolean] :reverse (false)
28
28
  # Reverse the load order
29
- # @option options [Hash] :fallback
30
- # Define elements that are loaded from another page if no element was found on given page.
31
29
  def initialize(options = {})
32
30
  @options = options
33
31
  end
@@ -83,6 +81,9 @@ module Alchemy
83
81
  when Alchemy::Page
84
82
  page_or_layout
85
83
  when String
84
+ Alchemy::Deprecation.warn "Passing a String as `from_page` option to " \
85
+ "`render_elements` is deprecated and will be removed with Alchemy 6.0. " \
86
+ "Please load the page beforehand and pass it as an object instead."
86
87
  Alchemy::Page.find_by(
87
88
  language: Alchemy::Language.current,
88
89
  page_layout: page_or_layout,
@@ -92,6 +93,9 @@ module Alchemy
92
93
  end
93
94
 
94
95
  def fallback_required?(elements)
96
+ if options[:fallback]
97
+ Alchemy::Deprecation.warn "Passing `fallback` options to `render_elements` is deprecated an will be removed with Alchemy 6.0."
98
+ end
95
99
  options[:fallback] && elements
96
100
  .where(Alchemy::Element.table_name => {name: options[:fallback][:for]})
97
101
  .none?
@@ -83,7 +83,7 @@ module Alchemy #:nodoc:
83
83
 
84
84
  if configuration[:belongs_to]
85
85
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
86
- belongs_to :ingredient_association, #{configuration[:belongs_to]}
86
+ belongs_to :ingredient_association, **#{configuration[:belongs_to]}
87
87
 
88
88
  alias_method :#{configuration[:ingredient_column]}, :ingredient_association
89
89
  alias_method :#{configuration[:ingredient_column]}=, :ingredient_association=
@@ -108,9 +108,9 @@ module Alchemy #:nodoc:
108
108
  # Register the current class as has_many association on +Alchemy::Page+ and +Alchemy::Element+ models
109
109
  def register_as_essence_association!
110
110
  klass_name = model_name.to_s
111
- arguments = [:has_many, klass_name.demodulize.tableize.to_sym, through: :contents,
112
- source: :essence, source_type: klass_name]
113
- %w(Page Element).each { |k| "Alchemy::#{k}".constantize.send(*arguments) }
111
+ arguments = [:has_many, klass_name.demodulize.tableize.to_sym]
112
+ kwargs = { through: :contents, source: :essence, source_type: klass_name }
113
+ %w(Page Element).each { |k| "Alchemy::#{k}".constantize.send(*arguments, **kwargs) }
114
114
  end
115
115
  end
116
116
 
@@ -40,7 +40,20 @@ module Alchemy
40
40
  EXCEL_FILE_TYPES = [
41
41
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
42
42
  "application/vnd.ms-excel",
43
+ "application/msexcel",
43
44
  "text/csv",
44
45
  ]
46
+
47
+ WORD_FILE_TYPES = [
48
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
49
+ "application/vnd.ms-word",
50
+ "application/msword",
51
+ ]
52
+
53
+ POWERPOINT_FILE_TYPES = [
54
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation",
55
+ "application/vnd.ms-powerpoint",
56
+ "application/mspowerpoint",
57
+ ]
45
58
  end
46
59
  end
@@ -11,7 +11,7 @@ module Alchemy
11
11
  if object.respond_to?(:attribute_fixed?) && object.attribute_fixed?(attribute_name)
12
12
  options[:disabled] = true
13
13
  options[:input_html] = options.fetch(:input_html, {}).merge(
14
- "data-alchemy-tooltip" => Alchemy.t(:attribute_fixed, attribute_name),
14
+ "data-alchemy-tooltip" => Alchemy.t(:attribute_fixed, attribute: attribute_name),
15
15
  )
16
16
  end
17
17
 
data/lib/alchemy/i18n.rb CHANGED
@@ -12,8 +12,8 @@ module Alchemy
12
12
  #
13
13
  # Alchemy.t(:hello)
14
14
  #
15
- def t(msg, *args)
16
- Alchemy::I18n.translate(msg, *args)
15
+ def t(msg, **kwargs)
16
+ Alchemy::I18n.translate(msg, **kwargs)
17
17
  end
18
18
  end
19
19
 
@@ -47,11 +47,10 @@ module Alchemy
47
47
  # world:
48
48
  # hello: Hallo
49
49
  #
50
- def translate(msg, *args)
51
- options = args.extract_options!
50
+ def translate(msg, **options)
52
51
  humanize_default_string!(msg, options)
53
52
  scope = alchemy_scoped_scope(options)
54
- ::I18n.t(msg, options.merge(scope: scope))
53
+ ::I18n.t(msg, **options.merge(scope: scope))
55
54
  end
56
55
 
57
56
  def available_locales
@@ -74,6 +74,7 @@ module Alchemy
74
74
  end
75
75
  mapped_layouts_for_select(layouts)
76
76
  end
77
+ deprecate :layouts_with_own_for_select, deprecator: Alchemy::Deprecation
77
78
 
78
79
  # Returns all layouts that can be used for creating a new page.
79
80
  #
@@ -6,16 +6,16 @@ module Alchemy
6
6
  # This file is included in spec_helper.rb
7
7
  #
8
8
  module IntegrationHelpers
9
- # Used to stub the current_alchemy_user
9
+ # Used to stub the current_user in integration specs
10
10
  #
11
11
  # Pass either a user object or a symbol in the format of ':as_admin'.
12
- # The browser language is set to english ('en')
13
12
  #
14
13
  def authorize_user(user_or_role = nil)
15
- if user_or_role.is_a?(Alchemy.user_class)
16
- user = user_or_role
17
- else
14
+ case user_or_role
15
+ when Symbol, String
18
16
  user = build(:alchemy_dummy_user, user_or_role)
17
+ else
18
+ user = user_or_role
19
19
  end
20
20
  allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
21
21
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "5.1.2"
4
+ VERSION = "5.2.0.b1"
5
5
 
6
6
  def self.version
7
7
  VERSION
data/lib/alchemy_cms.rb CHANGED
@@ -35,6 +35,7 @@ require_relative "alchemy/config"
35
35
  require_relative "alchemy/configuration_methods"
36
36
  require_relative "alchemy/controller_actions"
37
37
  require_relative "alchemy/deprecation"
38
+ require_relative "alchemy/element_definition"
38
39
  require_relative "alchemy/elements_finder"
39
40
  require_relative "alchemy/errors"
40
41
  require_relative "alchemy/essence"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.2
4
+ version: 5.2.0.b1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2021-01-26 00:00:00.000000000 Z
16
+ date: 2021-02-11 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: active_model_serializers
@@ -276,7 +276,7 @@ dependencies:
276
276
  version: '1.8'
277
277
  - - "<"
278
278
  - !ruby/object:Gem::Version
279
- version: '3.0'
279
+ version: 2.4.2
280
280
  type: :runtime
281
281
  prerelease: false
282
282
  version_requirements: !ruby/object:Gem::Requirement
@@ -286,7 +286,7 @@ dependencies:
286
286
  version: '1.8'
287
287
  - - "<"
288
288
  - !ruby/object:Gem::Version
289
- version: '3.0'
289
+ version: 2.4.2
290
290
  - !ruby/object:Gem::Dependency
291
291
  name: request_store
292
292
  requirement: !ruby/object:Gem::Requirement
@@ -513,14 +513,14 @@ dependencies:
513
513
  requirements:
514
514
  - - "~>"
515
515
  - !ruby/object:Gem::Version
516
- version: 0.17.1
516
+ version: '0.20'
517
517
  type: :development
518
518
  prerelease: false
519
519
  version_requirements: !ruby/object:Gem::Requirement
520
520
  requirements:
521
521
  - - "~>"
522
522
  - !ruby/object:Gem::Version
523
- version: 0.17.1
523
+ version: '0.20'
524
524
  - !ruby/object:Gem::Dependency
525
525
  name: webdrivers
526
526
  requirement: !ruby/object:Gem::Requirement
@@ -1086,6 +1086,7 @@ files:
1086
1086
  - lib/alchemy/configuration_methods.rb
1087
1087
  - lib/alchemy/controller_actions.rb
1088
1088
  - lib/alchemy/deprecation.rb
1089
+ - lib/alchemy/element_definition.rb
1089
1090
  - lib/alchemy/elements_finder.rb
1090
1091
  - lib/alchemy/engine.rb
1091
1092
  - lib/alchemy/errors.rb
@@ -1273,9 +1274,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1273
1274
  version: 2.3.0
1274
1275
  required_rubygems_version: !ruby/object:Gem::Requirement
1275
1276
  requirements:
1276
- - - ">="
1277
+ - - ">"
1277
1278
  - !ruby/object:Gem::Version
1278
- version: '0'
1279
+ version: 1.3.1
1279
1280
  requirements:
1280
1281
  - ImageMagick (libmagick), v6.6 or greater.
1281
1282
  rubygems_version: 3.1.4