scrivito_sdk 1.19.0 → 1.20.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebbd40a4e845d898a3b9f70d2a0c7a1302fea17b3106f547feae57b5a500a6a5
4
- data.tar.gz: ba6207f0ae4ad56339de6f85655fbf084e834752ae98839a78a666ccc9118f76
3
+ metadata.gz: 83ab8abce7b3bdd3029afc044601146bc3b1702af66106e19943de299c05e951
4
+ data.tar.gz: b30c1c3499e2ddd522981f2b665c04e008934c66064885c433fa7051ef2bcf61
5
5
  SHA512:
6
- metadata.gz: e5ddca7bf935f59ce92b443356388f96cdd2940e6263049996ae96411718bb97b7d950edb13c40fe92772e4eb57d2cd289ac23818bdc7108462bb1d89c76a0f4
7
- data.tar.gz: f82a13347f14a213f08fb9e1a28e185111de34ad042d02adf5ad943161ef525eee241cd8039caf4cc03a0310f6ff0beb0fef5ec9f5961f90ecf07ac5fe8c5498
6
+ metadata.gz: 72f68ad2c3c7cff70d055deac8a346c24b401ac3bdecb17dff39cc01145a85d034688f2f18283dcbc95f5ccc09b844ec2a3579b86c827e5a67c24973dd612281
7
+ data.tar.gz: f86f9983e797d8cad89ecd24d28be0daaf5b1b25221522a100949c667d00497da17959e173c7db93d98da716ff296f5f31483d758a56f8935deaa0999ec7fcfd
@@ -37,7 +37,7 @@ module BinaryParamVerifier
37
37
 
38
38
  private_class_method def self.message_verifier
39
39
  ActiveSupport::MessageVerifier.new(
40
- Rails.application.credentials.secret_key_base, serializer: JSON)
40
+ Rails.application.secret_key_base, serializer: JSON)
41
41
  end
42
42
  end
43
43
 
@@ -1,3 +1,5 @@
1
+ require 'cgi/escape'
2
+
1
3
  module Scrivito
2
4
 
3
5
  class CmsRouting < Struct.new(:request, :context, :scrivito_engine, :image_options)
@@ -20,18 +22,19 @@ class CmsRouting < Struct.new(:request, :context, :scrivito_engine, :image_optio
20
22
 
21
23
  if $2.present?
22
24
  begin
23
- uri = URI.parse($2)
25
+ uri = URI.parse(CGI.unescapeHTML($2))
24
26
  options.merge!(extract_query(uri))
25
27
  options[:anchor] = uri.fragment
26
28
  rescue
27
29
  end
28
30
  end
29
31
 
32
+ safe = "".html_safe
30
33
  if editing_context.display_mode == 'editing'
31
34
  options[:id] = obj.id
32
- scrivito_engine.base_id_path(options)
35
+ safe + scrivito_engine.base_id_path(options)
33
36
  else
34
- path_or_url(obj, :path, options)
37
+ safe + path_or_url(obj, :path, options)
35
38
  end
36
39
  else
37
40
  "#__target_object_not_reachable"
@@ -1,3 +1,5 @@
1
+ require 'benchmark'
2
+
1
3
  module Scrivito
2
4
  module Migrations
3
5
  class Migration
@@ -21,7 +23,7 @@ module Scrivito
21
23
  def migrate
22
24
  announce 'migrating'
23
25
 
24
- time = Benchmark.measure { up }
26
+ time = ::Benchmark.measure { up }
25
27
 
26
28
  announce 'migrated (%.4fs)' % time.real; puts
27
29
  end
@@ -110,11 +110,18 @@ class ModelLibrary
110
110
 
111
111
  def require_dependencies
112
112
  @require_dependencies ||= begin
113
+ zeitwerk_dirs = Rails.autoloaders.main.dirs.map(&:to_s)
113
114
  paths.each do |path|
115
+ path = path.to_s
114
116
  Dir["#{path}/**/*.rb"].sort.each do |file_path|
115
117
  begin
116
- require_dependency(file_path)
117
- rescue TypeError, Zeitwerk::NameError => e
118
+ if zeitwerk_dirs.include?(path)
119
+ relative = file_path.delete_prefix("#{path}/").delete_suffix('.rb')
120
+ relative.camelize.constantize
121
+ else
122
+ require file_path
123
+ end
124
+ rescue TypeError, NameError => e
118
125
  raise e if file_path.starts_with?(Rails.root.to_s)
119
126
  end
120
127
  end
@@ -123,7 +130,7 @@ class ModelLibrary
123
130
  end
124
131
 
125
132
  def autoload_model_paths
126
- ActiveSupport::Dependencies.autoload_paths.select do |path|
133
+ Rails.autoloaders.main.dirs.select do |path|
127
134
  path.to_s.ends_with?('/app/models')
128
135
  end
129
136
  end
@@ -67,7 +67,7 @@ module RoutingExtensions
67
67
  options[:constraints] = {id: /[a-f0-9]{16}/} if route_name == :slug_id
68
68
 
69
69
  begin
70
- match(path, options)
70
+ match(path, **options)
71
71
  rescue ArgumentError => error
72
72
  if error.message.include?(route.helper_name)
73
73
  raise ScrivitoError,
@@ -11,7 +11,7 @@ module ::Scrivito
11
11
  def self.to_prepare
12
12
  Scrivito::Configuration.to_prepare
13
13
 
14
- unless Rails.application.config.cache_classes
14
+ if Rails.application.config.enable_reloading
15
15
  Scrivito.models.clear_cache
16
16
  end
17
17
  end
@@ -68,6 +68,7 @@ module ::Scrivito
68
68
  end
69
69
 
70
70
  scrivito_path = root.join('app', 'cms').to_s
71
+ $LOAD_PATH.unshift(scrivito_path) unless $LOAD_PATH.include?(scrivito_path)
71
72
  config.autoload_paths += [scrivito_path, root.join('app', 'models').to_s]
72
73
  config.autoload_once_paths += [scrivito_path]
73
74
  end
@@ -89,7 +89,7 @@ module Scrivito
89
89
 
90
90
  def message_verifier
91
91
  @message_verifier ||= ActiveSupport::MessageVerifier.new(
92
- Rails.application.credentials.secret_key_base, serializer: JSON
92
+ Rails.application.secret_key_base, serializer: JSON
93
93
  )
94
94
  end
95
95