infopark_fiona_connector 7.0.1.5.2.3.rc4 → 7.0.1.5.2.3.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/cms_controller.rb +1 -1
- data/app/controllers/rails_connector/default_cms_controller.rb +0 -2
- data/app/helpers/cms_helper.rb +1 -1
- data/app/helpers/cms_routing_helper.rb +1 -1
- data/app/helpers/rails_connector/cms_asset_helper.rb +4 -5
- data/app/helpers/rails_connector/cms_tag_helper.rb +0 -3
- data/app/helpers/rails_connector/default_cms_helper.rb +0 -2
- data/app/helpers/rails_connector/default_cms_routing_helper.rb +15 -16
- data/app/helpers/rails_connector/display_helper.rb +31 -33
- data/app/helpers/rails_connector/editing_helper.rb +2 -8
- data/app/helpers/rails_connector/layout_helper.rb +2 -5
- data/app/helpers/rails_connector/marker_helper.rb +63 -64
- data/app/helpers/rails_connector/table_of_contents_helper.rb +1 -3
- data/config/cms_routes.rb +15 -15
- data/lib/gem_dependencies.rb +8 -7
- data/lib/generators/rails_connector/install/install_generator.rb +6 -6
- data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +1 -1
- data/lib/infopark_fiona_connector.rb +9 -9
- data/lib/rails_connector/attr_dict.rb +26 -18
- data/lib/rails_connector/attribute.rb +18 -21
- data/lib/rails_connector/authenticable.rb +12 -5
- data/lib/rails_connector/basic_obj.rb +64 -57
- data/lib/rails_connector/blob.rb +2 -5
- data/lib/rails_connector/blob_mapping.rb +2 -3
- data/lib/rails_connector/blob_mysql.rb +3 -5
- data/lib/rails_connector/blob_oracle.rb +5 -7
- data/lib/rails_connector/channel.rb +5 -6
- data/lib/rails_connector/cms_accessible.rb +16 -17
- data/lib/rails_connector/cms_base_model.rb +2 -4
- data/lib/rails_connector/cms_dispatch_controller.rb +3 -6
- data/lib/rails_connector/cms_env.rb +4 -7
- data/lib/rails_connector/cms_test_request.rb +1 -1
- data/lib/rails_connector/configuration.rb +12 -16
- data/lib/rails_connector/content.rb +0 -4
- data/lib/rails_connector/core_extensions/time.rb +3 -4
- data/lib/rails_connector/date_attribute.rb +1 -3
- data/lib/rails_connector/default_search_request.rb +1 -1
- data/lib/rails_connector/engine.rb +18 -21
- data/lib/rails_connector/errors.rb +2 -5
- data/lib/rails_connector/fiona_datetime.rb +2 -2
- data/lib/rails_connector/fiona_engine.rb +3 -4
- data/lib/rails_connector/html_string.rb +0 -2
- data/lib/rails_connector/job.rb +0 -3
- data/lib/rails_connector/link.rb +7 -4
- data/lib/rails_connector/link_list.rb +1 -5
- data/lib/rails_connector/link_resolvable.rb +1 -5
- data/lib/rails_connector/lucene_search_request.rb +20 -24
- data/lib/rails_connector/markdown_string.rb +0 -2
- data/lib/rails_connector/meta.rb +25 -30
- data/lib/rails_connector/meta/eager_loader.rb +14 -12
- data/lib/rails_connector/named_link.rb +12 -16
- data/lib/rails_connector/news.rb +3 -3
- data/lib/rails_connector/obj_class.rb +23 -25
- data/lib/rails_connector/obj_class_attr.rb +1 -1
- data/lib/rails_connector/object_with_meta_data.rb +0 -5
- data/lib/rails_connector/permission.rb +2 -6
- data/lib/rails_connector/ses.rb +3 -8
- data/lib/rails_connector/ses/verity_accessor.rb +43 -46
- data/lib/rails_connector/string_tagging.rb +0 -3
- data/lib/rails_connector/verity_search_request.rb +6 -9
- data/lib/search_request.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a758ecfed1d6c530c1ae32e5f893f07283905d44027ee8edbd138c8cc51047a2
|
4
|
+
data.tar.gz: 8706ba3ec80d4356d2cffb52414c34f264211b2f8adc0328faac2dd665b9bef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15962ebaa0a711d6f2ec3a0e23b661d17cb42e04815e116bde12047ac772914999eebcb74b03c3685906fa5a57de9bb63f1f0bc64ed5498e57e1a2a621963b09
|
7
|
+
data.tar.gz: a323ffab660d396984fd2f9384114c3544807bddf1a0a3117d83ba0d155016b907cb3ce0fe489e158685c04873bec6e3bb6bcecf833e83d463725ab1f114faee
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# This controller provides some default includes ({CmsAccessible}),
|
4
3
|
# before filters (+load_object+, among others), and actions to simplify
|
5
4
|
# CMS object handling. It should never be used directly, but only as a
|
@@ -39,5 +38,4 @@ module RailsConnector
|
|
39
38
|
true
|
40
39
|
end
|
41
40
|
end
|
42
|
-
|
43
41
|
end
|
data/app/helpers/cms_helper.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# This module contains helpers that can be used to reference images and other assets stored in the CMS.
|
4
3
|
#
|
5
4
|
# Use this helper to take advantage of rails' asset host mechanism.
|
@@ -38,6 +37,7 @@ module RailsConnector
|
|
38
37
|
def cms_asset_path(target)
|
39
38
|
regular_path = cms_path(target)
|
40
39
|
return regular_path if regular_path.first == "#"
|
40
|
+
|
41
41
|
asset_path(regular_path)
|
42
42
|
end
|
43
43
|
|
@@ -45,11 +45,10 @@ module RailsConnector
|
|
45
45
|
|
46
46
|
def display_title(target)
|
47
47
|
if target.respond_to?(:display_title)
|
48
|
-
|
48
|
+
target.display_title
|
49
49
|
elsif target.respond_to?(:first) && target.first.respond_to?(:display_title)
|
50
|
-
|
50
|
+
target.first.display_title
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
54
53
|
end
|
55
|
-
end
|
54
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# This is a wrapper module for the default set of Rails Connector helper modules.
|
4
3
|
#
|
5
4
|
# To make autoloading from +CmsController+ work, this module must be wrapped
|
@@ -19,5 +18,4 @@ module RailsConnector
|
|
19
18
|
include RailsConnector::LayoutHelper
|
20
19
|
include RailsConnector::CmsTagHelper
|
21
20
|
end
|
22
|
-
|
23
21
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# @api public
|
4
3
|
module DefaultCmsRoutingHelper
|
5
4
|
# Returns the path for +target+ using the +CmsController+ routes.
|
@@ -22,8 +21,8 @@ module RailsConnector
|
|
22
21
|
cms_path_or_url(target, "url", options)
|
23
22
|
end
|
24
23
|
|
25
|
-
LINK_TO_UNREACHABLE = "#__target_object_not_reachable"
|
26
|
-
LINK_TO_EMPTY_LINKLIST = "#__empty_linklist"
|
24
|
+
LINK_TO_UNREACHABLE = "#__target_object_not_reachable".freeze
|
25
|
+
LINK_TO_EMPTY_LINKLIST = "#__empty_linklist".freeze
|
27
26
|
|
28
27
|
def cms_path_or_url(target, path_or_url, options = {})
|
29
28
|
if target.is_a?(Link)
|
@@ -34,16 +33,17 @@ module RailsConnector
|
|
34
33
|
if target.first.is_a?(Link)
|
35
34
|
cms_path_or_url_for_links(target.first, path_or_url, options)
|
36
35
|
else
|
37
|
-
|
36
|
+
LINK_TO_EMPTY_LINKLIST
|
38
37
|
end
|
39
38
|
else
|
40
|
-
raise "cms_path or cms_url was called with an instance of #{target.class}. "+
|
41
|
-
|
39
|
+
raise "cms_path or cms_url was called with an instance of #{target.class}. " +
|
40
|
+
"It must only be called with an Obj or a Link or a non-empty LinkList."
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
44
|
def cms_path_or_url_for_links(link, path_or_url, options = {})
|
46
45
|
return LINK_TO_UNREACHABLE if link.internal? && link.destination_object.nil?
|
46
|
+
|
47
47
|
url = basic_url_or_path_for_link(link, path_or_url, options)
|
48
48
|
url = append_search(url, link) if options.empty?
|
49
49
|
|
@@ -54,7 +54,7 @@ module RailsConnector
|
|
54
54
|
permalink = obj.permalink
|
55
55
|
ignore_body_data_url = options.delete(:ignore_body_data_url)
|
56
56
|
if permalink && !Configuration.editor_interface_enabled?
|
57
|
-
__send__("cms_permalink_#{path_or_url}", options.merge(:
|
57
|
+
__send__("cms_permalink_#{path_or_url}", options.merge(permalink: permalink))
|
58
58
|
elsif obj.homepage? && !Configuration.editor_interface_enabled?
|
59
59
|
__send__("root_#{path_or_url}", options)
|
60
60
|
else
|
@@ -62,9 +62,9 @@ module RailsConnector
|
|
62
62
|
enforce_protocol_from_request(obj.body_data_url)
|
63
63
|
elsif obj.binary? && !obj.file_extension.blank?
|
64
64
|
__send__("cms_id_#{path_or_url}",
|
65
|
-
|
65
|
+
options.merge(id: obj.id, slug: obj.slug.presence, format: obj.file_extension))
|
66
66
|
else
|
67
|
-
routing_options = options.merge(:
|
67
|
+
routing_options = options.merge(id: obj.id, slug: obj.slug.presence)
|
68
68
|
__send__("cms_id_#{path_or_url}", routing_options)
|
69
69
|
end
|
70
70
|
end
|
@@ -76,11 +76,11 @@ module RailsConnector
|
|
76
76
|
if link.internal?
|
77
77
|
__send__("cms_#{path_or_url}", link.destination_object, options)
|
78
78
|
else
|
79
|
-
if link.external_prefix?
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
url = if link.external_prefix?
|
80
|
+
remove_external_prefix(link.url)
|
81
|
+
else
|
82
|
+
link.url
|
83
|
+
end
|
84
84
|
|
85
85
|
options.delete(:ignore_body_data_url)
|
86
86
|
url = merge_options(url, options) if options.any?
|
@@ -113,8 +113,7 @@ module RailsConnector
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def enforce_protocol_from_request(url)
|
116
|
-
request.ssl? && !url.starts_with?(
|
116
|
+
request.ssl? && !url.starts_with?("https") ? url.gsub(/^http/, "https") : url
|
117
117
|
end
|
118
|
-
|
119
118
|
end
|
120
119
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# This module contains a helper that can be used to render attributes of the CMS models.
|
4
3
|
# @api public
|
5
4
|
module DisplayHelper
|
6
|
-
|
7
5
|
# For a consistent look of your site and easy maintenance, only the display helpers
|
8
6
|
# should be used to render an attribute <em>value</em> of a CMS model.
|
9
7
|
#
|
@@ -17,18 +15,18 @@ module RailsConnector
|
|
17
15
|
# @api public
|
18
16
|
def display_value(value)
|
19
17
|
case value
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
when MarkdownString then markdown(convert_links(value)).html_safe
|
19
|
+
when HtmlString then convert_links(value).html_safe
|
20
|
+
when String then html_escape_once(value).html_safe
|
21
|
+
when Time then html_escape_once(l(value)).html_safe
|
22
|
+
else value
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
26
|
def display_original_value(value)
|
29
27
|
case value
|
30
|
-
|
31
|
-
|
28
|
+
when HtmlString then convert_links(value, ignore_body_data_url: true).html_safe
|
29
|
+
else display_value(value)
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
@@ -42,8 +40,8 @@ module RailsConnector
|
|
42
40
|
# @api public
|
43
41
|
def display_field(obj, attr, options = {})
|
44
42
|
options.reverse_merge!({
|
45
|
-
|
46
|
-
|
43
|
+
marker: !%i(id path created last_changed version).include?(attr.to_sym)
|
44
|
+
})
|
47
45
|
if options.delete :marker
|
48
46
|
edit_marker(obj, attr, options) do |obj, attr|
|
49
47
|
display_value obj[attr]
|
@@ -57,36 +55,38 @@ module RailsConnector
|
|
57
55
|
#
|
58
56
|
# Use display_value and display_field instead
|
59
57
|
def display(*args)
|
60
|
-
if args.last.
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
options = if args.last.is_a? Hash
|
59
|
+
args.pop
|
60
|
+
else
|
61
|
+
{}
|
62
|
+
end
|
65
63
|
return display_value(args.first) if args.size == 1
|
64
|
+
|
66
65
|
display_field(args[0], args[1], options)
|
67
66
|
end
|
68
67
|
|
69
68
|
private
|
70
69
|
|
71
70
|
def markdown(string)
|
72
|
-
require
|
71
|
+
require "maruku"
|
73
72
|
Maruku.new(string).to_html
|
74
73
|
end
|
75
74
|
|
76
|
-
LINK_PATTERN = '<?\binternallink:(\d+)\b>?'
|
77
|
-
LINK_EXPRESSION =
|
75
|
+
LINK_PATTERN = '<?\binternallink:(\d+)\b>?'.freeze
|
76
|
+
LINK_EXPRESSION = /#{LINK_PATTERN}/.freeze
|
78
77
|
|
79
78
|
def convert_links(content_attribute, cms_path_options = {})
|
80
79
|
return content_attribute unless content_attribute =~ LINK_EXPRESSION
|
80
|
+
|
81
81
|
link_map = content_attribute.source.text_links.each_with_object({}) do |link, map|
|
82
82
|
map[link.id.to_s] = link
|
83
83
|
end
|
84
|
-
content_attribute.gsub(
|
85
|
-
link = link_map[
|
84
|
+
content_attribute.gsub(/#{LINK_PATTERN}(['"]?)/) do
|
85
|
+
link = link_map[Regexp.last_match(1).to_s]
|
86
86
|
if link.blank?
|
87
|
-
"#{CmsRoutingHelper::LINK_TO_UNREACHABLE}#{
|
87
|
+
"#{CmsRoutingHelper::LINK_TO_UNREACHABLE}#{Regexp.last_match(2)}"
|
88
88
|
else
|
89
|
-
uri = "#{cms_path(link, cms_path_options)}#{
|
89
|
+
uri = "#{cms_path(link, cms_path_options)}#{Regexp.last_match(2)}"
|
90
90
|
if link.markdown?
|
91
91
|
markdown_link(link, uri)
|
92
92
|
else
|
@@ -99,15 +99,13 @@ module RailsConnector
|
|
99
99
|
def html_link(link, uri)
|
100
100
|
subst = uri
|
101
101
|
name, value =
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
if value
|
109
|
-
subst << %( #{name}="#{html_escape_once(value)}")
|
110
|
-
end
|
102
|
+
case link.tag_name
|
103
|
+
when "img", "input"
|
104
|
+
["alt", link.title || ""]
|
105
|
+
when "a", "link"
|
106
|
+
["title", begin link.title unless link.title.blank? end]
|
107
|
+
end
|
108
|
+
subst << %( #{name}="#{html_escape_once(value)}") if value
|
111
109
|
subst << %( target="#{html_escape_once(link.target)}") unless link.target.blank?
|
112
110
|
subst
|
113
111
|
end
|
@@ -116,7 +114,7 @@ module RailsConnector
|
|
116
114
|
subst = "<#{uri}>"
|
117
115
|
unless link.title.blank?
|
118
116
|
case link.markdown_type
|
119
|
-
when
|
117
|
+
when "inline", "reference"
|
120
118
|
subst << %( "#{html_escape_once(link.title)}")
|
121
119
|
end
|
122
120
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# This module contains helpers that render tags for the html head
|
4
3
|
# and the end of the html body.
|
5
4
|
# @api public
|
6
5
|
module LayoutHelper
|
7
|
-
|
8
6
|
# Renders all tags needed in the html head.
|
9
7
|
# @api public
|
10
8
|
def rails_connector_header_tags
|
11
9
|
html = "".html_safe
|
12
|
-
html += tag(
|
13
|
-
|
10
|
+
html += tag("meta", name: "generator",
|
11
|
+
content: "Rails Connector for Infopark CMS Fiona by Infopark AG (www.infopark.de)")
|
14
12
|
html += include_edit_marker_support
|
15
13
|
html += include_editing_stylesheet
|
16
14
|
html
|
@@ -25,5 +23,4 @@ module RailsConnector
|
|
25
23
|
html
|
26
24
|
end
|
27
25
|
end
|
28
|
-
|
29
26
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# This module contains helpers that can be used to build markers for the preview.
|
4
3
|
#
|
5
4
|
# The helpers will not render anything if not in editor mode!
|
@@ -42,13 +41,13 @@ module RailsConnector
|
|
42
41
|
# Hint: You should not render edit markers within elements that are hidden via CSS (<code>display:none</code>),
|
43
42
|
# otherwise they cannot be displayed correctly.
|
44
43
|
# @api public
|
45
|
-
def edit_marker(obj, attr, options = {}
|
44
|
+
def edit_marker(obj, attr, options = {})
|
46
45
|
if Configuration.editor_interface_enabled? && !session[:hide_editmarkers]
|
47
46
|
context = (options.delete :context) || @obj
|
48
47
|
default_value = options.delete(:default_value)
|
49
48
|
|
50
49
|
if block_given?
|
51
|
-
content =
|
50
|
+
content = yield(obj, attr)
|
52
51
|
content = default_value || raw(" ") if content.blank?
|
53
52
|
else
|
54
53
|
content = attr.to_s.humanize
|
@@ -56,25 +55,25 @@ module RailsConnector
|
|
56
55
|
end
|
57
56
|
|
58
57
|
marker_id = store_marker_definition(
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
58
|
+
obj_id: obj.id,
|
59
|
+
attribute: format_attribute_name_for_gui(attr),
|
60
|
+
context_id: context ? context.id : nil,
|
61
|
+
size: options.delete(:size),
|
62
|
+
target: options.delete(:target),
|
63
|
+
memberships: required_memberships_for_editing(obj, attr)
|
65
64
|
)
|
66
65
|
|
67
66
|
store_edit_marker_markup(content_tag(:a, "",
|
68
|
-
|
67
|
+
class: "nps_edit_marker nps_marker_id_#{marker_id}"))
|
69
68
|
|
70
69
|
tag_type = options.delete(:tag) || :span
|
71
70
|
content_tag(
|
72
71
|
tag_type,
|
73
72
|
content.to_s,
|
74
|
-
options.merge(:
|
73
|
+
options.merge(class: (options[:class]).to_s, id: "nps_marker_id_#{marker_id}")
|
75
74
|
)
|
76
75
|
else
|
77
|
-
block_given? ?
|
76
|
+
block_given? ? yield(obj, attr) : nil
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
@@ -84,9 +83,7 @@ module RailsConnector
|
|
84
83
|
# <em>value</em> the link text or e.g. an image_tag
|
85
84
|
# @api public
|
86
85
|
def toggle_edit_marker_link(value)
|
87
|
-
if Configuration.editor_interface_enabled?
|
88
|
-
link_to value, toggle_markers_url(@obj)
|
89
|
-
end
|
86
|
+
link_to value, toggle_markers_url(@obj) if Configuration.editor_interface_enabled?
|
90
87
|
end
|
91
88
|
|
92
89
|
# Renders a marker for an action to be performed with any number of objects.
|
@@ -102,7 +99,7 @@ module RailsConnector
|
|
102
99
|
#
|
103
100
|
# <%= action_marker :workflow_release, [@obj] %>
|
104
101
|
# @api public
|
105
|
-
def action_marker(action, objs, options = {}
|
102
|
+
def action_marker(action, objs, options = {})
|
106
103
|
return unless Configuration.editor_interface_enabled?
|
107
104
|
|
108
105
|
context = (options.delete :context) || @obj
|
@@ -111,20 +108,20 @@ module RailsConnector
|
|
111
108
|
params = options.delete(:params)
|
112
109
|
permissions = options.delete(:permissions) || [:read]
|
113
110
|
|
114
|
-
if objs.size == 1
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
111
|
+
memberships = if objs.size == 1
|
112
|
+
required_memberships_for_permissions(objs.first, permissions)
|
113
|
+
else
|
114
|
+
[]
|
115
|
+
end
|
119
116
|
|
120
117
|
marker_id = store_marker_definition(
|
121
|
-
:
|
118
|
+
memberships: memberships
|
122
119
|
)
|
123
120
|
|
124
121
|
link_to(
|
125
|
-
block_given? ?
|
122
|
+
block_given? ? yield : action.to_s.humanize,
|
126
123
|
uri_for_action_marker(action, objs, context, size, target, params),
|
127
|
-
options.merge(:
|
124
|
+
options.merge(class: ["nps_action_marker", "nps_marker_id_#{marker_id}", options[:class]].compact.join(" "))
|
128
125
|
)
|
129
126
|
end
|
130
127
|
|
@@ -141,7 +138,7 @@ module RailsConnector
|
|
141
138
|
size = options.delete(:size)
|
142
139
|
target = options.delete(:target) || "_blank"
|
143
140
|
|
144
|
-
link_to name.to_s,
|
141
|
+
link_to name.to_s, "#", onclick: "inline_editing.openEditDialog('#{obj.id}', '#{attr}', '#{context.id || "null"}', '#{size || "null"}', '#{target || "null"}'); return false;"
|
145
142
|
end
|
146
143
|
end
|
147
144
|
|
@@ -165,17 +162,17 @@ module RailsConnector
|
|
165
162
|
# Content
|
166
163
|
# <% end %>
|
167
164
|
# @api public
|
168
|
-
def marker_menu(left=0, top=0, &block)
|
165
|
+
def marker_menu(left = 0, top = 0, &block)
|
169
166
|
self.current_marker_menu_id = store_marker_definition(
|
170
|
-
:
|
171
|
-
:
|
167
|
+
offset_left: left,
|
168
|
+
offset_top: top
|
172
169
|
)
|
173
170
|
store_marker_markup(content_tag(
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
171
|
+
:div,
|
172
|
+
marker_menu_markup(capture(&block)),
|
173
|
+
class: "nps_marker_menu nps_marker_id_#{current_marker_menu_id}",
|
174
|
+
id: "nps_marker_menu_#{current_marker_menu_id}"
|
175
|
+
))
|
179
176
|
nil
|
180
177
|
end
|
181
178
|
|
@@ -191,7 +188,7 @@ module RailsConnector
|
|
191
188
|
content_tag(
|
192
189
|
tag_name,
|
193
190
|
capture(&block),
|
194
|
-
options.merge(:
|
191
|
+
options.merge(class: "#{marker_menu_target_class} #{options[:class]}")
|
195
192
|
)
|
196
193
|
end
|
197
194
|
|
@@ -203,7 +200,9 @@ module RailsConnector
|
|
203
200
|
# an element (e.g. an image) you need to supply this css class.
|
204
201
|
# @api public
|
205
202
|
def marker_menu_target_class
|
206
|
-
|
203
|
+
if Configuration.editor_interface_enabled?
|
204
|
+
"nps_marker_menu_target nps_marker_menu_target_#{current_marker_menu_id}"
|
205
|
+
end
|
207
206
|
end
|
208
207
|
|
209
208
|
# Renders the necessary JavaScript and CSS includes to use the edit markers.
|
@@ -212,7 +211,7 @@ module RailsConnector
|
|
212
211
|
raw <<-EOF
|
213
212
|
#{stylesheet_link_tag :editmarker}
|
214
213
|
#{javascript_include_tag :editmarker}
|
215
|
-
#{content_tag(:script, :
|
214
|
+
#{content_tag(:script, type: "text/javascript") { "inline_editing.init();" }}
|
216
215
|
EOF
|
217
216
|
end
|
218
217
|
end
|
@@ -220,6 +219,7 @@ module RailsConnector
|
|
220
219
|
# Renders the necessary marker code to use edit markers and marker menus.
|
221
220
|
def render_marker_code
|
222
221
|
return unless Configuration.editor_interface_enabled?
|
222
|
+
|
223
223
|
html = raw("#{render_marker_definitions}\n#{render_marker_menus}\n#{render_edit_markers}")
|
224
224
|
reset_marker_code
|
225
225
|
html
|
@@ -250,7 +250,7 @@ module RailsConnector
|
|
250
250
|
# [options] options that will be delegated to the {#link_to_edit} helper.
|
251
251
|
# @api public
|
252
252
|
def edit_item(title, css_class, obj, attribute, options = {})
|
253
|
-
edit_link = link_to_edit(content_tag(:span, title, :
|
253
|
+
edit_link = link_to_edit(content_tag(:span, title, class: css_class), obj, attribute, options)
|
254
254
|
content_tag(:li, edit_link)
|
255
255
|
end
|
256
256
|
|
@@ -263,27 +263,27 @@ module RailsConnector
|
|
263
263
|
# [options] options that will be delegated to the {#action_marker} helper.
|
264
264
|
# @api public
|
265
265
|
def action_item(title, css_class, objs, action, options = {})
|
266
|
-
action_link = action_marker(action, objs, options) { content_tag(:span, title, :
|
266
|
+
action_link = action_marker(action, objs, options) { content_tag(:span, title, class: css_class) }
|
267
267
|
content_tag(:li, action_link)
|
268
268
|
end
|
269
269
|
|
270
|
-
|
270
|
+
private
|
271
271
|
|
272
|
-
|
272
|
+
attr_writer :current_marker_menu_id
|
273
273
|
|
274
274
|
def current_marker_menu_id
|
275
275
|
@current_marker_menu_id or raise "Tried to create a marker menu target before a marker menu was created!"
|
276
276
|
end
|
277
277
|
|
278
|
-
JS_HEADER =
|
279
|
-
<script type="text/javascript">
|
280
|
-
// <![CDATA[
|
281
|
-
ENDOFSTRING
|
278
|
+
JS_HEADER = <<~ENDOFSTRING.freeze
|
279
|
+
<script type="text/javascript">
|
280
|
+
// <![CDATA[
|
281
|
+
ENDOFSTRING
|
282
282
|
|
283
|
-
JS_FOOTER =
|
284
|
-
// ]]>
|
285
|
-
</script>
|
286
|
-
ENDOFSTRING
|
283
|
+
JS_FOOTER = <<~ENDOFSTRING.freeze
|
284
|
+
// ]]>
|
285
|
+
</script>
|
286
|
+
ENDOFSTRING
|
287
287
|
|
288
288
|
def store_marker_definition(definition)
|
289
289
|
@marker_definitions ||= {}
|
@@ -298,8 +298,9 @@ ENDOFSTRING
|
|
298
298
|
|
299
299
|
def render_marker_definitions
|
300
300
|
return unless @marker_definitions.present?
|
301
|
+
|
301
302
|
"#{JS_HEADER}inline_editing.storeMarkerDefinitions(#{@marker_definitions.to_json});" +
|
302
|
-
|
303
|
+
JS_FOOTER.to_s
|
303
304
|
end
|
304
305
|
|
305
306
|
def store_marker_markup(markup)
|
@@ -326,11 +327,11 @@ ENDOFSTRING
|
|
326
327
|
|
327
328
|
def required_memberships_for_editing(obj, attr)
|
328
329
|
permissions = [:read]
|
329
|
-
if
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
330
|
+
permissions << if %i(name obj_class workflow suppressexport permalink).include?(attr.to_sym)
|
331
|
+
:root
|
332
|
+
else
|
333
|
+
:write
|
334
|
+
end
|
334
335
|
|
335
336
|
required_memberships_for_permissions(obj, permissions)
|
336
337
|
end
|
@@ -342,31 +343,29 @@ ENDOFSTRING
|
|
342
343
|
def uri_for_action_marker(action, objects, context = nil, size = nil, target = nil, params = nil)
|
343
344
|
action = action.to_s
|
344
345
|
objectIds = objects.collect(&:id).to_json
|
345
|
-
contextId = context.nil? ?
|
346
|
-
size = size.nil? ?
|
347
|
-
target = target.nil? ?
|
348
|
-
params = params.blank? ?
|
346
|
+
contextId = context.nil? ? "null" : context.id
|
347
|
+
size = size.nil? ? "null" : "'#{size}'"
|
348
|
+
target = target.nil? ? "null" : "'#{target}'"
|
349
|
+
params = params.blank? ? "null" : "'#{escape_javascript(params.to_json.gsub('"', "%22"))}'"
|
349
350
|
"javascript:parent.openActionDialog('#{action}',#{objectIds},#{contextId},#{params},#{size},#{target})"
|
350
351
|
end
|
351
352
|
|
352
353
|
def format_attribute_name_for_gui(attr)
|
353
354
|
attr = attr.to_s
|
354
|
-
attr =
|
355
|
-
attr = attr.camelize(:lower) if %w
|
355
|
+
attr = "blob" if attr == "body"
|
356
|
+
attr = attr.camelize(:lower) if %w(valid_from valid_until obj_class).include? attr
|
356
357
|
attr
|
357
358
|
end
|
358
359
|
|
359
360
|
def marker_menu_markup(content)
|
360
|
-
raw %
|
361
|
+
raw %(<a class="nps_marker_menu_button" name="nps_marker_menu_button" href="#">MENU</a>
|
361
362
|
<div class="nps_marker_menu_content" style="display:none;">
|
362
363
|
<div class="b1"></div><div class="b2"></div><div class="b3"></div><div class="b4"></div>
|
363
364
|
<div class="core">
|
364
365
|
#{content}
|
365
366
|
</div>
|
366
367
|
<div class="b4"></div><div class="b3"></div><div class="b2"></div><div class="b1"></div>
|
367
|
-
</div>
|
368
|
+
</div>)
|
368
369
|
end
|
369
|
-
|
370
370
|
end
|
371
|
-
|
372
371
|
end
|