infopark_fiona7 1.2.0.0.1 → 1.2.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/scrivito_patches/models/obj.js +2 -6
  3. data/infopark_fiona7.gemspec +1 -1
  4. data/lib/fiona7/attribute_readers/attribute_reader.rb +17 -0
  5. data/lib/fiona7/attribute_readers/binary_as_binary.rb +12 -0
  6. data/lib/fiona7/attribute_readers/binary_as_linklist.rb +26 -0
  7. data/lib/fiona7/attribute_readers/date_as_date.rb +18 -0
  8. data/lib/fiona7/attribute_readers/factory.rb +91 -0
  9. data/lib/fiona7/attribute_readers/helpers/html_deserializer.rb +21 -0
  10. data/lib/fiona7/attribute_readers/helpers/json_deserializer.rb +11 -0
  11. data/lib/fiona7/attribute_readers/helpers/link_deserializer.rb +32 -0
  12. data/lib/fiona7/attribute_readers/html_as_html.rb +14 -0
  13. data/lib/fiona7/attribute_readers/link_as_linklist.rb +13 -0
  14. data/lib/fiona7/attribute_readers/linklist_as_linklist.rb +15 -0
  15. data/lib/fiona7/attribute_readers/multienum_as_multienum.rb +12 -0
  16. data/lib/fiona7/attribute_readers/multienum_as_text.rb +14 -0
  17. data/lib/fiona7/attribute_readers/number_as_string.rb +11 -0
  18. data/lib/fiona7/attribute_readers/reference_as_linklist.rb +14 -0
  19. data/lib/fiona7/attribute_readers/reference_as_string.rb +11 -0
  20. data/lib/fiona7/attribute_readers/referencelist_as_linklist.rb +16 -0
  21. data/lib/fiona7/attribute_readers/referencelist_as_text.rb +14 -0
  22. data/lib/fiona7/attribute_readers/simple.rb +18 -0
  23. data/lib/fiona7/attribute_readers/stringlist_as_text.rb +18 -0
  24. data/lib/fiona7/attribute_readers/widgetlist_as_linklist.rb +33 -0
  25. data/lib/fiona7/attribute_type_mapper.rb +76 -0
  26. data/lib/fiona7/attribute_writers/attribute_writer.rb +16 -0
  27. data/lib/fiona7/attribute_writers/binary_as_binary.rb +74 -0
  28. data/lib/fiona7/attribute_writers/binary_as_linklist.rb +86 -0
  29. data/lib/fiona7/attribute_writers/date_as_date.rb +11 -0
  30. data/lib/fiona7/attribute_writers/factory.rb +90 -0
  31. data/lib/fiona7/attribute_writers/helpers/html_serializer.rb +21 -0
  32. data/lib/fiona7/attribute_writers/helpers/json_serializer.rb +11 -0
  33. data/lib/fiona7/attribute_writers/helpers/link_serializer.rb +37 -0
  34. data/lib/fiona7/attribute_writers/html_as_html.rb +12 -0
  35. data/lib/fiona7/attribute_writers/link_as_linklist.rb +18 -0
  36. data/lib/fiona7/attribute_writers/linklist_as_linklist.rb +16 -0
  37. data/lib/fiona7/attribute_writers/multienum_as_multienum.rb +11 -0
  38. data/lib/fiona7/attribute_writers/multienum_as_text.rb +12 -0
  39. data/lib/fiona7/attribute_writers/number_as_string.rb +11 -0
  40. data/lib/fiona7/attribute_writers/reference_as_linklist.rb +17 -0
  41. data/lib/fiona7/attribute_writers/reference_as_string.rb +11 -0
  42. data/lib/fiona7/attribute_writers/referencelist_as_linklist.rb +19 -0
  43. data/lib/fiona7/attribute_writers/referencelist_as_text.rb +13 -0
  44. data/lib/fiona7/attribute_writers/simple.rb +11 -0
  45. data/lib/fiona7/attribute_writers/stringlist_as_text.rb +16 -0
  46. data/lib/fiona7/attribute_writers/widgetlist_as_linklist.rb +33 -0
  47. data/lib/fiona7/builder/obj_builder.rb +12 -201
  48. data/lib/fiona7/controllers/rest_api/obj_controller.rb +23 -5
  49. data/lib/fiona7/engine.rb +39 -0
  50. data/lib/fiona7/json/obj_decorator.rb +29 -121
  51. data/lib/fiona7/prefetch/obj_prefetch.rb +42 -0
  52. data/lib/fiona7/prefetch/widget_resolver_prefetch.rb +36 -0
  53. data/lib/fiona7/scrivito_patches/date_attribute.rb +16 -0
  54. data/lib/fiona7/tools/attribute_remover.rb +70 -0
  55. data/lib/fiona7/type_register.rb +9 -1
  56. data/lib/fiona7/version.rb +1 -1
  57. data/lib/fiona7/widget_resolver.rb +6 -6
  58. metadata +51 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7d3bb2d10bc2f11b32b9754210ed0ef10341556
