scrivito_sdk 1.5.5 → 1.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/app/controllers/scrivito/obj_class_controller.rb +27 -4
  4. data/app/controllers/scrivito/objs_controller.rb +0 -26
  5. data/app/controllers/scrivito/resolve_paths_controller.rb +1 -1
  6. data/app/controllers/scrivito/ui_configs_controller.rb +8 -0
  7. data/app/controllers/scrivito/users_controller.rb +11 -1
  8. data/app/helpers/scrivito_helper.rb +56 -5
  9. data/app/views/scrivito/page_details.html.erb +6 -1
  10. data/app/views/scrivito/ui/index.html.erb +4 -1
  11. data/app/views/scrivito/ui_configs/ui_configs.json.jbuilder +7 -0
  12. data/app/views/scrivito/users/publish_ability.json.jbuilder +1 -0
  13. data/app/views/scrivito/users/users.json.jbuilder +7 -0
  14. data/config/ca-bundle.crt +2 -32
  15. data/config/precedence_routes.rb +6 -3
  16. data/lib/assets/javascripts/scrivito.js +0 -11
  17. data/lib/assets/javascripts/scrivito_sdk.js +17921 -0
  18. data/lib/assets/javascripts/scrivito_ui.js +35583 -32542
  19. data/lib/assets/javascripts/scrivito_ui_redirect.js +10 -0
  20. data/lib/assets/stylesheets/scrivito.css +1 -1
  21. data/lib/assets/stylesheets/scrivito_ui.css +1 -1
  22. data/lib/generators/scrivito/install/templates/app/models/download.rb +1 -0
  23. data/lib/generators/scrivito/install/templates/app/models/image.rb +1 -0
  24. data/lib/generators/scrivito/install/templates/app/models/page.rb +1 -0
  25. data/lib/generators/scrivito/install/templates/app/views/download/details.html.erb +4 -0
  26. data/lib/generators/scrivito/install/templates/app/views/image/details.html.erb +4 -0
  27. data/lib/generators/scrivito/install/templates/app/views/page/details.html.erb +4 -0
  28. data/lib/generators/scrivito/page/templates/details.html.erb +4 -0
  29. data/lib/generators/scrivito/page/templates/model.erb +1 -0
  30. data/lib/scrivito/associations.rb +200 -0
  31. data/lib/scrivito/attribute_content.rb +18 -10
  32. data/lib/scrivito/attribute_definition.rb +1 -1
  33. data/lib/scrivito/attribute_serializer.rb +1 -1
  34. data/lib/scrivito/base_widget_tag.rb +4 -5
  35. data/lib/scrivito/basic_obj.rb +15 -2
  36. data/lib/scrivito/basic_widget.rb +8 -2
  37. data/lib/scrivito/binary.rb +12 -24
  38. data/lib/scrivito/binary_rewrite.rb +1 -1
  39. data/lib/scrivito/binary_routing.rb +1 -1
  40. data/lib/scrivito/cms_env.rb +2 -6
  41. data/lib/scrivito/cms_field_tag.rb +4 -0
  42. data/lib/scrivito/cms_rest_api.rb +1 -1
  43. data/lib/scrivito/configuration.rb +7 -4
  44. data/lib/scrivito/connection_manager.rb +1 -1
  45. data/lib/scrivito/editing_context.rb +9 -4
  46. data/lib/scrivito/float_conversion.rb +2 -3
  47. data/lib/scrivito/integer_conversion.rb +2 -3
  48. data/lib/scrivito/link.rb +2 -2
  49. data/lib/scrivito/link_parser.rb +7 -7
  50. data/lib/scrivito/meta_data_collection.rb +3 -2
  51. data/lib/scrivito/migrations/workspace_lock.rb +1 -1
  52. data/lib/scrivito/obj_collection.rb +4 -2
  53. data/lib/scrivito/obj_create_params_parser.rb +25 -1
  54. data/lib/scrivito/obj_search_enumerator.rb +79 -37
  55. data/lib/scrivito/obj_ui_config.rb +20 -0
  56. data/lib/scrivito/publish_ability.rb +14 -0
  57. data/lib/scrivito/sdk_engine.rb +2 -0
  58. data/lib/scrivito/ui_config.rb +1 -3
  59. data/lib/scrivito/user.rb +17 -1
  60. data/lib/scrivito/widget_collection.rb +1 -1
  61. data/lib/scrivito/workspace.rb +0 -16
  62. data/lib/scrivito/workspace/publish_checker.rb +3 -3
  63. metadata +13 -7
  64. data/app/views/scrivito/users/suggest.json.jbuilder +0 -1
  65. data/lib/scrivito/obj_params_parser.rb +0 -36
  66. data/lib/scrivito/obj_update_params_parser.rb +0 -28
