scrivito_sdk 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +5 -0
- data/README +6 -0
- data/app/controllers/cms_controller.rb +7 -0
- data/app/controllers/scrivito/blobs_controller.rb +10 -0
- data/app/controllers/scrivito/default_cms_controller.rb +61 -0
- data/app/controllers/scrivito/objs_controller.rb +200 -0
- data/app/controllers/scrivito/tasks_controller.rb +11 -0
- data/app/controllers/scrivito/webservice_controller.rb +36 -0
- data/app/controllers/scrivito/workspaces_controller.rb +41 -0
- data/app/helpers/cms_helper.rb +7 -0
- data/app/helpers/cms_routing_helper.rb +7 -0
- data/app/helpers/scrivito/cms_asset_helper.rb +103 -0
- data/app/helpers/scrivito/cms_tag_helper.rb +231 -0
- data/app/helpers/scrivito/default_cms_helper.rb +21 -0
- data/app/helpers/scrivito/default_cms_routing_helper.rb +130 -0
- data/app/helpers/scrivito/display_helper.rb +71 -0
- data/app/helpers/scrivito/editing_helper.rb +26 -0
- data/app/helpers/scrivito/layout_helper.rb +28 -0
- data/app/models/named_link.rb +2 -0
- data/app/views/cms/_index.html.erb +7 -0
- data/app/views/cms/index.html.erb +1 -0
- data/app/views/scrivito/_editing_javascript.html.erb +7 -0
- data/app/views/scrivito/default_cms/show_widget.html.erb +1 -0
- data/app/views/scrivito/objs/copy_widget.html.erb +1 -0
- data/app/views/scrivito/objs/create_widget.html.erb +1 -0
- data/app/views/scrivito/widget_thumbnail.html.erb +9 -0
- data/config/ca-bundle.crt +3509 -0
- data/config/cms_routes.rb +17 -0
- data/config/locales/de.scrivito.errors.yml +7 -0
- data/config/locales/de.scrivito.lib.yml +6 -0
- data/config/locales/de.scrivito.models.yml +6 -0
- data/config/locales/en.scrivito.errors.yml +7 -0
- data/config/locales/en.scrivito.lib.yml +6 -0
- data/config/locales/en.scrivito.models.yml +6 -0
- data/config/routes.rb +37 -0
- data/lib/assets/images/180x120.gif +0 -0
- data/lib/assets/images/scrivito/image_placeholder.png +0 -0
- data/lib/assets/javascripts/scrivito_editing.js +14642 -0
- data/lib/assets/stylesheets/scrivito.css +180 -0
- data/lib/assets/stylesheets/scrivito_editing.css +2213 -0
- data/lib/generators/cms/migration/USAGE +9 -0
- data/lib/generators/cms/migration/migration_generator.rb +21 -0
- data/lib/generators/cms/migration/templates/migration.erb +10 -0
- data/lib/obj.rb +3 -0
- data/lib/scrivito/access_denied.rb +6 -0
- data/lib/scrivito/attribute_content.rb +194 -0
- data/lib/scrivito/backend_error.rb +4 -0
- data/lib/scrivito/basic_obj.rb +840 -0
- data/lib/scrivito/basic_widget.rb +238 -0
- data/lib/scrivito/blob.rb +48 -0
- data/lib/scrivito/cache.rb +41 -0
- data/lib/scrivito/cache_garbage_collector.rb +83 -0
- data/lib/scrivito/cache_middleware.rb +17 -0
- data/lib/scrivito/client_config.rb +62 -0
- data/lib/scrivito/client_error.rb +12 -0
- data/lib/scrivito/cms_accessible.rb +30 -0
- data/lib/scrivito/cms_backend.rb +238 -0
- data/lib/scrivito/cms_cache_storage.rb +51 -0
- data/lib/scrivito/cms_dispatch_controller.rb +46 -0
- data/lib/scrivito/cms_env.rb +63 -0
- data/lib/scrivito/cms_field_tag.rb +112 -0
- data/lib/scrivito/cms_rest_api.rb +151 -0
- data/lib/scrivito/cms_rest_api/attribute_serializer.rb +98 -0
- data/lib/scrivito/cms_rest_api/blob_uploader.rb +18 -0
- data/lib/scrivito/cms_rest_api/widget_extractor.rb +42 -0
- data/lib/scrivito/cms_test_request.rb +23 -0
- data/lib/scrivito/communication_error.rb +17 -0
- data/lib/scrivito/comparison.rb +67 -0
- data/lib/scrivito/configuration.rb +221 -0
- data/lib/scrivito/connection_manager.rb +100 -0
- data/lib/scrivito/content_conversion.rb +43 -0
- data/lib/scrivito/content_service.rb +118 -0
- data/lib/scrivito/content_state.rb +109 -0
- data/lib/scrivito/content_state_caching.rb +47 -0
- data/lib/scrivito/content_state_visitor.rb +19 -0
- data/lib/scrivito/controller_runtime.rb +35 -0
- data/lib/scrivito/date_attribute.rb +16 -0
- data/lib/scrivito/deprecation.rb +21 -0
- data/lib/scrivito/diff.rb +110 -0
- data/lib/scrivito/editing_context.rb +106 -0
- data/lib/scrivito/editing_context_middleware.rb +60 -0
- data/lib/scrivito/engine.rb +65 -0
- data/lib/scrivito/errors.rb +11 -0
- data/lib/scrivito/html_string.rb +18 -0
- data/lib/scrivito/link.rb +187 -0
- data/lib/scrivito/link_parser.rb +81 -0
- data/lib/scrivito/log_subscriber.rb +29 -0
- data/lib/scrivito/migration.rb +2 -0
- data/lib/scrivito/migrations.rb +12 -0
- data/lib/scrivito/migrations/cms_backend.rb +94 -0
- data/lib/scrivito/migrations/installer.rb +45 -0
- data/lib/scrivito/migrations/migration.rb +93 -0
- data/lib/scrivito/migrations/migration_dsl.rb +143 -0
- data/lib/scrivito/migrations/migration_store.rb +23 -0
- data/lib/scrivito/migrations/migrator.rb +135 -0
- data/lib/scrivito/migrations/workspace_lock.rb +39 -0
- data/lib/scrivito/model_identity.rb +13 -0
- data/lib/scrivito/modification.rb +8 -0
- data/lib/scrivito/named_link.rb +75 -0
- data/lib/scrivito/network_error.rb +11 -0
- data/lib/scrivito/obj_data.rb +140 -0
- data/lib/scrivito/obj_data_from_hash.rb +31 -0
- data/lib/scrivito/obj_data_from_service.rb +84 -0
- data/lib/scrivito/obj_params_parser.rb +61 -0
- data/lib/scrivito/obj_search_builder.rb +62 -0
- data/lib/scrivito/obj_search_enumerator.rb +374 -0
- data/lib/scrivito/rate_limit_exceeded.rb +5 -0
- data/lib/scrivito/revision.rb +9 -0
- data/lib/scrivito/string_tagging.rb +18 -0
- data/lib/scrivito/text_link.rb +52 -0
- data/lib/scrivito/text_link_conversion.rb +52 -0
- data/lib/scrivito/type_computer.rb +34 -0
- data/lib/scrivito/widget_field_params.rb +61 -0
- data/lib/scrivito/widget_garbage_collection.rb +97 -0
- data/lib/scrivito/workspace.rb +222 -0
- data/lib/scrivito/workspace_data_from_service.rb +80 -0
- data/lib/scrivito/workspace_selection_middleware.rb +23 -0
- data/lib/scrivito_sdk.rb +19 -0
- data/lib/tasks/cache.rake +12 -0
- data/lib/tasks/migration.rake +35 -0
- data/lib/widget.rb +3 -0
- metadata +291 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
module Scrivito
|
2
|
+
|
3
|
+
class EditingContext
|
4
|
+
# +options+:
|
5
|
+
# +:selected_workspace_id+: The id of the selected workspace. If empty +published+ workspace is used.
|
6
|
+
# +:display_mode+: Can be +view+, +editing+, +added+ or +deleted+. If empty +view+ is used.
|
7
|
+
# +:editor+: A block, which is lazy evaluated on first access, to determine the editor (details see {Scrivito::Configuation.editing_auth})
|
8
|
+
# @param [Hash] options
|
9
|
+
def initialize(options = {})
|
10
|
+
@selected_workspace_id = options[:selected_workspace_id]
|
11
|
+
@display_mode = options[:display_mode] || "view"
|
12
|
+
@editor_callback = options[:editor] || proc { false }
|
13
|
+
end
|
14
|
+
|
15
|
+
def editor
|
16
|
+
unless @editor_already_evaluated
|
17
|
+
@editor_already_evaluated = true
|
18
|
+
@editor = @editor_callback.call
|
19
|
+
end
|
20
|
+
|
21
|
+
@editor
|
22
|
+
end
|
23
|
+
|
24
|
+
# true iff {editor} truish
|
25
|
+
def authenticated_editor?
|
26
|
+
editor.present?
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
def display_mode
|
31
|
+
if authenticated_editor? && !selected_workspace.published?
|
32
|
+
@display_mode
|
33
|
+
else
|
34
|
+
'view'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# defaults to "published" if no workspace with `selected_workspace_id` can be found.
|
39
|
+
# @return [Workspace]
|
40
|
+
def selected_workspace
|
41
|
+
unless @selected_workspace
|
42
|
+
if @selected_workspace_id
|
43
|
+
begin
|
44
|
+
@selected_workspace = Workspace.find(@selected_workspace_id)
|
45
|
+
rescue Scrivito::ResourceNotFound
|
46
|
+
@selected_workspace = Workspace.default
|
47
|
+
end
|
48
|
+
else
|
49
|
+
@selected_workspace = Workspace.default
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
@selected_workspace
|
54
|
+
end
|
55
|
+
|
56
|
+
# when authenticated_editor? return selected_workspace, otherwise published workspace.
|
57
|
+
# @return [Workspace]
|
58
|
+
def visible_workspace
|
59
|
+
unless @visible_workspace
|
60
|
+
if authenticated_editor?
|
61
|
+
if display_mode == 'deleted'
|
62
|
+
@visible_workspace = Workspace.default
|
63
|
+
else
|
64
|
+
@visible_workspace = selected_workspace
|
65
|
+
end
|
66
|
+
else
|
67
|
+
@visible_workspace = Workspace.default
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
@visible_workspace
|
72
|
+
end
|
73
|
+
|
74
|
+
def comparison
|
75
|
+
@comparison ||=
|
76
|
+
begin
|
77
|
+
revision = compare_revision
|
78
|
+
Comparison.new(
|
79
|
+
revision, display_mode == 'deleted', revision ? display_mode : nil
|
80
|
+
)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def to_params
|
85
|
+
{
|
86
|
+
'_scrivito_display_mode' => display_mode,
|
87
|
+
'_scrivito_workspace_id' => selected_workspace.id,
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
# @return [Revision] or +nil+
|
94
|
+
def compare_revision
|
95
|
+
case display_mode
|
96
|
+
when 'added'
|
97
|
+
selected_workspace.base_revision
|
98
|
+
when 'deleted'
|
99
|
+
selected_workspace.revision
|
100
|
+
when 'diff'
|
101
|
+
selected_workspace.base_revision
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end # module Scrivito
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
|
3
|
+
module Scrivito
|
4
|
+
|
5
|
+
class EditingContextMiddleware
|
6
|
+
ENVKEY = 'SCRIVITO_EDITING_CONTEXT'
|
7
|
+
|
8
|
+
def initialize(app)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
request = Rack::Request.new(env)
|
14
|
+
|
15
|
+
url_params = parse_url_params(request)
|
16
|
+
header_params = parse_header_params(env)
|
17
|
+
cookie_params = parse_cookie_params(request)
|
18
|
+
|
19
|
+
display_mode = url_params['display_mode'] ||
|
20
|
+
header_params['display_mode'] ||
|
21
|
+
cookie_params['display_mode']
|
22
|
+
|
23
|
+
workspace_id = url_params['workspace_id'] ||
|
24
|
+
header_params['workspace_id'] ||
|
25
|
+
cookie_params['workspace_id']
|
26
|
+
|
27
|
+
env[ENVKEY] = EditingContext.new(
|
28
|
+
display_mode: display_mode,
|
29
|
+
editor: -> { Configuration.editing_auth_callback.call(env) },
|
30
|
+
selected_workspace_id: workspace_id
|
31
|
+
)
|
32
|
+
|
33
|
+
@app.call(env)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def parse_url_params(request)
|
39
|
+
{
|
40
|
+
'display_mode' => request.params['_scrivito_display_mode'],
|
41
|
+
'workspace_id' => request.params['_scrivito_workspace_id'],
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_header_params(env)
|
46
|
+
parse_json_params(env['HTTP_SCRIVITO_EDITING_CONTEXT'])
|
47
|
+
end
|
48
|
+
|
49
|
+
def parse_cookie_params(request)
|
50
|
+
parse_json_params(request.cookies['scrivito_editing_context'])
|
51
|
+
end
|
52
|
+
|
53
|
+
def parse_json_params(json_params)
|
54
|
+
MultiJson.decode(json_params)
|
55
|
+
rescue MultiJson::ParseError
|
56
|
+
{}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "rails"
|
2
|
+
require "action_view"
|
3
|
+
require "active_model"
|
4
|
+
|
5
|
+
require 'jquery-rails'
|
6
|
+
|
7
|
+
require 'scrivito/configuration'
|
8
|
+
|
9
|
+
module ::Scrivito
|
10
|
+
class Engine < Rails::Engine
|
11
|
+
config.to_prepare { Scrivito::Configuration.to_prepare }
|
12
|
+
|
13
|
+
# make sure our exceptions cause an adequate error page and http status code
|
14
|
+
config.action_dispatch.rescue_responses.merge!("Scrivito::ResourceNotFound" => :not_found)
|
15
|
+
|
16
|
+
initializer "scrivito.add_cms_routing_paths", :after => :add_routing_paths do |app|
|
17
|
+
cms_route = File.expand_path("cms_routes.rb", paths['config'].to_a.first)
|
18
|
+
app.routes_reloader.paths.push(cms_route)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Expose Scrivito SDK runtime to controller for logging.
|
22
|
+
initializer "scrivito.log_runtime" do |app|
|
23
|
+
runtime =
|
24
|
+
begin
|
25
|
+
Scrivito::ControllerRuntime
|
26
|
+
rescue NameError
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
|
30
|
+
if runtime
|
31
|
+
Scrivito::LogSubscriber.attach_to :scrivito
|
32
|
+
ActiveSupport.on_load(:action_controller) do
|
33
|
+
include runtime
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
initializer "scrivito.configure_database", :before => :load_config_initializers do |app|
|
39
|
+
Scrivito::Configuration.configure_cms_database
|
40
|
+
end
|
41
|
+
|
42
|
+
initializer "scrivito.routing_helpers" do
|
43
|
+
if Rails.env == 'test'
|
44
|
+
ActionDispatch::TestRequest.__send__(:include, Scrivito::CmsTestRequest)
|
45
|
+
end
|
46
|
+
|
47
|
+
ActionController::Base.__send__(:include, CmsRoutingHelper)
|
48
|
+
ActionView::Base.__send__(:include, CmsRoutingHelper)
|
49
|
+
end
|
50
|
+
|
51
|
+
initializer "scrivito.add_assets" do |app|
|
52
|
+
# Specify which file should be precompiled for packaging
|
53
|
+
app.config.assets.precompile += %w( scrivito_editing.js scrivito_editing.css scrivito.css )
|
54
|
+
app.config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
|
55
|
+
end
|
56
|
+
|
57
|
+
config.autoload_paths += paths['lib'].to_a
|
58
|
+
config.autoload_once_paths += paths['lib'].to_a
|
59
|
+
|
60
|
+
config.app_middleware.use "Scrivito::EditingContextMiddleware"
|
61
|
+
config.app_middleware.use "Scrivito::CacheMiddleware"
|
62
|
+
config.app_middleware.use "Scrivito::WorkspaceSelectionMiddleware"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Scrivito
|
2
|
+
|
3
|
+
# Include this module in order to tag the string as one with HTML content
|
4
|
+
module HtmlString
|
5
|
+
# Returns whether the String contains HTML (default to true, overrides String.html?).
|
6
|
+
def html?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
class String
|
14
|
+
# Returns whether the String contains HTML (default to false).
|
15
|
+
def html?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
module Scrivito
|
2
|
+
# This class provides an interfaces for handling CMS Links.
|
3
|
+
# To format a link for rendering in an html page, use the +cms_path+ or +cms_url+ methods.
|
4
|
+
# @api public
|
5
|
+
class Link
|
6
|
+
|
7
|
+
extend ActiveModel::Naming
|
8
|
+
|
9
|
+
# Parses a url and returns a {Link} object. Determines internal urls based on the given
|
10
|
+
# +hostname+ and +port+.
|
11
|
+
# @api public
|
12
|
+
# @param [String] url
|
13
|
+
# @param host [String] the hostname of internal urls
|
14
|
+
# @param port [String] the port of internal urls
|
15
|
+
def self.parse(url, host, port)
|
16
|
+
LinkParser.new(host, port).parse(url)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Create a new link obj
|
20
|
+
# @api public
|
21
|
+
# @param [Hash] link_data
|
22
|
+
# @option link_data [String] url
|
23
|
+
# @option link_data [Obj] obj
|
24
|
+
# @option link_data [String] title
|
25
|
+
# @option link_data [String] query
|
26
|
+
# @option link_data [String] target
|
27
|
+
# @option link_data [String] fragment
|
28
|
+
def initialize(link_data)
|
29
|
+
@link_data = link_data.with_indifferent_access
|
30
|
+
end
|
31
|
+
|
32
|
+
# The link's external url. Only available for external links.
|
33
|
+
# Warning: Do not output the url directly unless you know what you are doing.
|
34
|
+
# Normally you want to use the +cms_path+ or +cms_url+ methods to format a link.
|
35
|
+
# @api public
|
36
|
+
def url
|
37
|
+
@link_data[:url]
|
38
|
+
end
|
39
|
+
|
40
|
+
# Set the link's external url. This will lead to an external link.
|
41
|
+
# @api public
|
42
|
+
# @param value [String] the url of the link
|
43
|
+
def url=(value)
|
44
|
+
@link_data[:url] = value
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns the {BasicObj Obj} this link is referencing. May be nil if the
|
48
|
+
# link is external.
|
49
|
+
# @api public
|
50
|
+
def obj
|
51
|
+
@link_data[:obj]
|
52
|
+
end
|
53
|
+
|
54
|
+
# Set the {BasicObj Obj} this link is referencing. May be nil if the
|
55
|
+
# link is external.
|
56
|
+
# @api public
|
57
|
+
# @param value [Obj] the obj this link should be referencing
|
58
|
+
def obj=(value)
|
59
|
+
@link_data[:obj] = value
|
60
|
+
end
|
61
|
+
|
62
|
+
# The link's title.
|
63
|
+
# @api public
|
64
|
+
def title
|
65
|
+
@link_data[:title]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Set the link's title.
|
69
|
+
# @api public
|
70
|
+
# @param value [String] the link's title
|
71
|
+
def title=(value)
|
72
|
+
@link_data[:title] = value
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns the link's query string as in "index.html?query_string".
|
76
|
+
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
77
|
+
# @api public
|
78
|
+
def query
|
79
|
+
@link_data[:query]
|
80
|
+
end
|
81
|
+
|
82
|
+
# Set the link's query string as in "index.html?query_string".
|
83
|
+
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
84
|
+
# @api public
|
85
|
+
# @param value [String] the query string of the link
|
86
|
+
def query=(value)
|
87
|
+
@link_data[:query] = value
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns the link's anchor as in "index.html#anchor".
|
91
|
+
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
92
|
+
# @api public
|
93
|
+
def fragment
|
94
|
+
@link_data[:fragment]
|
95
|
+
end
|
96
|
+
|
97
|
+
# Set the link's anchor as in "index.html#anchor".
|
98
|
+
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
99
|
+
# @api public
|
100
|
+
# @param value [String] the anchor or fragement of the link
|
101
|
+
def fragment=(value)
|
102
|
+
@link_data[:fragment] = value
|
103
|
+
end
|
104
|
+
|
105
|
+
def target
|
106
|
+
@link_data[:target]
|
107
|
+
end
|
108
|
+
|
109
|
+
def target=(value)
|
110
|
+
@link_data[:target] = value
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns the file extension (e.g. zip, pdf) of this link's (internal or external) target.
|
114
|
+
# Returns an empty string if the file extension is can not be determined.
|
115
|
+
# @api public
|
116
|
+
def file_extension
|
117
|
+
if internal?
|
118
|
+
obj ? obj.file_extension : ""
|
119
|
+
else
|
120
|
+
path = URI.parse(url).path rescue nil
|
121
|
+
path.blank? ? "" : File.extname(path)[1..-1] || ""
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Returns the title of this Link if it is set.
|
126
|
+
# Otherwise it returns the display_title of the destination object for internal Links
|
127
|
+
# or the URL for external Links.
|
128
|
+
# @api public
|
129
|
+
def display_title
|
130
|
+
dt = title
|
131
|
+
dt = obj.display_title if dt.blank? && !external?
|
132
|
+
dt = url if dt.blank?
|
133
|
+
dt
|
134
|
+
end
|
135
|
+
|
136
|
+
# Returns true this Link links to a CMS Object.
|
137
|
+
# @api public
|
138
|
+
def internal?
|
139
|
+
url.nil?
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns true if this Link links to an external URL.
|
143
|
+
# @api public
|
144
|
+
def external?
|
145
|
+
!internal?
|
146
|
+
end
|
147
|
+
|
148
|
+
def resolved?
|
149
|
+
external? || !obj.nil?
|
150
|
+
end
|
151
|
+
|
152
|
+
def query_and_fragment
|
153
|
+
str = ''
|
154
|
+
str << "?#{query}" if query.present?
|
155
|
+
str << "##{fragment}" if fragment.present?
|
156
|
+
str
|
157
|
+
end
|
158
|
+
|
159
|
+
def internal_url
|
160
|
+
"objid:#{obj.id}"
|
161
|
+
end
|
162
|
+
|
163
|
+
def to_cms_api_html_url
|
164
|
+
if internal?
|
165
|
+
"#{internal_url}#{query_and_fragment}"
|
166
|
+
else
|
167
|
+
url
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def to_cms_api_linklist_params
|
172
|
+
params = {}
|
173
|
+
|
174
|
+
if internal?
|
175
|
+
params[:obj_id] = obj.id
|
176
|
+
params[:title] = title if title
|
177
|
+
params[:query] = query if query
|
178
|
+
params[:fragment] = fragment if fragment
|
179
|
+
else
|
180
|
+
params[:url] = url
|
181
|
+
params[:title] = title if title
|
182
|
+
end
|
183
|
+
|
184
|
+
params
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|