infopark_cloud_connector 6.9.4 → 6.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +15 -0
  2. data/README +1 -3
  3. data/app/controllers/cms_controller.rb +7 -0
  4. data/app/controllers/rails_connector/default_cms_controller.rb +43 -0
  5. data/app/controllers/rails_connector/objs_controller.rb +29 -0
  6. data/app/controllers/rails_connector/widget_renderer.rb +1 -1
  7. data/app/controllers/rails_connector/workspaces_controller.rb +4 -0
  8. data/app/helpers/cms_helper.rb +7 -0
  9. data/app/helpers/cms_routing_helper.rb +7 -0
  10. data/app/helpers/rails_connector/cms_asset_helper.rb +24 -17
  11. data/app/helpers/rails_connector/cms_tag_helper.rb +9 -6
  12. data/app/helpers/rails_connector/default_cms_helper.rb +23 -0
  13. data/app/helpers/rails_connector/default_cms_routing_helper.rb +101 -0
  14. data/app/helpers/rails_connector/display_helper.rb +4 -30
  15. data/app/helpers/rails_connector/editing_helper.rb +3 -0
  16. data/app/helpers/rails_connector/layout_helper.rb +29 -0
  17. data/app/helpers/rails_connector/table_of_contents_helper.rb +22 -0
  18. data/app/models/named_link.rb +2 -0
  19. data/app/views/cms/_index.html.erb +7 -0
  20. data/app/views/cms/index.html.erb +1 -0
  21. data/app/views/errors/403_forbidden.html.erb +3 -0
  22. data/app/views/errors/410_gone.html.erb +7 -0
  23. data/app/views/rails_connector/_editing_javascript.html.erb +2 -0
  24. data/config/ca-bundle.crt +1 -1
  25. data/config/cms_routes.rb +14 -0
  26. data/config/locales/de.rails_connector.errors.yml +11 -0
  27. data/config/locales/de.rails_connector.lib.yml +6 -0
  28. data/config/locales/de.rails_connector.views.yml +9 -0
  29. data/config/locales/en.rails_connector.errors.yml +10 -0
  30. data/config/locales/en.rails_connector.lib.yml +6 -0
  31. data/config/locales/en.rails_connector.views.yml +9 -0
  32. data/config/routes.rb +4 -0
  33. data/lib/assets/javascripts/infopark_editing.js +689 -285
  34. data/lib/assets/stylesheets/infopark_editing.css +17 -0
  35. data/lib/infopark_cloud_connector.rb +22 -0
  36. data/lib/obj.rb +3 -0
  37. data/lib/rails_connector/attribute_content.rb +190 -0
  38. data/lib/rails_connector/authenticable.rb +30 -0
  39. data/lib/rails_connector/basic_obj.rb +25 -139
  40. data/lib/rails_connector/basic_widget.rb +35 -0
  41. data/lib/rails_connector/cms_accessible.rb +114 -0
  42. data/lib/rails_connector/cms_cache_storage.rb +1 -1
  43. data/lib/rails_connector/cms_dispatch_controller.rb +46 -0
  44. data/lib/rails_connector/cms_env.rb +68 -0
  45. data/lib/rails_connector/cms_test_request.rb +23 -0
  46. data/lib/rails_connector/configuration.rb +3 -2
  47. data/lib/rails_connector/core_extensions.rb +1 -0
  48. data/lib/rails_connector/core_extensions/time.rb +18 -0
  49. data/lib/rails_connector/date_attribute.rb +1 -17
  50. data/lib/rails_connector/engine.rb +57 -0
  51. data/lib/rails_connector/html_string.rb +19 -0
  52. data/lib/rails_connector/link.rb +102 -17
  53. data/lib/rails_connector/link_resolvable.rb +9 -0
  54. data/lib/rails_connector/migrations/migrator.rb +8 -4
  55. data/lib/rails_connector/migrations/workspace_lock.rb +3 -2
  56. data/lib/rails_connector/named_link.rb +1 -1
  57. data/lib/rails_connector/obj_data_from_service.rb +18 -0
  58. data/lib/rails_connector/string_tagging.rb +29 -0
  59. data/lib/rails_connector/type_computer.rb +30 -0
  60. data/lib/widget.rb +3 -0
  61. metadata +103 -18
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjQxZDQ1MTE2NzI2YjU3MTQ3Zjg0MDY0MWFjZDEyZTE4Y2Q0MzQzMg==
5
+ data.tar.gz: !binary |-
6
+ YmNmZjYwMGZiYWRmZjRmODEzNGZlNGEwMWY4YmVlOTIyOTBiOTZjNA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Mzk1OGU2Y2FjNmY0Mzc4ZDA5MmFhOTVkZDI4ZWQ0ZjA2YjI0NmEyNjYzZDMw
10
+ MDRiNzIwNDNjMzhkZjI4MDJjNTliNDI0NDg5ZDM3NzllOTBiNDcwZjg3NjQy
11
+ ODI5NGNhZjNhMzQ0MzgzNTE3MDVjMGRlMzg3NzUwMDM2MDU2MDU=
12
+ data.tar.gz: !binary |-
13
+ ZmNiYjYyMTkzY2M3NzkzYTcwM2NlODk0YjRlNDExZDQ2MzM2ZTA0ZDc3M2U2
14
+ YmRlM2EyNTUzNzlmMGJlOTg4YzA2NjhjOGNhNzFiOWNlMDhhMzEyNDVjNDg5
15
+ N2QyNWI0MjhmZDU2OTFhZWZkMTkzOGZlYzA4NmNjOGMzMjFkNTc=
data/README CHANGED
@@ -1,7 +1,5 @@
1
1
  = Infopark Cloud Connector
