scrivito_sdk 1.17.0 → 1.18.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/cms/scrivito/application_error.rb +13 -0
  4. data/app/cms/scrivito/backend/base_index.rb +49 -0
  5. data/app/cms/scrivito/backend/index.rb +0 -41
  6. data/app/cms/scrivito/backend/parent_path_index.rb +1 -1
  7. data/app/cms/scrivito/backend/path_index.rb +1 -1
  8. data/app/cms/scrivito/backend/permalink_index.rb +1 -1
  9. data/app/cms/scrivito/cms_rest_api.rb +8 -3
  10. data/app/cms/scrivito/controller_actions.rb +1 -1
  11. data/app/cms/scrivito/generator_helper.rb +5 -3
  12. data/app/cms/scrivito/internal_error.rb +8 -0
  13. data/app/cms/scrivito/layout_tags.rb +1 -1
  14. data/app/cms/scrivito/model_library.rb +1 -1
  15. data/app/cms/scrivito/obj_class_not_found.rb +7 -0
  16. data/app/cms/scrivito/resource_not_found.rb +14 -0
  17. data/app/cms/scrivito/scrivito_error.rb +7 -0
  18. data/app/cms/scrivito/sdk_engine.rb +1 -1
  19. data/app/cms/scrivito/transformation_definition_error.rb +7 -0
  20. data/app/cms/scrivito/transformation_error.rb +13 -0
  21. data/app/cms/scrivito/transformation_source_error.rb +7 -0
  22. data/app/controllers/scrivito/binary_redirect_controller.rb +2 -2
  23. data/app/controllers/scrivito/ui_controller.rb +1 -1
  24. data/config/ca-bundle.crt +665 -820
  25. data/lib/assets/javascripts/scrivito.js +1 -1
  26. data/lib/assets/javascripts/scrivito_ui_redirect.js +1 -1
  27. data/lib/assets/javascripts/scrivito_with_js_sdk.js +1 -1
  28. data/lib/assets/stylesheets/scrivito_editing.css +3 -4
  29. data/lib/generators/scrivito/page/page_generator.rb +1 -1
  30. data/lib/generators/scrivito/page/templates/model.erb +1 -1
  31. data/lib/generators/scrivito/widget/templates/model.erb +1 -1
  32. data/lib/generators/scrivito/widget/widget_generator.rb +1 -1
  33. metadata +34 -12
  34. data/app/cms/scrivito/errors.rb +0 -55
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f613ff1d193d27a33755c7133ebef5951aea069c2717bdb3475e0891d8c53f8a
4
- data.tar.gz: a4fca2f5cef536b85f1100d1bcbe2c5528d2301775a683e116bd382fb7561abe
3
+ metadata.gz: 856c448a586b8d9fa46e5646c6f7032ea565d7655241986324b69ad307047d74
4
+ data.tar.gz: 1d340bc1501d4aa4377e6ab3e58897a5d44ce309400126cd31c007f111f67d16
5
5
  SHA512:
6
- metadata.gz: 6c9b223038d81fecce47bd95697083074147562eced6e8337d08be93bd737347e87000861cd2fe18c4ebaea2562d7644d65452da45343364f85d19ec307cc4a5
7
- data.tar.gz: 3f5c246a9e083b7bc564b17263c89012db5ca25b26c53487ac932065d59f5c9629a76b8557d716009bf2b8467860a0611030f444e03d782389c85f9fdff52406
6
+ metadata.gz: bb162b76792cda107d884e95d014c709bd01900983333e7210b13adbd7dd9aff754327ef462d70fd8344e3be9a8cf676dcf97930306f6ff0fc0561103229c3b7
7
+ data.tar.gz: 470df0ee44eb1237666078fd0c8b2d5891966183233097662ec8d8219895862a41c892e5fb561f18abde1423bb00ed3993606dbe196fe53121b75b1cce180ab2
data/README.md CHANGED
@@ -12,7 +12,7 @@ of concepts and APIs, tutorials, and release notes.
12
12
 
13
13
  ## License
14
14
 
