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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/scrivito_patches/models/obj.js +2 -6
- data/infopark_fiona7.gemspec +1 -1
- data/lib/fiona7/attribute_readers/attribute_reader.rb +17 -0
- data/lib/fiona7/attribute_readers/binary_as_binary.rb +12 -0
- data/lib/fiona7/attribute_readers/binary_as_linklist.rb +26 -0
- data/lib/fiona7/attribute_readers/date_as_date.rb +18 -0
- data/lib/fiona7/attribute_readers/factory.rb +91 -0
- data/lib/fiona7/attribute_readers/helpers/html_deserializer.rb +21 -0
- data/lib/fiona7/attribute_readers/helpers/json_deserializer.rb +11 -0
- data/lib/fiona7/attribute_readers/helpers/link_deserializer.rb +32 -0
- data/lib/fiona7/attribute_readers/html_as_html.rb +14 -0
- data/lib/fiona7/attribute_readers/link_as_linklist.rb +13 -0
- data/lib/fiona7/attribute_readers/linklist_as_linklist.rb +15 -0
- data/lib/fiona7/attribute_readers/multienum_as_multienum.rb +12 -0
- data/lib/fiona7/attribute_readers/multienum_as_text.rb +14 -0
- data/lib/fiona7/attribute_readers/number_as_string.rb +11 -0
- data/lib/fiona7/attribute_readers/reference_as_linklist.rb +14 -0
- data/lib/fiona7/attribute_readers/reference_as_string.rb +11 -0
- data/lib/fiona7/attribute_readers/referencelist_as_linklist.rb +16 -0
- data/lib/fiona7/attribute_readers/referencelist_as_text.rb +14 -0
- data/lib/fiona7/attribute_readers/simple.rb +18 -0
- data/lib/fiona7/attribute_readers/stringlist_as_text.rb +18 -0
- data/lib/fiona7/attribute_readers/widgetlist_as_linklist.rb +33 -0
- data/lib/fiona7/attribute_type_mapper.rb +76 -0
- data/lib/fiona7/attribute_writers/attribute_writer.rb +16 -0
- data/lib/fiona7/attribute_writers/binary_as_binary.rb +74 -0
- data/lib/fiona7/attribute_writers/binary_as_linklist.rb +86 -0
- data/lib/fiona7/attribute_writers/date_as_date.rb +11 -0
- data/lib/fiona7/attribute_writers/factory.rb +90 -0
- data/lib/fiona7/attribute_writers/helpers/html_serializer.rb +21 -0
- data/lib/fiona7/attribute_writers/helpers/json_serializer.rb +11 -0
- data/lib/fiona7/attribute_writers/helpers/link_serializer.rb +37 -0
- data/lib/fiona7/attribute_writers/html_as_html.rb +12 -0
- data/lib/fiona7/attribute_writers/link_as_linklist.rb +18 -0
- data/lib/fiona7/attribute_writers/linklist_as_linklist.rb +16 -0
- data/lib/fiona7/attribute_writers/multienum_as_multienum.rb +11 -0
- data/lib/fiona7/attribute_writers/multienum_as_text.rb +12 -0
- data/lib/fiona7/attribute_writers/number_as_string.rb +11 -0
- data/lib/fiona7/attribute_writers/reference_as_linklist.rb +17 -0
- data/lib/fiona7/attribute_writers/reference_as_string.rb +11 -0
- data/lib/fiona7/attribute_writers/referencelist_as_linklist.rb +19 -0
- data/lib/fiona7/attribute_writers/referencelist_as_text.rb +13 -0
- data/lib/fiona7/attribute_writers/simple.rb +11 -0
- data/lib/fiona7/attribute_writers/stringlist_as_text.rb +16 -0
- data/lib/fiona7/attribute_writers/widgetlist_as_linklist.rb +33 -0
- data/lib/fiona7/builder/obj_builder.rb +12 -201
- data/lib/fiona7/controllers/rest_api/obj_controller.rb +23 -5
- data/lib/fiona7/engine.rb +39 -0
- data/lib/fiona7/json/obj_decorator.rb +29 -121
- data/lib/fiona7/prefetch/obj_prefetch.rb +42 -0
- data/lib/fiona7/prefetch/widget_resolver_prefetch.rb +36 -0
- data/lib/fiona7/scrivito_patches/date_attribute.rb +16 -0
- data/lib/fiona7/tools/attribute_remover.rb +70 -0
- data/lib/fiona7/type_register.rb +9 -1
- data/lib/fiona7/version.rb +1 -1
- data/lib/fiona7/widget_resolver.rb +6 -6
- metadata +51 -4
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fiona7
|
2
|
+
module AttributeWriters
|
3
|
+
module Helpers
|
4
|
+
class LinkSerializer
|
5
|
+
def initialize(obj, klass)
|
6
|
+
self.obj = obj
|
7
|
+
self.klass = klass
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(link)
|
11
|
+
link = link.symbolize_keys
|
12
|
+
new_link = {}
|
13
|
+
|
14
|
+
if link[:url]
|
15
|
+
# handle www.example.com
|
16
|
+
new_link[:url] = "external:#{link[:url]}" unless link[:url] =~ /\A[a-zA-Z][a-zA-Z0-9+.-]:/
|
17
|
+
elsif obj_id = link[:obj_id]
|
18
|
+
# FIXME: use a repository here to speed up the lookup
|
19
|
+
new_link[:url] = self.klass.find(obj_id).path
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
new_link[:url] ||= link[:url]
|
24
|
+
new_link[:title] = link[:title] if link[:title]
|
25
|
+
new_link[:target] = link[:target] if link[:target]
|
26
|
+
new_link[:url] = "#{new_link[:url]}?#{link[:query]}" if link[:query]
|
27
|
+
new_link[:url] = "#{new_link[:url]}##{link[:fragment]}" if link[:fragment]
|
28
|
+
|
29
|
+
new_link
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
attr_accessor :obj, :klass
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'fiona7/attribute_writers/attribute_writer'
|
2
|
+
require 'fiona7/attribute_writers/helpers/html_serializer'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module AttributeWriters
|
6
|
+
class HtmlAsHtml < AttributeWriter
|
7
|
+
def call(value, claimed_type=nil)
|
8
|
+
self.obj.set(self.attr_name, Helpers::HtmlSerializer.new(self.obj, self.klass).call(value))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'fiona7/attribute_writers/attribute_writer'
|
2
|
+
require 'fiona7/attribute_writers/helpers/link_serializer'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module AttributeWriters
|
6
|
+
class LinkAsLinklist < AttributeWriter
|
7
|
+
def call(value, claimed_type=nil)
|
8
|
+
value = value || {}
|
9
|
+
if value.empty?
|
10
|
+
self.obj.set(self.attr_name, [])
|
11
|
+
else
|
12
|
+
link = Helpers::LinkSerializer.new(self.obj, self.klass).call(value)
|
13
|
+
self.obj.set(self.attr_name, [link])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fiona7/attribute_writers/attribute_writer'
|
2
|
+
require 'fiona7/attribute_writers/helpers/link_serializer'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module AttributeWriters
|
6
|
+
class LinklistAsLinklist < AttributeWriter
|
7
|
+
def call(value, claimed_type=nil)
|
8
|
+
links = (value || []).map do |link|
|
9
|
+
Helpers::LinkSerializer.new(self.obj, self.klass).call(link)
|
10
|
+
end
|
11
|
+
|
12
|
+
self.obj.set(self.attr_name, links)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'fiona7/attribute_writers/attribute_writer'
|
2
|
+
require 'fiona7/attribute_writers/helpers/json_serializer'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module AttributeWriters
|
6
|
+
class MultienumAsText < AttributeWriter
|
7
|
+
def call(value, claimed_type=nil)
|
8
|
+
self.obj.set(self.attr_name, Helpers::JsonSerializer.new.call(value || []))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fiona7/attribute_writers/attribute_writer'
|
2
|
+
|
3
|
+
module Fiona7
|
4
|
+
module AttributeWriters
|
5
|
+
class ReferenceAsLinklist < AttributeWriter
|
6
|
+
def call(value, claimed_type=nil)
|
7
|
+
# FIXME: use a repository to improve performance
|
8
|
+
obj = self.klass.find(value) rescue nil
|
9
|
+
if obj
|
10
|
+
self.obj.set(self.attr_name, [obj.path])
|
11
|
+
else
|
12
|
+
self.obj.set(self.attr_name, [])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'fiona7/attribute_writers/attribute_writer'
|
2
|
+
|
3
|
+
module Fiona7
|
4
|
+
module AttributeWriters
|
5
|
+
class ReferencelistAsLinklist < AttributeWriter
|
6
|
+
def call(value, claimed_type=nil)
|
7
|
+
# FIXME: use a repository to improve performance
|
8
|
+
ids = value || []
|
9
|
+
if ids.empty?
|
10
|
+
self.obj.set(self.attr_name, [])
|
11
|
+
else
|
12
|
+
objects_map = Hash[self.klass.where(obj_id: ids).map {|o| [o.id.to_s, o]}]
|
13
|
+
objects = ids.map {|id| objects_map[id] }.compact
|
14
|
+
self.obj.set(self.attr_name, objects)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'fiona7/attribute_writers/attribute_writer'
|
2
|
+
require 'fiona7/attribute_writers/helpers/json_serializer'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module AttributeWriters
|
6
|
+
class ReferencelistAsText < AttributeWriter
|
7
|
+
def call(value, claimed_type=nil)
|
8
|
+
ids = value || []
|
9
|
+
self.obj.set(self.attr_name, Helpers::JsonSerializer.new.call(ids))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fiona7/attribute_writers/attribute_writer'
|
2
|
+
require 'fiona7/attribute_writers/helpers/json_serializer'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
module AttributeWriters
|
6
|
+
class StringlistAsText < AttributeWriter
|
7
|
+
def call(value, claimed_type=nil)
|
8
|
+
if self.attr_name.to_s == "channels"
|
9
|
+
self.obj.set(:channels, value || [])
|
10
|
+
else
|
11
|
+
self.obj.set(self.attr_name, Helpers::JsonSerializer.new.call(value || []))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fiona7/attribute_writers/attribute_writer'
|
2
|
+
|
3
|
+
module Fiona7
|
4
|
+
module AttributeWriters
|
5
|
+
class WidgetlistAsLinklist < AttributeWriter
|
6
|
+
def call(value, claimed_type=nil)
|
7
|
+
# TODO: widget_respository
|
8
|
+
links = []
|
9
|
+
if value.kind_of?(Array)
|
10
|
+
(value || []).each do |widget_id|
|
11
|
+
if (path=self.widget_map[widget_id]||self.widget_map[widget_id.to_s])
|
12
|
+
links << {destination_object: path, title: widget_id}
|
13
|
+
else
|
14
|
+
raise Scrivito::ScrivitoError, "Inconsistent widget pool state detected, unable to store widgets (unable to find #{widget_id} in #{self.widget_map.inspect})"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
elsif value.kind_of?(Hash)
|
18
|
+
# stupid shits could not use one consistent format
|
19
|
+
(value || {})["list"].each do |crap|
|
20
|
+
widget_id = crap["widget"]
|
21
|
+
if (path=self.widget_map[widget_id]||self.widget_map[widget_id.to_s])
|
22
|
+
links << {destination_object: path, title: widget_id}
|
23
|
+
else
|
24
|
+
raise Scrivito::ScrivitoError, "Inconsistent widget pool state detected, unable to store widgets (unable to find #{widget_id} in #{self.widget_map.inspect})"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
self.obj.set(self.attr_name, links)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -11,11 +11,10 @@ require 'fiona7/obj_class_name_demangler'
|
|
11
11
|
#require 'fiona7/write_obj'
|
12
12
|
#require 'fiona7/released_obj'
|
13
13
|
require 'fiona7/builder/batch_widget_writer'
|
14
|
-
require 'fiona7/link_converter/scrivito_to_fiona'
|
15
14
|
require 'fiona7/widget_resolver'
|
16
|
-
require 'fiona7/
|
17
|
-
|
18
|
-
require 'fiona7/
|
15
|
+
require 'fiona7/prefetch/obj_prefetch'
|
16
|
+
|
17
|
+
require 'fiona7/attribute_writers/factory'
|
19
18
|
|
20
19
|
|
21
20
|
module Fiona7
|
@@ -66,16 +65,11 @@ module Fiona7
|
|
66
65
|
|
67
66
|
ensure_obj_class_exists
|
68
67
|
|
69
|
-
|
70
|
-
if (@widget_pool && !@widget_pool.empty?) || (@values.any? {|_, (_, v)| v.kind_of?(File) || v.kind_of?(ActionDispatch::Http::UploadedFile) } )
|
71
|
-
@obj = WriteObj.create!(name: @name, parent_obj_id: @parent.id, obj_class: @real_obj_class)
|
72
|
-
else
|
73
|
-
@obj = WriteObj.create!(name: @name, parent_obj_id: @parent.id, obj_class: @real_obj_class)
|
74
|
-
end
|
68
|
+
@obj = WriteObj.create!(name: @name, parent_obj_id: @parent.id, obj_class: @real_obj_class)
|
75
69
|
end
|
76
70
|
|
77
71
|
def write_widget_pool
|
78
|
-
resolver = WidgetResolver.new(@obj.attr_values["X_widget_pool"]||[], WriteObj)
|
72
|
+
resolver = WidgetResolver.new(@obj.attr_values["X_widget_pool"]||[], Prefetch::ObjPrefetch.new(WriteObj))
|
79
73
|
|
80
74
|
@id_map = resolver.id_map
|
81
75
|
@widget_path_map = resolver.path_map
|
@@ -115,171 +109,20 @@ module Fiona7
|
|
115
109
|
@obj.reload
|
116
110
|
end
|
117
111
|
@obj.send(:reload_attributes)
|
118
|
-
type_definition = Fiona7::TypeRegister.instance.write(@obj_class)
|
119
|
-
if type_definition.nil?
|
120
|
-
raise "Definition not found for #{@obj_class}"
|
121
|
-
end
|
122
|
-
@values.each do |attribute_name, possible_pair|
|
123
|
-
(claimed_type, value) = *possible_pair
|
124
|
-
attribute = type_definition.find_attribute(attribute_name)
|
125
|
-
if attribute.nil?
|
126
|
-
#debugger
|
127
|
-
raise "Attribute #{attribute_name} not found in #{@obj_class}"
|
128
|
-
end
|
129
|
-
|
130
|
-
virtual_name = attribute.name.to_sym
|
131
|
-
attribute_name = real_name = attribute.real_name.to_sym
|
132
|
-
virtual_type = attribute.type.to_sym
|
133
|
-
|
134
|
-
case virtual_type
|
135
|
-
when :linklist
|
136
|
-
links = (value || []).map do |link|
|
137
|
-
link = link.symbolize_keys
|
138
|
-
new_link = {}
|
139
|
-
|
140
|
-
if link[:url]
|
141
|
-
# handle www.example.com
|
142
|
-
new_link[:url] = "external:#{link[:url]}" unless link[:url] =~ /\A[a-zA-Z][a-zA-Z0-9+.-]:/
|
143
|
-
elsif obj_id = link[:obj_id]
|
144
|
-
new_link[:url] = WriteObj.find(obj_id).path
|
145
|
-
end
|
146
112
|
|
113
|
+
factory = Fiona7::AttributeWriters::Factory.new(@obj, @obj_class, WriteObj, @widget_path_map)
|
147
114
|
|
148
|
-
|
149
|
-
|
150
|
-
new_link[:target] = link[:target] if link[:target]
|
151
|
-
new_link[:url] = "#{new_link[:url]}?#{link[:query]}" if link[:query]
|
152
|
-
new_link[:url] = "#{new_link[:url]}##{link[:fragment]}" if link[:fragment]
|
153
|
-
|
154
|
-
new_link
|
155
|
-
end
|
156
|
-
@obj.set(attribute_name.to_s, links)
|
157
|
-
when :link
|
158
|
-
link = (value || {}).symbolize_keys
|
159
|
-
new_link = {}
|
160
|
-
|
161
|
-
if link[:url]
|
162
|
-
# handle www.example.com
|
163
|
-
new_link[:url] = "external:#{link[:url]}" unless link[:url] =~ /\A[a-zA-Z][a-zA-Z0-9+.-]:/
|
164
|
-
elsif obj_id = link[:obj_id]
|
165
|
-
new_link[:url] = WriteObj.find(obj_id).path
|
166
|
-
end
|
167
|
-
|
168
|
-
|
169
|
-
new_link[:url] ||= link[:url]
|
170
|
-
new_link[:title] = link[:title] if link[:title]
|
171
|
-
new_link[:target] = link[:target] if link[:target]
|
172
|
-
new_link[:url] = "#{new_link[:url]}?#{link[:query]}" if link[:query]
|
173
|
-
new_link[:url] = "#{new_link[:url]}##{link[:fragment]}" if link[:fragment]
|
115
|
+
@values.each do |attribute_name, possible_pair|
|
116
|
+
(claimed_type, value) = *possible_pair
|
174
117
|
|
175
|
-
|
176
|
-
|
177
|
-
@obj.set(attribute_name.to_s, [])
|
178
|
-
else
|
179
|
-
@obj.set(attribute_name.to_s, [new_link])
|
180
|
-
end
|
181
|
-
when :reference
|
182
|
-
obj = WriteObj.find(value) rescue nil
|
183
|
-
if obj
|
184
|
-
@obj.set(attribute_name.to_s, [obj.path])
|
185
|
-
else
|
186
|
-
@obj.set(attribute_name.to_s, [])
|
187
|
-
end
|
188
|
-
when :referencelist
|
189
|
-
ids = value || []
|
190
|
-
if ids.empty?
|
191
|
-
@obj.set(attribute_name.to_s, [])
|
192
|
-
else
|
193
|
-
objects_map = Hash[WriteObj.where(obj_id: ids).map {|o| [o.id.to_s, o]}]
|
194
|
-
objects = ids.map {|id| objects_map[id] }.compact
|
195
|
-
@obj.set(attribute_name, objects)
|
196
|
-
end
|
197
|
-
when :widgetlist
|
198
|
-
links = []
|
199
|
-
if value.kind_of?(Array)
|
200
|
-
(value || []).each do |widget_id|
|
201
|
-
if (path=@widget_path_map[widget_id]||@widget_path_map[widget_id.to_s])
|
202
|
-
links << {destination_object: path, title: widget_id}
|
203
|
-
else
|
204
|
-
raise Scrivito::ScrivitoError, "Inconsistent widget pool state detected, unable to store widgets (unable to find #{widget_id} in #{@widget_path_map.inspect})"
|
205
|
-
end
|
206
|
-
end
|
207
|
-
elsif value.kind_of?(Hash)
|
208
|
-
# stupid shits could not use one consistent format
|
209
|
-
(value || {})["list"].each do |crap|
|
210
|
-
widget_id = crap["widget"]
|
211
|
-
if (path=@widget_path_map[widget_id]||@widget_path_map[widget_id.to_s])
|
212
|
-
links << {destination_object: path, title: widget_id}
|
213
|
-
else
|
214
|
-
raise Scrivito::ScrivitoError, "Inconsistent widget pool state detected, unable to store widgets (unable to find #{widget_id} in #{@widget_path_map.inspect})"
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
@obj.set(attribute_name.to_s, links)
|
219
|
-
when :text, :string, :enum, :multienum, :date
|
220
|
-
#if value.nil? && value != @obj[attribute_name]
|
221
|
-
@obj.set(attribute_name.to_s, value)
|
222
|
-
#end
|
223
|
-
when :number
|
224
|
-
@obj.set(attribute_name.to_s, value.to_s)
|
225
|
-
when :stringlist
|
226
|
-
if Fiona7.mode == :legacy && attribute_name.to_s == "channels"
|
227
|
-
@obj.set(:channels, value || [])
|
228
|
-
else
|
229
|
-
@obj.set(attribute_name.to_s, value.to_json)
|
230
|
-
end
|
231
|
-
when :html
|
232
|
-
converted_links = LinkConverter::ScrivitoToFiona.new(WriteObj, value.to_s).convert
|
233
|
-
@obj.set(attribute_name.to_s, converted_links)
|
234
|
-
when :binary
|
235
|
-
if value.kind_of?(String)
|
236
|
-
# NOTE: this code path has not been tested yet.
|
237
|
-
target = {title: value, destination_object: InternalReleasedObj.find(value.to_i)}
|
238
|
-
@obj.set(attribute_name.to_s, target)
|
239
|
-
elsif value.kind_of?(File)
|
240
|
-
if !Fiona7.mode == :legacy || attribute_name.to_s != "blob"
|
241
|
-
@obj.set(attribute_name.to_s, upload_file(value))
|
242
|
-
else
|
243
|
-
special_upload_handling(attribute_name, value)
|
244
|
-
end
|
245
|
-
elsif value.kind_of?(ActionDispatch::Http::UploadedFile)
|
246
|
-
if !Fiona7.mode == :legacy || attribute_name.to_s != "blob"
|
247
|
-
@obj.set(attribute_name.to_s, upload_uploaded_file(value))
|
248
|
-
else
|
249
|
-
special_upload_uploaded_handling(attribute_name, value)
|
250
|
-
end
|
251
|
-
elsif value.nil?
|
252
|
-
@obj.set(attribute_name.to_s, [])
|
253
|
-
elsif value.kind_of?(Hash)
|
254
|
-
source_blob_id = value["id"] || value["id_to_copy"]
|
255
|
-
filename = value["filename"]
|
256
|
-
content_type = value["content_type"]
|
257
|
-
|
258
|
-
# There is a little bit of magic behind this.
|
259
|
-
# This will pass some data directly to the crul_obj
|
260
|
-
# bypassing @obj.set(), but calling @obj.save
|
261
|
-
# afterwards still persists the data correctly
|
262
|
-
#
|
263
|
-
# This works the same way as Reactor::Tools::Uploader
|
264
|
-
Fiona7::Builder::LazyBlobCopier.new({
|
265
|
-
destination_obj: @obj,
|
266
|
-
attr_name: attribute_name.to_s,
|
267
|
-
source_blob_id: source_blob_id,
|
268
|
-
filename: filename,
|
269
|
-
content_type: content_type
|
270
|
-
}).call
|
271
|
-
|
272
|
-
# NOTE: no @obj.set() required here
|
273
|
-
else
|
274
|
-
raise Scrivito::ClientError.new("Invalid input for binary field", 422)
|
275
|
-
end
|
276
|
-
else
|
277
|
-
raise Scrivito::ClientError.new("Unknown attribute type: #{virtual_type}", 418)
|
278
|
-
end
|
118
|
+
worker = factory.call(attribute_name)
|
119
|
+
worker.call(value, claimed_type)
|
279
120
|
end
|
121
|
+
|
280
122
|
if (@new_full_text)
|
281
123
|
@obj.set(:X_full_text, @new_full_text)
|
282
124
|
end
|
125
|
+
|
283
126
|
@obj.set(:X_widget_pool, @new_widget_pool) if @new_widget_pool
|
284
127
|
@obj.set(:permalink, @permalink) if @permalink
|
285
128
|
|
@@ -290,25 +133,6 @@ module Fiona7
|
|
290
133
|
#end
|
291
134
|
end
|
292
135
|
|
293
|
-
def special_upload_handling(attribute_name, file)
|
294
|
-
if !@obj.binary?
|
295
|
-
# standard handling!
|
296
|
-
@obj.set(attribute_name.to_s, upload_file(file))
|
297
|
-
else
|
298
|
-
ext = ::File.extname(file.path).to_s[1..-1]
|
299
|
-
@obj.upload(file, ext)
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
def special_upload_uploaded_handling(attribute_name, file)
|
304
|
-
if !@obj.binary?
|
305
|
-
# standard handling!
|
306
|
-
@obj.set(attribute_name.to_s, upload_uploaded_file(file))
|
307
|
-
else
|
308
|
-
ext = ::File.extname(file.original_filename).to_s[1..-1]
|
309
|
-
@obj.upload(file.open, ext)
|
310
|
-
end
|
311
|
-
end
|
312
136
|
|
313
137
|
def rewrite_full_text
|
314
138
|
full_text = ::YAML.load(@obj.attr_values["X_full_text"]) rescue {}
|
@@ -321,19 +145,6 @@ module Fiona7
|
|
321
145
|
nil
|
322
146
|
end
|
323
147
|
|
324
|
-
def upload_file(file)
|
325
|
-
upload = Fiona7::Builder::IndirectBlobBuilder.new(@obj, ::File.basename(file.path), file).call
|
326
|
-
encoded_id = Fiona7::BlobIdGenerator.new(upload.id, upload.last_changed).call
|
327
|
-
{title: encoded_id, destination_object: upload}
|
328
|
-
end
|
329
|
-
|
330
|
-
def upload_uploaded_file(file)
|
331
|
-
upload = Fiona7::Builder::IndirectBlobBuilder.new(@obj, file.original_filename, file.open).call
|
332
|
-
encoded_id = Fiona7::BlobIdGenerator.new(upload.id, upload.last_changed).call
|
333
|
-
{title: encoded_id, destination_object: upload}
|
334
|
-
end
|
335
|
-
|
336
|
-
|
337
148
|
def name_and_parent_path_from_path(path)
|
338
149
|
components = path.split('/')
|
339
150
|
name = components.pop.presence
|