infopark_cloud_connector 7.0.1 → 7.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,23 +1,3 @@
1
- # @api public
2
- module ::RailsConnector
3
- PLATFORM_CLOUD = :cloud.freeze
4
- PLATFORM_FIONA = :fiona.freeze
5
-
6
- # return either <tt>:fiona</tt> or <tt>:cloud</tt> depending on the app's configuration.
7
- # @return [Symbol]
8
- def self.platform
9
- PLATFORM_CLOUD
10
- end
11
-
12
- def self.platform_cloud?
13
- true
14
- end
15
-
16
- def self.platform_fiona?
17
- false
18
- end
19
- end
20
-
21
1
  require 'rails_connector/core_extensions'
22
2
  require 'rails_connector/rack_middlewares'
23
3
  require "rails_connector/errors"
@@ -215,29 +215,6 @@ module RailsConnector
215
215
  end
216
216
  end
217
217
 
218
- def permissions
219
- # FIXME permissions
220
- @permissions ||= OpenStruct.new({
221
- :live => permitted_groups,
222
- :read => [],
223
- :write => [],
224
- :root => [],
225
- :create_children => [],
226
- })
227
- end
228
-
229
- def permitted_for_user?(user)
230
- if permitted_groups.blank?
231
- true
232
- else
233
- if user
234
- (permitted_groups & user.live_server_groups).any?
235
- else
236
- false
237
- end
238
- end
239
- end
240
-
241
218
  # Returns the root {BasicObj Obj}, i.e. the Obj with the path "/"
242
219
  # @return [Obj]
243
220
  # @api public
@@ -382,13 +359,6 @@ module RailsConnector
382
359
  name
383
360
  end
384
361
 
385
- # Returns an array with the names of groups that are permitted to access this Obj.
386
- # This corresponds to the cms permission "permissionLiveServerRead".
387
- def permitted_groups
388
- # FIXME permissions not yet implemented in fiona 7
389
- []
390
- end
391
-
392
362
  # Returns true if this object is the root object.
393
363
  # @api public
394
364
  def root?
@@ -612,11 +582,6 @@ module RailsConnector
612
582
  end
613
583
  end
614
584
 
615
- def body_data_path
616
- # not needed/supported when using cloud connector.
617
- nil
618
- end
619
-
620
585
  # returns the content type of the Obj's body for binary Objs.
621
586
  # returns +nil+ for non-binary Objs.
622
587
  # @return [String]
@@ -652,6 +617,11 @@ module RailsConnector
652
617
  instantiate_widget(widget_id, widget_data) if widget_data
653
618
  end
654
619
 
620
+ # for internal testing purposes only
621
+ def blob_id
622
+ find_blob.try(:id)
623
+ end
624
+
655
625
  private
656
626
 
657
627
  def widget_data_from_pool(widget_id)
@@ -16,81 +16,14 @@ module RailsConnector
16
16
  @obj = loaded_obj
17
17
  end
18
18
 
19
- # Filter method to check if access to the loaded object is permitted. If it is
20
- # not, a 403 Forbidden error message will be generated (by calling render_obj_error)
21
- #
22
- # To require the check for all actions, use this in your controllers:
23
- # before_filter :load_object
24
- # before_filter :ensure_object_is_permitted
25
- def ensure_object_is_permitted
26
- unless is_permitted(@obj)
27
- @obj = nil
28
- render_obj_error(403, "forbidden")
29
- return false
30
- end
31
- return true
32
- end
33
-
34
- # This method is called when rendering an error caused by either {ensure_object_is_permitted}
35
- # or {ensure_object_is_active} before filter. It renders an error template located in
36
- # "errors/*.html.erb" with given HTTP status and content type "text/html" and with no layout.
37
- # Overwrite this method to change the error page.
38
- # @api public
39
- def render_obj_error(status, name)
40
- force_html_format
41
- render(
42
- :template => "errors/#{status}_#{name}",
43
- :layout => false,
44
- :status => status,
45
- :content_type => Mime::HTML
46
- )
47
- end
48
-
49
- # Enforce "html" as template format.
50
- # @api public
51
- def force_html_format
52
- request.format = :html
53
- end
54
-
55
- # Inclusion hook to make is_permitted available as helper method.
56
- def self.included(base)
57
- base.__send__ :helper_method, :is_permitted
58
- end
59
-
60
- # Helper method to check live permissions
61
- def is_permitted(obj)
62
- obj.permitted_for_user?(current_user)
63
- end
64
-
65
- # Filter method which sets the header 'X-Robots-Tag: unavailable_after'
66
- # to the valid_until date of the current object.
67
- def set_google_expire_header
68
- if @obj && (date = @obj.valid_until)
69
- headers['X-Robots-Tag: unavailable_after'] = date.rfc822
70
- end
71
- end
72
-
73
- # Deliver the obj's body as response by file or data.
74
- # May respond with status 304 if a If-Modified-Since header is found.
19
+ # Deliver a binary @obj by redirecting to it's `body_data_url`.
20
+ # Will respond with 404 if the @obj has no blob.
75
21
  # @api public
