alchemy_cms 5.1.10 → 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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -1
  3. data/CHANGELOG.md +21 -29
  4. data/Gemfile +2 -6
  5. data/alchemy_cms.gemspec +3 -3
  6. data/app/assets/stylesheets/alchemy/_variables.scss +2 -0
  7. data/app/assets/stylesheets/alchemy/elements.scss +38 -5
  8. data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +3 -3
  9. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +7 -7
  10. data/app/controllers/alchemy/admin/base_controller.rb +4 -9
  11. data/app/controllers/alchemy/admin/trash_controller.rb +2 -0
  12. data/app/decorators/alchemy/content_editor.rb +64 -0
  13. data/app/decorators/alchemy/element_editor.rb +1 -25
  14. data/app/helpers/alchemy/admin/contents_helper.rb +3 -8
  15. data/app/helpers/alchemy/elements_helper.rb +0 -18
  16. data/app/helpers/alchemy/pages_helper.rb +1 -1
  17. data/app/models/alchemy/attachment.rb +5 -1
  18. data/app/models/alchemy/content.rb +7 -0
  19. data/app/models/alchemy/element/definitions.rb +5 -22
  20. data/app/models/alchemy/element.rb +39 -1
  21. data/app/models/alchemy/node.rb +1 -1
  22. data/app/models/alchemy/page/page_elements.rb +9 -2
  23. data/app/models/alchemy/page.rb +1 -1
  24. data/app/models/alchemy/picture/transformations.rb +3 -3
  25. data/app/models/alchemy/picture.rb +2 -2
  26. data/app/models/alchemy/picture_variant.rb +1 -1
  27. data/app/views/alchemy/admin/elements/_element.html.erb +1 -1
  28. data/app/views/alchemy/admin/elements/_element_header.html.erb +2 -0
  29. data/app/views/alchemy/essences/_essence_picture_view.html.erb +3 -3
  30. data/config/brakeman.ignore +305 -17
  31. data/config/initializers/dragonfly.rb +0 -8
  32. data/config/locales/alchemy.en.yml +40 -24
  33. data/lib/alchemy/deprecation.rb +1 -1
  34. data/lib/alchemy/element_definition.rb +70 -0
  35. data/lib/alchemy/elements_finder.rb +6 -2
  36. data/lib/alchemy/engine.rb +1 -8
  37. data/lib/alchemy/essence.rb +4 -4
  38. data/lib/alchemy/filetypes.rb +13 -0
  39. data/lib/alchemy/forms/builder.rb +1 -1
  40. data/lib/alchemy/i18n.rb +4 -5
  41. data/lib/alchemy/page_layout.rb +1 -0
  42. data/lib/alchemy/resource.rb +3 -5
  43. data/lib/alchemy/test_support/integration_helpers.rb +5 -5
  44. data/lib/alchemy/upgrader/five_point_zero.rb +0 -32
  45. data/lib/alchemy/version.rb +1 -1
  46. data/lib/alchemy_cms.rb +1 -1
  47. data/lib/generators/alchemy/install/install_generator.rb +1 -2
  48. data/lib/tasks/alchemy/thumbnails.rake +2 -4
  49. data/lib/tasks/alchemy/upgrade.rake +0 -20
  50. data/package/admin.js +0 -2
  51. data/package/src/__tests__/i18n.spec.js +0 -23
  52. data/package/src/i18n.js +3 -1
  53. data/package.json +1 -1
  54. metadata +20 -17
  55. data/lib/alchemy/dragonfly/processors/crop_resize.rb +0 -35
  56. data/lib/alchemy/error_tracking/airbrake_handler.rb +0 -13
  57. data/lib/alchemy/error_tracking.rb +0 -14
@@ -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?
@@ -40,16 +40,9 @@ module Alchemy
40
40
  if Alchemy.user_class
41
41
  ActiveSupport.on_load(:active_record) do
42
42
  Alchemy.user_class.model_stamper
43
- Alchemy.user_class.stampable(stamper_class_name: Alchemy.user_class.name)
43
+ Alchemy.user_class.stampable(stamper_class_name: Alchemy.user_class_name)
44
44
  end
45
45
  end
46
46
  end
47
-
48
- initializer "alchemy.error_tracking" do
49
- if defined?(Airbrake)
50
- require_relative "error_tracking/airbrake_handler"
51
- Alchemy::ErrorTracking.notification_handler = Alchemy::ErrorTracking::AirbrakeHandler
52
- end
53
- end
54
47
  end
55
48
  end
@@ -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
  #
@@ -132,9 +132,7 @@ module Alchemy
132
132
  end
133
133
 
134
134
  def namespaced_resource_name
