scrivito_sdk 1.1.1 → 1.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/scrivito/blobs_controller.rb +7 -0
  3. data/app/controllers/scrivito/objs_controller.rb +0 -6
  4. data/app/controllers/scrivito/ui_controller.rb +2 -0
  5. data/app/views/scrivito/blobs/{activate_upload.json.jbuilder → blob.json.jbuilder} +0 -0
  6. data/config/ca-bundle.crt +1 -1
  7. data/config/precedence_routes.rb +1 -1
  8. data/lib/assets/javascripts/scrivito_ui.js +20072 -19687
  9. data/lib/assets/stylesheets/scrivito.css +1 -1
  10. data/lib/assets/stylesheets/scrivito_ui.css +1 -1
  11. data/lib/generators/scrivito/install/install_generator.rb +2 -8
  12. data/lib/generators/scrivito/install/templates/app/views/download/details.html.erb +11 -0
  13. data/lib/generators/scrivito/install/templates/app/views/headline_widget/thumbnail.html.erb +1 -1
  14. data/lib/generators/scrivito/install/templates/app/views/image/details.html.erb +17 -0
  15. data/lib/generators/scrivito/install/templates/app/views/image_widget/thumbnail.html.erb +1 -1
  16. data/lib/generators/scrivito/install/templates/app/views/page/details.html.erb +4 -2
  17. data/lib/generators/scrivito/install/templates/app/views/page/thumbnail.html.erb +1 -3
  18. data/lib/generators/scrivito/install/templates/app/views/text_widget/thumbnail.html.erb +2 -2
  19. data/lib/generators/scrivito/page/page_generator.rb +8 -0
  20. data/lib/generators/scrivito/page/templates/details.html.erb +4 -2
  21. data/lib/generators/scrivito/page/templates/thumbnail.html.erb +1 -3
  22. data/lib/generators/scrivito/widget/templates/details.html.erb +4 -2
  23. data/lib/generators/scrivito/widget/templates/show.html.erb +1 -2
  24. data/lib/generators/scrivito/widget/templates/thumbnail.html.erb +1 -3
  25. data/lib/generators/scrivito/widget/widget_generator.rb +0 -4
  26. data/lib/scrivito/attribute_content.rb +44 -15
  27. data/lib/scrivito/attribute_definition.rb +59 -3
  28. data/lib/scrivito/basic_obj.rb +11 -18
  29. data/lib/scrivito/basic_widget.rb +42 -0
  30. data/lib/scrivito/binary.rb +5 -5
  31. data/lib/scrivito/cache_middleware.rb +13 -17
  32. data/lib/scrivito/class_collection.rb +1 -1
  33. data/lib/scrivito/client_attribute_serializer.rb +5 -1
  34. data/lib/scrivito/cms_backend.rb +43 -60
  35. data/lib/scrivito/cms_data_cache.rb +18 -14
  36. data/lib/scrivito/cms_field_tag.rb +2 -2
  37. data/lib/scrivito/cms_rest_api.rb +9 -8
  38. data/lib/scrivito/cms_routing.rb +1 -1
  39. data/lib/scrivito/configuration.rb +15 -4
  40. data/lib/scrivito/connection_manager.rb +29 -23
  41. data/lib/scrivito/model_library.rb +43 -11
  42. data/lib/scrivito/obj_collection.rb +1 -1
  43. data/lib/scrivito/obj_params_parser.rb +1 -19
  44. data/lib/scrivito/obj_search_enumerator/query_executor.rb +1 -1
  45. data/lib/scrivito/obj_search_enumerator.rb +1 -1
  46. data/lib/scrivito/ui_config.rb +13 -2
  47. data/lib/scrivito/widget_collection.rb +1 -1
  48. data/lib/scrivito/workspace.rb +25 -26
  49. data/lib/scrivito_sdk.rb +67 -40
  50. metadata +21 -8
  51. data/lib/generators/scrivito/install/templates/app/views/download/embed.html.erb +0 -1
  52. data/lib/generators/scrivito/install/templates/app/views/image/embed.html.erb +0 -1
  53. data/lib/scrivito/widget_garbage_collection.rb +0 -97
