infopark_rails_connector 6.8.0.beta.200.621.4c8e1b0

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.
Files changed (184) hide show
  1. data/README +59 -0
  2. data/app/assets/images/admin/minus.gif +0 -0
  3. data/app/assets/images/bg80.png +0 -0
  4. data/app/assets/images/edit.png +0 -0
  5. data/app/assets/images/icons/mm_generic.png +0 -0
  6. data/app/assets/images/icons/mm_menu.png +0 -0
  7. data/app/assets/images/ratings/star.gif +0 -0
  8. data/app/assets/images/time_machine/calendar-menuarrow.gif +0 -0
  9. data/app/assets/images/time_machine/calendar_bg.png +0 -0
  10. data/app/assets/images/time_machine/icon.png +0 -0
  11. data/app/assets/images/time_machine/slider_bg.png +0 -0
  12. data/app/assets/images/time_machine/slider_handle.png +0 -0
  13. data/app/assets/images/time_machine/timemachine_bg.png +0 -0
  14. data/app/assets/javascripts/comments.js +29 -0
  15. data/app/assets/javascripts/editmarker.js +240 -0
  16. data/app/assets/javascripts/infopark_rails_connector.js.erb +3 -0
  17. data/app/assets/javascripts/initializer.js +9 -0
  18. data/app/assets/javascripts/ratings.js +26 -0
  19. data/app/assets/javascripts/time_machine/calendar-setup.js +200 -0
  20. data/app/assets/javascripts/time_machine/calendar.js +1806 -0
  21. data/app/assets/javascripts/time_machine/lang/calendar-de.js +127 -0
  22. data/app/assets/javascripts/time_machine/lang/calendar-en.js +127 -0
  23. data/app/assets/javascripts/time_machine/lang/calendar-es.js +129 -0
  24. data/app/assets/javascripts/time_machine/lang/calendar-fr.js +125 -0
  25. data/app/assets/javascripts/time_machine/lang/calendar-it.js +124 -0
  26. data/app/assets/javascripts/time_machine/slider.js +278 -0
  27. data/app/assets/javascripts/time_machine.js +8 -0
  28. data/app/assets/stylesheets/editmarker.css +70 -0
  29. data/app/assets/stylesheets/infopark_rails_connector.css.erb +4 -0
  30. data/app/assets/stylesheets/ratings.css +97 -0
  31. data/app/assets/stylesheets/time_machine/time_machine.css +292 -0
  32. data/app/assets/stylesheets/time_machine.css +6 -0
  33. data/app/controllers/cms_controller.rb +6 -0
  34. data/app/controllers/comments_controller.rb +6 -0
  35. data/app/controllers/crm_form_controller.rb +2 -0
  36. data/app/controllers/pdf_controller.rb +6 -0
  37. data/app/controllers/rails_connector/default_cms_controller.rb +40 -0
  38. data/app/controllers/rails_connector/default_comments_controller.rb +71 -0
  39. data/app/controllers/rails_connector/default_crm_form_controller.rb +167 -0
  40. data/app/controllers/rails_connector/default_pdf_controller.rb +136 -0
  41. data/app/controllers/rails_connector/default_ratings_controller.rb +84 -0
  42. data/app/controllers/rails_connector/default_rss_controller.rb +29 -0
  43. data/app/controllers/rails_connector/default_search_controller.rb +60 -0
  44. data/app/controllers/rails_connector/default_user_controller.rb +267 -0
  45. data/app/controllers/rails_connector/pdf_external_controller.rb +54 -0
  46. data/app/controllers/rails_connector/time_machine_controller.rb +48 -0
  47. data/app/controllers/ratings_controller.rb +6 -0
  48. data/app/controllers/rss_controller.rb +6 -0
  49. data/app/controllers/search_controller.rb +2 -0
  50. data/app/controllers/seo_sitemap_controller.rb +12 -0
  51. data/app/controllers/user_controller.rb +2 -0
  52. data/app/helpers/cms_helper.rb +6 -0
  53. data/app/helpers/cms_routing_helper.rb +6 -0
  54. data/app/helpers/crm_form_helper.rb +3 -0
  55. data/app/helpers/rails_connector/cms_asset_helper.rb +51 -0
  56. data/app/helpers/rails_connector/default_cms_helper.rb +27 -0
  57. data/app/helpers/rails_connector/default_cms_routing_helper.rb +93 -0
  58. data/app/helpers/rails_connector/default_crm_form_helper.rb +58 -0
  59. data/app/helpers/rails_connector/default_ratings_helper.rb +38 -0
  60. data/app/helpers/rails_connector/default_user_helper.rb +90 -0
  61. data/app/helpers/rails_connector/display_helper.rb +117 -0
  62. data/app/helpers/rails_connector/error_messages_helper.rb +23 -0
  63. data/app/helpers/rails_connector/layout_helper.rb +30 -0
  64. data/app/helpers/rails_connector/link_helper.rb +88 -0
  65. data/app/helpers/rails_connector/mandatory_label_helper.rb +10 -0
  66. data/app/helpers/rails_connector/marker_helper.rb +363 -0
  67. data/app/helpers/rails_connector/menu_helper.rb +72 -0
  68. data/app/helpers/rails_connector/micronav_helper.rb +107 -0
  69. data/app/helpers/rails_connector/seo_helper.rb +44 -0
  70. data/app/helpers/rails_connector/table_of_contents_helper.rb +20 -0
  71. data/app/helpers/rails_connector/time_machine_helper.rb +24 -0
  72. data/app/helpers/rails_connector/tracking_helper.rb +32 -0
  73. data/app/helpers/ratings_helper.rb +4 -0
  74. data/app/helpers/user_helper.rb +3 -0
  75. data/app/mailers/confirmation_mailer.rb +13 -0
  76. data/app/models/crm_form.rb +2 -0
  77. data/app/models/named_link.rb +2 -0
  78. data/app/models/obj.rb +9 -0
  79. data/app/models/rails_connector/default_comment.rb +28 -0
  80. data/app/models/rails_connector/default_rating.rb +20 -0
  81. data/app/models/rails_connector/link_list.rb +30 -0
  82. data/app/views/cms/_comments.html.erb +44 -0
  83. data/app/views/cms/_index.html.erb +7 -0
  84. data/app/views/cms/_rating.html.erb +31 -0
  85. data/app/views/cms/index.html.erb +3 -0
  86. data/app/views/comments/_comment.html.erb +28 -0
  87. data/app/views/confirmation_mailer/register_confirmation.erb +5 -0
  88. data/app/views/confirmation_mailer/reset_password.erb +5 -0
  89. data/app/views/crm_form/_flash_messages.html.erb +11 -0
  90. data/app/views/crm_form/_form.html.erb +17 -0
  91. data/app/views/crm_form/confirmation.html.erb +3 -0
  92. data/app/views/crm_form/index.html.erb +5 -0
  93. data/app/views/crm_form/not_logged_in.html.erb +1 -0
  94. data/app/views/errors/403_forbidden.html.erb +3 -0
  95. data/app/views/errors/410_gone.html.erb +7 -0
  96. data/app/views/layouts/rails_connector/time_machine.html.erb +12 -0
  97. data/app/views/pdf/index.html.erb +7 -0
  98. data/app/views/pdf/index.xsl +1240 -0
  99. data/app/views/rails_connector/time_machine/index.html.erb +88 -0
  100. data/app/views/rss/_item.rss.builder +11 -0
  101. data/app/views/rss/index.rss.builder +11 -0
  102. data/app/views/search/_hit.html.erb +12 -0
  103. data/app/views/search/_hits.html.erb +11 -0
  104. data/app/views/search/_mini_panel.html.erb +4 -0
  105. data/app/views/search/_pagination.html.erb +5 -0
  106. data/app/views/search/_panel.html.erb +4 -0
  107. data/app/views/search/search.html.erb +12 -0
  108. data/app/views/seo_sitemap/show.xml.builder +16 -0
  109. data/app/views/user/_flash_messages.html.erb +11 -0
  110. data/app/views/user/edit.html.erb +6 -0
  111. data/app/views/user/edit_password.html.erb +11 -0
  112. data/app/views/user/forgot_password.html.erb +7 -0
  113. data/app/views/user/login.html.erb +15 -0
  114. data/app/views/user/new.html.erb +11 -0
  115. data/app/views/user/profile.html.erb +8 -0
  116. data/app/views/user/register_pending.html.erb +1 -0
  117. data/app/views/user/set_password.html.erb +14 -0
  118. data/config/cms_routes.rb +13 -0
  119. data/config/locales/de.rails_connector.controllers.yml +30 -0
  120. data/config/locales/de.rails_connector.errors.yml +11 -0
  121. data/config/locales/de.rails_connector.helpers.yml +9 -0
  122. data/config/locales/de.rails_connector.lib.yml +6 -0
  123. data/config/locales/de.rails_connector.models.yml +8 -0
  124. data/config/locales/de.rails_connector.views.yml +87 -0
  125. data/config/locales/en.rails_connector.controllers.yml +30 -0
  126. data/config/locales/en.rails_connector.errors.yml +10 -0
  127. data/config/locales/en.rails_connector.helpers.yml +9 -0
  128. data/config/locales/en.rails_connector.lib.yml +6 -0
  129. data/config/locales/en.rails_connector.models.yml +8 -0
  130. data/config/locales/en.rails_connector.views.yml +87 -0
  131. data/config/routes.rb +37 -0
  132. data/lib/generators/rails_connector/comments/comments_generator.rb +21 -0
  133. data/lib/generators/rails_connector/comments/templates/migration.rb +17 -0
  134. data/lib/generators/rails_connector/install/install_generator.rb +38 -0
  135. data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +58 -0
  136. data/lib/generators/rails_connector/install/templates/local/configuration.rb +2 -0
  137. data/lib/generators/rails_connector/install/templates/obj_extensions.rb +25 -0
  138. data/lib/generators/rails_connector/ratings/ratings_generator.rb +21 -0
  139. data/lib/generators/rails_connector/ratings/templates/migration.rb +15 -0
  140. data/lib/infopark_rails_connector.rb +31 -0
  141. data/lib/obj_extensions.rb +6 -0
  142. data/lib/rails_connector/authenticable.rb +30 -0
  143. data/lib/rails_connector/cms_accessible.rb +114 -0
  144. data/lib/rails_connector/cms_dispatch_controller.rb +47 -0
  145. data/lib/rails_connector/cms_env.rb +55 -0
  146. data/lib/rails_connector/cms_test_request.rb +23 -0
  147. data/lib/rails_connector/commentable.rb +23 -0
  148. data/lib/rails_connector/configuration/google_analytics.rb +29 -0
  149. data/lib/rails_connector/configuration/pdf_generator.rb +15 -0
  150. data/lib/rails_connector/configuration/rss.rb +46 -0
  151. data/lib/rails_connector/configuration.rb +235 -0
  152. data/lib/rails_connector/core_extensions/time.rb +18 -0
  153. data/lib/rails_connector/core_extensions.rb +1 -0
  154. data/lib/rails_connector/crm.rb +282 -0
  155. data/lib/rails_connector/engine.rb +78 -0
  156. data/lib/rails_connector/fop.rb +18 -0
  157. data/lib/rails_connector/fop_on_rails/document/dom_tree.rb +42 -0
  158. data/lib/rails_connector/fop_on_rails/document/images.rb +34 -0
  159. data/lib/rails_connector/fop_on_rails/document/tables.rb +67 -0
  160. data/lib/rails_connector/fop_on_rails/document.rb +25 -0
  161. data/lib/rails_connector/fop_on_rails.rb +92 -0
  162. data/lib/rails_connector/googlebot_checker.rb +47 -0
  163. data/lib/rails_connector/html_string.rb +19 -0
  164. data/lib/rails_connector/infopark_base.rb +2 -0
  165. data/lib/rails_connector/link_resolvable.rb +9 -0
  166. data/lib/rails_connector/liquid_support/action_marker.rb +69 -0
  167. data/lib/rails_connector/liquid_support/field_value_drop.rb +22 -0
  168. data/lib/rails_connector/liquid_support/general_helper_tag.rb +44 -0
  169. data/lib/rails_connector/liquid_support/link_drop.rb +22 -0
  170. data/lib/rails_connector/liquid_support/liquid_template_handler.rb +162 -0
  171. data/lib/rails_connector/liquid_support/named_object_drop.rb +14 -0
  172. data/lib/rails_connector/liquid_support/obj_drop.rb +43 -0
  173. data/lib/rails_connector/liquid_support/obj_filters.rb +77 -0
  174. data/lib/rails_connector/liquid_support.rb +23 -0
  175. data/lib/rails_connector/markdown_string.rb +19 -0
  176. data/lib/rails_connector/rateable.rb +57 -0
  177. data/lib/rails_connector/seo.rb +52 -0
  178. data/lib/rails_connector/ses.rb +72 -0
  179. data/lib/rails_connector/string_tagging.rb +29 -0
  180. data/lib/rails_connector/syndicateable.rb +11 -0
  181. data/lib/search_request.rb +2 -0
  182. data/lib/tasks/check.rake +25 -0
  183. data/lib/tasks/cms_license_check.rake +17 -0
  184. metadata +489 -0