135
- @_namespaced_resource_name ||= begin
136
- namespaced_resources_name.to_s.singularize
137
- end.to_sym # Rails >= 6.0.3.7 needs symbols in polymorphic routes
135
+ @_namespaced_resource_name ||= namespaced_resources_name.singularize
138
136
  end
139
137
 
140
138
  def namespaced_resources_name
@@ -142,13 +140,13 @@ module Alchemy
142
140
  resource_name_array = resource_array.dup
143
141
  resource_name_array.delete(engine_name) if in_engine?
144
142
  resource_name_array.join("_")
145
- end.to_sym # Rails >= 6.0.3.7 needs symbols in polymorphic routes
143
+ end
146
144
  end
147
145
 
148
146
  def namespace_for_scope
149
147
  namespace_array = namespace_diff
150
148
  namespace_array.delete(engine_name) if in_engine?
151
- namespace_array.map(&:to_sym) # Rails >= 6.0.3.7 needs symbols in polymorphic routes
149
+ namespace_array
152
150
  end
153
151
 
154
152
  # Returns an array of underscored association names
@@ -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,19 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "tasks/harden_gutentag_migrations"
4
- require "rails/generators"
5
- require "thor"
6
- require "alchemy/install/tasks"
7
- require "alchemy/version"
8
4
 
9
5
  module Alchemy
10
6
  class Upgrader::FivePointZero < Upgrader
11
- include Rails::Generators::Actions
12
- include Thor::Base
13
- include Thor::Actions
14
-
15
- source_root File.expand_path("../../generators/alchemy/install/files", __dir__)
16
-
17
7
  class << self
18
8
  def install_gutentag_migrations
19
9
  desc "Install Gutentag migrations"
@@ -46,28 +36,6 @@ module Alchemy
46
36
  log "Root page not found.", :skip
47
37
  end
48
38
  end
49
-
50
- def run_webpacker_installer
51
- # Webpacker does not create a package.json, but we need one
52
- unless File.exist? app_root.join("package.json")
53
- in_root { run "echo '{}' > package.json" }
54
- end
55
- new.rake("webpacker:install", abort_on_failure: true)
56
- end
57
-
58
- def add_npm_package
59
- new.run "yarn add @alchemy_cms/admin@~#{Alchemy.version}"
60
- end
61
-
62
- def copy_alchemy_entry_point
63
- webpack_config = YAML.load_file(app_root.join("config", "webpacker.yml"))[Rails.env]
64
- new.copy_file "alchemy_admin.js",
65
- app_root.join(webpack_config["source_path"], webpack_config["source_entry_path"], "alchemy/admin.js")
66
- end
67
-
68
- def app_root
69
- @_app_root ||= Rails.root
70
- end
71
39
  end
72
40
  end
73
41
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "5.1.10"
4
+ VERSION = "5.2.0.b1"
5
5
 
6
6
  def self.version
7
7
  VERSION
data/lib/alchemy_cms.rb CHANGED
@@ -35,8 +35,8 @@ 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
- require_relative "alchemy/error_tracking"
40
40
  require_relative "alchemy/errors"
41
41
  require_relative "alchemy/essence"
42
42
  require_relative "alchemy/filetypes"
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require "rails/generators"
3
3
  require "alchemy/install/tasks"
4
- require "alchemy/version"
5
4
 
6
5
  module Alchemy
7
6
  module Generators
@@ -89,7 +88,7 @@ module Alchemy
89
88
  end
90
89
 
91
90
  def add_npm_package
92
- run "yarn add @alchemy_cms/admin@~#{Alchemy.version}"
91
+ run "yarn add @alchemy_cms/admin"
93
92
  end
94
93
 
95
94
  def copy_alchemy_entry_point
@@ -4,8 +4,8 @@ namespace :alchemy do
4
4
  namespace :generate do
5
5
  desc "Generates all thumbnails for Alchemy Pictures and EssencePictures."
6
6
  task thumbnails: [
7
- "alchemy:generate:picture_thumbnails",
8
- "alchemy:generate:essence_picture_thumbnails",
7
+ "alchemy_dragonfly_s3:generate:picture_thumbnails",
8
+ "alchemy_dragonfly_s3:generate:essence_picture_thumbnails",
9
9
  ]
10
10
 
11
11
  desc "Generates thumbnails for Alchemy Pictures."
@@ -14,8 +14,6 @@ namespace :alchemy do
14
14
  puts "Please wait..."
15
15
 
16
16
  Alchemy::Picture.find_each do |picture|
17
- next unless picture.has_convertible_format?
18
-
19
17
  puts Alchemy::PictureThumb.generate_thumbs!(picture)