@@ -41,18 +41,12 @@ module Scrivito
41
41
 
42
42
  def copy_image_files
43
43
  copy_file 'app/models/image.rb'
44
- #
45
- # FIXME content-widget
46
- #
47
- # copy_file 'app/views/image/embed.html.erb'
44
+ copy_file 'app/views/image/details.html.erb'
48
45
  end
49
46
 
50
47
  def copy_download_files
51
48
  copy_file 'app/models/download.rb'
52
- #
53
- # FIXME content-widget
54
- #
55
- # copy_file 'app/views/download/embed.html.erb'
49
+ copy_file 'app/views/download/details.html.erb'
56
50
  end
57
51
 
58
52
  def copy_headline_widget_files
@@ -0,0 +1,11 @@
1
+ <%= scrivito_medium_dialog do %>
2
+ <%= scrivito_details_for do %>
3
+ <%= scrivito_tag :div, @obj, :blob do %>
4
+ <%= link_to @obj.description_for_editor, scrivito_path(@obj), :target => :blank %>
5
+ <% end %>
6
+ <% end %>
7
+
8
+ <%= scrivito_details_for do %>
9
+ <%= number_to_human_size @obj.meta_data[:content_length] %>
10
+ <% end %>
11
+ <% end %>
@@ -1,3 +1,3 @@
1
- <%= scrivito_thumbnail 'Headline Widget', :headline do %>
1
+ <%= scrivito_thumbnail HeadlineWidget.description_for_editor, :headline do %>
2
2
  A headline widget.
3
3
  <% end %>
@@ -0,0 +1,17 @@
1
+ <%= scrivito_medium_dialog do %>
2
+ <%= scrivito_details_for do %>
3
+ <%= scrivito_image_tag @obj %>
4
+ <% end %>
5
+
6
+ <%= scrivito_details_for do %>
7
+ <% if @obj.meta_data[:width] && @obj.meta_data[:height]%>
8
+ <div>
9
+ <%= @obj.meta_data[:width] %> × <%= @obj.meta_data[:height] %> px
10
+ </div>
11
+ <% end %>
12
+
13
+ <div>
14
+ <%= number_to_human_size @obj.meta_data[:content_length] %>
15
+ </div>
16
+ <% end %>
17
+ <% end %>
@@ -1,3 +1,3 @@
1
- <%= scrivito_thumbnail 'Image Widget', :image do %>
1
+ <%= scrivito_thumbnail ImageWidget.description_for_editor, :image do %>
2
2
  A widget with an image.
3
3
  <% end %>
@@ -1,3 +1,5 @@
1
- <%= scrivito_details_for 'Title' do %>
2
- <%= scrivito_tag :div, @obj, :title %>
1
+ <%= scrivito_medium_dialog do %>
2
+ <%= scrivito_details_for "Title" do %>
3
+ <%= scrivito_tag :div, @obj, :title %>
4
+ <% end %>
3
5
  <% end %>
@@ -1,3 +1 @@
1
- <%= scrivito_thumbnail 'Page', :content do %>
2
- A simple content page with a headline and content consisting of widgets.
3
- <% end %>
1
+ <%= scrivito_thumbnail Page.description_for_editor, :content %>
@@ -1,3 +1,3 @@
1
- <%= scrivito_thumbnail 'Text Widget', :text do %>
2
- A widget for text and HTML content.
1
+ <%= scrivito_thumbnail TextWidget.description_for_editor, :text do %>
2
+ A widget for HTML content.
3
3
  <% end %>
@@ -19,6 +19,14 @@ module Scrivito
19
19
  copy_file 'details.html.erb', "app/views/#{file_name}/details.html.erb"
20
20
  template 'thumbnail.html.erb', "app/views/#{file_name}/thumbnail.html.erb"
21
21
  end
