infopark_fiona_connector 7.0.1.beta2 → 7.0.1.5.2.3.rc7

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