scrivito_sdk 0.66.0 → 0.70.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/scrivito/blobs_controller.rb +5 -0
- data/app/controllers/scrivito/objs_controller.rb +2 -1
- data/app/controllers/scrivito/ui_controller.rb +33 -3
- data/app/helpers/scrivito_helper.rb +14 -20
- data/app/views/scrivito/objs/update.json.jbuilder +1 -1
- data/app/views/scrivito/ui/index.html.erb +1 -1
- data/app/views/scrivito/webservice/_workspace.json.jbuilder +2 -1
- data/config/ca-bundle.crt +1 -1
- data/config/precedence_routes.rb +3 -2
- data/lib/assets/javascripts/scrivito.js +46 -0
- data/lib/assets/javascripts/scrivito_ui.js +931 -501
- data/lib/assets/stylesheets/scrivito.css +1 -0
- data/lib/assets/stylesheets/scrivito_ui.css +1 -1
- data/lib/generators/scrivito/install/templates/app/views/page/index.html.erb +3 -3
- data/lib/generators/scrivito/page/page_generator.rb +3 -0
- data/lib/generators/scrivito/page/templates/model.erb +3 -0
- data/lib/generators/scrivito/widget/templates/model.erb +3 -0
- data/lib/generators/scrivito/widget/widget_generator.rb +3 -0
- data/lib/scrivito/attribute_content.rb +93 -60
- data/lib/scrivito/attribute_definition.rb +3 -3
- data/lib/scrivito/attribute_serializer.rb +2 -2
- data/lib/scrivito/backend/obj_data_cache.rb +22 -9
- data/lib/scrivito/basic_obj.rb +238 -130
- data/lib/scrivito/basic_widget.rb +32 -20
- data/lib/scrivito/binary.rb +74 -45
- data/lib/scrivito/binary_routing.rb +52 -0
- data/lib/scrivito/cache_middleware.rb +0 -5
- data/lib/scrivito/client_attribute_serializer.rb +134 -0
- data/lib/scrivito/cms_backend.rb +51 -33
- data/lib/scrivito/cms_data_cache.rb +1 -0
- data/lib/scrivito/cms_dispatch_controller.rb +1 -1
- data/lib/scrivito/cms_env.rb +1 -11
- data/lib/scrivito/cms_field_tag.rb +10 -7
- data/lib/scrivito/cms_rest_api/rate_limit.rb +5 -5
- data/lib/scrivito/cms_rest_api/request_timer.rb +27 -0
- data/lib/scrivito/cms_rest_api/widget_extractor.rb +8 -6
- data/lib/scrivito/cms_rest_api.rb +107 -54
- data/lib/scrivito/cms_routing.rb +13 -25
- data/lib/scrivito/configuration.rb +5 -2
- data/lib/scrivito/controller_actions.rb +68 -7
- data/lib/scrivito/controller_runtime.rb +8 -0
- data/lib/scrivito/date_attribute.rb +8 -0
- data/lib/scrivito/errors.rb +6 -3
- data/lib/scrivito/generator_helper.rb +13 -0
- data/lib/scrivito/image_tag.rb +24 -30
- data/lib/scrivito/layout_tags.rb +12 -6
- data/lib/scrivito/link.rb +46 -30
- data/lib/scrivito/log_subscriber.rb +15 -0
- data/lib/scrivito/membership.rb +3 -3
- data/lib/scrivito/membership_collection.rb +10 -10
- data/lib/scrivito/meta_data_collection.rb +22 -0
- data/lib/scrivito/model_library.rb +7 -1
- data/lib/scrivito/obj_collection.rb +18 -16
- data/lib/scrivito/obj_params_parser.rb +1 -1
- data/lib/scrivito/obj_search_enumerator.rb +35 -35
- data/lib/scrivito/page_config.rb +55 -0
- data/lib/scrivito/request_homepage.rb +23 -0
- data/lib/scrivito/routing_helper.rb +8 -8
- data/lib/scrivito/sdk_engine.rb +2 -3
- data/lib/scrivito/ui_config.rb +85 -0
- data/lib/scrivito/user.rb +30 -23
- data/lib/scrivito/user_definition.rb +48 -47
- data/lib/scrivito/widget_tag.rb +11 -0
- data/lib/scrivito/workspace.rb +93 -35
- data/lib/scrivito/workspace_selection_middleware.rb +8 -1
- data/lib/scrivito_sdk.rb +24 -24
- metadata +24 -33
- data/lib/assets/javascripts/scrivito_sdk.js +0 -57
- data/lib/assets/stylesheets/scrivito_sdk.css +0 -1
- data/lib/scrivito/client_config.rb +0 -113
- data/lib/scrivito/editing_context_helper.rb +0 -19
- data/lib/scrivito/named_link.rb +0 -39
@@ -1,113 +0,0 @@
|
|
1
|
-
module Scrivito
|
2
|
-
|
3
|
-
class ClientConfig < Struct.new(:obj, :editing_context, :lookup_context, :resource, :return_to)
|
4
|
-
def initialize(obj, editing_context, lookup_context, options = {})
|
5
|
-
super(obj, editing_context, lookup_context, *options.values_at(:resource, :return_to))
|
6
|
-
end
|
7
|
-
|
8
|
-
def to_json
|
9
|
-
config = {}
|
10
|
-
config[:current_page] = current_page_config
|
11
|
-
config[:editing_context] = editing_context_config
|
12
|
-
config[:i18n] = i18n_config
|
13
|
-
config[:resource_dialog] = resource_dialog_config
|
14
|
-
config[:user] = user_config
|
15
|
-
config[:user_permissions] = user_permissions_config
|
16
|
-
config[:is_development_mode] = Rails.env.development?
|
17
|
-
config.to_json
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def editing_context_config
|
23
|
-
{
|
24
|
-
display_mode: editing_context.display_mode,
|
25
|
-
|
26
|
-
selected_workspace: {
|
27
|
-
id: selected_workspace.id,
|
28
|
-
title: selected_workspace.title,
|
29
|
-
outdated: selected_workspace.outdated?
|
30
|
-
},
|
31
|
-
|
32
|
-
visible_workspace: {
|
33
|
-
id: visible_workspace.id,
|
34
|
-
title: visible_workspace.title
|
35
|
-
}
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
def i18n_config
|
40
|
-
{locale: Scrivito::Configuration.ui_locale || I18n.locale}
|
41
|
-
end
|
42
|
-
|
43
|
-
def current_page_config
|
44
|
-
if obj
|
45
|
-
{
|
46
|
-
id: obj.id,
|
47
|
-
obj_class_name: obj.obj_class_name,
|
48
|
-
has_children: obj.children.any?,
|
49
|
-
has_conflict: obj.has_conflict?,
|
50
|
-
has_details_view: obj_has_details_view?,
|
51
|
-
modification: modification(obj),
|
52
|
-
restriction_messages: editor.restriction_messages_for(obj),
|
53
|
-
}
|
54
|
-
else
|
55
|
-
{}
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def obj_has_details_view?
|
60
|
-
lookup_context.find(obj.details_view_path).present?
|
61
|
-
rescue ActionView::MissingTemplate
|
62
|
-
false
|
63
|
-
end
|
64
|
-
|
65
|
-
def resource_dialog_config
|
66
|
-
if resource
|
67
|
-
{
|
68
|
-
obj: Configuration.obj_formats.fetch('_default').call(resource, editor),
|
69
|
-
return_to: return_to,
|
70
|
-
}
|
71
|
-
else
|
72
|
-
{}
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def user_permissions_config
|
77
|
-
{
|
78
|
-
create_workspace: editor.can?(:create, :workspace),
|
79
|
-
publish_workspace: editor.can?(:publish, selected_workspace),
|
80
|
-
}
|
81
|
-
end
|
82
|
-
|
83
|
-
def user_config
|
84
|
-
{
|
85
|
-
current: {
|
86
|
-
id: editor.id
|
87
|
-
}
|
88
|
-
}
|
89
|
-
end
|
90
|
-
|
91
|
-
def modification(obj_or_resource)
|
92
|
-
comparison = editing_context.comparison
|
93
|
-
if comparison.active?
|
94
|
-
comparison.modification(obj_or_resource)
|
95
|
-
else
|
96
|
-
obj_or_resource.modification
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def editor
|
101
|
-
editing_context.editor
|
102
|
-
end
|
103
|
-
|
104
|
-
def selected_workspace
|
105
|
-
editing_context.selected_workspace
|
106
|
-
end
|
107
|
-
|
108
|
-
def visible_workspace
|
109
|
-
editing_context.visible_workspace
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Scrivito
|
2
|
-
|
3
|
-
class EditingContextHelper < Struct.new(:request)
|
4
|
-
def scrivito_user
|
5
|
-
editing_context.editor
|
6
|
-
end
|
7
|
-
|
8
|
-
def in_editable_view?
|
9
|
-
editing_context.editable_display_mode?
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def editing_context
|
15
|
-
Scrivito::EditingContextMiddleware.from_request(request)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
data/lib/scrivito/named_link.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Scrivito
|
2
|
-
|
3
|
-
# This class provides methods used to retrieve objects from CMS based an entry
|
4
|
-
# in CMS of the obj_class <tt>NamedLink</tt>.
|
5
|
-
# @api public
|
6
|
-
class NamedLink
|
7
|
-
|
8
|
-
# @api public
|
9
|
-
class NotFound < StandardError
|
10
|
-
end
|
11
|
-
|
12
|
-
# This method will be called to retrieve the NamedLink {BasicObj Obj}.
|
13
|
-
# By default it will look for the Obj at the path "_named_links".
|
14
|
-
# Override this method only if you know what you are doing.
|
15
|
-
# @api public
|
16
|
-
def self.find_named_link_obj
|
17
|
-
BasicObj.find_by_path("/_named_links")
|
18
|
-
end
|
19
|
-
|
20
|
-
# Returns the CMS object mapped to the given title or nil.
|
21
|
-
# The title can be a string of symbol.
|
22
|
-
# @api public
|
23
|
-
def self.get_object(title, options = {})
|
24
|
-
link = named_links.find { |link| link.title == title.to_s }
|
25
|
-
raise NotFound, "The NamedLink '#{title.to_s}' does not exist" unless link
|
26
|
-
link.obj
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.named_links
|
30
|
-
named_link_obj = find_named_link_obj
|
31
|
-
|
32
|
-
if named_link_obj
|
33
|
-
named_link_obj.related_links
|
34
|
-
else
|
35
|
-
raise NotFound, "Couldn't find NamedLink CMS Object!"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|