infopark_fiona7 0.30.0.2 → 0.70.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/fiona7.js +1 -282
- data/app/assets/javascripts/fiona7_ui.js +335 -0
- data/app/assets/stylesheets/fiona7.css.scss +4 -36
- data/app/assets/stylesheets/fiona7_ui.css.scss +39 -0
- data/app/controllers/fiona7/blobs_controller.rb +13 -23
- data/app/controllers/fiona7/release_controller.rb +1 -0
- data/app/controllers/fiona7/sessions_controller.rb +3 -5
- data/app/helpers/fiona7_override_helper.rb +6 -2
- data/app/models/fiona7/edited_obj.rb +6 -1
- data/app/models/fiona7/released_obj.rb +11 -3
- data/app/models/fiona7/write_obj.rb +18 -3
- data/app/models/fiona7_login_page.rb +3 -0
- data/app/views/scrivito/ui/index.html.erb +16 -0
- data/config/routes.rb +2 -0
- data/infopark_fiona7.gemspec +6 -4
- data/lib/fiona7/builder/batch_widget_writer.rb +7 -3
- data/lib/fiona7/builder/obj_builder.rb +130 -42
- data/lib/fiona7/builder/obj_class_builder.rb +3 -59
- data/lib/fiona7/builder/obj_class_updater.rb +7 -44
- data/lib/fiona7/builder/obj_updater.rb +25 -7
- data/lib/fiona7/builder/widget_builder.rb +24 -0
- data/lib/fiona7/builder/widget_building.rb +2 -7
- data/lib/fiona7/builder/widget_updater.rb +21 -0
- data/lib/fiona7/controllers/content_service/obj_controller.rb +16 -25
- data/lib/fiona7/controllers/rest_api/blob_controller.rb +41 -2
- data/lib/fiona7/controllers/rest_api/obj_controller.rb +19 -7
- data/lib/fiona7/controllers/rest_api/workspace_controller.rb +1 -1
- data/lib/fiona7/engine.rb +58 -7
- data/lib/fiona7/fiona_connector_patches/basic_obj.rb +46 -0
- data/lib/fiona7/initializer.rb +15 -11
- data/lib/fiona7/json/obj_decorator.rb +53 -31
- data/lib/fiona7/json/reverse_obj_decorator.rb +36 -0
- data/lib/fiona7/json/widget_decorator.rb +3 -1
- data/lib/fiona7/link_converter/fiona_to_scrivito.rb +45 -13
- data/lib/fiona7/link_converter/scrivito_to_fiona.rb +1 -1
- data/lib/fiona7/middleware/server_detection_middleware.rb +27 -0
- data/lib/fiona7/middleware/table_switching_middleware.rb +33 -0
- data/lib/fiona7/mode_switch/cms_routes/scrivito_sdk.rb +5 -11
- data/lib/fiona7/mode_switch/composite.rb +2 -4
- data/lib/fiona7/naive_search_engine.rb +66 -16
- data/lib/fiona7/routers/rest_api.rb +50 -45
- data/lib/fiona7/routing_monkey_patch.rb +5 -3
- data/lib/fiona7/scrivito_patches/attribute_content.rb +9 -10
- data/lib/fiona7/scrivito_patches/attribute_serializer.rb +15 -0
- data/lib/fiona7/scrivito_patches/basic_obj.rb +25 -19
- data/lib/fiona7/scrivito_patches/basic_widget.rb +4 -0
- data/lib/fiona7/scrivito_patches/binary.rb +452 -33
- data/lib/fiona7/scrivito_patches/client_config.rb +0 -19
- data/lib/fiona7/scrivito_patches/cms_backend.rb +48 -0
- data/lib/fiona7/scrivito_patches/cms_field_tag.rb +19 -0
- data/lib/fiona7/scrivito_patches/cms_rest_api.rb +20 -3
- data/lib/fiona7/scrivito_patches/cms_routing.rb +20 -34
- data/lib/fiona7/scrivito_patches/controller_actions.rb +0 -8
- data/lib/fiona7/scrivito_patches/migrator.rb +4 -0
- data/lib/fiona7/scrivito_patches/objs_controller.rb +18 -0
- data/lib/fiona7/scrivito_patches/type_computer.rb +12 -12
- data/lib/fiona7/scrivito_patches/webservice_controller.rb +21 -0
- data/lib/fiona7/scrivito_patches/workspace.rb +8 -5
- data/lib/fiona7/shadow_classes.rb +74 -0
- data/lib/fiona7/table_switcher.rb +39 -0
- data/lib/fiona7/type_loader.rb +63 -0
- data/lib/fiona7/type_register.rb +170 -89
- data/lib/fiona7/type_synchronizer.rb +68 -0
- data/lib/fiona7/version.rb +1 -1
- data/lib/fiona7/version_helper.rb +35 -54
- data/lib/fiona7/widget_resolver.rb +1 -1
- data/lib/tasks/fiona7_tasks.rake +0 -8
- metadata +57 -18
- data/lib/fiona7/controllers/rest_api/obj_class_controller.rb +0 -39
- data/lib/fiona7/json/obj_class_decorator.rb +0 -45
- data/lib/fiona7/mode_switch/constants.rb +0 -86
- data/lib/fiona7/type_register_mixin.rb +0 -9
@@ -1,25 +1,17 @@
|
|
1
|
-
require 'fiona7/type_register_mixin'
|
2
1
|
|
3
2
|
module Fiona7
|
4
3
|
module Builder
|
5
4
|
class ObjClassBuilder
|
6
|
-
include TypeRegisterMixin
|
7
5
|
|
8
6
|
def initialize(values)
|
9
7
|
@values = values
|
10
|
-
@attrs_avail= @values.key?(:attributes)
|
11
8
|
@attributes = @values.delete(:attributes) {|_| [] }
|
12
9
|
end
|
13
10
|
|
14
11
|
def build
|
15
12
|
assert_valid
|
16
|
-
add_legacy_attributes
|
17
|
-
mode_dependant_attributes
|
18
|
-
namespace_attributes
|
19
13
|
persist_attributes
|
20
14
|
persist_obj_class
|
21
|
-
update_obj_class
|
22
|
-
load_cm_obj_class
|
23
15
|
end
|
24
16
|
|
25
17
|
def validate
|
@@ -37,47 +29,10 @@ module Fiona7
|
|
37
29
|
ret
|
38
30
|
end
|
39
31
|
|
40
|
-
def add_legacy_attributes
|
41
|
-
type = @values[:type].to_s
|
42
|
-
if type == 'generic' || type == 'image'
|
43
|
-
@attributes << {name: 'blob', type: :binary}
|
44
|
-
@attrs_avail = true
|
45
|
-
end
|
46
|
-
if type.present?
|
47
|
-
# legacy obj class
|
48
|
-
@attributes << {name: 'body', type: :html}
|
49
|
-
@attributes << {name: 'title', type: :html}
|
50
|
-
@attrs_avail = true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def mode_dependant_attributes
|
55
|
-
if Fiona7.mode == :standalone
|
56
|
-
# nop
|
57
|
-
elsif Fiona7.mode == :legacy
|
58
|
-
# in legacy mode body and title are always included
|
59
|
-
# and are mapped to built-in attributes, hence no
|
60
|
-
# need for custom attributes
|
61
|
-
@attributes.delete_if {|a| n = a[:name].to_s ; n == 'body' || n == 'title' }
|
62
|
-
else
|
63
|
-
raise "Invalid Fiona7.mode = #{Fiona7.mode}"
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def namespace_attributes
|
69
|
-
@attributes.each do |attribute|
|
70
|
-
# s_OBJ_CLASS__ATTRIBUTE_NAME
|
71
|
-
virtual_name = attribute[:name]
|
72
|
-
attribute[:name] = type_register.real_attribute_name(@values[:name], virtual_name)
|
73
|
-
attribute[:real_type] = type_register.map_virtual_to_real_type(attribute[:type])
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
32
|
def persist_attributes
|
78
33
|
@attributes.each do |attribute|
|
79
|
-
if !RailsConnector::Attribute.exists?(attribute_name: attribute[:
|
80
|
-
raw_attribute = Reactor::Cm::Attribute.create(attribute[:
|
34
|
+
if !RailsConnector::Attribute.exists?(attribute_name: attribute[:real_name])
|
35
|
+
raw_attribute = Reactor::Cm::Attribute.create(attribute[:real_name].to_s, attribute[:real_type].to_s)
|
81
36
|
raw_attribute.set(:helpText, ::ActiveSupport::JSON.encode({type: attribute[:type]}))
|
82
37
|
raw_attribute.set(:values, attribute[:values]) if attribute[:values]
|
83
38
|
raw_attribute.save!
|
@@ -86,25 +41,14 @@ module Fiona7
|
|
86
41
|
end
|
87
42
|
|
88
43
|
def persist_obj_class
|
89
|
-
# WARNING: in the never version no "type" is standard
|
90
44
|
@values[:type] ||= 'publication'
|
91
45
|
@raw_obj_class = Reactor::Cm::ObjClass.create(@values[:name].to_s, @values[:type].to_s)
|
92
|
-
user_attributes = @attributes.map {|a| a[:
|
46
|
+
user_attributes = @attributes.map {|a| a[:real_name] }
|
93
47
|
user_attributes ||= []
|
94
48
|
built_in_attributes = ['X_widget_pool']
|
95
49
|
@raw_obj_class.attributes = user_attributes + built_in_attributes
|
96
50
|
end
|
97
51
|
|
98
|
-
def update_obj_class
|
99
|
-
if @values.key?(:is_active)
|
100
|
-
@raw_obj_class.set('isEnabled', @values[:is_active] ? '1' : '0')
|
101
|
-
@raw_obj_class.save!
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def load_cm_obj_class
|
106
|
-
RailsConnector::ObjClass.find_by_obj_class_name(@values[:name])
|
107
|
-
end
|
108
52
|
end
|
109
53
|
end
|
110
54
|
end
|
@@ -6,18 +6,6 @@ module Fiona7
|
|
6
6
|
def validate
|
7
7
|
existing_obj_class
|
8
8
|
end
|
9
|
-
|
10
|
-
def build
|
11
|
-
assert_valid
|
12
|
-
mode_dependant_attributes
|
13
|
-
namespace_attributes
|
14
|
-
persist_attributes
|
15
|
-
persist_obj_class
|
16
|
-
update_obj_class
|
17
|
-
gc_attributes
|
18
|
-
load_cm_obj_class
|
19
|
-
end
|
20
|
-
|
21
9
|
protected
|
22
10
|
def existing_obj_class
|
23
11
|
ret = RailsConnector::ObjClass.exists?(obj_class_name: @values[:name])
|
@@ -27,43 +15,18 @@ module Fiona7
|
|
27
15
|
|
28
16
|
def persist_obj_class
|
29
17
|
@raw_obj_class = Reactor::Cm::ObjClass.get(@values[:name].to_s)
|
18
|
+
user_attributes = @attributes.map {|a| a[:real_name] }
|
19
|
+
user_attributes ||= []
|
30
20
|
|
31
|
-
|
32
|
-
if @attrs_avail
|
33
|
-
user_attributes = @attributes.map {|a| a[:name] }
|
34
|
-
user_attributes ||= []
|
35
|
-
else
|
36
|
-
user_attributes = @raw_obj_class.attributes
|
37
|
-
end
|
38
|
-
|
21
|
+
existing_attributes = @raw_obj_class.attributes
|
39
22
|
built_in_attributes = ['X_widget_pool']
|
40
|
-
@raw_obj_class.attributes = user_attributes + built_in_attributes
|
41
|
-
end
|
42
23
|
|
43
|
-
|
44
|
-
|
45
|
-
# TODO: changing attribute types
|
46
|
-
if !RailsConnector::Attribute.exists?(attribute_name: attribute[:name])
|
47
|
-
raw_attribute = Reactor::Cm::Attribute.create(attribute[:name].to_s, attribute[:real_type].to_s)
|
48
|
-
raw_attribute.set(:helpText, ::ActiveSupport::JSON.encode({type: attribute[:type]}))
|
49
|
-
raw_attribute.set(:values, attribute[:values]) if attribute[:values]
|
50
|
-
raw_attribute.save!
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def gc_attributes
|
56
|
-
return if Fiona7.mode == :legacy
|
57
|
-
return unless @attrs_avail
|
58
|
-
pattern = "s_#{@values[:name]}__%"
|
24
|
+
# NOTE: removing attributes is now impossible
|
25
|
+
new_attributes = (existing_attributes + built_in_attributes + user_attributes).map(&:to_s).uniq
|
59
26
|
|
60
|
-
|
61
|
-
stale = RailsConnector::Attribute.where('attribute_name LIKE ?', pattern).select(:attribute_name).map(&:name)
|
62
|
-
|
63
|
-
(stale - fresh).each do |attribute_name|
|
64
|
-
Reactor::Cm::Attribute.instance(attribute_name.to_s).delete!
|
65
|
-
end
|
27
|
+
@raw_obj_class.attributes = new_attributes
|
66
28
|
end
|
29
|
+
|
67
30
|
end
|
68
31
|
end
|
69
32
|
end
|
@@ -5,21 +5,39 @@ module Fiona7
|
|
5
5
|
module Builder
|
6
6
|
class ObjUpdater < ObjBuilder
|
7
7
|
protected
|
8
|
+
def update?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
8
12
|
def validate
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
|
16
|
+
def prepare_object
|
17
|
+
obj_id = @values.delete(:_id)
|
18
|
+
@obj = WriteObj.find(obj_id)
|
19
|
+
@path = @values.delete(:_path)
|
20
|
+
@widget_pool = @values.delete(:_widget_pool)
|
21
|
+
@permalink = @values.delete(:_permalink)
|
22
|
+
|
9
23
|
# revert command sends this info. which is silly.
|
10
24
|
@values.delete(:_last_changed)
|
11
25
|
|
12
|
-
|
13
|
-
|
26
|
+
@name, parent_path = name_and_parent_path_from_path(@path) if (@path)
|
27
|
+
if obj_class = @values.delete(:_obj_class)
|
28
|
+
@obj_class = obj_class
|
29
|
+
@real_obj_class = TypeRegister::NameAliaser.new(virtual: @obj_class).real_obj_class
|
30
|
+
else
|
31
|
+
@real_obj_class = @obj.obj_class
|
32
|
+
@obj_class = TypeRegister::NameAliaser.new(real: @real_obj_class).virtual_obj_class
|
33
|
+
end
|
34
|
+
|
35
|
+
ensure_obj_class_exists
|
14
36
|
|
15
|
-
def create_object
|
16
|
-
@obj_id = @values.delete(:_id)
|
17
|
-
@obj = WriteObj.find(@obj_id)
|
18
37
|
@obj.name = @name unless @name.blank?
|
19
|
-
@name = @obj.name
|
20
|
-
@obj_class ||= @obj.obj_class
|
21
38
|
# TODO: move (parent change)
|
22
39
|
end
|
40
|
+
|
23
41
|
end
|
24
42
|
end
|
25
43
|
end
|
@@ -8,6 +8,30 @@ module Fiona7
|
|
8
8
|
def initialize(owner_obj, widget_id, values, path_map)
|
9
9
|
@owner_obj, @widget_id, @values, @widget_path_map = owner_obj, widget_id, values.symbolize_keys, path_map
|
10
10
|
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
def update?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def prepare_object
|
18
|
+
@path = self.generate_widget_path
|
19
|
+
@obj_class = @values.delete(:_obj_class)
|
20
|
+
@real_obj_class = TypeRegister::NameAliaser.new(virtual: @obj_class).real_obj_class
|
21
|
+
|
22
|
+
@path = "/#{@path}" unless @path.start_with?('/')
|
23
|
+
@name, parent_path = name_and_parent_path_from_path(@path)
|
24
|
+
@parent = ensure_parent_exists(parent_path) if parent_path
|
25
|
+
|
26
|
+
ensure_obj_class_exists
|
27
|
+
|
28
|
+
# bottom one is faster, but can only work when there are no uploads
|
29
|
+
if (@values.any? {|_, (_, v)| v.kind_of?(File) || v.kind_of?(ActionDispatch::Http::UploadedFile) } )
|
30
|
+
@obj = WriteObj.create!(name: @name, parent_obj_id: @parent.id, obj_class: @real_obj_class)
|
31
|
+
else
|
32
|
+
@obj = WriteObj.new(name: @name, parent_obj_id: @parent.id, obj_class: @real_obj_class)
|
33
|
+
end
|
34
|
+
end
|
11
35
|
end
|
12
36
|
end
|
13
37
|
end
|
@@ -10,8 +10,7 @@ module Fiona7
|
|
10
10
|
end
|
11
11
|
|
12
12
|
protected
|
13
|
-
|
14
|
-
def prepare_object
|
13
|
+
def generate_widget_path
|
15
14
|
raise Scrivito::ScrivitoError, "Inconsistent internal state: unable to create widgets for nonexiting parent." if @owner_obj.path.nil?
|
16
15
|
# only publication type can contain children (code = "5")
|
17
16
|
# also handle / this way
|
@@ -20,11 +19,7 @@ module Fiona7
|
|
20
19
|
else
|
21
20
|
parent_path = "#{@owner_obj.path}/_widgets"
|
22
21
|
end
|
23
|
-
|
24
|
-
@name = @widget_id.to_s
|
25
|
-
@parent = ensure_parent_exists(parent_path)
|
26
|
-
raise Scrivito::ScrivitoError, "Error storing widget, container #{parent_path.inspect} not found." if @parent.nil?
|
27
|
-
@obj_class = @values.delete(:_obj_class)
|
22
|
+
"#{parent_path}/#{@widget_id}"
|
28
23
|
end
|
29
24
|
|
30
25
|
def write_widget_pool
|
@@ -8,6 +8,27 @@ module Fiona7
|
|
8
8
|
def initialize(owner_obj, widget_id, values, path_map)
|
9
9
|
@owner_obj, @widget_id, @values, @widget_path_map = owner_obj, widget_id, values.symbolize_keys, path_map
|
10
10
|
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
def update?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def prepare_object
|
18
|
+
@path = self.generate_widget_path
|
19
|
+
@obj = WriteObj.find(@values.delete(:_id))
|
20
|
+
@name = @widget_id
|
21
|
+
|
22
|
+
if obj_class = @values.delete(:_obj_class)
|
23
|
+
@obj_class = obj_class
|
24
|
+
@real_obj_class = TypeRegister::NameAliaser.new(virtual: @obj_class).real_obj_class
|
25
|
+
else
|
26
|
+
@real_obj_class = @obj.obj_class
|
27
|
+
@obj_class = TypeRegister::NameAliaser.new(real: @real_obj_class).virtual_obj_class
|
28
|
+
end
|
29
|
+
|
30
|
+
ensure_obj_class_exists
|
31
|
+
end
|
11
32
|
end
|
12
33
|
end
|
13
34
|
end
|
@@ -43,33 +43,17 @@ module Fiona7
|
|
43
43
|
if workspace_id && !SCRIVITO_DIFF_MODE_BROKEN
|
44
44
|
workspace_id == 'published' ? ReleasedObj : EditedObj
|
45
45
|
elsif revision_id
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
# in most cases a query without workspace_id is caused
|
51
|
-
# by modification calculation, which compares the object
|
52
|
-
# with it's base revision (i.e. revision of published)
|
53
|
-
if revision_id[0] == 'f' && published_workspace.revision_id == revision_id
|
46
|
+
# iwe know that published revisions start with a 'f'
|
47
|
+
# and rtc revisions start with a 'b'
|
48
|
+
if revision_id[0] == 'f'
|
54
49
|
ReleasedObj
|
55
|
-
elsif revision_id[0] == 'b'
|
50
|
+
elsif revision_id[0] == 'b'
|
56
51
|
EditedObj
|
57
52
|
else
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
# and rtc revisions start with a 'b'
|
63
|
-
if revision_id[0] == 'f'
|
64
|
-
ReleasedObj
|
65
|
-
elsif revision_id[0] == 'b'
|
66
|
-
EditedObj
|
67
|
-
else
|
68
|
-
Assert.input(
|
69
|
-
false,
|
70
|
-
"Invalid revision_id received: #{revision_id}"
|
71
|
-
)
|
72
|
-
end
|
53
|
+
Assert.input(
|
54
|
+
false,
|
55
|
+
"Invalid revision_id received: #{revision_id}"
|
56
|
+
)
|
73
57
|
end
|
74
58
|
else
|
75
59
|
Assert.input(
|
@@ -96,22 +80,29 @@ module Fiona7
|
|
96
80
|
)
|
97
81
|
end
|
98
82
|
|
99
|
-
refs = {"refs" => objs.map {|o| {"id" => o.id} } }
|
83
|
+
refs = {"refs" => objs.map {|o| {"id" => o.id.to_s} } }
|
100
84
|
objs = objs.map {|o| JSON::ObjDecorator.new(@klass, o) }
|
101
85
|
|
102
86
|
return objs, refs
|
103
87
|
end
|
104
88
|
|
105
89
|
def find_by_id(id)
|
90
|
+
if id.kind_of?(Array)
|
91
|
+
id = id.map(&:to_i)
|
92
|
+
else
|
93
|
+
id = id.to_i
|
94
|
+
end
|
106
95
|
@klass.where(obj_id: id).limit(1).to_a
|
107
96
|
end
|
108
97
|
|
109
98
|
def find_by_path(path)
|
99
|
+
return [] if path =~ /^\/_orphaned/
|
110
100
|
path = path.gsub('.', '_')
|
111
101
|
@klass.where(path: path).limit(1).to_a
|
112
102
|
end
|
113
103
|
|
114
104
|
def find_by_parent_path(path)
|
105
|
+
return [] if path =~ /^\/_orphaned/
|
115
106
|
parent = @klass.find_by_path(path)
|
116
107
|
parent ? parent.children : []
|
117
108
|
end
|
@@ -2,8 +2,47 @@ module Fiona7
|
|
2
2
|
module Controllers
|
3
3
|
module RestAPI
|
4
4
|
class BlobController
|
5
|
-
def fetch(blob_id)
|
6
|
-
|
5
|
+
def fetch(blob_id, transformation=false)
|
6
|
+
public_get_url = BinaryHandling::UrlGenerator.new(blob_id, 'public_access', 'get', transformation).generate
|
7
|
+
# all URLs are identic!
|
8
|
+
# private_get_url = BinaryHandling::UrlGenerator.new(blob_id, 'private_access', 'get', false).generate
|
9
|
+
# public_head_url = BinaryHandling::UrlGenerator.new(blob_id, 'public_access', 'head', false).generate
|
10
|
+
# private_head_url = BinaryHandling::UrlGenerator.new(blob_id, 'private_access', 'head', false).generate
|
11
|
+
private_head_url = public_head_url = private_get_url = public_get_url
|
12
|
+
|
13
|
+
return {
|
14
|
+
'public_access' => {
|
15
|
+
'get' => {
|
16
|
+
'url' => public_get_url
|
17
|
+
},
|
18
|
+
'head' => {
|
19
|
+
'url' => public_head_url
|
20
|
+
}
|
21
|
+
},
|
22
|
+
'private_access' => {
|
23
|
+
'get' => {
|
24
|
+
'url' => private_get_url
|
25
|
+
},
|
26
|
+
'head' => {
|
27
|
+
'url' => private_head_url
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
end
|
32
|
+
def metadata(blob_id)
|
33
|
+
meta_binary = BinaryHandling::MetaBinary.new(blob_id)
|
34
|
+
content_type = meta_binary.mime_type
|
35
|
+
content_length = meta_binary.length
|
36
|
+
width = meta_binary.width
|
37
|
+
height = meta_binary.height
|
38
|
+
{
|
39
|
+
'meta_data' => {
|
40
|
+
'content_type' => ['string', content_type],
|
41
|
+
'content_length' => ['number', content_length],
|
42
|
+
'width' => ['number', width],
|
43
|
+
'height' => ['number', height]
|
44
|
+
}
|
45
|
+
}
|
7
46
|
end
|
8
47
|
end
|
9
48
|
end
|
@@ -9,6 +9,7 @@ require 'fiona7/naive_search_engine'
|
|
9
9
|
|
10
10
|
require 'fiona7/assert'
|
11
11
|
|
12
|
+
require 'fiona7/json/reverse_obj_decorator'
|
12
13
|
require 'fiona7/json/typeless_obj_decorator'
|
13
14
|
|
14
15
|
module Fiona7
|
@@ -18,6 +19,9 @@ module Fiona7
|
|
18
19
|
def create(workspace_id, values)
|
19
20
|
assert_writable(workspace_id)
|
20
21
|
|
22
|
+
# some stupid creators give us an id. fck them
|
23
|
+
values[:obj].delete("_id")
|
24
|
+
values[:obj].delete(:_id)
|
21
25
|
# This is a hack to make it seem as if the root obj does not exist
|
22
26
|
if values[:obj][:_path] != '/' && values[:obj]["_path"] != '/'
|
23
27
|
obj = Builder::ObjBuilder.new(values[:obj].dup).build
|
@@ -26,7 +30,7 @@ module Fiona7
|
|
26
30
|
end
|
27
31
|
|
28
32
|
klass = EditedObj
|
29
|
-
decorated = Fiona7::JSON::
|
33
|
+
decorated = Fiona7::JSON::ReverseObjDecorator.new(klass, obj)
|
30
34
|
|
31
35
|
return ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
32
36
|
end
|
@@ -43,7 +47,7 @@ module Fiona7
|
|
43
47
|
404
|
44
48
|
)
|
45
49
|
|
46
|
-
decorated = Fiona7::JSON::
|
50
|
+
decorated = Fiona7::JSON::ReverseObjDecorator.new(klass, obj)
|
47
51
|
return ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
48
52
|
end
|
49
53
|
|
@@ -57,8 +61,9 @@ module Fiona7
|
|
57
61
|
404
|
58
62
|
)
|
59
63
|
|
60
|
-
decorated = Fiona7::JSON::
|
61
|
-
|
64
|
+
decorated = Fiona7::JSON::ReverseObjDecorator.new(klass, obj)
|
65
|
+
response = ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
66
|
+
return response
|
62
67
|
end
|
63
68
|
|
64
69
|
def fetch_by_id_from_revision(revision_id, obj_id)
|
@@ -73,16 +78,23 @@ module Fiona7
|
|
73
78
|
404
|
74
79
|
)
|
75
80
|
|
76
|
-
decorated = Fiona7::JSON::
|
81
|
+
decorated = Fiona7::JSON::ReverseObjDecorator.new(klass, obj)
|
77
82
|
return ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
78
83
|
end
|
79
84
|
|
80
85
|
def search(workspace_id, params)
|
81
86
|
klass = matching_class(workspace_id)
|
82
87
|
|
88
|
+
if params[:query].blank?
|
89
|
+
return ::JSON.parse(::ActiveSupport::JSON.encode({
|
90
|
+
total: 0,
|
91
|
+
results: []
|
92
|
+
}))
|
93
|
+
end
|
94
|
+
|
83
95
|
offset = params[:offset] || 0
|
84
96
|
size = params[:size] || 100
|
85
|
-
query = params[:query] || []
|
97
|
+
query = (params[:query] || []).dup
|
86
98
|
order = (params[:sort_order] || :asc).to_sym
|
87
99
|
sort = (params[:sort_by] || :id).to_sym
|
88
100
|
|
@@ -101,7 +113,7 @@ module Fiona7
|
|
101
113
|
|
102
114
|
obj = Builder::ObjUpdater.new(values[:obj].dup.with_indifferent_access).build
|
103
115
|
klass = EditedObj
|
104
|
-
decorated = Fiona7::JSON::
|
116
|
+
decorated = Fiona7::JSON::ReverseObjDecorator.new(klass, obj)
|
105
117
|
return ::JSON.parse(::ActiveSupport::JSON.encode(decorated))
|
106
118
|
end
|
107
119
|
|