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
@@ -26,6 +26,35 @@ module Scrivito
|
|
26
26
|
def reset_instance!
|
27
27
|
@instance = nil
|
28
28
|
end
|
29
|
+
|
30
|
+
def request(uri, request, timeout = nil)
|
31
|
+
instance_for(uri).request(request, timeout)
|
32
|
+
end
|
33
|
+
|
34
|
+
# For test purpose only.
|
35
|
+
def clear_cache!
|
36
|
+
@instances = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def cert_store
|
40
|
+
@cert_store ||= OpenSSL::X509::Store.new.tap do |store|
|
41
|
+
store.set_default_paths
|
42
|
+
store.add_file(Configuration.ca_file)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def instance_for(uri)
|
49
|
+
endpoint_url = "#{uri.scheme}://#{uri.host}:#{uri.port}"
|
50
|
+
instances.fetch(endpoint_url) do
|
51
|
+
instances[endpoint_url] = new(URI.parse(endpoint_url))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def instances
|
56
|
+
@instances ||= {}
|
57
|
+
end
|
29
58
|
end
|
30
59
|
|
31
60
|
def initialize(uri)
|
@@ -56,7 +85,7 @@ module Scrivito
|
|
56
85
|
if uri.scheme == 'https'
|
57
86
|
conn.use_ssl = true
|
58
87
|
conn.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
59
|
-
conn.
|
88
|
+
conn.cert_store = self.class.cert_store
|
60
89
|
end
|
61
90
|
configure_timeout(conn, timeout)
|
62
91
|
retry_twice_on_socket_error do
|
@@ -93,16 +93,19 @@ class ContentService
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def handle_response(response)
|
96
|
-
|
97
|
-
|
96
|
+
case code = response.code
|
97
|
+
when /^2/
|
98
|
+
retry_after = response['Retry-After']
|
98
99
|
@next_request_not_before = retry_after ? Time.now + retry_after.to_f : nil
|
99
100
|
MultiJson.load(response.body)
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
raise
|
101
|
+
when '429' then raise RateLimitExceeded.new(response['Retry-After'])
|
102
|
+
when '403' then raise AccessDenied.new(response.body)
|
103
|
+
when '401', '404'
|
104
|
+
raise NetworkError.new(
|
105
|
+
'There was a problem communicating with the Scrivito backend. '\
|
106
|
+
'Check your configuration, i.e. "tenant" and "api_key".', code)
|
104
107
|
else
|
105
|
-
raise NetworkError.new("Server responded with status code #{
|
108
|
+
raise NetworkError.new("Server responded with status code #{code}", code)
|
106
109
|
end
|
107
110
|
end
|
108
111
|
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module Scrivito
|
2
|
+
#
|
3
|
+
# This module provides CMS controller actions.
|
4
|
+
# Include it in controller you want to make able to deliver +Obj+s.
|
5
|
+
#
|
6
|
+
# @api public
|
7
|
+
#
|
8
|
+
# @see Scrivito::TestRequest#for_scrivito_obj
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# class PageCmsController < ApplicationController
|
12
|
+
# include Scrivito::ControllerActions
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
module ControllerActions
|
16
|
+
extend ActiveSupport::Concern
|
17
|
+
|
18
|
+
included do
|
19
|
+
before_filter :require_authenticated_editor, only: [
|
20
|
+
:details_page,
|
21
|
+
:show_widget,
|
22
|
+
:widget_details,
|
23
|
+
]
|
24
|
+
|
25
|
+
before_filter :load_object
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Default action.
|
30
|
+
# Delivers files directly if +Obj+ is binary.
|
31
|
+
# Otherwise the view is rendered.
|
32
|
+
#
|
33
|
+
# @api public
|
34
|
+
#
|
35
|
+
def index
|
36
|
+
deliver_file if @obj.binary?
|
37
|
+
end
|
38
|
+
|
39
|
+
def show_widget
|
40
|
+
widget = load_widget
|
41
|
+
render text: Scrivito::WidgetTag.new(view_context, widget).render, layout: false
|
42
|
+
end
|
43
|
+
|
44
|
+
def widget_details
|
45
|
+
widget = load_widget
|
46
|
+
template_path = "#{widget.obj_class_name.underscore}/details"
|
47
|
+
render template_path, layout: false, locals: {widget: widget}
|
48
|
+
end
|
49
|
+
|
50
|
+
def details_page
|
51
|
+
@scrivito_resource = editing_context.selected_workspace.objs
|
52
|
+
.find_including_deleted(params[:resource_id])
|
53
|
+
render text: '', layout: true
|
54
|
+
end
|
55
|
+
|
56
|
+
module ClassMethods
|
57
|
+
#
|
58
|
+
# This method indicates if this controller should be used automatically when an +Obj+ is
|
59
|
+
# requested via the SDK's standard routes. It returns +true+ by default.
|
60
|
+
#
|
61
|
+
# Overwrite it to return +false+ if you do want your controller to be excluded from +Obj+
|
62
|
+
# dispatching.
|
63
|
+
#
|
64
|
+
# @api public
|
65
|
+
# @see Obj#controller_name
|
66
|
+
#
|
67
|
+
def use_for_obj_dispatch?
|
68
|
+
true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def require_authenticated_editor
|
75
|
+
head(:forbidden) unless editing_context.authenticated_editor?
|
76
|
+
end
|
77
|
+
|
78
|
+
def editing_context
|
79
|
+
request.env[EditingContextMiddleware::ENVKEY] || EditingContext.new
|
80
|
+
end
|
81
|
+
|
82
|
+
def load_object
|
83
|
+
CmsEnv.new(request.env).load
|
84
|
+
loaded_obj = request.env[CmsEnv::OBJ_ENV_KEY]
|
85
|
+
raise loaded_obj if loaded_obj.is_a?(StandardError)
|
86
|
+
@obj = loaded_obj
|
87
|
+
end
|
88
|
+
|
89
|
+
def load_widget
|
90
|
+
@obj.widget_from_pool(params[:widget_id])
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# Deliver a binary +Obj+ by redirecting to its {BasicObj#binary Obj#binary}'s url.
|
95
|
+
# Will respond with 404 if the +Obj+ has no +blob+.
|
96
|
+
#
|
97
|
+
# @api public
|
98
|
+
#
|
99
|
+
def deliver_file
|
100
|
+
if url = @obj.binary_url
|
101
|
+
redirect_to CmsRouting.match_protocol(url, request)
|
102
|
+
else
|
103
|
+
render text: 'Empty Blob', status: 404
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
data/lib/scrivito/diff.rb
CHANGED
@@ -25,25 +25,40 @@ class Diff; class << self
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def for_html(mode, old, new)
|
28
|
-
return
|
29
|
-
return
|
30
|
-
|
31
|
-
hyp_diff_options =
|
32
|
-
case mode
|
33
|
-
when "added"
|
34
|
-
{render_deletion: proc {}, markup_from: "after"}
|
35
|
-
when "deleted"
|
36
|
-
{render_insertion: proc {}, markup_from: "before"}
|
37
|
-
when "diff"
|
38
|
-
{}
|
39
|
-
else
|
40
|
-
return nil
|
41
|
-
end
|
28
|
+
return if !old
|
29
|
+
return if !new
|
30
|
+
return unless %w[added deleted diff].include?(mode)
|
42
31
|
|
43
|
-
diff = HypDiff.compare(old, new, hyp_diff_options)
|
32
|
+
diff = HypDiff.compare(old, new, hyp_diff_options(mode))
|
44
33
|
[StringTagging.tag_as_html(diff)]
|
45
34
|
end
|
46
35
|
|
36
|
+
def hyp_diff_options(mode)
|
37
|
+
render_insertion_proc = proc { |html| "<span class='scrivito_insertion'>#{html}</span>" }
|
38
|
+
render_deletion_proc = proc { |html| "<span class='scrivito_deletion'>#{html}</span>" }
|
39
|
+
render_nothing_proc = proc {}
|
40
|
+
|
41
|
+
case mode
|
42
|
+
when 'added'
|
43
|
+
{
|
44
|
+
render_insertion: render_insertion_proc,
|
45
|
+
render_deletion: render_nothing_proc,
|
46
|
+
markup_from: 'after'
|
47
|
+
}
|
48
|
+
when 'deleted'
|
49
|
+
{
|
50
|
+
render_insertion: render_nothing_proc,
|
51
|
+
render_deletion: render_deletion_proc,
|
52
|
+
markup_from: 'before'
|
53
|
+
}
|
54
|
+
when 'diff'
|
55
|
+
{
|
56
|
+
render_insertion: render_insertion_proc,
|
57
|
+
render_deletion: render_deletion_proc
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
47
62
|
class ListComparison
|
48
63
|
def self.for(mode, old, new)
|
49
64
|
new(mode).compare(old, new).result
|
@@ -0,0 +1,19 @@
|
|
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
|
@@ -5,6 +5,10 @@ module Scrivito
|
|
5
5
|
class EditingContextMiddleware
|
6
6
|
ENVKEY = 'SCRIVITO_EDITING_CONTEXT'
|
7
7
|
|
8
|
+
def self.from_request(request)
|
9
|
+
request.env[ENVKEY]
|
10
|
+
end
|
11
|
+
|
8
12
|
def initialize(app)
|
9
13
|
@app = app
|
10
14
|
end
|
@@ -26,7 +30,7 @@ class EditingContextMiddleware
|
|
26
30
|
|
27
31
|
env[ENVKEY] = EditingContext.new(
|
28
32
|
display_mode: display_mode,
|
29
|
-
editor:
|
33
|
+
editor: editor_proc(env),
|
30
34
|
selected_workspace_id: workspace_id
|
31
35
|
)
|
32
36
|
|
@@ -35,6 +39,21 @@ class EditingContextMiddleware
|
|
35
39
|
|
36
40
|
private
|
37
41
|
|
42
|
+
def editor_proc(env)
|
43
|
+
if editing_auth_callback = Configuration.editing_auth_callback
|
44
|
+
-> { editing_auth_callback.call(env) }
|
45
|
+
else
|
46
|
+
Rails.logger.warn(%{
|
47
|
+
WARNING!
|
48
|
+
|
49
|
+
Application is running in "#{Rails.env}" environment, but authentication is not configured.
|
50
|
+
For security reasons the in-place editing is disabled.
|
51
|
+
Please see https://scrivito.com/permissions for details.
|
52
|
+
})
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
38
57
|
def parse_url_params(request)
|
39
58
|
{
|
40
59
|
'display_mode' => request.params['_scrivito_display_mode'],
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Scrivito
|
2
|
+
|
3
|
+
class ImageTagHelper < Struct.new(:view_context)
|
4
|
+
|
5
|
+
def self.display_title(target)
|
6
|
+
if target.respond_to?(:display_title)
|
7
|
+
return target.display_title
|
8
|
+
elsif target.respond_to?(:first) && target.first.respond_to?(:display_title)
|
9
|
+
return target.first.display_title
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def options(obj, field_name, tag_options, editing_options)
|
14
|
+
tag_options.reverse_merge(src: scrivito_image_tag_src(obj, field_name, editing_options),
|
15
|
+
alt: scrivito_image_tag_alt(obj, field_name))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def scrivito_image_tag_src(obj, field_name, editing_options)
|
21
|
+
scrivito_image_tag_path(obj, field_name) || editing_options[:placeholder] ||
|
22
|
+
view_context.image_path('scrivito/image_placeholder.png')
|
23
|
+
end
|
24
|
+
|
25
|
+
def scrivito_image_tag_alt(obj, field_name)
|
26
|
+
self.class.display_title(obj[field_name])
|
27
|
+
end
|
28
|
+
|
29
|
+
def scrivito_image_tag_path(obj, field_name)
|
30
|
+
field_type = obj.type_of_attribute(field_name)
|
31
|
+
field_value = obj[field_name]
|
32
|
+
|
33
|
+
case field_type
|
34
|
+
when 'reference' then field_value && view_context.scrivito_path(field_value)
|
35
|
+
when 'link' then field_value && view_context.scrivito_path(field_value)
|
36
|
+
when 'linklist'
|
37
|
+
path = view_context.scrivito_path(field_value)
|
38
|
+
path == CmsRouting::LINK_TO_EMPTY_LINKLIST ? nil : path
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Scrivito
|
2
|
+
|
3
|
+
class LayoutTags < Struct.new(:view)
|
4
|
+
def client_config(obj, resource)
|
5
|
+
if view.scrivito_user
|
6
|
+
editing_context = EditingContextMiddleware.from_request(view.request)
|
7
|
+
config = ClientConfig.new(obj, editing_context, view.lookup_context,
|
8
|
+
resource: resource,
|
9
|
+
return_to: view.params[:return_to]
|
10
|
+
).to_json
|
11
|
+
view.content_tag(:div, '', 'data-scrivito-private-config' => config, style: 'display:none')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def editing_auth_warning
|
16
|
+
view.render('scrivito/editing_auth_warning') unless Configuration.editing_auth_callback
|
17
|
+
end
|
18
|
+
|
19
|
+
def generator_meta_tag
|
20
|
+
content = 'Scrivito by Infopark AG (scrivito.com)'
|
21
|
+
content << "; Version #{GemInfo.version}" if view.scrivito_user
|
22
|
+
view.tag(:meta, name: 'generator', content: content)
|
23
|
+
end
|
24
|
+
|
25
|
+
def reset_stylesheet_tag
|
26
|
+
view.content_tag(:style, %{
|
27
|
+
*[data-scrivito-field-type="widget"],
|
28
|
+
*[data-scrivito-private-widget-id] { position: relative; }
|
29
|
+
}.squish, {type: 'text/css'}, false)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/scrivito/link.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require 'active_model/naming'
|
2
|
+
|
1
3
|
module Scrivito
|
2
4
|
# This class provides an interfaces for handling CMS Links.
|
3
|
-
# To format a link for rendering in an html page, use the +
|
5
|
+
# To format a link for rendering in an html page, use the +scrivito_path+ or +scrivito_url+ methods.
|
4
6
|
# @api public
|
5
7
|
class Link
|
6
8
|
|
@@ -31,7 +33,7 @@ module Scrivito
|
|
31
33
|
|
32
34
|
# The link's external url. Only available for external links.
|
33
35
|
# Warning: Do not output the url directly unless you know what you are doing.
|
34
|
-
# Normally you want to use the +
|
36
|
+
# Normally you want to use the +scrivito_path+ or +scrivito_url+ methods to format a link.
|
35
37
|
# @api public
|
36
38
|
def url
|
37
39
|
@link_data[:url]
|
data/lib/scrivito/membership.rb
CHANGED
data/lib/scrivito/migrations.rb
CHANGED