22
+
23
+ def file_name
24
+ super.ends_with?('page') ? super : "#{super}_page"
25
+ end
26
+
27
+ def class_name
28
+ super.ends_with?('page') || super.ends_with?('Page') ? super : "#{super}Page"
29
+ end
22
30
  end
23
31
  end
24
32
  end
@@ -1,3 +1,5 @@
1
- <%= scrivito_details_for 'Title' do %>
2
- <%= scrivito_tag :div, @obj, :title %>
1
+ <%= scrivito_medium_dialog do %>
2
+ <%= scrivito_details_for "Title" do %>
3
+ <%= scrivito_tag :div, @obj, :title %>
4
+ <% end %>
3
5
  <% end %>
@@ -1,3 +1 @@
1
- <%%= scrivito_thumbnail '<%= class_name %>', :content do %>
2
- <%= class_name %>
3
- <%% end %>
1
+ <%%= scrivito_thumbnail <%= class_name %>.description_for_editor, :content %>
@@ -1,2 +1,4 @@
1
- This is the details view of the <%= human_name %>.
2
- Edit "app/views/<%= file_name %>/details.html.erb" to change its appearance.
1
+ <%%= scrivito_medium_dialog do %>
2
+ <%%= scrivito_details_for <%= class_name %>.description_for_editor do %>
3
+ <%% end %>
4
+ <%% end %>
@@ -1,2 +1 @@
1
- This is the show view of the <%= human_name %>.
2
- Edit "app/views/<%= file_name %>/show.html.erb" to change its appearance.
1
+ This is the show view of the <%%= <%= class_name %>.description_for_editor %>.
@@ -1,3 +1 @@
1
- <%%= scrivito_thumbnail '<%= human_name %>' do %>
2
- <!-- Add the detailed description of the widget here. -->
3
- <%% end %>
1
+ <%%= scrivito_thumbnail <%= class_name %>.description_for_editor %>
@@ -23,10 +23,6 @@ module Scrivito
23
23
  def class_name
24
24
  super.ends_with?('Widget') ? super : "#{super}Widget"
25
25
  end
26
-
27
- def human_name
28
- class_name.underscore.humanize
29
- end
30
26
  end
31
27
  end
32
28
  end
@@ -200,11 +200,6 @@ module AttributeContent
200
200
  widgets
201
201
  end
202
202
 
203
- def contained_widgets
204
- referenced = referenced_widgets
205
- referenced + referenced.map { |widget| widget.contained_widgets }.flatten
206
- end
207
-
208
203
  def update_data(data)
209
204
  self.data_from_cms = data
210
205
  @attribute_cache = {}
@@ -342,15 +337,24 @@ module AttributeContent
342
337
  # @option options [Symbol, String] :default custom default value.
343
338
  # See {Scrivito::AttributeContent::DEFAULT_ATTRIBUTE_VALUES} for factory defaults.
344
339
  # See {Scrivito::AttributeContent::ClassMethods#default_for} for more advanced defaults.
340
+ # @option options [Class, Array<Class>] :only specifies (for use in the UI) the valid classes
341
+ # _of_ _the_ _values_ in a +reference+ or a +referencelist+ attribute, e.g. +Image+ or +Video+.
342
+ # Raises an error if the attribute type is neither +reference+ nor +referencelist+. If not
343
+ # specified, the UI assumes that any class is valid.
345
344
  #
346
345
  # @return nil
346
+ #
347
347
  # @raise [Scrivito::ScrivitoError] if the +type+ is unknown
348
348
  # @raise [Scrivito::ScrivitoError] if the +values+ include an empty string
349
+ # @raise [Scrivito::ScrivitoError] if the +only+ option is specified, but the +type+ is neither
350
+ # +reference+ nor +referencelist+
351
+ # @raise [Scrivito::ScrivitoError] if the +only+ option includes invalid value(s)
352
+ #
349
353
  # @see Scrivito::AttributeContent::DEFAULT_ATTRIBUTE_VALUES
