infopark_rails_connector 6.8.0.110.6570b45 → 6.8.0.210.ed204b0
Sign up to get free protection for your applications and to get access to all the features.
@@ -46,6 +46,9 @@ module RailsConnector
|
|
46
46
|
# `fiona connector` only. has no effect when used with the `cloud connector`.
|
47
47
|
attr_accessor :blob_cache_dir
|
48
48
|
|
49
|
+
# Configuration for Content Read Service API.
|
50
|
+
attr_reader :content_service
|
51
|
+
|
49
52
|
def search_options
|
50
53
|
@search_options || local_config_file["search"].symbolize_keys
|
51
54
|
end
|
@@ -147,6 +150,8 @@ module RailsConnector
|
|
147
150
|
def configure_cms_database
|
148
151
|
if RailsConnector::CmsBaseModel.superclass.to_s == "ActiveRecord::Base"
|
149
152
|
CmsBaseModel.configure_database("cms")
|
153
|
+
elsif local_config_file.configured? 'content_service'
|
154
|
+
@content_service = local_config_file['content_service']
|
150
155
|
else
|
151
156
|
CmsBaseModel.configure_database(local_config_file["cms_database"])
|
152
157
|
blob_storage_config = local_config_file["cms_blob_storage"]
|
@@ -252,7 +257,7 @@ module RailsConnector
|
|
252
257
|
"cms_api",
|
253
258
|
"a hash of options that specify access to the cms api"
|
254
259
|
)
|
255
|
-
|
260
|
+
config.explain 'content_service', 'a hash of options that specify access to content service'
|
256
261
|
config
|
257
262
|
end
|
258
263
|
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_rails_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 93109800
|
5
|
+
prerelease: 10
|
6
6
|
segments:
|
7
7
|
- 6
|
8
8
|
- 8
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
-
|
10
|
+
- 210
|
11
|
+
- ed
|
12
|
+
- 204
|
12
13
|
- b
|
13
|
-
-
|
14
|
-
version: 6.8.0.
|
14
|
+
- 0
|
15
|
+
version: 6.8.0.210.ed204b0
|
15
16
|
platform: ruby
|
16
17
|
authors:
|
17
18
|
- Infopark AG
|
@@ -19,7 +20,7 @@ autorequire:
|
|
19
20
|
bindir: bin
|
20
21
|
cert_chain: []
|
21
22
|
|
22
|
-
date: 2012-
|
23
|
+
date: 2012-11-06 00:00:00 +01:00
|
23
24
|
default_executable:
|
24
25
|
dependencies:
|
25
26
|
- !ruby/object:Gem::Dependency
|
@@ -206,54 +207,53 @@ executables: []
|
|
206
207
|
extensions: []
|
207
208
|
|
208
209
|
extra_rdoc_files:
|
210
|
+
- app/helpers/crm_form_helper.rb
|
211
|
+
- app/helpers/user_helper.rb
|
212
|
+
- app/helpers/cms_routing_helper.rb
|
213
|
+
- app/helpers/cms_helper.rb
|
214
|
+
- app/helpers/ratings_helper.rb
|
215
|
+
- app/helpers/rails_connector/display_helper.rb
|
216
|
+
- app/helpers/rails_connector/default_cms_helper.rb
|
217
|
+
- app/helpers/rails_connector/time_machine_helper.rb
|
218
|
+
- app/helpers/rails_connector/link_helper.rb
|
219
|
+
- app/helpers/rails_connector/cms_asset_helper.rb
|
220
|
+
- app/helpers/rails_connector/layout_helper.rb
|
221
|
+
- app/helpers/rails_connector/default_user_helper.rb
|
222
|
+
- app/helpers/rails_connector/table_of_contents_helper.rb
|
223
|
+
- app/helpers/rails_connector/menu_helper.rb
|
224
|
+
- app/helpers/rails_connector/seo_helper.rb
|
225
|
+
- app/helpers/rails_connector/default_crm_form_helper.rb
|
226
|
+
- app/helpers/rails_connector/default_ratings_helper.rb
|
227
|
+
- app/helpers/rails_connector/micronav_helper.rb
|
228
|
+
- app/helpers/rails_connector/tracking_helper.rb
|
229
|
+
- app/helpers/rails_connector/error_messages_helper.rb
|
230
|
+
- app/helpers/rails_connector/mandatory_label_helper.rb
|
231
|
+
- app/helpers/rails_connector/default_cms_routing_helper.rb
|
232
|
+
- app/controllers/rss_controller.rb
|
209
233
|
- app/controllers/search_controller.rb
|
210
|
-
- app/controllers/
|
234
|
+
- app/controllers/pdf_controller.rb
|
235
|
+
- app/controllers/ratings_controller.rb
|
211
236
|
- app/controllers/user_controller.rb
|
212
|
-
- app/controllers/
|
237
|
+
- app/controllers/cms_controller.rb
|
213
238
|
- app/controllers/seo_sitemap_controller.rb
|
214
|
-
- app/controllers/rails_connector/default_ratings_controller.rb
|
215
|
-
- app/controllers/rails_connector/default_crm_form_controller.rb
|
216
239
|
- app/controllers/rails_connector/default_rss_controller.rb
|
217
|
-
- app/controllers/rails_connector/pdf_external_controller.rb
|
218
|
-
- app/controllers/rails_connector/default_pdf_controller.rb
|
219
|
-
- app/controllers/rails_connector/default_comments_controller.rb
|
220
240
|
- app/controllers/rails_connector/default_search_controller.rb
|
241
|
+
- app/controllers/rails_connector/time_machine_controller.rb
|
242
|
+
- app/controllers/rails_connector/default_comments_controller.rb
|
243
|
+
- app/controllers/rails_connector/default_pdf_controller.rb
|
221
244
|
- app/controllers/rails_connector/default_cms_controller.rb
|
245
|
+
- app/controllers/rails_connector/pdf_external_controller.rb
|
246
|
+
- app/controllers/rails_connector/default_crm_form_controller.rb
|
247
|
+
- app/controllers/rails_connector/default_ratings_controller.rb
|
222
248
|
- app/controllers/rails_connector/default_user_controller.rb
|
223
|
-
- app/controllers/rails_connector/time_machine_controller.rb
|
224
249
|
- app/controllers/comments_controller.rb
|
225
250
|
- app/controllers/crm_form_controller.rb
|
226
|
-
- app/controllers/pdf_controller.rb
|
227
|
-
- app/controllers/ratings_controller.rb
|
228
|
-
- app/models/obj.rb
|
229
251
|
- app/models/crm_form.rb
|
252
|
+
- app/models/obj.rb
|
230
253
|
- app/models/named_link.rb
|
231
|
-
- app/models/rails_connector/link_list.rb
|
232
254
|
- app/models/rails_connector/default_comment.rb
|
233
255
|
- app/models/rails_connector/default_rating.rb
|
234
|
-
- app/
|
235
|
-
- app/helpers/cms_routing_helper.rb
|
236
|
-
- app/helpers/user_helper.rb
|
237
|
-
- app/helpers/cms_helper.rb
|
238
|
-
- app/helpers/ratings_helper.rb
|
239
|
-
- app/helpers/rails_connector/default_cms_routing_helper.rb
|
240
|
-
- app/helpers/rails_connector/tracking_helper.rb
|
241
|
-
- app/helpers/rails_connector/time_machine_helper.rb
|
242
|
-
- app/helpers/rails_connector/default_user_helper.rb
|
243
|
-
- app/helpers/rails_connector/seo_helper.rb
|
244
|
-
- app/helpers/rails_connector/display_helper.rb
|
245
|
-
- app/helpers/rails_connector/default_crm_form_helper.rb
|
246
|
-
- app/helpers/rails_connector/default_cms_helper.rb
|
247
|
-
- app/helpers/rails_connector/cms_asset_helper.rb
|
248
|
-
- app/helpers/rails_connector/table_of_contents_helper.rb
|
249
|
-
- app/helpers/rails_connector/micronav_helper.rb
|
250
|
-
- app/helpers/rails_connector/menu_helper.rb
|
251
|
-
- app/helpers/rails_connector/marker_helper.rb
|
252
|
-
- app/helpers/rails_connector/mandatory_label_helper.rb
|
253
|
-
- app/helpers/rails_connector/link_helper.rb
|
254
|
-
- app/helpers/rails_connector/layout_helper.rb
|
255
|
-
- app/helpers/rails_connector/error_messages_helper.rb
|
256
|
-
- app/helpers/rails_connector/default_ratings_helper.rb
|
256
|
+
- app/models/rails_connector/link_list.rb
|
257
257
|
- app/mailers/confirmation_mailer.rb
|
258
258
|
- README
|
259
259
|
files:
|
@@ -321,7 +321,6 @@ files:
|
|
321
321
|
- app/helpers/rails_connector/layout_helper.rb
|
322
322
|
- app/helpers/rails_connector/link_helper.rb
|
323
323
|
- app/helpers/rails_connector/mandatory_label_helper.rb
|
324
|
-
- app/helpers/rails_connector/marker_helper.rb
|
325
324
|
- app/helpers/rails_connector/menu_helper.rb
|
326
325
|
- app/helpers/rails_connector/micronav_helper.rb
|
327
326
|
- app/helpers/rails_connector/seo_helper.rb
|
@@ -423,7 +422,6 @@ files:
|
|
423
422
|
- lib/rails_connector/infopark_base.rb
|
424
423
|
- lib/rails_connector/link_resolvable.rb
|
425
424
|
- lib/rails_connector/liquid_support.rb
|
426
|
-
- lib/rails_connector/liquid_support/action_marker.rb
|
427
425
|
- lib/rails_connector/liquid_support/field_value_drop.rb
|
428
426
|
- lib/rails_connector/liquid_support/general_helper_tag.rb
|
429
427
|
- lib/rails_connector/liquid_support/link_drop.rb
|
@@ -1,363 +0,0 @@
|
|
1
|
-
module RailsConnector
|
2
|
-
|
3
|
-
# This module contains helpers that can be used to build markers for the preview.
|
4
|
-
#
|
5
|
-
# The helpers will not render anyhing if not in editor mode!
|
6
|
-
# See RailsConnector::Configuration for information on modes.
|
7
|
-
#
|
8
|
-
# All helpers have the following <em>options</em>, unknown options are passed
|
9
|
-
# to the HTML element which is being created:
|
10
|
-
#
|
11
|
-
# [:context] the context object that will be shown in the preview after editing
|
12
|
-
# [:size] the symbolic size of the target window to open
|
13
|
-
# [:target] the target frame in which the edit window is to be opened.
|
14
|
-
#
|
15
|
-
# You can specify the size of the edit window by means of the <tt>:size</tt> option:
|
16
|
-
#
|
17
|
-
# [<tt>'n'</tt>] normal browser window
|
18
|
-
# [<tt>'udl'</tt>] undecorated large browser window
|
19
|
-
# [<tt>'uds'</tt>] undecorated small browser window
|
20
|
-
# [<tt>'udt'</tt>] undecorated tiny browser window
|
21
|
-
#
|
22
|
-
# The <tt>:target</tt> option becomes the <tt>target</tt> attribute of the <tt><a></tt> tag.
|
23
|
-
module MarkerHelper
|
24
|
-
# Renders an edit marker for a named attribute of an active object in the preview.
|
25
|
-
# <em>obj</em> is the Obj to edit, <em>attr</em> the attribute as a Symbol or String.
|
26
|
-
# The helper will render nothing if the object is inactive! The :context defaults to obj.
|
27
|
-
#
|
28
|
-
# The following code will render an edit marker for the title attribute of the current object:
|
29
|
-
#
|
30
|
-
# <%= edit_marker @obj, :title %>
|
31
|
-
#
|
32
|
-
# By passing a block, the evaluated block will be included in the marker:
|
33
|
-
# <%= edit_marker @obj, :title do |obj, attr|
|
34
|
-
# display_value obj[attr]
|
35
|
-
# end %>
|
36
|
-
#
|
37
|
-
# The last form is the default of DisplayHelper::display_field without the option :marker => false.
|
38
|
-
# When the blob evaluates to nil, an empty string or array, the markup of the option :default_value
|
39
|
-
# will be rendered.
|
40
|
-
#
|
41
|
-
# Hint: You should not render edit markers within elements that are hidden via CSS (display:none),
|
42
|
-
# otherwise they cannot be displayed correctly.
|
43
|
-
def edit_marker(obj, attr, options = {}, &block)
|
44
|
-
if Configuration.editor_interface_enabled? && !session[:hide_editmarkers]
|
45
|
-
context = (options.delete :context) || @obj
|
46
|
-
default_value = options.delete(:default_value)
|
47
|
-
|
48
|
-
if block_given?
|
49
|
-
content = block.call(obj, attr)
|
50
|
-
content = default_value || raw(" ") if content.blank?
|
51
|
-
else
|
52
|
-
content = attr.to_s.humanize
|
53
|
-
content = obj.name + ": " + content if obj != context
|
54
|
-
end
|
55
|
-
|
56
|
-
marker_id = store_marker_definition(
|
57
|
-
:obj_id => obj.id,
|
58
|
-
:attribute => format_attribute_name_for_gui(attr),
|
59
|
-
:context_id => context ? context.id : nil,
|
60
|
-
:size => options.delete(:size),
|
61
|
-
:target => options.delete(:target),
|
62
|
-
:memberships => required_memberships_for_editing(obj, attr)
|
63
|
-
)
|
64
|
-
|
65
|
-
store_edit_marker_markup(content_tag(:a, "",
|
66
|
-
:class => "nps_edit_marker nps_marker_id_#{marker_id}"))
|
67
|
-
|
68
|
-
tag_type = options.delete(:tag) || :span
|
69
|
-
content_tag(
|
70
|
-
tag_type,
|
71
|
-
content.to_s,
|
72
|
-
options.merge(:class => "#{options[:class]}", :id => "nps_marker_id_#{marker_id}")
|
73
|
-
)
|
74
|
-
else
|
75
|
-
block_given? ? block.call(obj, attr) : nil
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Renders a link which the editor can use to toggle on/off the editmarkers shown
|
80
|
-
# in the preview.
|
81
|
-
# This link will only be shown if the Rails Connector is in <tt>editor</tt> mode.
|
82
|
-
# <em>value</em> the link text or e.g. an image_tag
|
83
|
-
def toggle_edit_marker_link(value)
|
84
|
-
if Configuration.editor_interface_enabled?
|
85
|
-
link_to value, toggle_markers_url(@obj)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# Renders a marker for an action to be performed with any number of objects.
|
90
|
-
# <em>action</em> the attribute as a Symbol or String.
|
91
|
-
# <em>objs</em> is an Array containing a single, none or more than one Obj.
|
92
|
-
# The helper has additional options:
|
93
|
-
# [:permissions] is an Array of permissions the current user needs to use
|
94
|
-
# the marker: :read, :write, :root, :create_children - defaults to [:read].
|
95
|
-
# This option is available for a single Obj passed to <em>objs</em>.
|
96
|
-
# [:params] a hash of parameters to be passed to the action.
|
97
|
-
#
|
98
|
-
# The following code will render an action marker for the release action of the current object:
|
99
|
-
#
|
100
|
-
# <%= action_marker :workflow_release, [@obj] %>
|
101
|
-
def action_marker(action, objs, options = {}, &block)
|
102
|
-
return unless Configuration.editor_interface_enabled?
|
103
|
-
|
104
|
-
context = (options.delete :context) || @obj
|
105
|
-
size = options.delete(:size)
|
106
|
-
target = options.delete(:target) || "_blank"
|
107
|
-
params = options.delete(:params)
|
108
|
-
permissions = options.delete(:permissions) || [:read]
|
109
|
-
|
110
|
-
if objs.size == 1
|
111
|
-
memberships = required_memberships_for_permissions(objs.first, permissions)
|
112
|
-
else
|
113
|
-
memberships = []
|
114
|
-
end
|
115
|
-
|
116
|
-
marker_id = store_marker_definition(
|
117
|
-
:memberships => memberships
|
118
|
-
)
|
119
|
-
|
120
|
-
link_to(
|
121
|
-
block_given? ? block.call : action.to_s.humanize,
|
122
|
-
uri_for_action_marker(action, objs, context, size, target, params),
|
123
|
-
options.merge(:class => ["nps_action_marker", "nps_marker_id_#{marker_id}", options[:class]].compact.join(' '))
|
124
|
-
)
|
125
|
-
end
|
126
|
-
|
127
|
-
# Generates an edit marker link.
|
128
|
-
#
|
129
|
-
# [name] the link caption.
|
130
|
-
# [obj] the object for which the edit dialog will be generated.
|
131
|
-
# [attr] the attribute for which the edit dialog will be generated.
|
132
|
-
# [options] options for the edit dialog (see +edit_marker+).
|
133
|
-
def link_to_edit(name, obj, attr, options = {})
|
134
|
-
if Configuration.editor_interface_enabled?
|
135
|
-
context = (options.delete :context) || @obj
|
136
|
-
size = options.delete(:size)
|
137
|
-
target = options.delete(:target) || "_blank"
|
138
|
-
|
139
|
-
link_to_function(name.to_s,
|
140
|
-
"inline_editing.openEditDialog('#{obj.id}', '#{attr}', '#{context.id || 'null'}', '#{size || 'null'}', '#{target || 'null'}')"
|
141
|
-
)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
# Renders a folding menu which can be used to insert various edit actions or
|
146
|
-
# informations.
|
147
|
-
#
|
148
|
-
# [left] the left offset.
|
149
|
-
# [top] the top offset.
|
150
|
-
# [&block] the content which will be displayed in the menu.
|
151
|
-
#
|
152
|
-
# To generate a menu you have to create one using the +marker_menu+ helper.
|
153
|
-
# Than you have to mark the target for which the menu should be displayed
|
154
|
-
# using the +marker_menu_target+ helper.
|
155
|
-
#
|
156
|
-
# Usage:
|
157
|
-
# <%= marker_menu do %>
|
158
|
-
# Menu
|
159
|
-
# <% end %>
|
160
|
-
#
|
161
|
-
# <%= marker_menu_target(:div) do %>
|
162
|
-
# Content
|
163
|
-
# <% end %>
|
164
|
-
def marker_menu(left=0, top=0, &block)
|
165
|
-
self.current_marker_menu_id = store_marker_definition(
|
166
|
-
:offset_left => left,
|
167
|
-
:offset_top => top
|
168
|
-
)
|
169
|
-
store_marker_markup(content_tag(
|
170
|
-
:div,
|
171
|
-
marker_menu_markup(capture(&block)),
|
172
|
-
:class => "nps_marker_menu nps_marker_id_#{current_marker_menu_id}",
|
173
|
-
:id => "nps_marker_menu_#{current_marker_menu_id}"
|
174
|
-
))
|
175
|
-
nil
|
176
|
-
end
|
177
|
-
|
178
|
-
# Marks the given content to display the previous defined marker menu.
|
179
|
-
#
|
180
|
-
# [tag_name] the tag in which the content will be displayed.
|
181
|
-
# [options] the options for the tag.
|
182
|
-
# [&block] the content which will be displayed with the menu.
|
183
|
-
#
|
184
|
-
# See +marker_menu+ for an example.
|
185
|
-
def marker_menu_target(tag_name, options = {}, &block)
|
186
|
-
content_tag(
|
187
|
-
tag_name,
|
188
|
-
capture(&block),
|
189
|
-
options.merge(:class => "#{marker_menu_target_class} #{options[:class]}")
|
190
|
-
)
|
191
|
-
end
|
192
|
-
|
193
|
-
# Returns the css class used for the target element where the marker menu
|
194
|
-
# should be displayed.
|
195
|
-
#
|
196
|
-
# Will be used automatically if you use the helpers +marker_menu+ and
|
197
|
-
# +marker_menu_target+. But if you want to set a marker menu manually to
|
198
|
-
# an element (e.g. an image) you need to supply this css class.
|
199
|
-
def marker_menu_target_class
|
200
|
-
"nps_marker_menu_target nps_marker_menu_target_#{current_marker_menu_id}" if Configuration.editor_interface_enabled?
|
201
|
-
end
|
202
|
-
|
203
|
-
# Renders the necessary JavaScript and CSS includes to use the edit markers.
|
204
|
-
def include_edit_marker_support # :nodoc:
|
205
|
-
if Configuration.editor_interface_enabled?
|
206
|
-
raw <<-EOF
|
207
|
-
#{stylesheet_link_tag :editmarker}
|
208
|
-
#{javascript_include_tag :editmarker}
|
209
|
-
#{content_tag(:script, :type => 'text/javascript') { 'inline_editing.init();' }}
|
210
|
-
EOF
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
# Renders the necessary marker code to use edit markers and marker menus.
|
215
|
-
def render_marker_code # :nodoc:
|
216
|
-
return unless Configuration.editor_interface_enabled?
|
217
|
-
html = raw("#{render_marker_definitions}\n#{render_marker_menus}\n#{render_edit_markers}")
|
218
|
-
reset_marker_code
|
219
|
-
html
|
220
|
-
end
|
221
|
-
|
222
|
-
# This helper method can be used in +marker_menu+ to generate a list with
|
223
|
-
# actions using +edit_item+ or +action_item+. For each action a icon and
|
224
|
-
# title will be shown.
|
225
|
-
#
|
226
|
-
# Usage:
|
227
|
-
# <%= marker_menu do %>
|
228
|
-
# <%= iconlist do %>
|
229
|
-
# <%= edit_item("edit title", "css_class", @obj, :image) %>
|
230
|
-
# <%= action_item("edit image", "css_class", [@obj], :editImage) %>
|
231
|
-
# <% end %>
|
232
|
-
# <% end %>
|
233
|
-
def iconlist(&block)
|
234
|
-
content_tag(:ul, capture(&block)) if block_given?
|
235
|
-
end
|
236
|
-
|
237
|
-
# Creates an edit marker item for the list generated by +iconlist+.
|
238
|
-
#
|
239
|
-
# [title] the title which will be displayed.
|
240
|
-
# [css_class] the css-class can be used to display a different icon.
|
241
|
-
# [obj] the object for which the edit dialog will be generated.
|
242
|
-
# [attribute] the attribute for which the edit dialog will be generated.
|
243
|
-
# [options] options that will be delegated to the +link_to_edit+ helper.
|
244
|
-
def edit_item(title, css_class, obj, attribute, options = {})
|
245
|
-
edit_link = link_to_edit(content_tag(:span, title, :class => css_class), obj, attribute, options)
|
246
|
-
content_tag(:li, edit_link)
|
247
|
-
end
|
248
|
-
|
249
|
-
# Creates an action marker item for the list generated by +iconlist+.
|
250
|
-
#
|
251
|
-
# [title] the title which will be displayed.
|
252
|
-
# [css_class] the css-class can be used to display a different icon.
|
253
|
-
# [objs] the array of objects for which the action dialog will be generated.
|
254
|
-
# [action] the action for which the action dialog will be generated.
|
255
|
-
# [options] options that will be delegated to the +action_marker+ helper.
|
256
|
-
def action_item(title, css_class, objs, action, options = {})
|
257
|
-
action_link = action_marker(action, objs, options) { content_tag(:span, title, :class => css_class) }
|
258
|
-
content_tag(:li, action_link)
|
259
|
-
end
|
260
|
-
|
261
|
-
private
|
262
|
-
|
263
|
-
attr_accessor :current_marker_menu_id
|
264
|
-
|
265
|
-
def current_marker_menu_id
|
266
|
-
@current_marker_menu_id or raise "Tried to create a marker menu target before a marker menu was created!"
|
267
|
-
end
|
268
|
-
|
269
|
-
JS_HEADER = <<ENDOFSTRING
|
270
|
-
<script type="text/javascript">
|
271
|
-
// <![CDATA[
|
272
|
-
ENDOFSTRING
|
273
|
-
|
274
|
-
JS_FOOTER = <<ENDOFSTRING
|
275
|
-
// ]]>
|
276
|
-
</script>
|
277
|
-
ENDOFSTRING
|
278
|
-
|
279
|
-
def store_marker_definition(definition)
|
280
|
-
@marker_definitions ||= {}
|
281
|
-
marker_id = random_marker_id
|
282
|
-
@marker_definitions[marker_id] = definition
|
283
|
-
marker_id
|
284
|
-
end
|
285
|
-
|
286
|
-
def random_marker_id
|
287
|
-
rand(1_000_000_000)
|
288
|
-
end
|
289
|
-
|
290
|
-
def render_marker_definitions
|
291
|
-
return unless @marker_definitions.present?
|
292
|
-
"#{JS_HEADER}inline_editing.storeMarkerDefinitions(#{@marker_definitions.to_json});" +
|
293
|
-
"#{JS_FOOTER}"
|
294
|
-
end
|
295
|
-
|
296
|
-
def store_marker_markup(markup)
|
297
|
-
@marker_markup ||= []
|
298
|
-
@marker_markup << markup
|
299
|
-
end
|
300
|
-
|
301
|
-
def store_edit_marker_markup(markup)
|
302
|
-
@edit_marker_markup ||= []
|
303
|
-
@edit_marker_markup << markup
|
304
|
-
end
|
305
|
-
|
306
|
-
def reset_marker_code
|
307
|
-
@marker_definitions = @marker_markup = @edit_marker_markup = nil
|
308
|
-
end
|
309
|
-
|
310
|
-
def render_marker_menus
|
311
|
-
(@marker_markup || []).join
|
312
|
-
end
|
313
|
-
|
314
|
-
def render_edit_markers
|
315
|
-
(@edit_marker_markup || []).join
|
316
|
-
end
|
317
|
-
|
318
|
-
def required_memberships_for_editing(obj, attr)
|
319
|
-
permissions = [:read]
|
320
|
-
if [:name, :obj_class, :workflow, :suppressexport, :permalink].include?(attr.to_sym)
|
321
|
-
permissions << :root
|
322
|
-
else
|
323
|
-
permissions << :write
|
324
|
-
end
|
325
|
-
|
326
|
-
required_memberships_for_permissions(obj, permissions)
|
327
|
-
end
|
328
|
-
|
329
|
-
def required_memberships_for_permissions(obj, permissions)
|
330
|
-
permissions.map { |perm| obj.permissions.__send__(perm) }
|
331
|
-
end
|
332
|
-
|
333
|
-
def uri_for_action_marker(action, objects, context = nil, size = nil, target = nil, params = nil) #:nodoc:
|
334
|
-
action = action.to_s
|
335
|
-
objectIds = objects.collect(&:id).to_json
|
336
|
-
contextId = context.nil? ? 'null' : context.id
|
337
|
-
size = size.nil? ? 'null' : "'#{size}'"
|
338
|
-
target = target.nil? ? 'null' : "'#{target}'"
|
339
|
-
params = params.blank? ? 'null' : "'#{escape_javascript(params.to_json.gsub('"','%22'))}'"
|
340
|
-
"javascript:parent.openActionDialog('#{action}',#{objectIds},#{contextId},#{params},#{size},#{target})"
|
341
|
-
end
|
342
|
-
|
343
|
-
def format_attribute_name_for_gui(attr)
|
344
|
-
attr = attr.to_s
|
345
|
-
attr = 'blob' if attr == 'body'
|
346
|
-
attr = attr.camelize(:lower) if %w{ valid_from valid_until obj_class }.include? attr
|
347
|
-
attr
|
348
|
-
end
|
349
|
-
|
350
|
-
def marker_menu_markup(content)
|
351
|
-
raw %Q{<a class="nps_marker_menu_button" name="nps_marker_menu_button" href="#">MENU</a>
|
352
|
-
<div class="nps_marker_menu_content" style="display:none;">
|
353
|
-
<div class="b1"></div><div class="b2"></div><div class="b3"></div><div class="b4"></div>
|
354
|
-
<div class="core">
|
355
|
-
#{content}
|
356
|
-
</div>
|
357
|
-
<div class="b4"></div><div class="b3"></div><div class="b2"></div><div class="b1"></div>
|
358
|
-
</div>}
|
359
|
-
end
|
360
|
-
|
361
|
-
end
|
362
|
-
|
363
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
module RailsConnector::LiquidSupport
|
2
|
-
|
3
|
-
# Usage example for actionmarkers in Liquid templates:
|
4
|
-
# {% actionmarker obj.images[0] editImageWizard param_a:value_a param_b:value_b %}
|
5
|
-
# [Edit image]
|
6
|
-
# {% endactionmarker %}
|
7
|
-
#
|
8
|
-
# The first parameter may be an instance of +ObjDrop+ (usually +obj+ in Liquid templates),
|
9
|
-
# +Array+ (such as a +LinkList+ field), or +LinkDrop+ (as in the example above).
|
10
|
-
#
|
11
|
-
# The second parameter is the action to be run on the target objects.
|
12
|
-
# Additional parameters to be forwarded to the action can be added as <tt>key:value</tt> pairs.
|
13
|
-
# All parameters are evaluated in the current Liquid context and thus may contain,
|
14
|
-
# for example, method calls on objects.
|
15
|
-
#
|
16
|
-
# Internally, the parameter <tt>:context</tt> is always set to the currently viewed object (+obj+)
|
17
|
-
# and can not be overwritten.
|
18
|
-
#
|
19
|
-
# The Liquid actionmarker uses RailsConnector::MarkerHelper#action_marker.
|
20
|
-
class ActionMarker < Liquid::Block
|
21
|
-
def initialize(tag_name, markup, tokens)
|
22
|
-
@obj_name, @method_name = markup.to_s.split(/\s+/)
|
23
|
-
unless @obj_name && @method_name
|
24
|
-
raise Liquid::SyntaxError.new("Syntax Error in 'actionmarker' - Valid syntax: actionmarker obj [action] [foo:bar]")
|
25
|
-
end
|
26
|
-
@params = {}
|
27
|
-
markup.scan(/#{Liquid::TagAttributes}(#{Liquid::SpacelessFilter})?/) do |key, value, spaceless_filter|
|
28
|
-
@params[key] = spaceless_filter.blank? ? value : "#{value}|#{spaceless_filter}"
|
29
|
-
end
|
30
|
-
super
|
31
|
-
end
|
32
|
-
|
33
|
-
def render(context)
|
34
|
-
context.registers[:action_view].action_marker(
|
35
|
-
(context[@method_name] || @method_name).to_s,
|
36
|
-
target_objs(context),
|
37
|
-
:params => params(context),
|
38
|
-
:context => context['obj'].__drop_content
|
39
|
-
) do
|
40
|
-
context.stack { render_all(@nodelist, context) }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
protected
|
45
|
-
|
46
|
-
def target_objs(context)
|
47
|
-
[ context[@obj_name] ].flatten.map do |item|
|
48
|
-
case item
|
49
|
-
when RailsConnector::Link
|
50
|
-
item.destination_object
|
51
|
-
when LinkDrop
|
52
|
-
item.destination.__drop_content
|
53
|
-
else
|
54
|
-
item.__drop_content
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def params(context)
|
60
|
-
result = {}
|
61
|
-
@params.each do |key, value|
|
62
|
-
result[(context[key] || key).to_s] = (context[value] || value).to_s
|
63
|
-
end
|
64
|
-
result
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
Liquid::Template.register_tag('actionmarker', ActionMarker)
|
69
|
-
end
|