4
- data.tar.gz: fd71316becc16a5f10c1c546ca1c97389cb9afbb
3
+ metadata.gz: 8a6ec5e35fd0d8751ebef7a921e1041b74b6991f
4
+ data.tar.gz: 0340bd069fc11e65504711408488f8a6b088a7ec
5
5
  SHA512:
6
- metadata.gz: 454999faa3d435587f987af8f1af4a636e75b767e50938bf2e2235541e1a35fe3a4cf7133b407f407e31d5ce936fecbcab41b6fb3d43a29ce4585008463f7356
7
- data.tar.gz: 0271a2e3031ec96cdc812903d97d29bdb445a9efc5c77afe712f081c012ffaba693c61289a74fe2199838897d674371e34033a3d6f5b44217e7b0b2accbde1e3
6
+ metadata.gz: 9c37220478fa274a9afaff2535af1bdfcf6cdc4d25b14ea6f9f219738fa36a6c4314b633317977c86be20ea3f8d055480141bcd5b9c99f4c0860a5337a4e8127
7
+ data.tar.gz: 23adf98f303eb22bfe138f66934fc421b9f0dbbdf11619ef99bfdce3f1df1dd897ef5acfa7f66430a242c494f9bd4d986643378743aca3bfc33376864d553c91
@@ -232,7 +232,7 @@
232
232
  $.each(attrs, function (key, value) {
233
233
  if (value && value.is_uploaded_binary && value.filename) {
234
234
  default_name = value.filename;
235
- } else if (instance_of_anywhere(value, 'File')) {
235
+ } else if (is_file(value)) {
236
236
  default_name = value.name;
237
237
  }
238
238
  });
@@ -273,7 +273,7 @@
273
273
  $.each(attributes, function (key, value) {
274
274
  if (value && value.is_uploaded_binary) {
275
275
  has_binary=true;
276
- } else if (instance_of_anywhere(value, 'File')) {
276
+ } else if (is_file(value)) {
277
277
  has_binary=true
278
278
  }
279
279
  });
@@ -344,10 +344,6 @@
344
344
  _.isString(object.name);
345
345
  };
346
346
 