350
354
  # @see Scrivito::AttributeContent::ClassMethods#default_for
351
355
  #
352
356
  # @example Defining attributes:
353
- # class Page < ::Obj
357
+ # class Page < Obj
354
358
  # attribute :my_string, :string
355
359
  # attribute 'my_html', 'my_html'
356
360
  # attribute :my_enum, :enum, values: %w[a b c], default: 'a'
@@ -380,7 +384,7 @@ module AttributeContent
380
384
  # #=> []
381
385
  #
382
386
  # @example Inheriting attributes:
383
- # class Page < ::Obj
387
+ # class Page < Obj
384
388
  # attribute :title, :string
385
389
  # end
386
390
  #
@@ -391,7 +395,7 @@ module AttributeContent
391
395
  # #=> "string"
392
396
  #
393
397
  # @example Overriding inherited attributes:
394
- # class Page < ::Obj
398
+ # class Page < Obj
395
399
  # attribute :title, :string
396
400
  # end
397
401
  #
@@ -405,6 +409,18 @@ module AttributeContent
405
409
  # SpecialPage.attribute_definitions[:title].type
406
410
  # #=> "html"
407
411
  #
412
+ # @example Specifying valid classes for +reference+ attributes:
413
+ # class Page < Obj
414
+ # attribute :my_reference1, :reference, only: Image
415
+ # attribute :my_reference2, :reference, only: [Image, Video]
416
+ # end
417
+ #
418
+ # ImageWidget.attribute_definitions[:my_reference1].valid_classes
419
+ # #=> [Image]
420
+ #
421
+ # ImageWidget.attribute_definitions[:my_reference2].valid_classes
422
+ # #=> [Image, Video]
423
+ #
408
424
  # @see http://scrivito.com/default-attribute-values Specifying default attribute values
409
425
  #
410
426
  def attribute(name, type, options = {})
@@ -421,7 +437,8 @@ module AttributeContent
421
437
  end
422
438
 
423
439
  #
424
- # Sets the default value of an attribute.
440
+ # Sets the default value of an attribute defined by
441
+ # {Scrivito::AttributeContent::ClassMethods#attribute}.
425
442
  #
426
443
  # @api public
427
444
  #
@@ -524,18 +541,22 @@ module AttributeContent
524
541
  nil
525
542
  end
526
543
 
544
+ #
545
+ # Short description of a CMS object or widget type for the UI.
546
+ #
527
547
  # @api public
528
548
  #
529
- # Short description of a CMS object or widget type for the UI. The description is displayed
530
- # when adding new pages or widgets, for example. As a general rule, it is used whenever no
531
- # widget or object instance is available. If there is, the {Scrivito::BasicObj#description_for_editor}
532
- # and, respectively, {Scrivito::BasicWidget#description_for_editor} instance methods are used instead.
549
+ # The description is displayed when adding new pages or widgets, for example. As a general rule,
550
+ # it is used whenever no widget or object instance is available. If there is, the
551
+ # {Scrivito::BasicObj#description_for_editor} and, respectively,
552
+ # {Scrivito::BasicWidget#description_for_editor} instance methods are used instead.
533
553
  #
534
554
  # This method can be overridden to customize the description displayed to editors.
535
555
  #
536
- # @return [String] the +Class+ name
556
+ # @return [String] short description of a CMS object or widget type for the UI
557
+ #
537
558
  def description_for_editor
538
- name
559
+ name.titleize
539
560
  end
540
561
 
541
562
  #
@@ -622,6 +643,14 @@ module AttributeContent
622
643
  attributes
623
644
  end
624
645
 
646
+ def as_json
647
+ {
648
+ name: name,
649
+ descriptionForEditor: description_for_editor,
650
+ attributes: attribute_definitions.map(&:as_json),
651
+ }
652
+ end
653
+
625
654
  protected
626
655
 
627
656
  def assert_valid_attribute_name(name)
@@ -37,17 +37,59 @@ class AttributeDefinition
37
37
  end
38
38
  end
39
39
 