15
- Copyright (c) 2009 - 2020 Infopark Group GmbH (http://www.infopark.com)
15
+ Copyright (c) 2009 - 2021 JustRelate Group GmbH (https://www.justrelate.com)
16
16
 
17
17
  This software can be used and modified under the LGPL-3.0. Please refer to
18
18
  http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
@@ -0,0 +1,13 @@
1
+ module Scrivito
2
+
3
+ class ApplicationError < ScrivitoError
4
+ def http_code
5
+ 412
6
+ end
7
+
8
+ def as_json
9
+ {message: message, message_for_editor: message}
10
+ end
11
+ end
12
+
13
+ end # module Scrivito
@@ -0,0 +1,49 @@
1
+ module Scrivito
2
+ module Backend
3
+
4
+ # Abstract Base for Index Implementations
5
+ module BaseIndex
6
+ def id
7
+ abstract_base_method
8
+ end
9
+
10
+ def update(key, cached_result, change_index)
11
+ updated = Set.new(cached_result)
12
+
13
+ change_index.each do |id, data|
14
+ value = extract_update_value_from_data(data)
15
+
16
+ if value == key
17
+ updated.add(id)
18
+ else
19
+ updated.delete(id)
20
+ end
21
+ end
22
+
23
+ updated.to_a
24
+ end
25
+
26
+ def extract_update_value_from_data(data)
27
+ abstract_base_method
28
+ end
29
+
30
+ def group_by(keys, obj_datas)
31
+ return [obj_datas] if keys.length == 1
32
+
33
+ group_by_multiple(keys, obj_datas)
34
+ end
35
+
36
+ def group_by_multiple(parent_paths, obj_datas)
37
+ abstract_base_method
38
+ end
39
+
40
+ private
41
+
42
+ def abstract_base_method
43
+ raise Scrivito::InternalError, "not implemented"
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+ end
@@ -1,7 +1,6 @@
1
1
  module Scrivito
2
2
  module Backend
3
3
 
4
- # Abstract Base for Index Implementations
5
4
  module Index
6
5
 
7
6
  IMPLEMENTATIONS = [
@@ -19,46 +18,6 @@ module Index
19
18
  raise Scrivito::InternalError, "unknown index #{name}"
20
19
  end
21
20
 
22
- def id
23
- abstract_base_method
24
- end
25
-
26
- def update(key, cached_result, change_index)
27
- updated = Set.new(cached_result)
28
-
29
- change_index.each do |id, data|
30
- value = extract_update_value_from_data(data)
31
-
32
- if value == key
33
- updated.add(id)
34
- else
35
- updated.delete(id)
36
- end
37
- end
38
-
39
- updated.to_a
40
- end
41
-
42
- def extract_update_value_from_data(data)
43
- abstract_base_method
44
- end
45
-
46
- def group_by(keys, obj_datas)
47
- return [obj_datas] if keys.length == 1
48
-
49
- group_by_multiple(keys, obj_datas)
50
- end
51
-
52
- def group_by_multiple(parent_paths, obj_datas)
53
- abstract_base_method
54
- end
55
-
56
- private
57
-
58
- def abstract_base_method
59
- raise Scrivito::InternalError, "not implemented"
60
- end
61
-
62
21
  end
63
22
 
64
23
  end
@@ -2,7 +2,7 @@ module Scrivito
2
2
  module Backend
3
3
 
4
4
  module ParentPathIndex
5
- extend Backend::Index
5
+ extend Backend::BaseIndex
6
6
 
7
7
  def self.id
8
8
  "ppath"
@@ -2,7 +2,7 @@ module Scrivito
2
2
  module Backend
3
3
 
4
4
  module PathIndex
5
- extend Backend::Index
5
+ extend Backend::BaseIndex
6
6
 
7
7
  def self.id
8
8
  "path"
@@ -2,7 +2,7 @@ module Scrivito
2
2
  module Backend
3
3
 
4
4
  module PermalinkIndex
5
- extend Backend::Index
5
+ extend Backend::BaseIndex
6
6
 
7
7
  def self.id
8
8
  "permalink"
@@ -136,21 +136,26 @@ module Scrivito
136
136
  end
137
137
 
138
138
  private_class_method def self.handle_response(resource_path, response)
139
- http_code = response.code.to_i
140
139
  if response.code.start_with?('2')
141
140
  JSON.parse(response.body)
142
141
  elsif response.code == '403'
143
142
  raise AccessDenied.new(response.body)
144
143
  else
144
+ http_code = response.code.to_i
145
145
  begin
146
- error_body = JSON.parse(response.body)
146
+ error_body =
147
+ if http_code == 404 && response.body == "Not Found"
148
+ {'error' => response.body}
149
+ else
150
+ JSON.parse(response.body)
151
+ end
147
152
  specific_output = error_body['error']
148
153
 
149
154
  if response.code.start_with?('4')
150
155
  backend_code = error_body['code']
151
156
  raise ClientError.new(specific_output,
152
157
  http_code: http_code, backend_code: backend_code)
153
- elsif response.code == '500' && specific_output
158
+ elsif http_code == 500 && specific_output
154
159
  raise BackendError.new(specific_output, http_code)
155
160
  else # 3xx and >500 are treated as NetworkErrors
156
161
  raise NetworkError.new(response.body, http_code)
@@ -164,7 +164,7 @@ module ControllerActions
164
164
  def deliver_file
165
165
  if binary = @obj.binary
166
166
  binary_routing = BinaryRouting.new(request, scrivito_engine)
167
- redirect_to binary_routing.resolved_binary_url(binary)
167
+ redirect_to binary_routing.resolved_binary_url(binary), allow_other_host: true
168
168
  else
169
169
  render plain: 'Empty Blob', status: 404
170
170
  end
@@ -1,10 +1,12 @@
1
1
  module Scrivito
2
2
  module GeneratorHelper
3
3
  def self.attribute_definition(arg)
4
- if %w(enum multienum).include?(arg.type.to_s)
5
- "attribute :#{arg.name}, :#{arg.type}, values: []"
4
+ name, type = arg.to_s.split(":")
5
+
6
+ if %w(enum multienum).include?(type)
7
+ "attribute :#{name}, :#{type}, values: []"
6
8
  else
7
- "attribute :#{arg.name}, :#{arg.type}"
9
+ "attribute :#{name}, :#{type}"
8
10
  end
9
11
  end
10
12
  end
@@ -0,0 +1,8 @@
1
+ module Scrivito
2
+
3
+ # this error is raised if scrivito detects an internal problem.
4
+ # these errors should never occur when using the public api of the SDK.
5
+ class InternalError < ScrivitoError
6
+ end
7
+
8
+ end # module Scrivito
@@ -17,7 +17,7 @@ class LayoutTags < Struct.new(:view)
17
17
  end
18
18
 
19
19
  def generator_meta_tag
20
- content = 'Scrivito by Infopark Group GmbH (scrivito.com)'
20
+ content = 'Scrivito by JustRelate Group GmbH (scrivito.com)'
21
21
  content << "; Version #{GemInfo.version}" if view.scrivito_user
22
22
  view.tag(:meta, name: 'generator', content: content)
23
23
  end
@@ -114,7 +114,7 @@ class ModelLibrary
114
114
  Dir["#{path}/**/*.rb"].sort.each do |file_path|
115
115
  begin
116
116
  require_dependency(file_path)
117
- rescue TypeError => e
117
+ rescue TypeError, Zeitwerk::NameError => e
118
118
  raise e if file_path.starts_with?(Rails.root.to_s)
119
119
  end
120
120
  end
@@ -0,0 +1,7 @@
1
+ module Scrivito
2
+
3
+ # @api public
4
+ class ObjClassNotFound < ResourceNotFound
5
+ end
6
+
7
+ end # module Scrivito
@@ -0,0 +1,14 @@
1
+ module Scrivito
2
+
3
+ # @api public
4
+ class ResourceNotFound < ScrivitoError
5
+ def http_code
6
+ 404
7
+ end
8
+
9
+ def as_json
10
+ {message: message}
11
+ end
12
+ end
13
+
14
+ end # module Scrivito
@@ -0,0 +1,7 @@
1
+ module Scrivito
2
+
3
+ # @api public
4
+ class ScrivitoError < StandardError
5
+ end
6
+
7
+ end # module Scrivito
@@ -1,10 +1,10 @@
1
1
  require 'rails'
2
+ require 'sprockets/railtie'
2
3
 
3
4
  require 'jbuilder'
4
5
  require 'jquery-rails'
5
6
  require 'net/http/post/multipart'
6
7
  require 'json'
7
- require_relative './errors'
8
8
 
9
9
  module ::Scrivito
10
10
  class SdkEngine < Rails::Engine
@@ -0,0 +1,7 @@
1
+ module Scrivito
2
+
3
+ # @api public
4
+ class TransformationDefinitionError < TransformationError
5
+ end
6
+
7
+ end # module Scrivito
@@ -0,0 +1,13 @@
1
+ module Scrivito
2
+
3
+ # @api public
4
+ class TransformationError < ScrivitoError
5
+ attr_reader :code
6
+
7
+ def initialize(message, code)
8
+ @code = code
9
+ super(message)
10
+ end
11
+ end
12
+
13
+ end # module Scrivito
@@ -0,0 +1,7 @@
1
+ module Scrivito
2
+
3
+ # @api public
4
+ class TransformationSourceError < TransformationError
5
+ end
6
+
7
+ end # module Scrivito
@@ -2,7 +2,7 @@ module Scrivito
2
2
  class BinaryRedirectController < ActionController::Base
3
3
  def to_binary
4
4
  binary = BinaryParamVerifier.verify(params[:encrypted_params])
5
- redirect_to BinaryRewrite.call(request, binary.url), status: 301
5
+ redirect_to BinaryRewrite.call(request, binary.url), status: 301, allow_other_host: true
6
6
  rescue BinaryParamVerifier::InvalidSignature
7
7
  head :precondition_failed
8
8
  rescue TransformationSourceError => error
@@ -15,7 +15,7 @@ module Scrivito
15
15
  private
16
16
 
17
17
  def render_error(error_name)
18
- redirect_to view_context.image_path("scrivito/#{error_name}.png")
18
+ redirect_to view_context.image_path("scrivito/#{error_name}.png"), allow_other_host: true
19
19
  end
20
20
  end
21
21
  end
@@ -15,7 +15,7 @@ class UiController < ActionController::Base
15
15
  lookup_context: lookup_context,
16
16
  })
17
17
 
18
- render 'scrivito/ui/index.html'
18
+ render 'scrivito/ui/index', formats: [:html]
19
19
  else
20
20
  redirect_to @application_src
21
21
  end