2
2
 
3
- Infopark Cloud Connector is part of {https://rubygems.org/gems/infopark_rails_connector Infopark Rails Connector}.
4
-
5
3
  The Cloud Connector makes CMS objects maintained by means of the cloud-based Infopark CMS available to your Rails application. It offers easy-to-use functionality for rendering CMS content, doing searches, etc.
6
4
 
7
- For more information about Infopark Rails and Cloud Connector, please visit {http://dev.infopark.net/ the Infopark Dev Center}. For details regarding recent changes to the Infopark CMS and the Cloud Connector can be found in our {http://dev.infopark.net/blog Dev Center Blog}.
5
+ For more information about Infopark Cloud Connector, please visit {http://dev.infopark.net/ the Infopark Dev Center}. For details regarding recent changes to the Infopark CMS and the Cloud Connector can be found in our {http://dev.infopark.net/blog Dev Center Blog}.
@@ -0,0 +1,7 @@
1
+ # This controller inherits all of its behavior from
2
+ # {RailsConnector::DefaultCmsController}.
3
+ #
4
+ # {CmsController} is referenced by the Rails Connector routes.
5
+ # @api public
6
+ class CmsController < RailsConnector::DefaultCmsController
7
+ end
@@ -0,0 +1,43 @@
1
+ module RailsConnector
2
+
3
+ # This controller provides some default includes ({CmsAccessible}),
4
+ # before filters (+load_object+, among others), and actions to simplify
5
+ # CMS object handling. It should never be used directly, but only as a
6
+ # super class to {CmsController}.
7
+ # @api public
8
+ class DefaultCmsController < ApplicationController
9
+ 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
14
+
15
+ # Default Action. Delivers files directly if their mime type is not text/html
16
+ # @api public
17
+ def index
18
+ deliver_file if @obj.mime_type != "text/html"
19
+ end
20
+
21
+ # Toggles edit markers. The current status is stored in the session.
22
+ # @api public
23
+ def toggle_editmarkers
24
+ session[:hide_editmarkers] = !session[:hide_editmarkers]
25
+ redirect_to cms_id_url(@obj)
26
+ end
27
+
28
+ # This method indicates if this controller should be used automatically when an Obj is
29
+ # requested via the Rails Connector's standard routes. It returns true by default.
30
+ #
31
+ # Overwrite it to return false if you do want your controller to be excluded from Obj dispatching.
32
+ #
33
+ # You may also implement a method with the name {use_for_obj_dispatch?} in controllers not
34
+ # descending from {DefaultCmsController} to include them in Obj dispatching.
35
+ #
36
+ # @see Obj#controller_name
37
+ # @api public
38
+ def self.use_for_obj_dispatch?
39
+ true
40
+ end
41
+ end
42
+
43
+ end
@@ -33,6 +33,16 @@ module RailsConnector
33
33
  render json: {}
34
34
  end
35
35
 
36
+ def copy
37
+ render json: copy_obj(get_obj_attributes(params[:id]), params[:parent_path])
38
+ end
39
+
40
+ def duplicate
41
+ attributes = get_obj_attributes(params[:id])
42
+
43
+ render json: copy_obj(attributes, parent_path(attributes['_path']))
44
+ end
45
+
36
46
  def page_class_selection
37
47
  valid_page_classes = Obj.valid_page_classes_beneath(params[:parent_path]) || all_page_classes
38
48
  valid_page_classes.map!(&:to_s)
@@ -104,6 +114,25 @@ module RailsConnector
104
114
  end
105
115
  end
106
116
 
117
+ def copy_obj(copied_attributes, target_path=nil)
118
+ copied_attributes.delete('id')
119
+ copied_attributes.delete('_last_changed')
120
+
121
+ copied_attributes['_path'] = "#{target_path}/#{SecureRandom.hex(6)}"
122
+
123
+ CmsRestApi.task_unaware_request(
124
+ :post, "revisions/#{Workspace.current.revision_id}/objs", obj: copied_attributes)
125
+ end
126
+
127
+ def get_obj_attributes(id)
128
+ CmsRestApi.task_unaware_request(
129
+ :get, "revisions/#{Workspace.current.revision_id}/objs/#{id}")
130
+ end
131
+
132
+ def parent_path(path)
133
+ path.split('/')[0..-2].join('/')
134
+ end
135
+
107
136
  def current_page
108
137
  Obj.find(params[:current_page_id]) if params[:current_page_id].present?
109
138
  end
@@ -31,7 +31,7 @@ class WidgetRenderer < AbstractController::Base
31
31
  rescue ActionView::MissingTemplate => e
32
32
  view_context.widget_thumbnail(
33
33
  widget_dir.titleize,
34
- 'thumbnail.html.erb does not existing. Please provide one.',
34
+ 'thumbnail.html.erb does not exist. Please provide one.',
35
35
  view_context.image_tag('180x120.gif')
36
36
  )
37
37
  end
@@ -25,6 +25,10 @@ module RailsConnector
25
25
  render json: CmsRestApi.task_unaware_request(:put, "workspaces/#{params[:id]}/publish", {})
26
26
  end
27
27
 
28
+ def rebase
29
+ render json: CmsRestApi.task_unaware_request(:put, "workspaces/#{params[:id]}/rebase", {})
30
+ end
31
+
28
32
  private
29
33
 
30
34
  def workspace_params
@@ -0,0 +1,7 @@
1
+ # {CmsHelper} is a wrapper around {RailsConnector::DefaultCmsHelper}.
2
+ # It can be replaced in your application in order to add or
3
+ # modify helpers.
4
+ # @api public
5
+ module CmsHelper
6
+ include RailsConnector::DefaultCmsHelper
7
+ end
@@ -0,0 +1,7 @@
1
+ # {CmsRoutingHelper} is a wrapper around {RailsConnector::DefaultCmsRoutingHelper}.
2
+ # It can be replaced in your application in order to add or
3
+ # modify helpers.
4
+ # @api public
5
+ module CmsRoutingHelper
6
+ include RailsConnector::DefaultCmsRoutingHelper
7
+ end
@@ -44,12 +44,6 @@ module RailsConnector
44
44
  if args.second.nil? || args.second.is_a?(Hash)
45
45
  # Backwards compatibility.
46
46
  target = args.first
47
- if target.is_a?(LinkList)
48
- ActiveSupport::Deprecation.warn(%{
49
- Calling "cms_image_tag" with a "LinkList" is not allowed anymore.
50
- Please use following syntax instead: cms_image_tag(@obj, :linklist).
51
- })
52
- end
53
47
 
54
48
  tag_options = args.second || {}
55
49
  tag_options.symbolize_keys!
@@ -63,7 +57,7 @@ module RailsConnector
63
57
  tag_options = args.third || {}
64
58
  editing_options = args.fourth || {}
65
59
 
66
- cms_tag('img', obj, field_name, cms_image_tag_options(field_name, obj[field_name],
60
+ cms_tag('img', obj, field_name, cms_image_tag_options(obj, field_name,
67
61
  tag_options.symbolize_keys, editing_options.symbolize_keys))
68
62
  end
69
63
 
@@ -71,16 +65,29 @@ module RailsConnector
71
65
 
72
66
  private
73
67
 
74
- def cms_image_tag_options(field_name, target, tag_options, editing_options)
75
- tag_options.reverse_merge(alt: display_title(target)).tap do |options|
76
- options[:src] ||= begin
77
- target_path = cms_path(target)
78
- if target_path == RailsConnector::DefaultCmsRoutingHelper::LINK_TO_EMPTY_LINKLIST
79
- editing_options[:placeholder] || image_path('rails_connector/image_placeholder.png')
80
- else
81
- target_path
82
- end
83
- end
68
+ def cms_image_tag_options(obj, field_name, tag_options, editing_options)
69
+ tag_options.reverse_merge(src: cms_image_tag_src(obj, field_name, editing_options),
70
+ alt: cms_image_tag_alt(obj, field_name))
71
+ end
72
+
73
+ def cms_image_tag_src(obj, field_name, editing_options)
74
+ cms_image_tag_path(obj, field_name) || editing_options[:placeholder] ||
75
+ image_path('rails_connector/image_placeholder.png')
76
+ end
77
+
78
+ def cms_image_tag_alt(obj, field_name)
79
+ display_title(obj[field_name])
80
+ end
81
+
82
+ def cms_image_tag_path(obj, field_name)
83
+ field_type = obj.type_of_attribute(field_name)
84
+ field_value = obj[field_name]
85
+
86
+ case field_type
87
+ when 'reference' then field_value && cms_path(field_value)
88
+ when 'linklist'
89
+ path = cms_path(field_value)
90
+ path == DefaultCmsRoutingHelper::LINK_TO_EMPTY_LINKLIST ? nil : path
84
91
  end
85
92
  end
86
93
 
@@ -46,7 +46,7 @@ module RailsConnector
46
46
  end
47
47
 
48
48
  options = options.merge({
49
- 'data-ip-field-id' => obj.id,
49
+ 'data-ip-private-field-id' => obj.id,
50
50
  'data-ip-field-obj-class' => obj.obj_class,
51
51
  'data-ip-field-name' => field_name,
52
52
  'data-ip-field-type' => field_type,
@@ -61,7 +61,7 @@ module RailsConnector
61
61
  if inplace_editing_allowed? && FIELD_TYPES_WITH_ORIGINAL_CONTENT.include?(field_type)
62
62
  original_value = display_original_value(obj[field_name])
63
63
  original_content = cms_tag_original_content(field_type, original_value)
64
- options['data-ip-field-original-content'] = MultiJson.encode(original_content)
64
+ options['data-ip-private-field-original-content'] = MultiJson.encode(original_content)
65
65
  end
66
66
 
67
67
  inner_html = block_given? ? capture { yield } : display_value(obj[field_name])
@@ -150,8 +150,11 @@ module RailsConnector
150
150
  inner_html << list.output
151
151
  end
152
152
 
153
+ valid_page_classes = Obj.valid_page_classes_beneath(obj.path)
154
+
153
155
  options = options.merge({
154
- 'data-ip-child-list-path' => obj.path,
156
+ 'data-ip-private-child-list-path' => obj.path,
157
+ 'data-ip-private-child-list-allowed-classes' => valid_page_classes.to_json,
155
158
  }) if inplace_editing_allowed?
156
159
 
157
160
  content_tag(tag_name, inner_html, options)
@@ -163,9 +166,9 @@ module RailsConnector
163
166
  options = {}
164
167
 
165
168
  if inplace_editing_allowed?
166
- options['data-ip-widget-id'] = widget.id
167
- options['data-ip-widget-obj-class'] = widget.obj_class
168
- options['data-ip-widget-has-edit-view'] = true if renderer.has_edit_view?(widget.obj_class)
169
+ options['data-ip-private-widget-id'] = widget.id
170
+ options['data-ip-private-widget-obj-class'] = widget.obj_class
171
+ options['data-ip-private-widget-has-edit-view'] = true if renderer.has_edit_view?(widget.obj_class)
169
172
  end
170
173
 
171
174
  content_tag(:div, options) do
@@ -0,0 +1,23 @@
1
+ module RailsConnector
2
+
3
+ # This is a wrapper module for the default set of Rails Connector helper modules.
4
+ #
5
+ # To make autoloading from +CmsController+ work, this module must be wrapped
6
+ # by a module named +CmsHelper+:
7
+ #
8
+ # module CmsHelper
9
+ # include RailsConnector::DefaultCmsHelper
10
+ # end
11
+ # @api public
12
+ module DefaultCmsHelper
13
+ include DisplayHelper
14
+ include MarkerHelper
15
+ include CmsAssetHelper
16
+ include RailsConnector::CmsAssetHelper
17
+ include RailsConnector::TableOfContentsHelper
18
+ include RailsConnector::EditingHelper
19
+ include RailsConnector::LayoutHelper
20
+ include RailsConnector::CmsTagHelper
21
+ end
22
+
23
+ end
@@ -0,0 +1,101 @@
1
+ module RailsConnector
2
+
3
+ # @api public
4
+ module DefaultCmsRoutingHelper
5
+ # Returns the path for +target+ using the +CmsController+ routes.
6
+ # +target+ can be an +Obj+ or a +Link+ or a +LinkList+.
7
+ # If +target+ is a +Linklist+, it must be non-empty. The first +Link+ from the +LinkList+ will be used.
8
+ # +options+ are optional and include url settings such as path parameters or protocol.
9
+ # @return [String]
10
+ # @api public
11
+ def cms_path(target, options = {})
12
+ cms_path_or_url(target, "path", options)
13
+ end
14
+
15
+ # Returns the absolute URL for target using the +CmsController+ routes.
16
+ # +target+ can be an +Obj+ or a +Link+ or a +LinkList+.
17
+ # If +target+ is a +Linklist+, it must be non-empty. The first +Link+ from the +LinkList+ will be used.
18
+ # +options+ are optional and include url settings such as path parameters or protocol.
19
+ # @return [String]
20
+ # @api public
21
+ def cms_url(target, options = {})
22
+ cms_path_or_url(target, "url", options)
23
+ end
24
+
25
+ LINK_TO_UNREACHABLE = "#__target_object_not_reachable"
26
+ LINK_TO_EMPTY_LINKLIST = "#__empty_linklist"
27
+
28
+ def cms_path_or_url(target, path_or_url, options = {})
29
+ if target.is_a?(Link)
30
+ cms_path_or_url_for_links(target, path_or_url, options)
31
+ elsif target.is_a?(Obj)
32
+ cms_path_or_url_for_objs(target, path_or_url, options)
33
+ elsif target.respond_to?(:first)
34
+ if target.first.is_a?(Link)
35
+ cms_path_or_url_for_links(target.first, path_or_url, options)
36
+ else
37
+ return LINK_TO_EMPTY_LINKLIST
38
+ end
39
+ 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."
42
+ end
43
+ end
44
+
45
+ def cms_path_or_url_for_links(link, path_or_url, options = {})
46
+ return LINK_TO_UNREACHABLE if link.internal? && link.obj.nil?
47
+ url = basic_url_or_path_for_link(link, path_or_url, options)
48
+ url = url + "?#{link.query}" if link.query.present? && options.empty?
49
+ url = url + "##{link.fragment}" if link.fragment.present?
50
+ url
51
+ end
52
+
53
+ def cms_path_or_url_for_objs(obj, path_or_url, options = {})
54
+ permalink = obj.permalink
55
+ ignore_body_data_url = options.delete(:ignore_body_data_url)
56
+ if permalink && !Configuration.editor_interface_enabled?
57
+ __send__("cms_permalink_#{path_or_url}", options.merge(:permalink => permalink))
58
+ elsif obj.homepage? && !Configuration.editor_interface_enabled?
59
+ __send__("root_#{path_or_url}", options)
60
+ else
61
+ if obj.body_data_url && !ignore_body_data_url
62
+ enforce_protocol_from_request(obj.body_data_url)
63
+ elsif obj.binary? && !obj.file_extension.blank?
64
+ __send__("cms_id_#{path_or_url}",
65
+ options.merge(:id => obj.id, :slug => obj.slug.presence, :format => obj.file_extension))
66
+ else
67
+ routing_options = options.merge(:id => obj.id, :slug => obj.slug.presence)
68
+ __send__("cms_id_#{path_or_url}", routing_options)
69
+ end
70
+ end
71
+ end
72
+
73
+ private
74
+
75
+ def basic_url_or_path_for_link(link, path_or_url, options = {})
76
+ if link.internal?
77
+ __send__("cms_#{path_or_url}", link.obj, options)
78
+ else
79
+ url = link.external_url
80
+ options.delete(:ignore_body_data_url)
81
+ url = merge_options(url, options) if options.any?
82
+ url
83
+ end
84
+ end
85
+
86
+ def merge_options(url, options)
87
+ parsed_url = URI.parse(url)
88
+
89
+ query = Rack::Utils.parse_query(parsed_url.query)
90
+ merged_query = query.merge(options.stringify_keys)
91
+ parsed_url.query = merged_query.to_query
92
+
93
+ parsed_url.to_s
94
+ end
95
+
96
+ def enforce_protocol_from_request(url)
97
+ request.ssl? && !url.starts_with?('https') ? url.gsub(/^http/, 'https') : url
98
+ end
99
+
100
+ end
101
+ end
@@ -67,39 +67,13 @@ module RailsConnector
67
67
 
68
68
  private
69
69
 
70
- LINK_PATTERN = '<?\binternallink:(\d+)\b>?'
71
- LINK_EXPRESSION = %r(#{LINK_PATTERN})
72
-
73
- def convert_links(content_attribute, cms_path_options = {})
74
- return content_attribute unless content_attribute =~ LINK_EXPRESSION
75
- link_map = content_attribute.source.text_links.each_with_object({}) do |link, map|
76
- map[link.id.to_s] = link
77
- end
78
- content_attribute.gsub(%r(#{LINK_PATTERN}(['"]?))) do
79
- link = link_map[$1.to_s]
80
- if link.blank?
81
- "#{CmsRoutingHelper::LINK_TO_UNREACHABLE}#{$2}"
82
- else
83
- uri = "#{cms_path(link, cms_path_options)}#{$2}"
84
- html_link(link, uri)
70
+ def convert_links(html, cms_path_options = {})
71
+ if html
72
+ html.gsub(%r{<?\bobjid:([a-f0-9]{16})\b>?}) do
73
+ cms_path(Obj.find($1), cms_path_options)
85
74
  end
86
75
  end
87
76
  end
88
77
 
89
- def html_link(link, uri)
90
- subst = uri
91
- name, value =
92
- case link.tag_name
93
- when 'img', 'input'
94
- ['alt', link.title || ""]
95
- when 'a', 'link'
96
- ['title', begin link.title unless link.title.blank? end]
97
- end
98
- if value
99
- subst << %( #{name}="#{h(value)}")
100
- end
101
- subst << %( target="#{h(link.target)}") unless link.target.blank?
102
- subst
103
- end
104
78
  end
105
79
  end
@@ -22,6 +22,9 @@ module RailsConnector
22
22
  false
23
23
  end
24
24
 
25
+ def current_page_has_children?
26
+ @obj && @obj.children.any?
27
+ end
25
28
  end
26
29
 
27
30
  end