40
- def widgetlist?
41
- type == 'widgetlist'
40
+ #
41
+ # Valid classes of a +reference+ or a +referencelist+ attribute.
42
+ #
43
+ # @api beta
44
+ #
45
+ # @raise [Scrivito::ScrivitoError] if +type+ is neither +reference+, nor +referencelist+.
46
+ # @return [Array<Class>] valid classes specified using the
47
+ # {Scrivito::AttributeContent::ClassMethods#attribute only} option.
48
+ # @return +nil+ if no valid classes has been specified.
49
+ #
50
+ def valid_classes
51
+ assert_restrictable
52
+ @valid_classes
53
+ end
54
+
55
+ AttributeContent::ATTRIBUTE_TYPES.each do |attribute_type|
56
+ define_method "#{attribute_type}?" do
57
+ type == attribute_type
58
+ end
59
+ end
60
+
61
+ def as_json
62
+ hash = {
63
+ name: name,
64
+ type: type,
65
+ }
66
+
67
+ if enum? || multienum?
68
+ hash[:validValues] = values
69
+ end
70
+
71
+
72
+ if (reference? || referencelist?) && valid_classes
73
+ hash[:validClasses] = valid_classes.map(&:name)
74
+ end
75
+
76
+ hash
42
77
  end
43
78
 
44
79
  private
45
80
 
46
81
  def assert_valid_options
47
- @options.assert_valid_keys(:values, 'values')
82
+ @options.assert_valid_keys(:values, 'values', :only, 'only')
83
+
48
84
  if values = @options[:values]
49
85
  values.each(&method(:assert_valid_value))
50
86
  end
87
+
88
+ if only = @options[:only]
89
+ assert_restrictable
90
+ @valid_classes = [@options[:only]].flatten
91
+ @valid_classes.each(&method(:assert_valid_restriction_class))
92
+ end
51
93
  end
52
94
 
53
95
  def assert_valid_value(value)
@@ -60,6 +102,20 @@ class AttributeDefinition
60
102
  raise ScrivitoError, %{Empty string is not allowed as value for #{type} attribute "#{name}".}
61
103
  end
62
104
  end
105
+
106
+ def assert_restrictable
107
+ unless %w[reference referencelist].include?(type)
108
+ raise ScrivitoError, "#{type} attribute \"#{name}\" has no restrictions: "\
109
+ 'only reference and referencelist attributes can be restricted with the "only" option.'
110
+ end
111
+ end
112
+
113
+ def assert_valid_restriction_class(obj_class)
114
+ unless obj_class.is_a?(Class) && BasicObj > obj_class
115
+ raise ScrivitoError, "Cannot restrict attribute \"#{name}\" to #{obj_class.inspect}: "\
116
+ "#{obj_class} is not a valid model class."
117
+ end
118
+ end
63
119
  end
64
120
 
65
121
  end
@@ -664,7 +664,7 @@ module Scrivito
664
664
  def reload_data
665
665
  id = self.id.to_s
666
666
  update_data -> {
667
- CmsBackend.instance.find_obj_data_by(workspace.revision, :id, [id]).first.first
667
+ CmsBackend.find_obj_data_by(workspace.revision, :id, [id]).first.first
668
668
  }
669
669
  end
670
670
 
@@ -927,7 +927,7 @@ module Scrivito
927
927
  return [self, attribute_name]
928
928
  end
929
929
 
930
- all_widgets_from_pool.each do |container_widget|
930
+ contained_widgets.each do |container_widget|
931
931
  if attribute_name = container_widget.find_attribute_containing_widget(widget_id)
932
932
  return [container_widget, attribute_name]
933
933
  end
@@ -948,12 +948,6 @@ module Scrivito
948
948
  !has_conflict?
949
949
  end
950
950
 
951
- def all_widgets_from_pool
952
- read_widget_pool.keys.map do |widget_id|
953
- widget_from_pool(widget_id)
954
- end
955
- end
956
-
957
951
  def generate_widget_pool_id
958
952
  10.times do
959
953
  id = self.class.generate_widget_pool_id
@@ -964,6 +958,10 @@ module Scrivito
964
958
  raise ScrivitoError.new('Could not generate a new unused widget id')
965
959
  end
966
960
 
961
+ def contained_widgets
962
+ read_widget_pool.keys.map(&method(:widget_from_pool))
963
+ end
964
+
967
965
  def parent_path
968
966
  ParentPath.of(path) unless root?
969
967
  end
@@ -1027,7 +1025,7 @@ module Scrivito
1027
1025
 
1028
1026
  def reset_modifications
1029
1027
  case
1030
- when new? then destroy
1028
+ when new? then workspace.api_request(:delete, "/objs/#{id}")
1031
1029
  when deleted? then self.class.restore(id)
1032
1030
  else revert
1033
1031
  end
@@ -1036,7 +1034,7 @@ module Scrivito
1036
1034
  def cms_data_for_revision(revision)
1037
1035
  return nil unless revision
1038
1036
 
1039
- result = CmsBackend.instance.find_obj_data_by(revision, "id", [id])
1037
+ result = CmsBackend.find_obj_data_by(revision, "id", [id])
1040
1038
  obj_data = result.first.first
1041
1039
 
1042
1040
  if obj_data && obj_data.value_of("_modification") != "deleted"
@@ -1183,13 +1181,6 @@ module Scrivito
1183
1181
  obj_attributes, widget_pool_attributes, workspace, obj_id
1184
1182
  )