347
- var instance_of_anywhere = function (object, ctor_name) {
348
- return (object && (typeof object === 'object') && object.constructor && object.constructor.name === ctor_name);
349
- };
350
-
351
347
  var format_date_number = function(number) {
352
348
  var string = number.toString();
353
349
  return string.length === 1 ? '0' + string : string;
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency "scrivito_sdk"
22
22
  s.add_dependency "scrivito_editors"
23
23
  s.add_dependency "infopark_fiona_connector", "= 7.0.1.beta2"
24
- s.add_dependency "infopark_reactor", ">= 1.22.3"
24
+ s.add_dependency "infopark_reactor", ">= 1.22.4"
25
25
  s.add_dependency "mini_magick"
26
26
  #s.add_development_dependency "ruby-prof"
27
27
  end
@@ -0,0 +1,17 @@
1
+ module Fiona7
2
+ module AttributeReaders
3
+ class AttributeReader
4
+ def initialize(obj, attr_name, widget_resolver)
5
+ self.obj = obj
6
+ self.attr_name = attr_name
7
+ self.widget_resolver = widget_resolver
8
+ end
9
+
10
+ def call
11
+ end
12
+
13
+ protected
14
+ attr_accessor :obj, :attr_name, :widget_resolver
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+ require 'fiona7/blob_id_generator'
3
+
4
+ module Fiona7
5
+ module AttributeReaders
6
+ class BinaryAsBinary < AttributeReader
7
+ def call
8
+ {id: Fiona7::BlobIdGenerator.new(self.obj.id, self.obj.last_changed).call}
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,26 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+ require 'fiona7/blob_id_generator'
3
+
4
+ module Fiona7
5
+ module AttributeReaders
6
+ class BinaryAsLinklist < AttributeReader
7
+ def call
8
+ if !Fiona7.mode == :legacy || !self.obj.binary?
9
+ deserialize_binary(self.obj.attr_values[self.attr_name].try(:first))
10
+ else
11
+ {id: Fiona7::BlobIdGenerator.new(self.obj.id, self.obj.last_changed).call}
12
+ end
13
+ end
14
+
15
+ protected
16
+ def deserialize_binary(link)
17
+ if link
18
+ binary_id = link["title"]
19
+ if binary_id.length == 32
20
+ {id: binary_id}
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+
3
+ module Fiona7
4
+ module AttributeReaders
5
+ class DateAsDate < AttributeReader
6
+ def call
7
+ # NOTE: this is a bug in fiona connector
8
+ # [valid_(from|until)] returns a raw string
9
+ if ["valid_from", "valid_until"].include?(self.attr_name.to_s)
10
+ self.obj[self.attr_name]
11
+ else
12
+ self.obj[self.attr_name].try(:utc).try(:to_iso)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,91 @@
1
+ require 'fiona7/attribute_readers/binary_as_binary'
2
+ require 'fiona7/attribute_readers/binary_as_linklist'
3
+ require 'fiona7/attribute_readers/date_as_date'
4
+ require 'fiona7/attribute_readers/html_as_html'
5
+ require 'fiona7/attribute_readers/link_as_linklist'
6
+ require 'fiona7/attribute_readers/linklist_as_linklist'
7
+ require 'fiona7/attribute_readers/multienum_as_multienum'
8
+ require 'fiona7/attribute_readers/multienum_as_text'
9
+ require 'fiona7/attribute_readers/number_as_string'
10
+ require 'fiona7/attribute_readers/reference_as_linklist'
11
+ require 'fiona7/attribute_readers/reference_as_string'
12
+ require 'fiona7/attribute_readers/referencelist_as_linklist'
13
+ require 'fiona7/attribute_readers/referencelist_as_text'
14
+ require 'fiona7/attribute_readers/simple'
15
+ require 'fiona7/attribute_readers/stringlist_as_text'
16
+ require 'fiona7/attribute_readers/widgetlist_as_linklist'
17
+
18
+ module Fiona7
19
+ module AttributeReaders
20
+ class Factory
21
+ def initialize(obj, type_def, widget_resolver)
22
+ self.obj = obj
23
+ self.type_def = type_def
24
+ self.widget_resolver = widget_resolver
25
+ end
26
+
27
+ def call(attribute, virtual_type, real_type)
28
+ virtual = virtual_type.to_sym
29
+ real = real_type.to_sym
30
+
31
+ worker = case [virtual, real]
32
+ when [:linklist, :linklist]
33
+ Fiona7::AttributeReaders::LinklistAsLinklist
34
+ when [:link, :linklist]
35
+ Fiona7::AttributeReaders::LinkAsLinklist
36
+ when [:reference, :linklist]
37
+ Fiona7::AttributeReaders::ReferenceAsLinklist
38
+ when [:reference, :string], [:reference, :text]
39
+ Fiona7::AttributeReaders::ReferenceAsString
40
+ when [:referencelist, :linklist]
41
+ Fiona7::AttributeReaders::ReferencelistAsLinklist
42
+ when [:referencelist, :text], [:referencelist, :string]
43
+ Fiona7::AttributeReaders::ReferencelistAsText
44
+ when [:widgetlist, :linklist]
45
+ Fiona7::AttributeReaders::WidgetlistAsLinklist
46
+ when [:multienum, :text], [:multienum, :string]
47
+ Fiona7::AttributeReaders::MultienumAsText
48
+ when [:multienum, :multienum]
49
+ Fiona7::AttributeReaders::MultienumAsMultienum
50
+ when [:number, :string], [:number, :text]
51
+ Fiona7::AttributeReaders::NumberAsString
52
+ when [:html, :html]
53
+ Fiona7::AttributeReaders::HtmlAsHtml
54
+ when [:binary, :linklist]
55
+ Fiona7::AttributeReaders::BinaryAsLinklist
56
+ when [:binary, :binary]
57
+ Fiona7::AttributeReaders::BinaryAsBinary
58
+ when [:stringlist, :text], [:stringlist, :string]
59
+ Fiona7::AttributeReaders::StringlistAsText
60
+ when [:stringlist, :multienum]
61
+ Fiona7::AttributeReaders::Simple
62
+ when [:stringlist, :stringlist]
63
+ # NOTE: this is practically only used for "channels"
64
+ Fiona7::AttributeReaders::Simple
65
+ else
66
+ case virtual
67
+ when :text, :string, :enum, :markdown
68
+ Fiona7::AttributeReaders::Simple
69
+ when :date
70
+ Fiona7::AttributeReaders::DateAsDate
71
+ else
72
+ # It would perhaps be practical to raise this error here
73
+ # but also risky: broken configurations may surface
74
+ # (attributes which had their attribute types changed).
75
+ # This would break some pages
76
+ #
77
+ # raise(Fiona7::TypeSystemError.new("Unable to read #{attribute} in #{self.type_def.name} with typing #{virtual}:#{real}"))
78
+ #
79
+ # So instead, it is better to "lose" some information.
80
+ return nil
81
+ end
82
+ end
83
+
84
+ worker.new(self.obj, attribute, self.widget_resolver)
85
+ end
86
+
87
+ protected
88
+ attr_accessor :obj, :obj_class, :type_def, :widget_resolver
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,21 @@
1
+ require 'fiona7/link_converter/fiona_to_scrivito'
2
+
3
+ module Fiona7
4
+ module AttributeReaders
5
+ module Helpers
6
+ class HtmlDeserializer
7
+ def initialize(obj)
8
+ self.link_converter = Fiona7::LinkConverter::FionaToScrivito.new(obj)
9
+ end
10
+
11
+ def call(value)
12
+ self.link_converter.convert(value)
13
+ end
14
+
15
+ protected
16
+ attr_accessor :link_converter
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,11 @@
1
+ module Fiona7
2
+ module AttributeReaders
3
+ module Helpers
4
+ class JsonDeserializer
5
+ def call(value)
6
+ ::JSON.parse(value) rescue nil
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,32 @@
1
+ module Fiona7
2
+ module AttributeReaders
3
+ module Helpers
4
+ class LinkDeserializer
5
+ def call(link)
6
+ if link
7
+ deserialized = {
8
+ # remove possible external prefix for protcol-less urls
9
+ url: link["url"].try(:gsub, /\Aexternal:/, ''),
10
+ title: link["title"],
11
+ target: link["target"],
12
+ # content service uses destination
13
+ destination: link["destination"].to_s,
14
+ # rest api uses obj_id
15
+ obj_id: link["destination"].to_s,
16
+ query: link["search"],
17
+ fragment: link["fragment"]
18
+ }
19
+
20
+ # TODO: refactor this code
21
+ if deserialized[:url].present?
22
+ deserialized.delete(:destination)
23
+ deserialized.delete(:obj_id)
24
+ end
25
+
26
+ deserialized
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,14 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+ require 'fiona7/attribute_readers/helpers/html_deserializer'
3
+
4
+ module Fiona7
5
+ module AttributeReaders
6
+ class HtmlAsHtml < AttributeReader
7
+ def call
8
+ value = self.obj[self.attr_name].to_s
9
+ Helpers::HtmlDeserializer.new(self.obj).call(value)
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,13 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+ require 'fiona7/attribute_readers/helpers/link_deserializer'
3
+
4
+ module Fiona7
5
+ module AttributeReaders
6
+ class LinkAsLinklist < AttributeReader
7
+ def call
8
+ link = self.obj.attr_values[self.attr_name].try(:first)
9
+ Helpers::LinkDeserializer.new.call(link)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+ require 'fiona7/attribute_readers/helpers/link_deserializer'
3
+
4
+ module Fiona7
5
+ module AttributeReaders
6
+ class LinklistAsLinklist < AttributeReader
7
+ def call
8
+ links = self.obj.attr_values[self.attr_name] || []
9
+ links.map do |link|
10
+ Helpers::LinkDeserializer.new.call(link)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+
3
+ module Fiona7
4
+ module AttributeReaders
5
+ class MultienumAsMultienum < AttributeReader
6
+ def call
7
+ self.obj[self.attr_name] || []
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,14 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+ require 'fiona7/attribute_readers/helpers/json_deserializer'
3
+
4
+ module Fiona7
5
+ module AttributeReaders
6
+ class MultienumAsText < AttributeReader
7
+ def call
8
+ value = self.obj[self.attr_name]
9
+ Helpers::JsonDeserializer.new.call(value).presence || []
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,11 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+
3
+ module Fiona7
4
+ module AttributeReaders
5
+ class NumberAsString < AttributeReader
6
+ def call
7
+ self.obj[self.attr_name].to_f
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+
3
+ module Fiona7
4
+ module AttributeReaders
5
+ class ReferenceAsLinklist < AttributeReader
6
+ def call
7
+ link = self.obj.attr_values[self.attr_name].try(:first)
8
+ if link && link["type"] == "internal"
9
+ link["destination"].to_s
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+
3
+ module Fiona7
4
+ module AttributeReaders
5
+ class ReferenceAsString < AttributeReader
6
+ def call
7
+ self.obj.attr_values[self.attr_name]
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+
3
+ module Fiona7
4
+ module AttributeReaders
5
+ class ReferencelistAsLinklist < AttributeReader
6
+ def call
7
+ links = self.obj.attr_values[self.attr_name] || []
8
+ links.map do |link|
9
+ if link && link["type"] == "internal"
10
+ link["destination"].to_s
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ require 'fiona7/attribute_readers/attribute_reader'
2
+ require 'fiona7/attribute_readers/helpers/json_deserializer'
3
+
4
+ module Fiona7
5
+ module AttributeReaders
6
+ class ReferencelistAsText < AttributeReader
7
+ def call
8
+ value = self.obj[self.attr_name]
9
+ Helpers::JsonDeserializer.new.call(value).presence || []
10
+ end
11
+ end
12
+ end
13
+ end
14
+