scrivito_sdk 0.50.1 → 0.60.0.rc1
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/controllers/scrivito/objs_controller.rb +25 -21
- data/app/controllers/scrivito/ui_controller.rb +1 -1
- data/app/controllers/scrivito/webservice_controller.rb +1 -1
- data/app/models/scrivito/content_widget.rb +1 -3
- data/app/views/cms/index.html.erb +3 -0
- data/app/views/scrivito/objs/destroy.json.jbuilder +1 -0
- data/app/views/scrivito/objs/show.json.jbuilder +2 -0
- data/app/views/scrivito/objs/update.json.jbuilder +1 -1
- data/app/views/scrivito/objs/{widget_modification.json.jbuilder → widget.json.jbuilder} +0 -0
- data/config/ca-bundle.crt +24 -219
- data/config/precedence_routes.rb +60 -0
- data/config/routes.rb +13 -46
- data/lib/assets/javascripts/scrivito_ui.js +360 -202
- data/lib/assets/stylesheets/scrivito_sdk.css +1 -1
- data/lib/assets/stylesheets/scrivito_ui.css +1 -1
- data/lib/generators/scrivito/install/templates/app/models/download.rb +1 -3
- data/lib/generators/scrivito/install/templates/app/models/headline_widget.rb +1 -5
- data/lib/generators/scrivito/install/templates/app/models/image.rb +1 -3
- data/lib/generators/scrivito/install/templates/app/models/image_widget.rb +1 -5
- data/lib/generators/scrivito/install/templates/app/models/page.rb +3 -6
- data/lib/generators/scrivito/install/templates/app/models/text_widget.rb +1 -5
- data/lib/generators/scrivito/install/templates/scrivito/migrate/install_scrivito_migration.rb +1 -25
- data/lib/generators/scrivito/migration/templates/migration.erb +2 -26
- data/lib/generators/scrivito/page/page_generator.rb +0 -11
- data/lib/generators/scrivito/page/templates/model.erb +3 -7
- data/lib/generators/scrivito/widget/widget_generator.rb +0 -11
- data/lib/scrivito/attribute.rb +10 -16
- data/lib/scrivito/attribute_collection.rb +4 -0
- data/lib/scrivito/attribute_content.rb +239 -161
- data/lib/scrivito/attribute_definition.rb +16 -10
- data/lib/scrivito/attribute_definition_collection.rb +7 -4
- data/lib/scrivito/attribute_definition_migrator.rb +1 -3
- data/lib/scrivito/attribute_deserializer.rb +111 -0
- data/lib/scrivito/attribute_serializer.rb +189 -0
- data/lib/scrivito/basic_obj.rb +113 -78
- data/lib/scrivito/basic_widget.rb +103 -37
- data/lib/scrivito/binary.rb +3 -3
- data/lib/scrivito/cache/chainable.rb +10 -4
- data/lib/scrivito/cache/file_store.rb +7 -4
- data/lib/scrivito/cache/ram_store.rb +1 -1
- data/lib/scrivito/class_collection.rb +2 -2
- data/lib/scrivito/client_config.rb +7 -6
- data/lib/scrivito/cms_backend.rb +2 -2
- data/lib/scrivito/cms_field_tag.rb +33 -25
- data/lib/scrivito/cms_rest_api/{attribute_serializer.rb → legacy_attribute_serializer.rb} +1 -1
- data/lib/scrivito/cms_routing.rb +20 -14
- data/lib/scrivito/configuration.rb +1 -1
- data/lib/scrivito/controller_actions.rb +12 -4
- data/lib/scrivito/date_attribute.rb +8 -0
- data/lib/scrivito/diff.rb +1 -1
- data/lib/scrivito/editing_context.rb +1 -1
- data/lib/scrivito/editing_context_middleware.rb +1 -1
- data/lib/scrivito/errors.rb +4 -0
- data/lib/scrivito/link_parser.rb +6 -1
- data/lib/scrivito/migrations/cms_backend.rb +17 -60
- data/lib/scrivito/migrations/migration_store.rb +0 -1
- data/lib/scrivito/model_library.rb +6 -6
- data/lib/scrivito/obj_class.rb +34 -48
- data/lib/scrivito/obj_class_collection.rb +21 -3
- data/lib/scrivito/obj_create_params_parser.rb +2 -1
- data/lib/scrivito/obj_data.rb +9 -103
- data/lib/scrivito/obj_data_from_hash.rb +19 -21
- data/lib/scrivito/obj_data_from_service.rb +28 -48
- data/lib/scrivito/obj_params_parser.rb +14 -14
- data/lib/scrivito/obj_search_enumerator.rb +1 -1
- data/lib/scrivito/obj_update_params_parser.rb +2 -2
- data/lib/scrivito/restriction_set.rb +1 -1
- data/lib/scrivito/sdk_engine.rb +2 -2
- data/lib/scrivito/test_request.rb +10 -0
- data/lib/scrivito/type_computer.rb +5 -1
- data/lib/scrivito/widget_collection.rb +15 -0
- data/lib/scrivito/widget_garbage_collection.rb +1 -1
- data/lib/scrivito/widget_tag.rb +2 -0
- data/lib/scrivito/workspace.rb +2 -1
- data/lib/scrivito/workspace_data_from_service.rb +1 -0
- data/lib/scrivito_sdk.rb +17 -1
- metadata +36 -34
- data/app/views/scrivito/objs/modification.json.jbuilder +0 -1
- data/config/cms_routes.rb +0 -22
- data/lib/generators/scrivito/page/templates/migration.erb +0 -9
- data/lib/generators/scrivito/widget/templates/migration.erb +0 -7
@@ -4,6 +4,7 @@ module Scrivito
|
|
4
4
|
# instance by accessing {Workspace#obj_classes}.
|
5
5
|
#
|
6
6
|
# @api public
|
7
|
+
# @deprecated
|
7
8
|
class ObjClassCollection
|
8
9
|
include Enumerable
|
9
10
|
|
@@ -18,6 +19,7 @@ module Scrivito
|
|
18
19
|
# Finds an obj class by its name in the working copy of the collection.
|
19
20
|
#
|
20
21
|
# @api public
|
22
|
+
# @deprecated
|
21
23
|
#
|
22
24
|
# @example Find the obj class named "Homepage" in the "rtc" {Workspace}.
|
23
25
|
# Workspace.find('rtc').obj_classes['Homepage']
|
@@ -30,21 +32,37 @@ module Scrivito
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
35
|
+
#
|
33
36
|
# @!method each
|
37
|
+
#
|
34
38
|
# Yields successive obj classes of the collection. Implements the +Enumerable+ interface.
|
39
|
+
#
|
35
40
|
# @api public
|
36
|
-
# @
|
41
|
+
# @deprecated
|
42
|
+
# @see Scrivito::ObjClass.remove
|
43
|
+
#
|
44
|
+
# @yield [ObjClass] successive obj classes of the collection if the corresponding workspace
|
45
|
+
# still uses {Scrivito::ObjClass}.
|
46
|
+
# @yield [Array] an empty array if the corresponding workspace does not use {Scrivito::ObjClass}
|
47
|
+
# anymore.
|
48
|
+
#
|
37
49
|
# @example Find all obj classes in the "rtc" {Workspace} and print their name.
|
38
50
|
# Workspace.find('rtc').obj_classes.each do |obj_class|
|
39
51
|
# puts obj_class.name
|
40
52
|
# end
|
53
|
+
#
|
41
54
|
delegate :each, to: :obj_classes
|
42
55
|
|
43
56
|
private
|
44
57
|
|
45
58
|
def obj_classes
|
46
|
-
|
47
|
-
|
59
|
+
if workspace.uses_obj_classes
|
60
|
+
CmsBackend.instance.find_all_obj_class_data(workspace.revision).map do |obj_class_data|
|
61
|
+
ObjClass.new(obj_class_data, workspace)
|
62
|
+
end
|
63
|
+
else
|
64
|
+
Scrivito.print_obj_class_deprecated_warning
|
65
|
+
[]
|
48
66
|
end
|
49
67
|
end
|
50
68
|
|
@@ -6,7 +6,8 @@ module Scrivito
|
|
6
6
|
|
7
7
|
def convert_params(params)
|
8
8
|
if obj_class_name = params['_obj_class']
|
9
|
-
|
9
|
+
model_class = Obj.type_computer.compute_type(obj_class_name)
|
10
|
+
convert_field_params(params, model_class.attribute_definitions)
|
10
11
|
else
|
11
12
|
raise ArgumentError, 'Missing "_obj_class" param'
|
12
13
|
end
|
data/lib/scrivito/obj_data.rb
CHANGED
@@ -1,39 +1,5 @@
|
|
1
1
|
module Scrivito
|
2
|
-
|
3
2
|
class ObjData
|
4
|
-
internal_key_list = %w[
|
5
|
-
last_changed
|
6
|
-
modification
|
7
|
-
permalink
|
8
|
-
text_links
|
9
|
-
conflicts
|
10
|
-
]
|
11
|
-
|
12
|
-
INTERNAL_KEYS = Set.new(internal_key_list.map { |name| "_#{name}" } )
|
13
|
-
|
14
|
-
internal_comparison_key_list = %w[
|
15
|
-
path
|
16
|
-
permalink
|
17
|
-
widget_pool
|
18
|
-
]
|
19
|
-
|
20
|
-
INTERNAL_COMPARISON_KEYS = Set.new(internal_comparison_key_list.map { |name| "_#{name}" })
|
21
|
-
|
22
|
-
ATTRIBUTE_DEFAULT_VALUES = {
|
23
|
-
"string" => "",
|
24
|
-
"text" => "",
|
25
|
-
"html" => "",
|
26
|
-
"multienum" => [],
|
27
|
-
"linklist" => [],
|
28
|
-
"referencelist" => [],
|
29
|
-
"widget" => [],
|
30
|
-
"enum" => nil,
|
31
|
-
"binary" => nil,
|
32
|
-
"date" => nil,
|
33
|
-
"reference" => nil,
|
34
|
-
"link" => nil,
|
35
|
-
}.freeze
|
36
|
-
|
37
3
|
def value_of(attribute_name)
|
38
4
|
value_and_type_of(attribute_name).first
|
39
5
|
end
|
@@ -42,32 +8,14 @@ module Scrivito
|
|
42
8
|
value_and_type_of(attribute_name).second
|
43
9
|
end
|
44
10
|
|
45
|
-
def value_without_default_of(attribute_name)
|
46
|
-
value_and_type_without_default_of(attribute_name).first
|
47
|
-
end
|
48
|
-
|
49
11
|
def value_and_type_of(attribute_name)
|
50
|
-
if
|
51
|
-
|
52
|
-
else
|
53
|
-
custom_value_and_type_with_default(attribute_name)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def value_and_type_without_default_of(attribute_name)
|
58
|
-
if internal_attribute?(attribute_name)
|
59
|
-
internal_value_and_type(attribute_name)
|
12
|
+
if attribute_name.starts_with?('_')
|
13
|
+
[raw_value_and_type_of(attribute_name).first, nil]
|
60
14
|
else
|
61
15
|
raw_value_and_type_of(attribute_name)
|
62
16
|
end
|
63
17
|
end
|
64
18
|
|
65
|
-
def all_custom_attributes
|
66
|
-
@all_custom_attributes ||= all_attributes.select do |attribute|
|
67
|
-
has_custom_attribute?(attribute)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
19
|
def to_h
|
72
20
|
raise NotImplementedError, 'implement in subclass'
|
73
21
|
end
|
@@ -76,62 +24,20 @@ module Scrivito
|
|
76
24
|
raise NotImplementedError, "implement in subclass"
|
77
25
|
end
|
78
26
|
|
79
|
-
def
|
80
|
-
raise NotImplementedError, "implement in subclass"
|
81
|
-
end
|
82
|
-
|
83
|
-
def all_attributes
|
27
|
+
def attribute_names_for_comparison
|
84
28
|
raise NotImplementedError, "implement in subclass"
|
85
29
|
end
|
86
30
|
|
87
31
|
def ==(other)
|
88
|
-
|
89
|
-
(all_attributes | other.all_attributes).each do |attr|
|
90
|
-
attr = attr.to_s
|
91
|
-
|
92
|
-
next if attr.start_with?('_') && !INTERNAL_COMPARISON_KEYS.include?(attr)
|
93
|
-
|
94
|
-
if value_without_default_of(attr) != other.value_without_default_of(attr)
|
95
|
-
return false
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
return true
|
100
|
-
end
|
101
|
-
|
102
|
-
false
|
103
|
-
end
|
32
|
+
return false unless other.is_a?(ObjData)
|
104
33
|
|
105
|
-
|
34
|
+
attribute_names = attribute_names_for_comparison | other.attribute_names_for_comparison
|
35
|
+
attribute_names.reject! { |attribute_name| attribute_name.starts_with?('_') }
|
36
|
+
attribute_names += %w[_path _permalink _widget_pool]
|
106
37
|
|
107
|
-
|
108
|
-
|
109
|
-
value = ATTRIBUTE_DEFAULT_VALUES[type] if value.nil?
|
110
|
-
[value, type]
|
111
|
-
end
|
112
|
-
|
113
|
-
def internal_value_and_type(attribute_name)
|
114
|
-
value, type = raw_value_and_type_of(attribute_name)
|
115
|
-
type = type_of_internal(attribute_name)
|
116
|
-
[value, type]
|
117
|
-
end
|
118
|
-
|
119
|
-
def internal_attribute?(attribute_name)
|
120
|
-
attribute_name.starts_with?('_')
|
121
|
-
end
|
122
|
-
|
123
|
-
def type_of_internal(key)
|
124
|
-
case key
|
125
|
-
when "_permalink"
|
126
|
-
"string"
|
127
|
-
when "_text_links"
|
128
|
-
"linklist"
|
129
|
-
when "_last_changed"
|
130
|
-
"date"
|
131
|
-
else
|
132
|
-
nil
|
38
|
+
attribute_names.all? do |attribute_name|
|
39
|
+
value_of(attribute_name) == other.value_of(attribute_name)
|
133
40
|
end
|
134
41
|
end
|
135
42
|
end
|
136
|
-
|
137
43
|
end
|
@@ -1,31 +1,29 @@
|
|
1
1
|
module Scrivito
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def raw_value_and_type_of(attribute_name)
|
10
|
-
[@hash[attribute_name], @type_hash[attribute_name]]
|
11
|
-
end
|
12
|
-
|
13
|
-
def has_custom_attribute?(name)
|
14
|
-
@hash.has_key?(name) || name == '_id'
|
15
|
-
end
|
3
|
+
class ObjDataFromHash < ObjData
|
4
|
+
def initialize(attributes)
|
5
|
+
@attributes = attributes.stringify_keys
|
6
|
+
end
|
16
7
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
8
|
+
def raw_value_and_type_of(attribute_name)
|
9
|
+
if attribute_data = @attributes[attribute_name]
|
10
|
+
if attribute_name.starts_with?('_')
|
11
|
+
[attribute_data, nil]
|
12
|
+
else
|
13
|
+
attribute_data.reverse
|
22
14
|
end
|
15
|
+
else
|
16
|
+
[nil, nil]
|
23
17
|
end
|
18
|
+
end
|
24
19
|
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
def attribute_names_for_comparison
|
21
|
+
@attributes.keys
|
22
|
+
end
|
28
23
|
|
24
|
+
def to_h
|
25
|
+
@attributes
|
29
26
|
end
|
27
|
+
end
|
30
28
|
|
31
29
|
end
|
@@ -6,54 +6,42 @@ module Scrivito
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def raw_value_and_type_of(attribute_name)
|
9
|
-
if attribute_name == '_widget_pool'
|
10
|
-
|
9
|
+
return [value_of_widget_pool, nil] if attribute_name == '_widget_pool'
|
10
|
+
if value_and_type = @data[attribute_name]
|
11
|
+
value, type = value_and_type
|
12
|
+
value = convert_value(value, type)
|
13
|
+
[value, type]
|
11
14
|
else
|
12
|
-
|
13
|
-
|
14
|
-
if type_and_value.present?
|
15
|
-
type = if type_and_value.length == 1
|
16
|
-
type_of_internal(attribute_name)
|
17
|
-
else
|
18
|
-
type_and_value.last
|
19
|
-
end
|
20
|
-
|
21
|
-
[convert_value(type_and_value.first, type), type]
|
22
|
-
end
|
15
|
+
[nil, nil]
|
23
16
|
end
|
24
17
|
end
|
25
18
|
|
26
|
-
def
|
27
|
-
|
19
|
+
def convert_value(value, type)
|
20
|
+
case type
|
21
|
+
when 'html' then convert_text_links(value)
|
22
|
+
when 'widget'
|
23
|
+
if value.is_a?(Hash) && value.size == 1 && value.has_key?('list')
|
24
|
+
# Legacy data with obj classes.
|
25
|
+
value['list'].map { |item| item['widget'] }
|
26
|
+
else
|
27
|
+
value
|
28
|
+
end
|
29
|
+
else value
|
30
|
+
end
|
28
31
|
end
|
29
32
|
|
30
|
-
def
|
31
|
-
@
|
33
|
+
def attribute_names_for_comparison
|
34
|
+
@data.keys
|
32
35
|
end
|
33
36
|
|
34
37
|
def to_h
|
35
|
-
@data.
|
36
|
-
h.each_pair { |k, v| h[k] = v.first }
|
37
|
-
end
|
38
|
+
@data.to_h
|
38
39
|
end
|
39
40
|
|
40
41
|
private
|
41
42
|
|
42
|
-
def
|
43
|
-
|
44
|
-
when "html"
|
45
|
-
text_links_conversion.convert(value)
|
46
|
-
when "widget"
|
47
|
-
if !value
|
48
|
-
[]
|
49
|
-
else
|
50
|
-
(value['list'] || []).map do |list_item|
|
51
|
-
list_item['widget']
|
52
|
-
end
|
53
|
-
end
|
54
|
-
else
|
55
|
-
value
|
56
|
-
end
|
43
|
+
def convert_text_links(value)
|
44
|
+
text_links_conversion.convert(value)
|
57
45
|
end
|
58
46
|
|
59
47
|
def text_links_conversion
|
@@ -70,21 +58,13 @@ module Scrivito
|
|
70
58
|
end
|
71
59
|
|
72
60
|
def value_of_widget_pool
|
73
|
-
|
74
|
-
|
75
|
-
hash
|
61
|
+
if widget_pool = @data['_widget_pool']
|
62
|
+
widget_pool.first.dup.tap do |hash|
|
63
|
+
hash.each_pair do |widget_id, raw_widget_data|
|
64
|
+
hash[widget_id] = self.class.new(raw_widget_data)
|
65
|
+
end
|
76
66
|
end
|
77
67
|
end
|
78
68
|
end
|
79
|
-
|
80
|
-
def raw_value_of_widget_pool
|
81
|
-
@data['_widget_pool'].first
|
82
|
-
end
|
83
|
-
|
84
|
-
def is_custom_attribute?(attribute_name)
|
85
|
-
!internal_attribute?(attribute_name)
|
86
|
-
end
|
87
|
-
|
88
69
|
end
|
89
|
-
|
90
70
|
end
|
@@ -11,25 +11,21 @@ module Scrivito
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
def convert_field_params(
|
14
|
+
def convert_field_params(params, attribute_definitions)
|
15
15
|
params.each_pair do |key, value|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
when '
|
23
|
-
when 'linklist' then ContentConversion.convert_linklist_urls(value, host, port)
|
24
|
-
when 'link' then ContentConversion.convert_link(value, host, port)
|
25
|
-
when 'widget' then parse_widget_field_params(value)
|
26
|
-
when 'binary' then parse_binary_field_params(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 'widgetlist' then parse_widgetlist_params(value)
|
22
|
+
when 'date' then parse_date_params(value)
|
27
23
|
else value
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
32
|
-
def
|
28
|
+
def parse_widgetlist_params(params)
|
33
29
|
params.map do |widget_id_or_params|
|
34
30
|
if widget_id_or_params.is_a?(Hash)
|
35
31
|
action, widget_params = widget_id_or_params.flatten
|
@@ -50,8 +46,12 @@ module Scrivito
|
|
50
46
|
end
|
51
47
|
end
|
52
48
|
|
53
|
-
def
|
49
|
+
def parse_binary_params(params)
|
54
50
|
UploadedBinary.new(params) if params
|
55
51
|
end
|
52
|
+
|
53
|
+
def parse_date_params(params)
|
54
|
+
DateAttribute.parse(params)
|
55
|
+
end
|
56
56
|
end
|
57
57
|
end
|
@@ -5,7 +5,7 @@ module Scrivito
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def convert_params(params)
|
8
|
-
convert_field_params(obj.
|
8
|
+
convert_field_params(params, obj.attribute_definitions)
|
9
9
|
convert_widget_pool_params(params)
|
10
10
|
end
|
11
11
|
|
@@ -16,7 +16,7 @@ module Scrivito
|
|
16
16
|
params['_widget_pool'].each_pair do |widget_id, widget_params|
|
17
17
|
if widget_params.present?
|
18
18
|
widget = obj.widgets[widget_id]
|
19
|
-
widget_pool[widget] = convert_field_params(widget.
|
19
|
+
widget_pool[widget] = convert_field_params(widget_params, widget.attribute_definitions)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
params['_widget_pool'] = widget_pool
|