1185
1183
 
1186
- if obj
1187
- widget_pool = api_attributes['_widget_pool']
1188
- widget_gc = WidgetGarbageCollection.new(obj,
1189
- {obj => obj_attributes}.merge(widget_pool_attributes))
1190
- widget_gc.widgets_to_delete.each { |widget| widget_pool[widget.id] = nil }
1191
- end
1192
-
1193
1184
  [api_attributes, widget_pool_attributes]
1194
1185
  end
1195
1186
 
@@ -1210,7 +1201,9 @@ module Scrivito
1210
1201
  {}.tap do |serialized_attributes|
1211
1202
  widget_pool_attributes.each_pair do |widget, widget_attributes|
1212
1203
  obj_class = widget_attributes['_obj_class']
1213
- serialized_attributes[widget.id] = serializer.serialize(widget_attributes,
1204
+ widget_serializer = AttributeSerializer.new(obj_class, serializer.obj_id)
1205
+
1206
+ serialized_attributes[widget.id] = widget_serializer.serialize(widget_attributes,
1214
1207
  find_attribute_definitions(obj_class, BasicWidget) || widget.attribute_definitions)
1215
1208
  end
1216
1209
  end
@@ -55,6 +55,43 @@ class BasicWidget
55
55
  computed_classes.nil? || computed_classes.include?(container_class)
56
56
  end
57
57
 
58
+ # @api beta
59
+ def self.embeds(attribute_name)
60
+ @embedding_attribute = attribute_name
61
+ nil
62
+ end
63
+
64
+ # @api beta
65
+ def self.embeds?
66
+ !!@embedding_attribute || !!superclass.try(:embeds?)
67
+ end
68
+
69
+ # @api beta
70
+ def self.embedding_attribute
71
+ raise ScrivitoError, "#{self} has no embedding attribute" unless embeds?
72
+
73
+ if @embedding_attribute
74
+ unless attribute_definition = attribute_definitions[@embedding_attribute]
75
+ raise ScrivitoError, %{Unknown attribute: "#{@embedding_attribute}"}
76
+ end
77
+
78
+ unless attribute_definition.reference?
79
+ raise ScrivitoError, %{Embedding attribute "#{@embedding_attribute}" must be a reference}
80
+ end
81
+
82
+ attribute_definition
83
+ else
84
+ superclass.embedding_attribute
85
+ end
86
+ end
87
+
88
+ def self.as_json
89
+ super.merge(
90
+ embeds: embeds?,
91
+ embeddingAttribute: @embedding_attribute,
92
+ )
93
+ end
94
+
58
95
  attr_accessor :container, :container_attribute_name
59
96
 
60
97
  attr_writer :obj, :id
@@ -363,6 +400,11 @@ class BasicWidget
363
400
  end
364
401
  end
365
402
 
403
+ def contained_widgets
404
+ referenced = referenced_widgets
405
+ referenced + referenced.map { |widget| widget.contained_widgets }.flatten
406
+ end
407
+
366
408
  private
367
409
 
368
410
  def workspace
@@ -112,12 +112,12 @@ class Binary
112
112
 
113
113
  def no_cache_url
114
114
  if private?
115
- CmsBackend.instance.find_blob_data(id, 'private_access', 'get', no_cache: true)['url']
115
+ CmsBackend.find_blob_data(id, 'private_access', 'get', no_cache: true)['url']
116
116
  end
117
117
  end
118
118
 
119
119
  def url_from_cache
120
- blob_data = CmsBackend.instance.find_blob_data_from_cache(id, access_type, 'get',
120
+ blob_data = CmsBackend.find_blob_data_from_cache(id, access_type, 'get',
121
121
  transformation_definition: transformation_definition)
122
122
  if blob_data
123
123
  blob_data['url']
@@ -290,7 +290,7 @@ class Binary
290
290
  raise_field_not_available('Meta data') if transformed?
291
291
 
292
292
  @meta_data ||= begin
293
- deserialized_meta_data = deserialize_meta_data(CmsBackend.instance.find_binary_meta_data(id))
293
+ deserialized_meta_data = deserialize_meta_data(CmsBackend.find_binary_meta_data(id))
294
294
  MetaDataCollection.new(deserialized_meta_data)
295
295
  end
296
296
  end
@@ -306,11 +306,11 @@ class Binary
306
306
  end
307
307
 
308
308
  def headers
309
- CmsBackend.instance.find_blob_metadata(id, find_url('head'))
309
+ CmsBackend.find_blob_metadata(id, find_url('head'))
310
310
  end
311
311
 
312
312
  def find_url(verb)
313
- blob_data = CmsBackend.instance.find_blob_data(id, access_type, verb,
313
+ blob_data = CmsBackend.find_blob_data(id, access_type, verb,
314
314
  transformation_definition: transformation_definition)
315
315
  blob_data['url']
316
316
  rescue ClientError => e
@@ -1,23 +1,19 @@
1
1
  module Scrivito
2
+ class CacheMiddleware
3
+ def initialize(app)
4
+ @app = app
5
+ end
2
6
 
3
- class CacheMiddleware
4
- def initialize(app)
5
- @app = app
6
- end
7
-
8
- def call(env)
9
- clear_caches
10
-
11
- @app.call(env)
12
- end
13
-
7
+ def call(env)
8
+ clear_cache
9
+ @app.call(env)
10
+ end
14
11
 
15
- private
12
+ private
16
13
 
17
- def clear_caches
18
- Workspace.cache.clear
19
- CmsBackend.instance.clear_cache
14
+ def clear_cache
15
+ Workspace.cache.clear
16
+ CmsDataCache.clear_request_cache
17
+ end
20
18
  end
21
19
  end
22
-
23
- end # module Scrivito
@@ -7,7 +7,7 @@ class ClassCollection
7
7
  include Enumerable
8
8
 
9
9
  def initialize(classes)
10
- @classes = classes
10
+ @classes = classes.compact.uniq
11
11
  end
12
12
 
13
13
  #
@@ -67,7 +67,11 @@ module ClientAttributeSerializer
67
67
  end
68
68
 
69
69
  def self.serialize_binary_value(value)
70
- {'url' => value.url, 'filename' => value.filename}
70
+ {
71
+ 'filename' => value.filename,
72
+ 'id' => value.id,
73
+ 'url' => value.url,
74
+ }
71
75
  end
72
76
 
73
77
  def self.serialize_date_value(value)