@@ -0,0 +1,363 @@
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("&nbsp;") 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 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
@@ -0,0 +1,72 @@
1
+ module RailsConnector
2
+
3
+ # This module contains helpers that can be used to build all kinds of menus.
4
+ module MenuHelper
5
+ include DisplayHelper
6
+
7
+ # The <tt>build_menu</tt> method should serve as an example of how to build navigational
8
+ # menus using Infopark Rails Connector. If you need to extend this method, copy it into
9
+ # the relevant helper for your application.
10
+ #
11
+ # Example 1 - Single-tier menu:
12
+ #
13
+ # build_menu(Obj.find(123), nil, :id => "menu")
14
+ #
15
+ # produces:
16
+ #
17
+ # <ul id="menu">
18
+ # <li>
19
+ # <a href="path/to/history">History</a>
20
+ # </li>
21
+ # <li>
22
+ # <a href="path/to/services">Services</a>
23
+ # </li>
24
+ # </ul>
25
+ #
26
+ # <tt>build_menu</tt> also takes a block so you can use it recursively for multiple levels
27
+ # (<tt>current_page</tt> returns the Obj for "Insurance" in this example):
28
+ #
29
+ # Example 2 - Two-tier Menu:
30
+ #
31
+ # build_menu(Obj.find(123), current_page, :id => "main_menu") do |entry|
32
+ # build_menu(entry, current_page, :id => "sub_menu")
33
+ # end
34
+ #
35
+ # produces:
36
+ #
37
+ # <ul id="main_menu">
38
+ # <li>
39
+ # <a href="path/to/history">History</a>
40
+ # </li>
41
+ # <li>
42
+ # <a href="path/to/products">Services</a>
43
+ # <ul id="sub_menu">
44
+ # <li>
45
+ # <a href="path/to/products/insurance">Insurance</a>
46
+ # </li>
47
+ # <li>
48
+ # <a href="path/to/products/finance">Finance</a>
49
+ # </li>
50
+ # </ul>
51
+ # </li>
52
+ # </ul>
53
+ #
54
+
55
+ def build_menu(start_obj, current_obj, html_options, &block)
56
+ children = table_of_contents(start_obj)
57
+ content_tag(:ul, html_options) do
58
+ content = "".html_safe
59
+ children.each do |child|
60
+ content << content_tag(:li) do
61
+ list_entry = link_to(child.display_title, cms_path(child))
62
+ list_entry += block.call(child) if block_given? && current_obj &&
63
+ (current_obj == child || current_obj.ancestors.include?(child))
64
+ list_entry
65
+ end
66
+ end
67
+ content
68
+ end
69
+ end
70
+ end
71
+
72
+ end
@@ -0,0 +1,107 @@
1
+ module RailsConnector
2
+
3
+ # This module contains a helper that can be used to build a micronavigation.
4
+ module MicronavHelper
5
+
6
+ # Generates a micronavigation by producing HTML markup.
7
+ # <em>obj</em> becomes the rightmost Obj in the micronavigation since it is the one
8
+ # for which the micronavigation is built. Assume that all the ancestors of this obj are
9
+ # available as an array starting with the root object at index 1.
10
+ # The following <em>options</em> exist:
11
+ #
12
+ # [:start] index of the ancestor object to start with. Default is 1, i.e. the object Obj::root.
13
+ # [:micronav_id] ID of the micronavigation. Default is 'micronav'.
14
+ #
15
+ # All ancestors of <em>obj</em> are linked to the respective objects. <em>obj</em>
16
+ # has no linkage. The first and the last <tt><li></tt> tags have apropriate CSS classes.
17
+ #
18
+ # For example, assume that you have the following object hierarchy:
19
+ #
20
+ # * Root
21
+ # * Ancestor_1
22
+ # * Ancestor_2
23
+ # * Current_Object
24
+ #
25
+ # Normal usage with the context Obj set to <tt>@obj</tt>:
26
+ #
27
+ # <%= micronav(@obj) %>
28
+ #
29
+ # The helper will start with the Root and will generate the follwing HTML if <tt>@obj</tt> is set to Current_Object:
30
+ #
31
+ # <ul id='micronav'>
32
+ # <li class='first'>
33
+ # <a href='/2001/Root'>
34
+ # Root
35
+ # </a>
36
+ # </li>
37
+ # <li>
38
+ # <a href='/2011/Ancestor_1'>
39
+ # Ancestor_1
40
+ # </a>
41
+ # </li>
42
+ # <li>
43
+ # <a href='/2012/Ancestor_2'>
44
+ # Ancestor_2
45
+ # </a>
46
+ # </li>
47
+ # <li class='last'>
48
+ # <span>
49
+ # Current_Object
50
+ # </span>
51
+ # </li>
52
+ # </ul>
53
+ #
54
+ # If the <tt>:start</tt> option is set to 2
55
+ #
56
+ # <%= micronav(@obj, :start => 2) %>
57
+ #
58
+ # then the helper will start with Ancestor_1 and will generate:
59
+ #
60
+ # <ul id='micronav'>
61
+ # <li class='first'>
62
+ # <a href='/2011/Ancestor_1'>
63
+ # Ancestor_1
64
+ # </a>
65
+ # </li>
66
+ # <li>
67
+ # <a href='/2012/Ancestor_2'>
68
+ # Ancestor_2
69
+ # </a>
70
+ # </li>
71
+ # <li class='last'>
72
+ # <span>
73
+ # Current_Object
74
+ # </span>
75
+ # </li>
76
+ # </ul>
77
+ #
78
+ # If you specify the <tt>:micronav_id</tt> option as in
79
+ #
80
+ # <%= micronav(@obj, :micronav_id => '<em><b>micronav_below_banner</b></em>') %>
81
+ #
82
+ # then the <tt><ul></tt> tag of the micronavigation will get your custom ID:
83
+ #
84
+ # <ul id='<em><b>micronav_below_banner</b></em>'></tt>
85
+ # ...
86
+ # </ul>
87
+ def micronav(obj, options = {})
88
+ options.reverse_merge!({:start => 1, :micronav_id => 'micronav'})
89
+ ancestors = obj.ancestors
90
+ start = options[:start] - 1
91
+ start = 0 if start < 0
92
+ ancestors = ancestors[start..-1]
93
+ ancestors ||= []
94
+ li_tags = "".html_safe
95
+ ancestors.each do |ancestor|
96
+ tag_options = {}
97
+ tag_options[:class] = "first" if li_tags.empty?
98
+ li_tags << content_tag(:li, link_to(display_value(ancestor.display_title), cms_path(ancestor)), tag_options)
99
+ end
100
+ li_tags << content_tag(:li, content_tag(:span, display_value(obj.display_title)), :class => 'last')
101
+ content_tag(:ul, li_tags, :id => options[:micronav_id])
102
+ end
103
+
104
+ include DisplayHelper
105
+ end
106
+
107
+ end
@@ -0,0 +1,44 @@
1
+ module RailsConnector
2
+
3
+ # This helper provides methods for Search Engine Optimization.
4
+ module SeoHelper
5
+
6
+ # Generate search engine optimized meta tags for the html head.
7
+ #
8
+ # Example:
9
+ #
10
+ # seo_header_tags(
11
+ # :company_name => 'Infopark AG',
12
+ # :default_keywords => 'default, key, words',
13
+ # :default_description => 'one description for all views using this layout'
14
+ # )
15
+ #
16
+ # # =>
17
+ #
18
+ # <title>Dialog im Web. | Infopark AG</title>
19
+ # <meta name="description" content="SEO description of the current page" />
20
+ # <meta content="default, key, words" name="keywords" />
21
+ # <meta content="Rails Connector for Infopark CMS Fiona by Infopark AG (www.infopark.de); Version 6.7.1" name="generator" />
22
+ # <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
23
+ # <link href="http://test.host/2001/basisordner" rel="canonical" />
24
+ def seo_header_tags(options = {})
25
+ html = content_tag('title', [@obj && @obj.display_title, options[:company_name]].compact.join(' | '))
26
+ html += tag('meta', :name => 'description', :content => @obj && @obj.seo_description || options[:default_description])
27
+ html += tag('meta', :name => 'keywords', :content => seo_keywords(options))
28
+ html += tag('meta', 'http-equiv' => "Content-Type", :content => "text/html; charset=utf-8")
29
+ html += tag('link', :rel => 'canonical', :href => canonical_url) if @obj
30
+ html
31
+ end
32
+
33
+ private
34
+
35
+ def seo_keywords(options)
36
+ (@obj && @obj.seo_keywords.to_s.strip).blank? ? options[:default_keywords] : @obj.seo_keywords.strip
37
+ end
38
+
39
+ def canonical_url
40
+ cms_path_or_url_for_objs(@obj, :url, :protocol => request.ssl? ? 'https' : 'http')
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,20 @@
1
+ module RailsConnector
2
+
3
+ #
4
+ # This module contains a helper that can be used to build a table of contents of an object.
5
+ #
6
+ module TableOfContentsHelper
7
+
8
+ #
9
+ # The <tt>table_of_contents</tt> helper method gets an object as argument and returns an array,
10
+ # which can be used as the table of contents of the given object.
11
+ #
12
+ # The returned array consists of the child objects of the given object.
13
+ # The array is sorted according to the configured sort order and the sort keys.
14
+ # It also contains only objects which the current user is permitted to view.
15
+ #
16
+ def table_of_contents(obj)
17
+ obj.sorted_toclist.reject { |o| not o.permitted_for_user?(current_user) }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ module RailsConnector
2
+
3
+ # A helper to access the preview time machine.
4
+ module TimeMachineHelper
5
+
6
+ # Renders a link to open the time machine.
7
+ def time_machine_link(content)
8
+ if Configuration.enabled?(:time_machine) && Configuration.editor_interface_enabled?
9
+ (<<-EOF).html_safe
10
+ #{link_to_function content, "window.open('#{time_machine_url :action => 'index'}', 'time_machine', 'height=350,location=no,menubar=no,status=no,toolbar=no,width=500')"}
11
+ <script type="text/javascript">
12
+ // <!--
13
+ function sendRequest(url)
14
+ {
15
+ jQuery.getScript(url);
16
+ }
17
+ // -->
18
+ </script>
19
+ EOF
20
+ end
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,32 @@
1
+ module RailsConnector
2
+
3
+ # This module contains helpers for Google Analytics and Infopark Tracking.
4
+ module TrackingHelper
5
+
6
+ # This helper renders the Google Analytics snippet using the domain code
7
+ # for the current domain as configured via <tt>Configuration::GoogleAnalytics.domain_code</tt>.
8
+ # The helper is automatically run when using the +rails_connector_after_content_tags+,
9
+ # if the feature <tt>:google_analytics</tt> is enabled.
10
+ def google_analytics
11
+ if domain_code = Configuration::GoogleAnalytics.domain_code(request.host)
12
+ raw %Q{
13
+ <script type="text/javascript" src='#{ga_prefix}google-analytics.com/ga.js'></script>
14
+ <script type="text/javascript">
15
+ try {
16
+ var pageTracker = _gat._getTracker("#{domain_code}");
17
+ pageTracker._setAllowAnchor(true);
18
+ pageTracker._addIgnoredOrganic("#{request.host}");
19
+ pageTracker._trackPageview();
20
+ } catch(err) {}
21
+ </script>
22
+ }
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def ga_prefix
29
+ request.ssl? ? 'https://ssl.' : 'http://www.'
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ # This helper includes RailsConnector::DefaultRatingsHelper
2
+ module RatingsHelper
3
+ include RailsConnector::DefaultRatingsHelper
4
+ end
@@ -0,0 +1,3 @@
1
+ module UserHelper
2
+ include RailsConnector::DefaultUserHelper
3
+ end