@@ -0,0 +1,20 @@
1
+ module Scrivito
2
+ class ObjUiConfig < Struct.new(:obj)
3
+ def self.mget(*ids)
4
+ objs = Obj.find(ids)
5
+
6
+ ids.map do |id|
7
+ if obj = objs.find { |o| o.id == id }
8
+ ObjUiConfig.new(obj)
9
+ end
10
+ end
11
+ end
12
+
13
+ def as_json
14
+ {
15
+ description_for_editor: obj.description_for_editor,
16
+ info_for_content_browser: obj.try(:info_for_content_browser),
17
+ }.compact
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ module Scrivito
2
+ class PublishAbility < Struct.new(:scrivito_user, :obj_id)
3
+ def as_json
4
+ {restriction_messages: restriction_messages}
5
+ end
6
+
7
+ private
8
+
9
+ def restriction_messages
10
+ obj = Obj.find(obj_id)
11
+ scrivito_user.restriction_messages_for(obj)
12
+ end
13
+ end
14
+ end
@@ -48,8 +48,10 @@ module ::Scrivito
48
48
  app.config.assets.precompile += %w[
49
49
  scrivito.css
50
50
  scrivito.js
51
+ scrivito_ui_redirect.js
51
52
  scrivito_ui.css
52
53
  scrivito_ui.js
54
+ scrivito_sdk.js
53
55
  ]
54
56
  app.config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
55
57
  end