76
22
  def deliver_file
77
23
  if @obj.body_data_url
78
24
  redirect_to enforce_protocol_from_request(@obj.body_data_url)
79
- elsif stale?(:last_modified => @obj.last_changed.utc)
80
- mime_type = @obj.mime_type
81
- mime_type += '; charset=utf-8' if mime_type =~ /^text\//
82
-
83
- if (filepath = @obj.body_data_path).present?
84
- send_file(File.expand_path(filepath), {
85
- :type => mime_type,
86
- :filename => @obj.filename,
87
- :disposition => 'inline',
88
- })
89
- else
90
- # generics should send its body, empty files should be delivered as
91
- # empty files - and not lead to an application error
92
- send_data @obj.body || '', :type => mime_type, :filename => @obj.filename, :disposition => 'inline'
93
- end
25
+ else
26
+ render text: "Empty Blob", status: 404
94
27
  end
95
28
  end
96
29
  end
@@ -135,13 +135,8 @@ module RailsConnector
135
135
  cms_api.api_key = value
136
136
  end
137
137
 
138
- def after_initialize
139
- enable_authentication
140
- end
141
-
142
138
  def to_prepare
143
139
  unless Rails.configuration.cache_classes
144
- after_initialize
145
140
  NamedLink.reset_cache
146
141
  BasicObj.reset_type_computer!
147
142
  BasicWidget.reset_type_computer!
@@ -184,10 +179,6 @@ module RailsConnector
184
179
  def cms_api
185
180
  RailsConnector::CmsRestApi.configuration
186
181
  end
187
-
188
- def enable_authentication
189
- ::ApplicationController.__send__(:include, RailsConnector::Authenticable)
190
- end
191
182
  end
192
183
 
193
184
  # defaults
@@ -8,7 +8,6 @@ require 'rails_connector/configuration'
8
8
  module ::RailsConnector
9
9
  class Engine < Rails::Engine
10
10
  config.to_prepare { RailsConnector::Configuration.to_prepare }
11
- config.after_initialize { RailsConnector::Configuration.after_initialize }
12
11
 
13
12
  # make sure our exceptions cause an adequate error page and http status code
14
13
  config.action_dispatch.rescue_responses.merge!("RailsConnector::ResourceNotFound" => :not_found)
@@ -11,7 +11,7 @@ module RailsConnector
11
11
  value_and_type = @data[attribute_name]
12
12
 
13
13
  if value_and_type.blank?
14
- if INTERNAL_KEYS.include?(attribute_name)
14
+ if INTERNAL_KEYS.include?(attribute_name) || SPECIAL_KEYS.include?(attribute_name)
15
15
  type = type_of_internal(attribute_name)
16
16
  [default_attribute_value(type), type]
17
17
  else
@@ -47,7 +47,7 @@ module RailsConnector
47
47
  end
48
48
 
49
49
  def is_custom_attribute?(attribute_name)
50
- !attribute_name.starts_with?('_')
50
+ !attribute_name.starts_with?('_') && !SPECIAL_KEYS.include?(attribute_name)
51
51
  end
52
52
 
