infopark_fiona_connector 6.8.0.210.ed204b0 → 6.8.0.322.c003f11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +5 -0
- data/README +2 -2
- data/app/helpers/rails_connector/marker_helper.rb +31 -20
- data/lib/comment.rb +2 -1
- data/lib/infopark_fiona_connector.rb +1 -0
- data/lib/rails_connector/attr_dict.rb +3 -3
- data/lib/rails_connector/blob.rb +1 -1
- data/lib/rails_connector/blob_mysql.rb +1 -1
- data/lib/rails_connector/blob_oracle.rb +1 -1
- data/lib/rails_connector/cache_middleware.rb +1 -1
- data/lib/rails_connector/cms_base_model.rb +1 -1
- data/lib/rails_connector/date_attribute.rb +1 -1
- data/lib/rails_connector/default_search_request.rb +2 -1
- data/lib/rails_connector/errors.rb +1 -0
- data/lib/rails_connector/fiona_engine.rb +1 -1
- data/lib/rails_connector/link.rb +22 -8
- data/lib/rails_connector/liquid_support/action_marker.rb +10 -4
- data/lib/rails_connector/lucene_search_request.rb +1 -2
- data/lib/rails_connector/named_link.rb +9 -6
- data/lib/rails_connector/news.rb +1 -1
- data/lib/rails_connector/obj.rb +54 -18
- data/lib/rails_connector/ses/verity_accessor.rb +1 -1
- data/lib/rails_connector/verity_search_request.rb +6 -2
- data/lib/rating.rb +3 -0
- metadata +15 -18
data/.yardopts
ADDED
data/README
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
= Infopark Fiona Connector
|
2
2
|
|
3
|
-
Infopark
|
4
|
-
|
3
|
+
Infopark Cloud Connector integrates the {https://rubygems.org/gems/infopark_rails_connector Infopark Rails Connector} with the Infopark CMS Fiona.
|
5
4
|
|
5
|
+
For more information about Infopark Rails and Fiona Connector, please visit {http://kb.infopark.de/ Infopark’s Knowledge Base}.
|
@@ -2,8 +2,8 @@ module RailsConnector
|
|
2
2
|
|
3
3
|
# This module contains helpers that can be used to build markers for the preview.
|
4
4
|
#
|
5
|
-
# The helpers will not render
|
6
|
-
# See RailsConnector::Configuration for information on modes.
|
5
|
+
# The helpers will not render anything if not in editor mode!
|
6
|
+
# See {RailsConnector::Configuration} for information on modes.
|
7
7
|
#
|
8
8
|
# All helpers have the following <em>options</em>, unknown options are passed
|
9
9
|
# to the HTML element which is being created:
|
@@ -20,6 +20,7 @@ module RailsConnector
|
|
20
20
|
# [<tt>'udt'</tt>] undecorated tiny browser window
|
21
21
|
#
|
22
22
|
# The <tt>:target</tt> option becomes the <tt>target</tt> attribute of the <tt><a></tt> tag.
|
23
|
+
# @api public
|
23
24
|
module MarkerHelper
|
24
25
|
# Renders an edit marker for a named attribute of an active object in the preview.
|
25
26
|
# <em>obj</em> is the Obj to edit, <em>attr</em> the attribute as a Symbol or String.
|
@@ -34,12 +35,13 @@ module RailsConnector
|
|
34
35
|
# display_value obj[attr]
|
35
36
|
# end %>
|
36
37
|
#
|
37
|
-
# The last form is the default of DisplayHelper
|
38
|
-
# When the blob evaluates to nil, an empty string or array, the markup of the option
|
38
|
+
# The last form is the default of {DisplayHelper#display_field} without the option <code>:marker => false</code>.
|
39
|
+
# When the blob evaluates to nil, an empty string or array, the markup of the option +:default_value+
|
39
40
|
# will be rendered.
|
40
41
|
#
|
41
|
-
# Hint: You should not render edit markers within elements that are hidden via CSS (display:none),
|
42
|
+
# Hint: You should not render edit markers within elements that are hidden via CSS (<code>display:none</code>),
|
42
43
|
# otherwise they cannot be displayed correctly.
|
44
|
+
# @api public
|
43
45
|
def edit_marker(obj, attr, options = {}, &block)
|
44
46
|
if Configuration.editor_interface_enabled? && !session[:hide_editmarkers]
|
45
47
|
context = (options.delete :context) || @obj
|
@@ -80,6 +82,7 @@ module RailsConnector
|
|
80
82
|
# in the preview.
|
81
83
|
# This link will only be shown if the Rails Connector is in <tt>editor</tt> mode.
|
82
84
|
# <em>value</em> the link text or e.g. an image_tag
|
85
|
+
# @api public
|
83
86
|
def toggle_edit_marker_link(value)
|
84
87
|
if Configuration.editor_interface_enabled?
|
85
88
|
link_to value, toggle_markers_url(@obj)
|
@@ -98,6 +101,7 @@ module RailsConnector
|
|
98
101
|
# The following code will render an action marker for the release action of the current object:
|
99
102
|
#
|
100
103
|
# <%= action_marker :workflow_release, [@obj] %>
|
104
|
+
# @api public
|
101
105
|
def action_marker(action, objs, options = {}, &block)
|
102
106
|
return unless Configuration.editor_interface_enabled?
|
103
107
|
|
@@ -129,7 +133,8 @@ module RailsConnector
|
|
129
133
|
# [name] the link caption.
|
130
134
|
# [obj] the object for which the edit dialog will be generated.
|
131
135
|
# [attr] the attribute for which the edit dialog will be generated.
|
132
|
-
# [options] options for the edit dialog (see
|
136
|
+
# [options] options for the edit dialog (see {MarkerHelper#edit_marker}).
|
137
|
+
# @api public
|
133
138
|
def link_to_edit(name, obj, attr, options = {})
|
134
139
|
if Configuration.editor_interface_enabled?
|
135
140
|
context = (options.delete :context) || @obj
|
@@ -149,9 +154,9 @@ module RailsConnector
|
|
149
154
|
# [top] the top offset.
|
150
155
|
# [&block] the content which will be displayed in the menu.
|
151
156
|
#
|
152
|
-
# To generate a menu you have to create one using the
|
157
|
+
# To generate a menu you have to create one using the {#marker_menu} helper.
|
153
158
|
# Than you have to mark the target for which the menu should be displayed
|
154
|
-
# using the
|
159
|
+
# using the {#marker_menu_target} helper.
|
155
160
|
#
|
156
161
|
# Usage:
|
157
162
|
# <%= marker_menu do %>
|
@@ -161,6 +166,7 @@ module RailsConnector
|
|
161
166
|
# <%= marker_menu_target(:div) do %>
|
162
167
|
# Content
|
163
168
|
# <% end %>
|
169
|
+
# @api public
|
164
170
|
def marker_menu(left=0, top=0, &block)
|
165
171
|
self.current_marker_menu_id = store_marker_definition(
|
166
172
|
:offset_left => left,
|
@@ -181,7 +187,8 @@ module RailsConnector
|
|
181
187
|
# [options] the options for the tag.
|
182
188
|
# [&block] the content which will be displayed with the menu.
|
183
189
|
#
|
184
|
-
# See
|
190
|
+
# See {#marker_menu} for an example.
|
191
|
+
# @api public
|
185
192
|
def marker_menu_target(tag_name, options = {}, &block)
|
186
193
|
content_tag(
|
187
194
|
tag_name,
|
@@ -193,15 +200,16 @@ module RailsConnector
|
|
193
200
|
# Returns the css class used for the target element where the marker menu
|
194
201
|
# should be displayed.
|
195
202
|
#
|
196
|
-
# Will be used automatically if you use the helpers
|
197
|
-
#
|
203
|
+
# Will be used automatically if you use the helpers {#marker_menu} and
|
204
|
+
# {#marker_menu_target}. But if you want to set a marker menu manually to
|
198
205
|
# an element (e.g. an image) you need to supply this css class.
|
206
|
+
# @api public
|
199
207
|
def marker_menu_target_class
|
200
208
|
"nps_marker_menu_target nps_marker_menu_target_#{current_marker_menu_id}" if Configuration.editor_interface_enabled?
|
201
209
|
end
|
202
210
|
|
203
211
|
# Renders the necessary JavaScript and CSS includes to use the edit markers.
|
204
|
-
def include_edit_marker_support
|
212
|
+
def include_edit_marker_support
|
205
213
|
if Configuration.editor_interface_enabled?
|
206
214
|
raw <<-EOF
|
207
215
|
#{stylesheet_link_tag :editmarker}
|
@@ -212,15 +220,15 @@ module RailsConnector
|
|
212
220
|
end
|
213
221
|
|
214
222
|
# Renders the necessary marker code to use edit markers and marker menus.
|
215
|
-
def render_marker_code
|
223
|
+
def render_marker_code
|
216
224
|
return unless Configuration.editor_interface_enabled?
|
217
225
|
html = raw("#{render_marker_definitions}\n#{render_marker_menus}\n#{render_edit_markers}")
|
218
226
|
reset_marker_code
|
219
227
|
html
|
220
228
|
end
|
221
229
|
|
222
|
-
# This helper method can be used in
|
223
|
-
# actions using
|
230
|
+
# This helper method can be used in {#marker_menu} to generate a list with
|
231
|
+
# actions using {#edit_item} or {#action_item}. For each action a icon and
|
224
232
|
# title will be shown.
|
225
233
|
#
|
226
234
|
# Usage:
|
@@ -230,29 +238,32 @@ module RailsConnector
|
|
230
238
|
# <%= action_item("edit image", "css_class", [@obj], :editImage) %>
|
231
239
|
# <% end %>
|
232
240
|
# <% end %>
|
241
|
+
# @api public
|
233
242
|
def iconlist(&block)
|
234
243
|
content_tag(:ul, capture(&block)) if block_given?
|
235
244
|
end
|
236
245
|
|
237
|
-
# Creates an edit marker item for the list generated by
|
246
|
+
# Creates an edit marker item for the list generated by {#iconlist}.
|
238
247
|
#
|
239
248
|
# [title] the title which will be displayed.
|
240
249
|
# [css_class] the css-class can be used to display a different icon.
|
241
250
|
# [obj] the object for which the edit dialog will be generated.
|
242
251
|
# [attribute] the attribute for which the edit dialog will be generated.
|
243
|
-
# [options] options that will be delegated to the
|
252
|
+
# [options] options that will be delegated to the {#link_to_edit} helper.
|
253
|
+
# @api public
|
244
254
|
def edit_item(title, css_class, obj, attribute, options = {})
|
245
255
|
edit_link = link_to_edit(content_tag(:span, title, :class => css_class), obj, attribute, options)
|
246
256
|
content_tag(:li, edit_link)
|
247
257
|
end
|
248
258
|
|
249
|
-
# Creates an action marker item for the list generated by
|
259
|
+
# Creates an action marker item for the list generated by {#iconlist}.
|
250
260
|
#
|
251
261
|
# [title] the title which will be displayed.
|
252
262
|
# [css_class] the css-class can be used to display a different icon.
|
253
263
|
# [objs] the array of objects for which the action dialog will be generated.
|
254
264
|
# [action] the action for which the action dialog will be generated.
|
255
|
-
# [options] options that will be delegated to the
|
265
|
+
# [options] options that will be delegated to the {#action_marker} helper.
|
266
|
+
# @api public
|
256
267
|
def action_item(title, css_class, objs, action, options = {})
|
257
268
|
action_link = action_marker(action, objs, options) { content_tag(:span, title, :class => css_class) }
|
258
269
|
content_tag(:li, action_link)
|
@@ -330,7 +341,7 @@ ENDOFSTRING
|
|
330
341
|
permissions.map { |perm| obj.permissions.__send__(perm) }
|
331
342
|
end
|
332
343
|
|
333
|
-
def uri_for_action_marker(action, objects, context = nil, size = nil, target = nil, params = nil)
|
344
|
+
def uri_for_action_marker(action, objects, context = nil, size = nil, target = nil, params = nil)
|
334
345
|
action = action.to_s
|
335
346
|
objectIds = objects.collect(&:id).to_json
|
336
347
|
contextId = context.nil? ? 'null' : context.id
|
data/lib/comment.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rails_connector/rack_middlewares'
|
|
2
2
|
require 'rails_connector/core_extensions'
|
3
3
|
require "rails_connector/errors"
|
4
4
|
|
5
|
+
# @api public
|
5
6
|
module RailsConnector
|
6
7
|
def self.autoload_all_sources
|
7
8
|
source_files = Dir.glob(File.expand_path("../rails_connector/*.rb", __FILE__)).map do |file|
|
@@ -8,7 +8,7 @@ module RailsConnector
|
|
8
8
|
# [editor] The login of the current editor of the edited content, if set
|
9
9
|
#
|
10
10
|
# Any custom Attribute can be accessed directly or via [].
|
11
|
-
class AttrDict
|
11
|
+
class AttrDict
|
12
12
|
include DateAttribute
|
13
13
|
|
14
14
|
def initialize(object, keys_and_values = {}, defs = {})
|
@@ -28,7 +28,7 @@ module RailsConnector
|
|
28
28
|
StringTagging.tag_as_html(raw, self)
|
29
29
|
end
|
30
30
|
|
31
|
-
def sort_keys
|
31
|
+
def sort_keys
|
32
32
|
[sort_key1, sort_key2, sort_key3]
|
33
33
|
end
|
34
34
|
|
@@ -140,7 +140,7 @@ module RailsConnector
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
class UnknownAttributeError < StandardError
|
143
|
+
class UnknownAttributeError < StandardError
|
144
144
|
end
|
145
145
|
|
146
146
|
end
|
data/lib/rails_connector/blob.rb
CHANGED
@@ -2,7 +2,7 @@ module RailsConnector
|
|
2
2
|
|
3
3
|
# A binary containing the blob data of a Content or CMS management
|
4
4
|
# data of Attribute (fields), ObjClass (object classes), for example.
|
5
|
-
class Blob < CmsBaseModel
|
5
|
+
class Blob < CmsBaseModel
|
6
6
|
self.primary_key = "blob_name"
|
7
7
|
|
8
8
|
class << self
|
@@ -5,7 +5,7 @@ module RailsConnector
|
|
5
5
|
# determined from the instance_name.
|
6
6
|
#
|
7
7
|
# [instance_name] the name of the CMS instance
|
8
|
-
class CmsBaseModel < ActiveRecord::Base
|
8
|
+
class CmsBaseModel < ActiveRecord::Base
|
9
9
|
@@instance_name = 'default'
|
10
10
|
cattr_accessor :instance_name
|
11
11
|
self.abstract_class = true
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module RailsConnector
|
2
2
|
# This class provides a default implementation for accessing the search server.
|
3
|
-
# It is used by DefaultSearchController.
|
3
|
+
# It is used by {DefaultSearchController}.
|
4
|
+
# @api public
|
4
5
|
class DefaultSearchRequest < VeritySearchRequest
|
5
6
|
end
|
6
7
|
end
|
data/lib/rails_connector/link.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module RailsConnector
|
2
2
|
# This class provides an interfaces for handling CMS Links.
|
3
3
|
# To format a link for rendering in an html page, use the +cms_path+ or +cms_url+ methods.
|
4
|
+
# @api public
|
4
5
|
class Link
|
5
6
|
|
6
7
|
extend ActiveModel::Naming
|
7
8
|
|
8
|
-
def initialize(link_data, destination_object = nil)
|
9
|
+
def initialize(link_data, destination_object = nil)
|
9
10
|
@link_data = link_data.symbolize_keys
|
10
11
|
@destination_object = destination_object
|
11
12
|
end
|
@@ -13,17 +14,20 @@ module RailsConnector
|
|
13
14
|
# The link's external url. Only available for external links.
|
14
15
|
# Warning: Do not output the url directly unless you know what you are doing.
|
15
16
|
# Normally you want to use the +cms_path+ or +cms_url+ methods to format a link.
|
17
|
+
# @api public
|
16
18
|
def url
|
17
19
|
@link_data[:url]
|
18
20
|
end
|
19
21
|
|
20
22
|
# The link's title.
|
23
|
+
# @api public
|
21
24
|
def title
|
22
25
|
@link_data[:title]
|
23
26
|
end
|
24
27
|
|
25
28
|
# Returns the link's query string as in "index.html?query_string".
|
26
29
|
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
30
|
+
# @api public
|
27
31
|
def query
|
28
32
|
@link_data[:search]
|
29
33
|
end
|
@@ -31,40 +35,44 @@ module RailsConnector
|
|
31
35
|
# Deprecated: use Link#query instead.
|
32
36
|
# Returns the link's query string as in "index.html?query_string".
|
33
37
|
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
38
|
+
# @api public
|
34
39
|
def search
|
35
40
|
query
|
36
41
|
end
|
37
42
|
|
38
43
|
# Returns the link's anchor as in "index.html#anchor".
|
39
44
|
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
45
|
+
# @api public
|
40
46
|
def fragment
|
41
47
|
@link_data[:fragment]
|
42
48
|
end
|
43
49
|
|
44
50
|
# Returns the browser window or browser frame to be used as a target for this link.
|
45
51
|
# Example: Links that should be opened in a new window will return "_blank" as their target.
|
52
|
+
# @api public
|
46
53
|
def target
|
47
54
|
@link_data[:target]
|
48
55
|
end
|
49
56
|
|
50
|
-
def id
|
57
|
+
def id
|
51
58
|
@link_data[:link_id]
|
52
59
|
end
|
53
60
|
|
54
|
-
def tag_name
|
61
|
+
def tag_name
|
55
62
|
@link_data[:tag_name]
|
56
63
|
end
|
57
64
|
|
58
|
-
def markdown_type
|
65
|
+
def markdown_type
|
59
66
|
@link_data[:markdown_type]
|
60
67
|
end
|
61
68
|
|
62
|
-
def markdown?
|
69
|
+
def markdown?
|
63
70
|
'markdown' == @link_data[:source_format]
|
64
71
|
end
|
65
72
|
|
66
73
|
# Returns the file extension (e.g. zip, pdf) of this link's (internal or external) target.
|
67
74
|
# Returns an empty string if the file extension is can not be determined.
|
75
|
+
# @api public
|
68
76
|
def file_extension
|
69
77
|
if internal?
|
70
78
|
destination_object ? destination_object.file_extension : ""
|
@@ -75,6 +83,7 @@ module RailsConnector
|
|
75
83
|
end
|
76
84
|
|
77
85
|
# Returns the id of the Links' destination_object.
|
86
|
+
# @api public
|
78
87
|
def destination_object_id
|
79
88
|
destination
|
80
89
|
end
|
@@ -82,6 +91,7 @@ module RailsConnector
|
|
82
91
|
# Returns the title of this Link if it is set.
|
83
92
|
# Otherwise it returns the display_title of the destination object for internal Links
|
84
93
|
# or the URL for external Links.
|
94
|
+
# @api public
|
85
95
|
def display_title
|
86
96
|
dt = title
|
87
97
|
dt = destination_object.display_title if dt.blank? && !external?
|
@@ -90,35 +100,39 @@ module RailsConnector
|
|
90
100
|
end
|
91
101
|
|
92
102
|
# Returns true this Link links to a CMS Object.
|
103
|
+
# @api public
|
93
104
|
def internal?
|
94
105
|
url.nil?
|
95
106
|
end
|
96
107
|
|
97
108
|
# Returns true if this Link links to an external URL.
|
109
|
+
# @api public
|
98
110
|
def external?
|
99
111
|
!internal?
|
100
112
|
end
|
101
113
|
|
102
114
|
# An internal Link is active if it's destination object is active.
|
103
115
|
# An external Link is always active.
|
116
|
+
# @api public
|
104
117
|
def active?
|
105
118
|
external? || (destination_object && destination_object.active?)
|
106
119
|
end
|
107
120
|
|
108
|
-
def external_prefix?
|
121
|
+
def external_prefix?
|
109
122
|
url =~ /\s?external:/
|
110
123
|
end
|
111
124
|
|
112
|
-
def resolved?
|
125
|
+
def resolved?
|
113
126
|
external? || resolved_internal?
|
114
127
|
end
|
115
128
|
|
116
129
|
# Returns the destination object (+Obj+) of this Link.
|
130
|
+
# @api public
|
117
131
|
def destination_object
|
118
132
|
@destination_object ||= Obj.find(destination) if resolved_internal?
|
119
133
|
end
|
120
134
|
|
121
|
-
def to_liquid
|
135
|
+
def to_liquid
|
122
136
|
LiquidSupport::LinkDrop.new(self)
|
123
137
|
end
|
124
138
|
|
@@ -1,12 +1,15 @@
|
|
1
|
-
module RailsConnector
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# @api public
|
4
|
+
module LiquidSupport
|
2
5
|
|
3
6
|
# Usage example for actionmarkers in Liquid templates:
|
4
7
|
# {% actionmarker obj.images[0] editImageWizard param_a:value_a param_b:value_b %}
|
5
8
|
# [Edit image]
|
6
9
|
# {% endactionmarker %}
|
7
10
|
#
|
8
|
-
# The first parameter may be an instance of
|
9
|
-
# +Array+ (such as a +LinkList+ field), or
|
11
|
+
# The first parameter may be an instance of {ObjDrop} (usually +obj+ in Liquid templates),
|
12
|
+
# +Array+ (such as a +LinkList+ field), or {LinkDrop} (as in the example above).
|
10
13
|
#
|
11
14
|
# The second parameter is the action to be run on the target objects.
|
12
15
|
# Additional parameters to be forwarded to the action can be added as <tt>key:value</tt> pairs.
|
@@ -16,7 +19,8 @@ module RailsConnector::LiquidSupport
|
|
16
19
|
# Internally, the parameter <tt>:context</tt> is always set to the currently viewed object (+obj+)
|
17
20
|
# and can not be overwritten.
|
18
21
|
#
|
19
|
-
# The Liquid actionmarker uses RailsConnector::MarkerHelper#action_marker.
|
22
|
+
# The Liquid actionmarker uses {RailsConnector::MarkerHelper#action_marker}.
|
23
|
+
# @api public
|
20
24
|
class ActionMarker < Liquid::Block
|
21
25
|
def initialize(tag_name, markup, tokens)
|
22
26
|
@obj_name, @method_name = markup.to_s.split(/\s+/)
|
@@ -67,3 +71,5 @@ module RailsConnector::LiquidSupport
|
|
67
71
|
|
68
72
|
Liquid::Template.register_tag('actionmarker', ActionMarker)
|
69
73
|
end
|
74
|
+
|
75
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#:enddoc:
|
2
1
|
require 'rsolr'
|
3
2
|
|
4
3
|
module RailsConnector
|
@@ -36,7 +35,7 @@ module RailsConnector
|
|
36
35
|
end
|
37
36
|
|
38
37
|
# Removes unwanted characters from +text+.
|
39
|
-
def self.sanitize(text)
|
38
|
+
def self.sanitize(text)
|
40
39
|
text.gsub(/[^\w\*]/, ' ').gsub(/\s+/, ' ').strip
|
41
40
|
end
|
42
41
|
|
@@ -2,9 +2,10 @@ module RailsConnector
|
|
2
2
|
|
3
3
|
# This class provides methods used to retrieve objects from CMS based an entry
|
4
4
|
# in CMS of the obj_class <tt>NamedLink</tt>.
|
5
|
-
|
5
|
+
# @api public
|
6
6
|
class NamedLink < Obj
|
7
7
|
|
8
|
+
# @api public
|
8
9
|
class NotFound < StandardError
|
9
10
|
end
|
10
11
|
|
@@ -36,38 +37,40 @@ module RailsConnector
|
|
36
37
|
|
37
38
|
# Sets the time in minutes after which the cache will be expired.
|
38
39
|
# The default expiry time is set to 1 minute
|
40
|
+
# @api public
|
39
41
|
def self.cache_expiry_time=(value)
|
40
42
|
@@cache_expiry_time = value
|
41
43
|
end
|
42
44
|
|
43
|
-
def self.cache_expiry_time
|
45
|
+
def self.cache_expiry_time
|
44
46
|
@@cache_expiry_time || 1
|
45
47
|
end
|
46
48
|
|
47
|
-
def self.cache_expired?
|
49
|
+
def self.cache_expired?
|
48
50
|
@@updated_at.nil? || @@updated_at <= cache_expiry_time.minute.ago
|
49
51
|
end
|
50
52
|
|
51
53
|
# Returns the CMS object mapped to the given title or nil.
|
52
54
|
# The title can be a string of symbol.
|
53
55
|
# If :cache => false is provided, the object will not be fetched from the cache.
|
56
|
+
# @api public
|
54
57
|
def self.get_object(title, options = {})
|
55
58
|
object = named_links[title.to_s]
|
56
59
|
raise NotFound, "The NamedLink '#{title.to_s}' does not exist" if object.nil?
|
57
60
|
options[:cache] == false ? object.reload : object
|
58
61
|
end
|
59
62
|
|
60
|
-
def self.reset_cache
|
63
|
+
def self.reset_cache
|
61
64
|
@@named_links_cache = nil
|
62
65
|
end
|
63
66
|
|
64
|
-
def self.named_links
|
67
|
+
def self.named_links
|
65
68
|
reset_cache if cache_expired?
|
66
69
|
generate_named_links_cache unless named_links_cache
|
67
70
|
named_links_cache
|
68
71
|
end
|
69
72
|
|
70
|
-
def self.named_links_cache
|
73
|
+
def self.named_links_cache
|
71
74
|
@@named_links_cache
|
72
75
|
end
|
73
76
|
|
data/lib/rails_connector/news.rb
CHANGED
data/lib/rails_connector/obj.rb
CHANGED
@@ -6,7 +6,7 @@ module RailsConnector
|
|
6
6
|
#
|
7
7
|
# [children] an Array of objects, Obj, of which this one is the parent
|
8
8
|
# [parent] the Obj of which this one is a child - nil for the root object
|
9
|
-
#
|
9
|
+
# @api public
|
10
10
|
class Obj < CmsBaseModel
|
11
11
|
include AttrValueProvider
|
12
12
|
include DateAttribute
|
@@ -14,7 +14,7 @@ module RailsConnector
|
|
14
14
|
|
15
15
|
self.store_full_sti_class = false
|
16
16
|
|
17
|
-
def self.configure_for_content(which)
|
17
|
+
def self.configure_for_content(which)
|
18
18
|
case which
|
19
19
|
when :released then configure_column_information("objs", true)
|
20
20
|
when :edited
|
@@ -39,7 +39,7 @@ module RailsConnector
|
|
39
39
|
configure_for_content(:released)
|
40
40
|
|
41
41
|
# Patch to avoid a type_condition being added by ActiveRecord::Base.add_conditions! for Obj.find(params):
|
42
|
-
def self.descends_from_active_record?
|
42
|
+
def self.descends_from_active_record?
|
43
43
|
superclass == CmsBaseModel
|
44
44
|
end
|
45
45
|
|
@@ -54,15 +54,17 @@ module RailsConnector
|
|
54
54
|
# In any other case, RailsConnector::Obj is used, except when explicitely asked
|
55
55
|
# for a model in the RailsConnector namespace (RailsConnector::Permission etc.)
|
56
56
|
|
57
|
-
def self.compute_type(type_name)
|
57
|
+
def self.compute_type(type_name)
|
58
58
|
try_type { type_name.constantize } ||
|
59
59
|
self
|
60
60
|
end
|
61
61
|
|
62
|
+
# @api public
|
62
63
|
def permissions
|
63
64
|
@@use_cached_permissions ? attr_dict.permissions : super
|
64
65
|
end
|
65
66
|
|
67
|
+
# @api public
|
66
68
|
def permitted_for_user?(user)
|
67
69
|
if permitted_groups.blank?
|
68
70
|
true
|
@@ -76,22 +78,25 @@ module RailsConnector
|
|
76
78
|
end
|
77
79
|
|
78
80
|
# Returns the root Obj. Its id is 2001 and cannot be changed.
|
81
|
+
# @api public
|
79
82
|
def self.root
|
80
83
|
Obj.find(2001)
|
81
84
|
end
|
82
85
|
|
83
86
|
# Returns the homepage object. This can be overwritten in your application's +ObjExtensions+.
|
84
87
|
# Use <tt>Obj#homepage?</tt> to check if an object is the homepage.
|
88
|
+
# @api public
|
85
89
|
def self.homepage
|
86
90
|
root
|
87
91
|
end
|
88
92
|
|
89
93
|
# for testing purposes only
|
90
|
-
def self.reset_homepage
|
94
|
+
def self.reset_homepage
|
91
95
|
@@homepage_id = nil
|
92
96
|
end
|
93
97
|
|
94
98
|
# returns the obj's permalink.
|
99
|
+
# @api public
|
95
100
|
def permalink
|
96
101
|
self[:permalink]
|
97
102
|
end
|
@@ -100,6 +105,7 @@ module RailsConnector
|
|
100
105
|
# By default a controller matching the Obj's obj_class will be used.
|
101
106
|
# If the controller does not exist, the CmsController will be used as a fallback.
|
102
107
|
# Overwrite this method to force a different controller to be used.
|
108
|
+
# @api public
|
103
109
|
def controller_name
|
104
110
|
obj_class
|
105
111
|
end
|
@@ -107,19 +113,23 @@ module RailsConnector
|
|
107
113
|
# This method determines the action that should be invoked when the Obj is requested.
|
108
114
|
# The default action is 'index'.
|
109
115
|
# Overwrite this method to force a different action to be used.
|
116
|
+
# @api public
|
110
117
|
def controller_action_name
|
111
118
|
"index"
|
112
119
|
end
|
113
120
|
|
114
121
|
@@homepage_id = nil
|
122
|
+
|
115
123
|
# Returns true if the current object has the same id as the homepage object. Always use this method instead of
|
116
124
|
# manually comparing an object to <tt>Obj.homepage</tt>, as Obj#homepage? caches the object id
|
117
125
|
# and thus requires no extra database access.
|
126
|
+
# @api public
|
118
127
|
def homepage?
|
119
128
|
self.id == (@@homepage_id ||= self.class.homepage.id)
|
120
129
|
end
|
121
130
|
|
122
131
|
# Returns the title of the content or the name.
|
132
|
+
# @api public
|
123
133
|
def display_title
|
124
134
|
self.title || name
|
125
135
|
end
|
@@ -132,36 +142,43 @@ module RailsConnector
|
|
132
142
|
}.freeze unless defined?(OBJECT_TYPES)
|
133
143
|
|
134
144
|
# Returns the type of the object: :document, :publication, :image or :generic
|
145
|
+
# @api public
|
135
146
|
def object_type
|
136
147
|
OBJECT_TYPES[obj_type_code]
|
137
148
|
end
|
138
149
|
|
139
150
|
# Returns true if image? or generic?
|
151
|
+
# @api public
|
140
152
|
def binary?
|
141
153
|
[:image, :generic].include? object_type
|
142
154
|
end
|
143
155
|
|
144
156
|
# Returns true if object_type == :image
|
157
|
+
# @api public
|
145
158
|
def image?
|
146
159
|
object_type == :image
|
147
160
|
end
|
148
161
|
|
149
162
|
# Returns true if object_type == :generic
|
163
|
+
# @api public
|
150
164
|
def generic?
|
151
165
|
object_type == :generic
|
152
166
|
end
|
153
167
|
|
154
168
|
# Returns true if object_type == :publication (for folders)
|
169
|
+
# @api public
|
155
170
|
def publication?
|
156
171
|
object_type == :publication
|
157
172
|
end
|
158
173
|
|
159
174
|
# Returns true if object_type == :document
|
175
|
+
# @api public
|
160
176
|
def document?
|
161
177
|
object_type == :document
|
162
178
|
end
|
163
179
|
|
164
180
|
# Returns true if this object is active (time_when is in objects time interval)
|
181
|
+
# @api public
|
165
182
|
def active?(time_when = nil)
|
166
183
|
return false if !valid_from
|
167
184
|
time_then = time_when || Obj.preview_time
|
@@ -171,11 +188,13 @@ module RailsConnector
|
|
171
188
|
# Returns true if this object has edited content.
|
172
189
|
# Note that edited content is not available when Configuration.mode == :live
|
173
190
|
# and edited? will always return false in this case.
|
191
|
+
# @api public
|
174
192
|
def edited?
|
175
193
|
(is_edited == 1)
|
176
194
|
end
|
177
195
|
|
178
196
|
# Returns true if this object has released content
|
197
|
+
# @api public
|
179
198
|
def released?
|
180
199
|
(is_released == 1)
|
181
200
|
end
|
@@ -184,16 +203,19 @@ module RailsConnector
|
|
184
203
|
# A suppressed Obj does not represent an entire web page, but only a part of a page
|
185
204
|
# (for example a teaser) and will not be delivered by the rails application
|
186
205
|
# as a standalone web page.
|
206
|
+
# @api public
|
187
207
|
def suppressed?
|
188
208
|
suppress_export == 1
|
189
209
|
end
|
190
210
|
|
191
211
|
# Returns true if the export of the object is not suppressed and the content is active?
|
212
|
+
# @api public
|
192
213
|
def exportable?(current_time = nil)
|
193
214
|
!suppressed? && active?(current_time)
|
194
215
|
end
|
195
216
|
|
196
217
|
# Returns the file name to which the Content.file_extension has been appended.
|
218
|
+
# @api public
|
197
219
|
def filename
|
198
220
|
extension = ".#{file_extension}" unless file_extension.blank?
|
199
221
|
"#{name}#{extension}"
|
@@ -203,11 +225,13 @@ module RailsConnector
|
|
203
225
|
|
204
226
|
# Returns an array with the names of groups that are permitted to access this Obj.
|
205
227
|
# This corresponds to the cms permission "permissionLiveServerRead".
|
228
|
+
# @api public
|
206
229
|
def permitted_groups
|
207
230
|
attr_dict.permitted_groups
|
208
231
|
end
|
209
232
|
|
210
233
|
# Returns true if this object is the root object.
|
234
|
+
# @api public
|
211
235
|
def root?
|
212
236
|
parent_obj_id.nil?
|
213
237
|
end
|
@@ -217,6 +241,7 @@ module RailsConnector
|
|
217
241
|
|
218
242
|
# Returns a list of exportable? children excluding the binary? ones unless :all is specfied.
|
219
243
|
# This is mainly used for navigations.
|
244
|
+
# @api public
|
220
245
|
def toclist(*args)
|
221
246
|
return [] unless publication?
|
222
247
|
time = args.detect {|value| value.kind_of? Time}
|
@@ -226,6 +251,7 @@ module RailsConnector
|
|
226
251
|
end
|
227
252
|
|
228
253
|
# Returns the sorted +toclist+, respecting sort order and type of this Obj.
|
254
|
+
# @api public
|
229
255
|
def sorted_toclist(*args)
|
230
256
|
list = self.toclist(*args)
|
231
257
|
return [] if list.blank?
|
@@ -257,19 +283,20 @@ module RailsConnector
|
|
257
283
|
return self.sort_order == "descending" ? sorted_list.reverse : sorted_list
|
258
284
|
end
|
259
285
|
|
260
|
-
def sort_key1
|
286
|
+
def sort_key1
|
261
287
|
self[:sort_key1]
|
262
288
|
end
|
263
289
|
|
264
|
-
def sort_key2
|
290
|
+
def sort_key2
|
265
291
|
self[:sort_key2]
|
266
292
|
end
|
267
293
|
|
268
|
-
def sort_key3
|
294
|
+
def sort_key3
|
269
295
|
self[:sort_key3]
|
270
296
|
end
|
271
297
|
|
272
298
|
# Returns an Array of all the ancestor objects, starting at the root and ending at this object's parent.
|
299
|
+
# @api public
|
273
300
|
def ancestors
|
274
301
|
if parent
|
275
302
|
parent.ancestors + [parent]
|
@@ -280,6 +307,7 @@ module RailsConnector
|
|
280
307
|
|
281
308
|
# Returns the Object with the given name next in the hierarchy
|
282
309
|
# returns nil if no object with the given name was found.
|
310
|
+
# @api public
|
283
311
|
def find_nearest(name)
|
284
312
|
obj = self.children.find_by_name(name)
|
285
313
|
return obj if obj and obj.active?
|
@@ -289,6 +317,7 @@ module RailsConnector
|
|
289
317
|
# Returns the value of the attribute specified by its name.
|
290
318
|
#
|
291
319
|
# Passing an invalid key will not raise an error, but return nil.
|
320
|
+
# @api public
|
292
321
|
def [](key)
|
293
322
|
# convenience access to name
|
294
323
|
return name if key.to_sym == :name
|
@@ -313,6 +342,7 @@ module RailsConnector
|
|
313
342
|
end
|
314
343
|
|
315
344
|
# Reloads the attributes of this object from the database, invalidates custom attributes
|
345
|
+
# @api public
|
316
346
|
def reload
|
317
347
|
super
|
318
348
|
@attr_dict = nil
|
@@ -329,12 +359,14 @@ module RailsConnector
|
|
329
359
|
|
330
360
|
# object_class is a legacy alias to name. Please use obj_class instead, because only obj_class
|
331
361
|
# works with ActiveRecord's dynamic finder methods like find_by_obj_class(...)
|
362
|
+
# @api public
|
332
363
|
def object_class
|
333
364
|
obj_class
|
334
365
|
end
|
335
366
|
|
336
367
|
# for binary Objs body_length equals the file size
|
337
368
|
# for non-binary Objs body_length equals the number of characters in the body (main content)
|
369
|
+
# @api public
|
338
370
|
def body_length
|
339
371
|
attr_dict.body_length
|
340
372
|
end
|
@@ -352,28 +384,29 @@ module RailsConnector
|
|
352
384
|
#
|
353
385
|
# Note also that the url will be used regardless of the Obj's permissions, so be careful not
|
354
386
|
# to provide urls that contain unprotected secrets.
|
387
|
+
# @api public
|
355
388
|
def body_data_url
|
356
389
|
nil
|
357
390
|
end
|
358
391
|
|
359
|
-
def set_attr_values(dictionary)
|
392
|
+
def set_attr_values(dictionary)
|
360
393
|
@attr_values = dictionary
|
361
394
|
@attr_dict = nil
|
362
395
|
end
|
363
396
|
|
364
397
|
# Returns an instance of AttrDict which provides access to formatted attribute values (i.e. content).
|
365
398
|
# The method uses attr_defs to determine the right formatting depending on the particular field type.
|
366
|
-
def attr_dict
|
399
|
+
def attr_dict
|
367
400
|
@attr_dict ||= AttrDict.new(self, attr_values, attr_defs)
|
368
401
|
end
|
369
402
|
|
370
403
|
# Returns a nested hash of attribute values.
|
371
|
-
def attr_values
|
404
|
+
def attr_values
|
372
405
|
@attr_values ||= fetch_attr_values
|
373
406
|
end
|
374
407
|
|
375
408
|
# Returns a nested hash of attribute definitions.
|
376
|
-
def attr_defs
|
409
|
+
def attr_defs
|
377
410
|
@attr_defs ||= JSON.parse(read_attribute(:attr_defs) || "{}")
|
378
411
|
end
|
379
412
|
|
@@ -385,8 +418,7 @@ module RailsConnector
|
|
385
418
|
# constituting a path through the nested (hash) structures of the attribute definition (attr_defs).
|
386
419
|
#
|
387
420
|
# If the path doesn't fit the metadata structure, the method returns nil and doesn't raise an exception.
|
388
|
-
|
389
|
-
def metadata_for_field(field, *args) # :nodoc:
|
421
|
+
def metadata_for_field(field, *args)
|
390
422
|
rslt = fiona_fields[field.to_s] || attr_defs[field.to_s]
|
391
423
|
args.each do |key|
|
392
424
|
rslt = rslt[key.to_s] unless rslt.nil?
|
@@ -394,14 +426,17 @@ module RailsConnector
|
|
394
426
|
rslt
|
395
427
|
end
|
396
428
|
|
429
|
+
# @api public
|
397
430
|
def last_changed
|
398
431
|
self[:last_changed]
|
399
432
|
end
|
400
433
|
|
434
|
+
# @api public
|
401
435
|
def valid_from
|
402
436
|
self[:valid_from]
|
403
437
|
end
|
404
438
|
|
439
|
+
# @api public
|
405
440
|
def valid_until
|
406
441
|
self[:valid_until]
|
407
442
|
end
|
@@ -413,15 +448,16 @@ module RailsConnector
|
|
413
448
|
end
|
414
449
|
|
415
450
|
# Returns the MIME-type as determined from the file_extension - see MIME::Types
|
451
|
+
# @api public
|
416
452
|
def mime_type
|
417
453
|
@mime_type ||= compute_mime_type
|
418
454
|
end
|
419
455
|
|
420
|
-
def to_liquid
|
456
|
+
def to_liquid
|
421
457
|
LiquidSupport::ObjDrop.new(self)
|
422
458
|
end
|
423
459
|
|
424
|
-
def respond_to?(method_id, include_private=false)
|
460
|
+
def respond_to?(method_id, include_private=false)
|
425
461
|
if super
|
426
462
|
true
|
427
463
|
elsif %w(_attr_dict _attr_defs _attr_values).include?(method_id.to_s)
|
@@ -433,11 +469,11 @@ module RailsConnector
|
|
433
469
|
end
|
434
470
|
end
|
435
471
|
|
436
|
-
def self.preview_time=(t)
|
472
|
+
def self.preview_time=(t)
|
437
473
|
Thread.current[:preview_time] = t
|
438
474
|
end
|
439
475
|
|
440
|
-
def self.preview_time
|
476
|
+
def self.preview_time
|
441
477
|
Thread.current[:preview_time] || Time.now
|
442
478
|
end
|
443
479
|
|
@@ -2,6 +2,7 @@ module RailsConnector
|
|
2
2
|
|
3
3
|
# This class provides an implementation for accessing the Verity based search server.
|
4
4
|
# It should be customized by subclassing.
|
5
|
+
# @api public
|
5
6
|
class VeritySearchRequest
|
6
7
|
attr_reader :query_string
|
7
8
|
|
@@ -21,6 +22,7 @@ module RailsConnector
|
|
21
22
|
# <tt>:sort_order</tt>:: The sort order of the hits, a list of key-value pairs, each consisting of the sortkey and the sort direction ("asc"=ascending, "desc"=descending), default: <tt>[["score", "desc"], ["name", "asc"]]</tt>
|
22
23
|
# <tt>:collections</tt>:: The collections to be searched, default: <tt>['cm-contents']</tt>
|
23
24
|
# <tt>:base_query</tt>:: The VQL base query, default: <tt>nil</tt>
|
25
|
+
# @api public
|
24
26
|
def initialize(query_string, options=nil)
|
25
27
|
@query_string = self.class.sanitize(query_string)
|
26
28
|
@options = Configuration.search_options.merge(options || {})
|
@@ -29,12 +31,13 @@ module RailsConnector
|
|
29
31
|
# Accesses the SES and fetches search hits.
|
30
32
|
#
|
31
33
|
# Uses the #base_query and +options+ given in #new.
|
34
|
+
# @api public
|
32
35
|
def fetch_hits
|
33
36
|
SES::VerityAccessor.new(vql_query_for(@query_string), {:base_query => base_query}.merge(@options)).search
|
34
37
|
end
|
35
38
|
|
36
39
|
# Removes unwanted characters from +text+.
|
37
|
-
def self.sanitize(text)
|
40
|
+
def self.sanitize(text)
|
38
41
|
text.strip.gsub(/[<>"'´`,()\[\]{}=!@\\]/, '')
|
39
42
|
end
|
40
43
|
|
@@ -63,6 +66,7 @@ module RailsConnector
|
|
63
66
|
# super.merge(:content => '("edited" <#IN> state)'
|
64
67
|
# end
|
65
68
|
# end
|
69
|
+
# @api public
|
66
70
|
def base_query_conditions
|
67
71
|
conditions = {}
|
68
72
|
conditions[:objTypes] = '<#ANY> (
|
@@ -81,4 +85,4 @@ module RailsConnector
|
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
84
|
-
end
|
88
|
+
end
|
data/lib/rating.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_fiona_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 695044912
|
5
5
|
prerelease: 10
|
6
6
|
segments:
|
7
7
|
- 6
|
8
8
|
- 8
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
version: 6.8.0.
|
10
|
+
- 322
|
11
|
+
- c
|
12
|
+
- 3
|
13
|
+
- f
|
14
|
+
- 11
|
15
|
+
version: 6.8.0.322.c003f11
|
16
16
|
platform: ruby
|
17
17
|
authors:
|
18
18
|
- Infopark AG
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date: 2012-11-
|
23
|
+
date: 2012-11-14 00:00:00 +01:00
|
24
24
|
default_executable:
|
25
25
|
dependencies:
|
26
26
|
- !ruby/object:Gem::Dependency
|
@@ -76,9 +76,11 @@ executables: []
|
|
76
76
|
|
77
77
|
extensions: []
|
78
78
|
|
79
|
-
extra_rdoc_files:
|
80
|
-
|
79
|
+
extra_rdoc_files: []
|
80
|
+
|
81
81
|
files:
|
82
|
+
- .yardopts
|
83
|
+
- README
|
82
84
|
- app/helpers/rails_connector/marker_helper.rb
|
83
85
|
- lib/comment.rb
|
84
86
|
- lib/infopark_fiona_connector.rb
|
@@ -107,18 +109,13 @@ files:
|
|
107
109
|
- lib/rails_connector/ses/verity_accessor.rb
|
108
110
|
- lib/rails_connector/verity_search_request.rb
|
109
111
|
- lib/rating.rb
|
110
|
-
|
111
|
-
has_rdoc: true
|
112
|
+
has_rdoc: yard
|
112
113
|
homepage: http://www.infopark.de
|
113
114
|
licenses: []
|
114
115
|
|
115
116
|
post_install_message:
|
116
|
-
rdoc_options:
|
117
|
-
|
118
|
-
- --title
|
119
|
-
- Infopark Fiona Connector
|
120
|
-
- --main
|
121
|
-
- README
|
117
|
+
rdoc_options: []
|
118
|
+
|
122
119
|
require_paths:
|
123
120
|
- lib
|
124
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|