20
18
  end
21
19
 
@@ -42,9 +42,6 @@ namespace :alchemy do
42
42
  "alchemy:upgrade:5.0:install_gutentag_migrations",
43
43
  "alchemy:upgrade:5.0:remove_layout_roots",
44
44
  "alchemy:upgrade:5.0:remove_root_page",
45
- "alchemy:upgrade:5.0:run_webpacker_installer",
46
- "alchemy:upgrade:5.0:add_npm_package",
47
- "alchemy:upgrade:5.0:copy_alchemy_entry_point",
48
45
  ]
49
46
 
50
47
  desc "Install Gutentag migrations"
@@ -61,23 +58,6 @@ namespace :alchemy do
61
58
  task remove_root_page: [:environment] do
62
59
  Alchemy::Upgrader::FivePointZero.remove_root_page
63
60
  end
64
-
65
- desc "Run webpacker installer"
66
- task run_webpacker_installer: [:environment] do
67
- Alchemy::Upgrader::FivePointZero.run_webpacker_installer
68
- end
69
-
70
- desc "Add NPM package"
71
- task add_npm_package: [:environment] do
72
- puts "adding npm_package..."
73
- Alchemy::Upgrader::FivePointZero.add_npm_package
74
- end
75
-
76
- desc "Copy alchemy entry point"
77
- task copy_alchemy_entry_point: [:environment] do
78
- puts "copying alchemy entry point"
79
- Alchemy::Upgrader::FivePointZero.copy_alchemy_entry_point
80
- end
81
61
  end
82
62
  end
83
63
  end
data/package/admin.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import translate from "./src/i18n"
2
- import translationData from "./src/translations"
3
2
  import NodeTree from "./src/node_tree"
4
3
 
5
4
  // Global Alchemy object
@@ -11,6 +10,5 @@ if (typeof window.Alchemy === "undefined") {
11
10
  Object.assign(Alchemy, {
12
11
  // Global utility method for translating a given string
13
12
  t: translate,
14
- translations: Object.assign(Alchemy.translations || {}, translationData),
15
13
  NodeTree
16
14
  })
@@ -15,20 +15,12 @@ describe("translate", () => {
15
15
  })
16
16
 
17
17
  describe("if translation is present", () => {
18
- beforeEach(() => {
19
- Alchemy.translations = { en: { help: "Help" } }
20
- })
21
-
22
18
  it("Returns translated string", () => {
23
19
  expect(translate("help")).toEqual("Help")
24
20
  })
25
21
 
26
22
  describe("if key includes a period", () => {
27
23
  describe("that is translated", () => {
28
- beforeEach(() => {
29
- Alchemy.translations = { en: { formats: { date: "Y-m-d" } } }
30
- })
31
-
32
24
  it("splits into group", () => {
33
25
  expect(translate("formats.date")).toEqual("Y-m-d")
34
26
  })
@@ -48,10 +40,6 @@ describe("translate", () => {
48
40
  })
49
41
 
50
42
  describe("if replacement is given", () => {
51
- beforeEach(() => {
52
- Alchemy.translations = { en: { allowed_chars: "of %{number} chars" } }
53
- })
54
-
55
43
  it("replaces it", () => {
56
44
  expect(translate("allowed_chars", 5)).toEqual("of 5 chars")
57
45
  })
@@ -79,15 +67,4 @@ describe("translate", () => {
79
67
  spy.mockRestore()
80
68
  })
81
69
  })
82
-
83
- describe("if Alchemy.translations is not set", () => {
84
- it("Returns passed string and logs a warning", () => {
85
- const spy = jest.spyOn(console, "warn").mockImplementation(() => {})
86
- expect(translate("help")).toEqual("help")
87
- expect(spy.mock.calls).toEqual([
88
- ["Translations for locale kl not found!"]
89
- ])
90
- spy.mockRestore()
91
- })
92
- })
93
70
  })
data/package/src/i18n.js CHANGED
@@ -1,3 +1,5 @@
1
+ import translationData from "./translations"
2
+
1
3
  const KEY_SEPARATOR = /\./
2
4
 
3
5
  function currentLocale() {
@@ -9,7 +11,7 @@ function currentLocale() {
9
11
 
10
12
  function getTranslations() {
11
13
  const locale = currentLocale()
12
- const translations = Alchemy.translations && Alchemy.translations[locale]
14
+ const translations = translationData[locale]
13
15
 
14
16
  if (translations) {
15
17
  return translations
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy_cms/admin",
3
- "version": "5.1.10",
3
+ "version": "0.2.0",
4
4
  "description": "AlchemyCMS",
5
5
  "browser": "package/admin.js",
6
6
  "files": [