scrivito_sdk 0.18.1 → 0.30.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 +1 -2
- data/app/controllers/scrivito/default_cms_controller.rb +9 -75
- data/app/controllers/scrivito/objs_controller.rb +107 -119
- data/app/controllers/scrivito/tasks_controller.rb +1 -1
- data/app/controllers/scrivito/users_controller.rb +1 -1
- data/app/controllers/scrivito/webservice_controller.rb +6 -2
- data/app/controllers/scrivito/workspaces_controller.rb +57 -17
- data/app/helpers/scrivito_helper.rb +285 -0
- data/app/views/google_maps_widget/show.html.erb +1 -0
- data/app/views/scrivito/_editing_auth_warning.html.erb +43 -0
- data/app/views/scrivito/blobs/upload_permission.json.jbuilder +1 -0
- data/app/views/scrivito/objs/copy.json.jbuilder +1 -0
- data/app/views/scrivito/objs/copy_widget.html.erb +1 -1
- data/app/views/scrivito/objs/create.json.jbuilder +1 -0
- data/app/views/scrivito/objs/create_widget.html.erb +1 -1
- data/app/views/scrivito/objs/details.json.jbuilder +1 -0
- data/app/views/scrivito/objs/format_missing_error.json.jbuilder +1 -0
- data/app/views/scrivito/objs/modification.json.jbuilder +1 -0
- data/app/views/scrivito/objs/page_class_selection.json.jbuilder +1 -0
- data/app/views/scrivito/objs/search.json.jbuilder +6 -0
- data/app/views/scrivito/objs/search_only_size.json.jbuilder +1 -0
- data/app/views/scrivito/objs/update.json.jbuilder +1 -0
- data/app/views/scrivito/objs/widget_class_selection.json.jbuilder +1 -0
- data/app/views/scrivito/objs/widget_modification.json.jbuilder +1 -0
- data/app/views/scrivito/tasks/show.json.jbuilder +3 -0
- data/app/views/scrivito/users/suggest.json.jbuilder +1 -0
- data/app/views/scrivito/webservice/empty.json +1 -0
- data/app/views/scrivito/webservice/error.json.jbuilder +2 -0
- data/app/views/scrivito/workspaces/_workspace.json.jbuilder +5 -0
- data/app/views/scrivito/workspaces/check.json.jbuilder +1 -0
- data/app/views/scrivito/workspaces/create.json.jbuilder +1 -0
- data/app/views/scrivito/workspaces/index.json.jbuilder +1 -0
- data/app/views/scrivito/workspaces/show.json.jbuilder +1 -0
- data/app/views/scrivito/workspaces/task.json.jbuilder +5 -0
- data/config/ca-bundle.crt +259 -234
- data/config/cms_routes.rb +2 -2
- data/config/routes.rb +3 -0
- data/lib/assets/javascripts/{scrivito_editing.js → scrivito_sdk.js} +1662 -1180
- data/lib/assets/stylesheets/{scrivito_editing.css → scrivito_sdk.css} +242 -6
- data/lib/generators/scrivito/install/install_generator.rb +62 -0
- data/lib/generators/scrivito/install/templates/app/controllers/cms_controller.rb +3 -0
- data/lib/generators/scrivito/install/templates/app/controllers/page_controller.rb +2 -0
- data/lib/generators/scrivito/install/templates/app/models/headline_widget.rb +7 -0
- data/lib/generators/scrivito/install/templates/app/models/image.rb +5 -0
- data/lib/generators/scrivito/install/templates/app/models/image_widget.rb +7 -0
- data/lib/generators/scrivito/install/templates/app/models/obj.rb +2 -0
- data/lib/generators/scrivito/install/templates/app/models/page.rb +8 -0
- data/lib/generators/scrivito/install/templates/app/models/text_widget.rb +7 -0
- data/lib/generators/scrivito/install/templates/app/models/widget.rb +2 -0
- data/lib/generators/scrivito/install/templates/app/views/headline_widget/show.html.erb +1 -0
- data/lib/generators/scrivito/install/templates/app/views/headline_widget/thumbnail.html.erb +3 -0
- data/lib/generators/scrivito/install/templates/app/views/image_widget/show.html.erb +1 -0
- data/lib/generators/scrivito/install/templates/app/views/image_widget/thumbnail.html.erb +3 -0
- data/lib/generators/scrivito/install/templates/app/views/page/details.html.erb +1 -0
- data/lib/generators/scrivito/install/templates/app/views/page/index.html.erb +16 -0
- data/lib/generators/scrivito/install/templates/app/views/page/thumbnail.html.erb +3 -0
- data/lib/generators/scrivito/install/templates/app/views/text_widget/show.html.erb +1 -0
- data/lib/generators/scrivito/install/templates/app/views/text_widget/thumbnail.html.erb +3 -0
- data/lib/generators/scrivito/install/templates/config/initializers/scrivito.rb +10 -0
- data/lib/generators/scrivito/install/templates/scrivito/migrate/install_scrivito.rb +49 -0
- data/lib/generators/scrivito/migration/USAGE +9 -0
- data/lib/generators/{cms → scrivito}/migration/migration_generator.rb +4 -9
- data/lib/generators/{cms → scrivito}/migration/templates/migration.erb +3 -3
- data/lib/generators/{cms → scrivito}/widget/templates/details.html.erb +0 -0
- data/lib/generators/{cms → scrivito}/widget/templates/migration.erb +0 -0
- data/lib/generators/{cms → scrivito}/widget/templates/model.erb +0 -0
- data/lib/generators/{cms → scrivito}/widget/templates/show.html.erb +0 -0
- data/lib/generators/scrivito/widget/templates/thumbnail.html.erb +3 -0
- data/lib/generators/{cms → scrivito}/widget/widget_generator.rb +3 -2
- data/lib/obj.rb +17 -3
- data/lib/scrivito/attribute_collection.rb +7 -12
- data/lib/scrivito/attribute_content.rb +31 -12
- data/lib/scrivito/basic_obj.rb +186 -96
- data/lib/scrivito/basic_widget.rb +25 -10
- data/lib/scrivito/binary.rb +75 -0
- data/lib/scrivito/cache_garbage_collector.rb +19 -4
- data/lib/scrivito/child_list_tag.rb +108 -0
- data/lib/scrivito/client_config.rb +2 -1
- data/lib/scrivito/client_error.rb +3 -2
- data/lib/scrivito/cms_backend.rb +81 -16
- data/lib/scrivito/cms_dispatch_controller.rb +7 -0
- data/lib/scrivito/cms_env.rb +0 -2
- data/lib/scrivito/cms_field_tag.rb +44 -35
- data/lib/scrivito/cms_rest_api.rb +23 -6
- data/lib/scrivito/cms_rest_api/attribute_serializer.rb +1 -1
- data/lib/scrivito/cms_routing.rb +120 -0
- data/lib/scrivito/configuration.rb +69 -58
- data/lib/scrivito/connection_manager.rb +30 -1
- data/lib/scrivito/content_service.rb +10 -7
- data/lib/scrivito/controller_actions.rb +108 -0
- data/lib/scrivito/diff.rb +30 -15
- data/lib/scrivito/editing_context.rb +4 -0
- data/lib/scrivito/editing_context_helper.rb +19 -0
- data/lib/scrivito/editing_context_middleware.rb +20 -1
- data/lib/scrivito/image_tag_helper.rb +44 -0
- data/lib/scrivito/layout_tags.rb +33 -0
- data/lib/scrivito/link.rb +4 -2
- data/lib/scrivito/membership.rb +0 -8
- data/lib/scrivito/migrations.rb +0 -1
- data/lib/scrivito/migrations/installer.rb +1 -1
- data/lib/scrivito/migrations/migration.rb +0 -2
- data/lib/scrivito/migrations/migrator.rb +2 -3
- data/lib/scrivito/obj_class.rb +64 -16
- data/lib/scrivito/obj_class_data.rb +4 -0
- data/lib/scrivito/obj_search_enumerator.rb +1 -1
- data/lib/scrivito/routing_helper.rb +42 -0
- data/lib/scrivito/{engine.rb → sdk_engine.rb} +15 -29
- data/lib/scrivito/tag_renderer.rb +40 -0
- data/lib/scrivito/test_request.rb +40 -0
- data/lib/scrivito/type_computer.rb +1 -6
- data/lib/scrivito/user.rb +33 -15
- data/lib/scrivito/user_definition.rb +34 -6
- data/lib/scrivito/widget_tag.rb +67 -0
- data/lib/scrivito/workspace.rb +12 -24
- data/lib/scrivito_sdk.rb +17 -1
- data/lib/tasks/cache.rake +4 -5
- data/lib/tasks/migration.rake +1 -1
- data/lib/widget.rb +21 -3
- metadata +119 -70
- data/README +0 -6
- data/app/controllers/cms_controller.rb +0 -7
- data/app/helpers/cms_helper.rb +0 -7
- data/app/helpers/cms_routing_helper.rb +0 -7
- data/app/helpers/scrivito/cms_asset_helper.rb +0 -110
- data/app/helpers/scrivito/cms_tag_helper.rb +0 -232
- data/app/helpers/scrivito/default_cms_helper.rb +0 -21
- data/app/helpers/scrivito/default_cms_routing_helper.rb +0 -128
- data/app/helpers/scrivito/display_helper.rb +0 -64
- data/app/helpers/scrivito/editing_helper.rb +0 -32
- data/app/helpers/scrivito/layout_helper.rb +0 -21
- data/app/models/named_link.rb +0 -2
- data/app/views/cms/_index.html.erb +0 -7
- data/app/views/cms/index.html.erb +0 -1
- data/app/views/scrivito/_editing_javascript.html.erb +0 -7
- data/app/views/scrivito/default_cms/show_widget.html.erb +0 -1
- data/lib/assets/stylesheets/scrivito.css +0 -199
- data/lib/generators/cms/migration/USAGE +0 -9
- data/lib/generators/cms/widget/templates/thumbnail.html.erb +0 -2
- data/lib/scrivito/blob.rb +0 -48
- data/lib/scrivito/cms_accessible.rb +0 -30
- data/lib/scrivito/cms_rest_api/blob_uploader.rb +0 -18
- data/lib/scrivito/cms_test_request.rb +0 -23
- data/lib/scrivito/migrations/migration_dsl.rb +0 -180
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbff45be246233cd7451a407ed46408c36322d0d
|
4
|
+
data.tar.gz: fb419781d2d22902ebf33cac737e83aab5fab40e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 688e86b1a099cc1a3dd3c53817be88772167f87fb28fb27c9f5c3aa513bcafff5170a62df30dd174a0d95d103834f6c25871d350d2c3c8d2b2c8d7276b957f4b
|
7
|
+
data.tar.gz: abcea67939882a5911bde30834f84f854397a00fe26ec123f3bba27ad276e19177e507f29d04fff5517ab3e55cdfc3f7cb73e58d60a7b7cf533a147510719246
|
@@ -2,8 +2,7 @@ module Scrivito
|
|
2
2
|
|
3
3
|
class BlobsController < WebserviceController
|
4
4
|
def upload_permission
|
5
|
-
permission = CmsRestApi.task_unaware_request(:get, 'blobs/upload_permission')
|
6
|
-
render json: permission
|
5
|
+
@permission = CmsRestApi.task_unaware_request(:get, 'blobs/upload_permission')
|
7
6
|
end
|
8
7
|
end
|
9
8
|
|
@@ -1,80 +1,14 @@
|
|
1
1
|
module Scrivito
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
before_filter :load_object
|
12
|
-
before_filter :authorize_editor, only: [:show_widget, :widget_details, :details_page]
|
13
|
-
|
14
|
-
around_action :authorize_workspace_read, only: [:show_widget, :widget_details, :details_page]
|
15
|
-
|
16
|
-
# Default Action. Delivers files directly if {BasicObj#binary?}.
|
17
|
-
# Otherwise the view is rendered.
|
18
|
-
# @api public
|
19
|
-
def index
|
20
|
-
deliver_file if @obj.binary?
|
21
|
-
end
|
22
|
-
|
23
|
-
def show_widget
|
24
|
-
widget = load_widget
|
25
|
-
render layout: false, locals: {widget: widget}
|
26
|
-
end
|
27
|
-
|
28
|
-
def widget_details
|
29
|
-
widget = load_widget
|
30
|
-
template_path = "#{widget.obj_class_name.underscore}/details"
|
31
|
-
render template_path, layout: false, locals: {widget: widget}
|
32
|
-
end
|
33
|
-
|
34
|
-
def details_page
|
35
|
-
@scrivito_resource = selected_workspace.objs.find_including_deleted(params[:resource_id])
|
36
|
-
render text: '', layout: true
|
37
|
-
end
|
38
|
-
|
39
|
-
# This method indicates if this controller should be used automatically when an Obj is
|
40
|
-
# requested via the Scrivito's standard routes. It returns true by default.
|
41
|
-
#
|
42
|
-
# Overwrite it to return false if you do want your controller to be excluded from Obj dispatching.
|
43
|
-
#
|
44
|
-
# You may also implement a method with the name {use_for_obj_dispatch?} in controllers not
|
45
|
-
# descending from {DefaultCmsController} to include them in Obj dispatching.
|
46
|
-
#
|
47
|
-
# @see Obj#controller_name
|
48
|
-
# @api public
|
49
|
-
def self.use_for_obj_dispatch?
|
50
|
-
true
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
def authorize_editor
|
56
|
-
head(:forbidden) unless editing_context.authenticated_editor?
|
57
|
-
end
|
58
|
-
|
59
|
-
def editing_context
|
60
|
-
request.env[EditingContextMiddleware::ENVKEY] || EditingContext.new
|
61
|
-
end
|
62
|
-
|
63
|
-
def load_widget
|
64
|
-
@obj.widget_from_pool(params[:widget_id])
|
65
|
-
end
|
66
|
-
|
67
|
-
def authorize_workspace_read
|
68
|
-
can_user_read_workspace? ? yield : render(text: 'Forbidden', status: 403)
|
69
|
-
end
|
70
|
-
|
71
|
-
def can_user_read_workspace?
|
72
|
-
editing_context.editor.can?(:read, selected_workspace)
|
73
|
-
end
|
74
|
-
|
75
|
-
def selected_workspace
|
76
|
-
editing_context.selected_workspace
|
77
|
-
end
|
3
|
+
class DefaultCmsController
|
4
|
+
def self.inherited(other_class)
|
5
|
+
raise %{
|
6
|
+
The controller class `Scrivito::DefaultCmsController' has been removed.
|
7
|
+
A Scrivito Cms Controllers should no longer inherit from `Scrivito::DefaultCmsController'.
|
8
|
+
Instead it should include the module `Scrivito::ControllerActions' and
|
9
|
+
inherit from the `ApplicationController' of your application.
|
10
|
+
}
|
78
11
|
end
|
12
|
+
end
|
79
13
|
|
80
14
|
end
|
@@ -1,58 +1,59 @@
|
|
1
1
|
module Scrivito
|
2
|
-
|
3
2
|
class ObjsController < WebserviceController
|
4
|
-
around_action :
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
around_action :require_selected_workspace_write_authorization, only: [
|
4
|
+
:copy,
|
5
|
+
:create,
|
6
|
+
:destroy,
|
7
|
+
:destroy_widget,
|
8
|
+
:duplicate,
|
9
|
+
:mark_resolved,
|
10
|
+
:restore,
|
11
|
+
:revert,
|
12
|
+
:revert_widget,
|
13
|
+
:update,
|
14
|
+
]
|
15
|
+
|
16
|
+
before_filter :require_identical_selected_and_visible_workspace, only: [
|
17
|
+
:copy,
|
18
|
+
:create,
|
19
|
+
:duplicate,
|
20
|
+
:page_class_selection,
|
21
|
+
:update,
|
22
|
+
:widget_class_selection,
|
23
|
+
]
|
13
24
|
|
14
25
|
def create
|
15
|
-
|
16
|
-
|
17
|
-
{obj: obj_params}
|
18
|
-
)
|
19
|
-
render json: created_obj
|
26
|
+
obj_params = obj_params_parser.parse(nil, params[:obj])
|
27
|
+
@obj = selected_workspace.task_unaware_api_request(:post, '/objs', obj: obj_params)
|
20
28
|
end
|
21
29
|
|
22
30
|
def details
|
23
|
-
|
24
|
-
render json: {markup: render_to_string(@obj.details_view_path, layout: false)}
|
31
|
+
@markup = render_to_string(current_obj.details_view_path, layout: false, formats: :html)
|
25
32
|
end
|
26
33
|
|
27
34
|
def update
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
{obj: obj_params}
|
32
|
-
)
|
33
|
-
render json: changed_obj
|
35
|
+
obj_params = obj_params_parser.parse(current_obj, params[:obj])
|
36
|
+
@api_response = selected_workspace
|
37
|
+
.task_unaware_api_request(:put, "/objs/#{params[:id]}", obj: obj_params)
|
34
38
|
end
|
35
39
|
|
36
40
|
def destroy
|
37
|
-
in_selected_workspace {
|
41
|
+
in_selected_workspace { current_obj.destroy }
|
38
42
|
render_empty_json
|
39
43
|
end
|
40
44
|
|
41
45
|
def destroy_widget
|
42
|
-
|
43
|
-
in_selected_workspace do
|
44
|
-
widget = load_object.widget_from_pool(params[:widget_id])
|
45
|
-
unless widget
|
46
|
-
raise ScrivitoError,
|
47
|
-
"widget with ID '#{params[:widget_id]}' not found in obj with ID '#{@obj.id}'"
|
48
|
-
end
|
49
|
-
widget.destroy
|
50
|
-
end
|
46
|
+
in_selected_workspace { current_widget.destroy }
|
51
47
|
render_empty_json
|
52
48
|
end
|
53
49
|
|
54
50
|
def revert
|
55
|
-
in_selected_workspace {
|
51
|
+
in_selected_workspace { current_obj.revert }
|
52
|
+
render_empty_json
|
53
|
+
end
|
54
|
+
|
55
|
+
def revert_widget
|
56
|
+
in_selected_workspace { current_widget.revert }
|
56
57
|
render_empty_json
|
57
58
|
end
|
58
59
|
|
@@ -62,159 +63,146 @@ module Scrivito
|
|
62
63
|
end
|
63
64
|
|
64
65
|
def mark_resolved
|
65
|
-
in_selected_workspace {
|
66
|
+
in_selected_workspace { current_obj.mark_resolved }
|
66
67
|
render_empty_json
|
67
68
|
end
|
68
69
|
|
69
70
|
def copy
|
70
|
-
|
71
|
+
@attributes = copy_obj(current_obj, params[:parent_path])
|
71
72
|
end
|
72
73
|
|
73
74
|
def duplicate
|
74
|
-
|
75
|
-
|
76
|
-
render json: copy_obj(@obj, parent_path(@obj.path))
|
75
|
+
@attributes = copy_obj(current_obj, current_obj.parent_path)
|
76
|
+
render :copy
|
77
77
|
end
|
78
78
|
|
79
79
|
def page_class_selection
|
80
|
-
|
81
|
-
Obj.descendants
|
82
|
-
valid_page_classes.map!(&:to_s)
|
83
|
-
|
84
|
-
page_class_names = valid_page_classes.map do |page_class_name|
|
80
|
+
@page_class_markup = valid_page_classes.map do |page_class_name|
|
85
81
|
begin
|
86
|
-
markup = render_to_string("#{page_class_name.underscore}/thumbnail")
|
82
|
+
markup = render_to_string("#{page_class_name.underscore}/thumbnail", formats: :html)
|
87
83
|
{name: page_class_name, markup: markup}
|
88
84
|
rescue ActionView::MissingTemplate
|
89
85
|
end
|
90
86
|
end
|
91
|
-
|
92
|
-
render json: page_class_names.compact
|
87
|
+
@page_class_markup.compact!
|
93
88
|
end
|
94
89
|
|
95
90
|
def widget_class_selection
|
96
|
-
|
97
|
-
valid_widget_classes = @obj.valid_widget_classes_for(params[:field_name]) ||
|
98
|
-
Widget.descendants
|
99
|
-
valid_widget_classes.map!(&:to_s)
|
91
|
+
load_obj
|
100
92
|
|
101
|
-
widgets_classes = valid_widget_classes.map do |widget_class_name|
|
93
|
+
@widgets_classes = valid_widget_classes.map do |widget_class_name|
|
102
94
|
template_path = "#{widget_class_name.underscore}/thumbnail"
|
103
95
|
markup = begin
|
104
|
-
render_to_string(template_path, layout: false)
|
96
|
+
render_to_string(template_path, layout: false, formats: :html)
|
105
97
|
rescue ActionView::MissingTemplate
|
106
|
-
render_to_string('scrivito/widget_thumbnail', layout: false,
|
98
|
+
render_to_string('scrivito/widget_thumbnail', layout: false, formats: :html,
|
107
99
|
locals: {widget_class_name: widget_class_name, template_path: template_path})
|
108
100
|
end
|
109
101
|
{name: widget_class_name, markup: markup}
|
110
102
|
end
|
111
|
-
|
112
|
-
render json: widgets_classes
|
113
103
|
end
|
114
104
|
|
115
105
|
def search
|
116
106
|
in_selected_workspace do
|
117
|
-
query = MultiJson.decode(params[:query]).with_indifferent_access
|
118
|
-
|
119
|
-
enumerator = search_builder.build
|
120
|
-
formatter = fetch_formatter(query[:format])
|
107
|
+
@query = MultiJson.decode(params[:query]).with_indifferent_access
|
108
|
+
@enumerator = ObjSearchBuilder.new(@query).build
|
121
109
|
|
122
110
|
if params[:query_action] == 'size'
|
123
|
-
render
|
124
|
-
elsif formatter
|
125
|
-
|
126
|
-
|
127
|
-
result = {
|
128
|
-
total: enumerator.size,
|
129
|
-
hits: batch.map { |obj| formatter.call(obj, scrivito_user) }
|
130
|
-
}
|
131
|
-
|
132
|
-
render json: result
|
111
|
+
render :search_only_size
|
112
|
+
elsif @formatter = fetch_formatter(@query[:format])
|
113
|
+
render :search
|
133
114
|
else
|
134
|
-
render
|
115
|
+
render :format_missing_error, status: :not_found
|
135
116
|
end
|
136
117
|
end
|
137
118
|
end
|
138
119
|
|
139
|
-
|
120
|
+
def modification
|
121
|
+
in_selected_workspace { render }
|
122
|
+
end
|
140
123
|
|
141
|
-
def
|
142
|
-
|
124
|
+
def widget_modification
|
125
|
+
in_selected_workspace { render }
|
143
126
|
end
|
144
127
|
|
145
|
-
|
128
|
+
private
|
129
|
+
|
130
|
+
def require_identical_selected_and_visible_workspace
|
146
131
|
if selected_workspace != editing_context.visible_workspace
|
147
|
-
raise ScrivitoError,
|
132
|
+
raise ScrivitoError, 'selected and visible workspace are not identical'
|
148
133
|
end
|
149
134
|
end
|
150
135
|
|
151
|
-
def
|
152
|
-
|
136
|
+
def require_selected_workspace_write_authorization(&block)
|
137
|
+
authorize_workspace_access(:write, selected_workspace, &block)
|
153
138
|
end
|
154
139
|
|
155
|
-
def
|
156
|
-
|
157
|
-
|
158
|
-
copied_obj = obj.copy(_id: id, _path: "#{target_path}/#{id}")
|
159
|
-
dumped_last_changed = CmsRestApi::AttributeSerializer
|
160
|
-
.convert_time(copied_obj[:_last_changed])
|
161
|
-
|
162
|
-
{
|
163
|
-
_id: copied_obj[:_id],
|
164
|
-
_last_changed: dumped_last_changed,
|
165
|
-
_obj_class: copied_obj[:_obj_class_name],
|
166
|
-
_path: copied_obj[:_path],
|
167
|
-
}
|
140
|
+
def in_selected_workspace(&block)
|
141
|
+
selected_workspace.as_current(&block)
|
168
142
|
end
|
169
143
|
|
170
|
-
def
|
171
|
-
|
144
|
+
def selected_workspace
|
145
|
+
editing_context.selected_workspace
|
172
146
|
end
|
173
147
|
|
174
|
-
def
|
175
|
-
|
148
|
+
def current_obj
|
149
|
+
@obj || load_obj
|
176
150
|
end
|
151
|
+
helper_method :current_obj
|
177
152
|
|
178
|
-
def
|
179
|
-
Obj.find(params[:
|
153
|
+
def load_obj
|
154
|
+
@obj = Obj.find(params[:id])
|
180
155
|
end
|
181
|
-
helper_method :current_page
|
182
|
-
|
183
|
-
delegate :task_unaware_request, to: CmsRestApi
|
184
156
|
|
185
|
-
|
157
|
+
def current_widget
|
158
|
+
@widget || load_widget
|
159
|
+
end
|
160
|
+
helper_method :current_widget
|
186
161
|
|
187
|
-
def
|
188
|
-
|
162
|
+
def load_widget
|
163
|
+
raise ScrivitoError, 'no widget_id param specified' if params[:widget_id].blank?
|
164
|
+
unless @widget = current_obj.widget_from_pool(params[:widget_id])
|
165
|
+
raise ScrivitoError, "widget with ID '#{params[:widget_id]}' not found"
|
166
|
+
end
|
167
|
+
@widget
|
189
168
|
end
|
190
169
|
|
191
|
-
def
|
192
|
-
|
170
|
+
def copy_obj(obj, target_path)
|
171
|
+
id = SecureRandom.hex(8)
|
172
|
+
copied_obj = obj.copy(_id: id, _path: "#{target_path}/#{id}")
|
173
|
+
dumped_last_changed = CmsRestApi::AttributeSerializer.convert_time(copied_obj[:_last_changed])
|
174
|
+
{
|
175
|
+
_id: copied_obj[:_id],
|
176
|
+
_last_changed: dumped_last_changed,
|
177
|
+
_obj_class: copied_obj[:_obj_class_name],
|
178
|
+
_path: copied_obj[:_path],
|
179
|
+
}
|
193
180
|
end
|
194
181
|
|
195
|
-
def
|
196
|
-
|
182
|
+
def fetch_formatter(name)
|
183
|
+
name ? Configuration.obj_formats[name] : proc { |obj, _| obj.id }
|
197
184
|
end
|
198
185
|
|
199
|
-
def
|
200
|
-
|
186
|
+
def valid_page_classes
|
187
|
+
(Obj.valid_page_classes_beneath(params[:parent_path]) || Obj.descendants).map(&:to_s)
|
201
188
|
end
|
202
189
|
|
203
|
-
def
|
204
|
-
|
190
|
+
def valid_widget_classes
|
191
|
+
(widget_classes_from_widget || widget_classes_from_obj || Widget.descendants).map(&:to_s)
|
205
192
|
end
|
206
193
|
|
207
|
-
def
|
208
|
-
if
|
209
|
-
|
210
|
-
else
|
211
|
-
proc { |obj, _| obj.id }
|
194
|
+
def widget_classes_from_widget
|
195
|
+
if params[:widget_id] && (widget = current_obj.widget_from_pool(params[:widget_id]))
|
196
|
+
widget.valid_widget_classes_for(params[:field_name])
|
212
197
|
end
|
213
198
|
end
|
214
199
|
|
215
|
-
def
|
216
|
-
|
200
|
+
def widget_classes_from_obj
|
201
|
+
current_obj.valid_widget_classes_for(params[:field_name])
|
217
202
|
end
|
218
|
-
end
|
219
203
|
|
204
|
+
def obj_params_parser
|
205
|
+
ObjParamsParser.new(request.host, request.port)
|
206
|
+
end
|
207
|
+
end
|
220
208
|
end
|