53
53
  internal_key_list = %w[
@@ -68,6 +68,8 @@ module RailsConnector
68
68
 
69
69
  INTERNAL_KEYS = Set.new(internal_key_list.map { |name| "_#{name}" } )
70
70
 
71
+ SPECIAL_KEYS = Set.new(%w[ body title blob ])
72
+
71
73
  end
72
74
 
73
75
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_cloud_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 7.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infopark AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-12 00:00:00.000000000 Z
11
+ date: 2013-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -139,13 +139,11 @@ files:
139
139
  - app/helpers/rails_connector/display_helper.rb
140
140
  - app/helpers/rails_connector/editing_helper.rb
141
141
  - app/helpers/rails_connector/layout_helper.rb
142
- - app/helpers/rails_connector/marker_helper.rb
143
142
  - app/helpers/rails_connector/table_of_contents_helper.rb
144
143
  - app/helpers/rails_connector/widget_helper.rb
145
144
  - app/models/named_link.rb
146
145
  - app/views/cms/_index.html.erb
147
146
  - app/views/cms/index.html.erb
148
- - app/views/errors/403_forbidden.html.erb
149
147
  - app/views/rails_connector/_editing_javascript.html.erb
150
148
  - app/views/rails_connector/objs/create_widget.html.erb
151
149
  - app/views/rails_connector/objs/show_widget.html.erb
@@ -154,11 +152,9 @@ files:
154
152
  - config/locales/de.rails_connector.errors.yml
155
153
  - config/locales/de.rails_connector.lib.yml
156
154
  - config/locales/de.rails_connector.models.yml
157
- - config/locales/de.rails_connector.views.yml
158
155
  - config/locales/en.rails_connector.errors.yml
159
156
  - config/locales/en.rails_connector.lib.yml
160
157
  - config/locales/en.rails_connector.models.yml
161
- - config/locales/en.rails_connector.views.yml
162
158
  - config/routes.rb
163
159
  - lib/assets/fonts/infopark_icons-webfont.eot
164
160
  - lib/assets/fonts/infopark_icons-webfont.ttf
@@ -177,7 +173,6 @@ files:
177
173
  - lib/obj.rb
178
174
  - lib/rails_connector/access_denied.rb
179
175
  - lib/rails_connector/attribute_content.rb
180
- - lib/rails_connector/authenticable.rb
181
176
  - lib/rails_connector/backend_not_available.rb
182
177
  - lib/rails_connector/basic_obj.rb
183
178
  - lib/rails_connector/basic_widget.rb
@@ -1,46 +0,0 @@
1
- module RailsConnector
2
-
3
- module MarkerHelper
4
-
5
- def edit_marker(obj, attr, options = {}, &block)
6
- if Configuration.editor_interface_enabled?
7
- default_value = options.delete(:default_value)
8
-
9
- if block_given?
10
- content = block.call(obj, attr)
11
- content = default_value || raw("&nbsp;") if content.blank?
12
- end
13
-
14
- tag_type = options.delete(:tag) || :span
15
- content_tag(
16
- tag_type,
17
- content.to_s,
18
- options
19
- )
20
- else
21
- block_given? ? block.call(obj, attr) : nil
22
- end
23
- end
24
-
25
- def marker_menu(left=0, top=0, &block)
26
- end
27
-
28
- def marker_menu_target(tag_name, options = {}, &block)
29
- content_tag(
30
- tag_name,
31
- capture(&block),
32
- options
33
- )
34
- end
35
-
36
- def include_edit_marker_support
37
- end
38
-
39
- def render_marker_code
40
- end
41
-
42
- private
43
-
44
- end
45
-
46
- end
@@ -1,3 +0,0 @@
1
- <h1><%= t(:'rails_connector.lib.cms_accessible.protected') %></h1>
2
-
3
- <p><%= t(:"rails_connector.views.errors.forbidden.no_permissions") %></p>
@@ -1,6 +0,0 @@
1
- de:
2
- rails_connector:
3
- views:
4
- errors:
5
- forbidden:
6
- no_permissions: "Sie haben nicht die notwendigen Zugriffsrechte"
@@ -1,6 +0,0 @@
1
- en:
2
- rails_connector:
3
- views:
4
- errors:
5
- forbidden:
6
- no_permissions: "You don't have the required permissions"
@@ -1,30 +0,0 @@
1
- module RailsConnector
2
- module Authenticable
3
- def self.included(mod)
4
- %w(logged_in? admin? current_user).each do |method_name|
5
- unless instance_method_defined?(mod, method_name)
6
- mod.class_eval do
7
- private
8
- define_method(method_name, InstanceMethods.method(method_name).to_proc)
9
- end
10
- end
11
-
12
- mod.send(:helper_method, method_name)
13
- end
14
- end
15
-
16
- module InstanceMethods
17
- def self.logged_in?; false; end
18
- def self.admin?; false; end
19
- def self.current_user; nil; end
20
- end
21
-
22
- private
23
-
24
- def self.instance_method_defined?(mod, method_name)
25
- (
26
- mod.instance_methods + mod.protected_instance_methods + mod.private_instance_methods
27
- ).map(&:to_s).include?(method_name)
28
- end
29
- end
30
- end