@@ -87,9 +87,7 @@ class UiConfig < Struct.new(:editing_context, :resource, :return_to, :app_extens
87
87
 
88
88
  def user_config
89
89
  {
90
- current: {
91
- id: editor.id
92
- }
90
+ current: editor.as_json,
93
91
  }
94
92
  end
95
93
 
data/lib/scrivito/user.rb CHANGED
@@ -108,6 +108,10 @@ module Scrivito
108
108
  end
109
109
  end
110
110
 
111
+ def mget(*ids)
112
+ ids.map(&method(:find))
113
+ end
114
+
111
115
  private
112
116
 
113
117
  def define_user(id = nil)
@@ -224,6 +228,14 @@ module Scrivito
224
228
  id.nil?
225
229
  end
226
230
 
231
+ def as_json
232
+ {
233
+ id: id,
234
+ description: description,
235
+ explicit_rules: explicit_rules_as_json,
236
+ }
237
+ end
238
+
227
239
  private
228
240
 
229
241
  def calculate_description
@@ -242,11 +254,15 @@ module Scrivito
242
254
 
243
255
  def sandbox_suggest_user_proc(input)
244
256
  suggest_users_proc.call(input)
245
- rescue Exception => e
257
+ rescue StandardError => e
246
258
  message = %{Method `suggest_users' of the user "#{id}" raised an error on input "#{input}"}
247
259
  Warning.error(message, e)
248
260
 
249
261
  nil
250
262
  end
263
+
264
+ def explicit_rules_as_json
265
+ @explicit_rules.map { |(adverb, verb, _)| "#{adverb}-#{verb}" }
266
+ end
251
267
  end
252
268
  end
@@ -20,7 +20,7 @@ module Scrivito
20
20
  # @api public
21
21
  #
22
22
  # Enables you to iterate the {Scrivito::BasicWidget Widgets} of an {Scrivito::BasicObj Obj}.
23
- # Includes the {http://ruby-doc.org/core-2.1.0/Enumerable.html Enumerable} mixin
23
+ # Includes the {https://ruby-doc.org/core-2.1.0/Enumerable.html Enumerable} mixin
24
24
  # and thereby provides methods like +map+ or +select+.
25
25
  # @yield [Scrivito::BasicWidget] the {Scrivito::BasicWidget Widgets} of an {Scrivito::BasicObj Obj}
26
26
  #
@@ -357,22 +357,6 @@ class Workspace
357
357
  "<#{self.class} id=\"#{id}\" title=\"#{title}\">"
358
358
  end
359
359
 
360
- def has_modification_for?(obj_id)
361
- !!objs.find_including_deleted(obj_id).modification
362
- rescue Scrivito::ResourceNotFound
363
- false
364
- end
365
-
366
- def self.all_with_modification_for(obj_id)
367
- all.select do |ws|
368
- ws.has_modification_for?(obj_id)
369
- end
370
- end
371
-
372
- def conflict_warning_for(obj_id)
373
- self.class.all_with_modification_for(obj_id) - [self]
374
- end
375
-
376
360
  private
377
361
 
378
362
  def update_data(new_data)
@@ -98,10 +98,10 @@ module Scrivito
98
98
  response[:from].to_i
99
99
  end
100
100
 
101
- last_until = sorted_responses.inject(-1) do |last_until, response|
102
- if last_until == 'END'
101
+ last_until = sorted_responses.inject(-1) do |inner_last_until, response|
102
+ if inner_last_until == 'END'
103
103
  raise_invalid_certificates_error
104
- elsif (last_until + 1) == response[:from].to_i
104
+ elsif (inner_last_until + 1) == response[:from].to_i
105
105
  if response[:until] == 'END'
106
106
  'END'
107
107
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.6.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infopark AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-19 00:00:00.000000000 Z
11
+ date: 2016-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -181,6 +181,7 @@ files:
181
181
  - app/controllers/scrivito/resolve_paths_controller.rb
182
182
  - app/controllers/scrivito/sessions_controller.rb
183
183
  - app/controllers/scrivito/tasks_controller.rb
184
+ - app/controllers/scrivito/ui_configs_controller.rb
184
185
  - app/controllers/scrivito/ui_controller.rb
185
186
  - app/controllers/scrivito/users_controller.rb
186
187
  - app/controllers/scrivito/webservice_controller.rb
@@ -211,7 +212,9 @@ files:
211
212
  - app/views/scrivito/sessions/update.json.jbuilder
212
213
  - app/views/scrivito/tasks/show.json.jbuilder
213
214
  - app/views/scrivito/ui/index.html.erb
214
- - app/views/scrivito/users/suggest.json.jbuilder
215
+ - app/views/scrivito/ui_configs/ui_configs.json.jbuilder
216
+ - app/views/scrivito/users/publish_ability.json.jbuilder
217
+ - app/views/scrivito/users/users.json.jbuilder
215
218
  - app/views/scrivito/webservice/_workspace.json.jbuilder
216
219
  - app/views/scrivito/webservice/empty.json
217
220
  - app/views/scrivito/webservice/error.json.jbuilder
@@ -234,7 +237,9 @@ files:
234
237
  - lib/assets/images/scrivito/source_too_large.png
235
238
  - lib/assets/images/scrivito/source_type_invalid.png
236
239
  - lib/assets/javascripts/scrivito.js
240
+ - lib/assets/javascripts/scrivito_sdk.js
237
241
  - lib/assets/javascripts/scrivito_ui.js
242
+ - lib/assets/javascripts/scrivito_ui_redirect.js
238
243
  - lib/assets/stylesheets/scrivito.css
239
244
  - lib/assets/stylesheets/scrivito_ui.css
240
245
  - lib/generators/scrivito/install/install_generator.rb
@@ -278,6 +283,7 @@ files:
278
283
  - lib/generators/scrivito/widget/widget_generator.rb
279
284
  - lib/obj.rb
280
285
  - lib/scrivito/access_denied.rb
286
+ - lib/scrivito/associations.rb
281
287
  - lib/scrivito/attribute_content.rb
282
288
  - lib/scrivito/attribute_definition.rb
283
289
  - lib/scrivito/attribute_definition_collection.rb
@@ -367,17 +373,17 @@ files:
367
373
  - lib/scrivito/obj_data.rb
368
374
  - lib/scrivito/obj_data_from_hash.rb
369
375
  - lib/scrivito/obj_facet_value.rb
370
- - lib/scrivito/obj_params_parser.rb
371
376
  - lib/scrivito/obj_search_builder.rb
372
377
  - lib/scrivito/obj_search_enumerator.rb
373
378
  - lib/scrivito/obj_search_enumerator/batch.rb
374
379
  - lib/scrivito/obj_search_enumerator/batch_iterator.rb
375
380
  - lib/scrivito/obj_search_enumerator/facet_query.rb
376
381
  - lib/scrivito/obj_search_enumerator/query_executor.rb
377
- - lib/scrivito/obj_update_params_parser.rb
382
+ - lib/scrivito/obj_ui_config.rb
378
383
  - lib/scrivito/page_config.rb
379
384
  - lib/scrivito/parent_path.rb
380
385
  - lib/scrivito/preset_routes.rb
386
+ - lib/scrivito/publish_ability.rb
381
387
  - lib/scrivito/rate_limit_exceeded.rb
382
388
  - lib/scrivito/request_homepage.rb
383
389
  - lib/scrivito/restriction_set.rb
@@ -421,9 +427,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
421
427
  version: 2.1.0
422
428
  required_rubygems_version: !ruby/object:Gem::Requirement
423
429
  requirements:
424
- - - ">="
430
+ - - ">"
425
431
  - !ruby/object:Gem::Version
426
- version: '0'
432
+ version: 1.3.1
427
433
  requirements: []
428
434
  rubyforge_project:
429
435
  rubygems_version: 2.4.5
@@ -1 +0,0 @@
1
- json.array! @suggested_users, :id, :description
@@ -1,36 +0,0 @@
1
- module Scrivito
2
- class ObjParamsParser < Struct.new(:host, :port, :context)
3
- class UnknownWidgetAction < ScrivitoError
4
- end
5
-
6
- def parse(params)
7
- params = params.deep_dup
8
- convert_params(params)
9
- params
10
- end
11
-
12
- private
13
-
14
- def convert_field_params(params, attribute_definitions)
15
- params.each_pair do |key, value|
16
- params[key] = case type = attribute_definitions[key.to_s].try(:type)
17
- when 'binary' then parse_binary_params(value)
18
- when 'html' then ContentConversion.convert_html_links(value, host, port)
19
- when 'link' then ContentConversion.convert_link(value, host, port)
20
- when 'linklist' then ContentConversion.convert_linklist_urls(value, host, port)
21
- when 'date' then DateConversion.deserialize_from_client(value)
22
- else value
23
- end
24
- end
25
- end
26
-
27
- def parse_binary_params(params)
28
- return unless params
29
- UploadedBinary.new(params)
30
- end
31
-
32
- def raise_widget_not_found_error(widget_id)
33
- raise ResourceNotFound, "Could not find Widget with id #{widget_id}"
34
- end
35
- end
36
- end
@@ -1,28 +0,0 @@
1
- module Scrivito
2
- class ObjUpdateParamsParser < ObjParamsParser
3
- private
4
-
5
- def obj
6
- context[:current_obj]
7
- end
8
-
9
- def convert_params(params)
10
- convert_field_params(params, obj.attribute_definitions)
11
- convert_widget_pool_params(params)
12
- end
13
-
14
- def convert_widget_pool_params(params)
15
- return unless params['_widget_pool']
16
-
17
- widget_pool = {}
18
- params['_widget_pool'].each_pair do |widget_id, widget_params|
19
- if widget_params.present?
20
- widget = obj.widgets[widget_id]
21
- raise_widget_not_found_error(widget_id) unless widget
22
- widget_pool[widget] = convert_field_params(widget_params, widget.attribute_definitions)
23
- end
24
- end
25
- params['_widget_pool'] = widget_pool
26
- end
27
- end
28
- end