infopark_fiona7 0.70.0.1 → 0.70.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fb73f7dbb42f72a2226f87ebefc5917d783bc43
4
- data.tar.gz: a44f89e1afabe37ea6b3dac2e090b7ea2e4e1330
3
+ metadata.gz: f088c3d3fb8b3fb487f3ec6fb4aa27f6956381f1
4
+ data.tar.gz: 267da049a8f2ace22d74c96f491f78337cfb9387
5
5
  SHA512:
6
- metadata.gz: 08b11f576e6b7250c72fd1d8edd3e4651e5438a09c58c6a4f77815e1d50ad65cd9e117e15681b7ba4017516e3b7910f19dd4e6ecb6acd924f9fe9e90d8cd67de
7
- data.tar.gz: 0ab455e74160f1d43e325b52d0cf65bf83becddd06fed7c5d1e9c1ede64a709b002055a6a4c310aeb608b71ca927bff3a1148592e33b979db49c9472a48e2fcf
6
+ metadata.gz: 93e13fbd24b6925353e4148c0a8c9c9035e1a83a14bc9e633a6d3a1ec34d9d10d9f78554374559a2ad613706d2af296b586e959a8626d54e4a8deb03f942719c
7
+ data.tar.gz: 4d1bdb3634d7cba7a39f247033fe9f0cb5046905c70b990d9239e11372876024032703f08f38eab081a8b826fba7fe1d0aedcb76b67d9418152c132b09a9ad4e
@@ -0,0 +1,87 @@
1
+ module Scrivito
2
+
3
+ class CmsDispatchController < ActionController::Metal
4
+ include ActionController::Redirecting
5
+ include Rails.application.routes.url_helpers
6
+ include Scrivito::RoutingHelper
7
+
8
+ def process(action)
9
+ CmsEnv.new(env).load
10
+
11
+ if !obj_not_found? && action == 'legacy'
12
+ if Scrivito::Configuration.legacy_routing
13
+ action = 'index'
14
+ else
15
+ redirect_to scrivito_path(loaded_obj), status: :moved_permanently
16
+ return self.response
17
+ end
18
+ end
19
+
20
+ if obj_not_found? && editing_context.workspace_changed?
21
+ redirect_to :scrivito_root
22
+ return self.response
23
+ end
24
+
25
+ controller = target_controller(env)
26
+ env["action_dispatch.request.path_parameters"]["controller"] = controller.controller_path
27
+
28
+ if !obj_not_found? && action == 'index'
29
+ action = loaded_obj.controller_action_name
30
+ end
31
+
32
+ env["action_dispatch.request.path_parameters"]["action"] = action
33
+
34
+ self.response = controller.action(action).call(env)
35
+ end
36
+
37
+ private
38
+
39
+ def main_app
40
+ Rails.application.routes.url_helpers
41
+ end
42
+
43
+ def scrivito_engine
44
+ Scrivito::SdkEngine.routes.url_helpers
45
+ end
46
+
47
+ def editing_context
48
+ EditingContextMiddleware.from_request(request)
49
+ end
50
+
51
+ # support legacy mode
52
+ def target_controller(env)
53
+ return default_controller if obj_not_found?
54
+ controller = "#{loaded_obj.controller_name}Controller".constantize
55
+
56
+ if controller.respond_to?(:use_for_obj_dispatch?) && controller.use_for_obj_dispatch? && controller.include?(Scrivito::ControllerActions)
57
+ controller
58
+ else
59
+ default_controller
60
+ end
61
+ rescue NameError
62
+ default_controller
63
+ end
64
+
65
+ def loaded_obj
66
+ env[CmsEnv::OBJ_ENV_KEY]
67
+ end
68
+
69
+ def obj_not_found?
70
+ loaded_obj.is_a?(StandardError)
71
+ end
72
+
73
+ # support DefaultScrivitoCmsController!
74
+ def default_controller
75
+ return Fiona7::DefaultScrivitoCmsController if Fiona7.mode == :legacy
76
+ CmsController
77
+ rescue NameError => e
78
+ if e.message.include?('CmsController')
79
+ raise 'Your application does not define the "CmsController" needed for Scrivito. '\
80
+ 'Did you forget to run "rails generate scrivito:install"?'
81
+ else
82
+ raise
83
+ end
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,240 @@
1
+ module Scrivito
2
+ class ObjsController < WebserviceController
3
+ around_action :require_selected_workspace_write_authorization, only: [
4
+ :copy,
5
+ :create,
6
+ :destroy,
7
+ :destroy_widget,
8
+ :duplicate,
9
+ :mark_resolved,
10
+ :restore,
11
+ :restore_widget,
12
+ :revert,
13
+ :revert_widget,
14
+ :update,
15
+ ]
16
+
17
+ before_filter :require_identical_selected_and_visible_workspace, only: [
18
+ :copy,
19
+ :create,
20
+ :duplicate,
21
+ :page_class_selection,
22
+ :update,
23
+ :widget_class_selection,
24
+ ]
25
+
26
+ def show
27
+ in_selected_workspace { render }
28
+ end
29
+
30
+ def widget
31
+ in_selected_workspace { render }
32
+ end
33
+
34
+ def create
35
+ params_parser = ObjCreateParamsParser.new(request.host, request.port)
36
+ @obj = Obj.create(params_parser.parse(params[:obj]), scrivito_user: scrivito_user)
37
+ render :obj
38
+ rescue ObjClassNotFound
39
+ head :not_found
40
+ end
41
+
42
+ def details
43
+ assert_dialog_layout
44
+ render current_obj.details_view_path, layout: 'scrivito_dialog', formats: :html
45
+ end
46
+
47
+ def update
48
+ params_parser = ObjUpdateParamsParser.new(request.host, request.port,
49
+ current_obj: current_obj, scrivito_user: scrivito_user)
50
+ current_obj.update(params_parser.parse(params[:obj]))
51
+ rescue ObjClassNotFound
52
+ head :not_found
53
+ end
54
+
55
+ def destroy
56
+ in_selected_workspace do
57
+ parent = current_obj.parent
58
+ @redirect_to = parent ? scrivito_path(parent) : scrivito_root_path
59
+ current_obj.destroy
60
+ end
61
+ end
62
+
63
+ def destroy_widget
64
+ in_selected_workspace { current_widget.destroy }
65
+ render_empty_json
66
+ end
67
+
68
+ def revert
69
+ in_selected_workspace { current_obj.revert }
70
+ render_empty_json
71
+ end
72
+
73
+ def revert_widget
74
+ in_selected_workspace { current_widget.revert }
75
+ render_empty_json
76
+ end
77
+
78
+ def restore
79
+ in_selected_workspace { Obj.restore(params[:id]) }
80
+ render_empty_json
81
+ end
82
+
83
+ def restore_widget
84
+ in_selected_workspace { current_obj.restore_widget(params[:widget_id]) }
85
+ render_empty_json
86
+ end
87
+
88
+ # optimized away
89
+ def conflicting_workspaces
90
+ @workspaces = []
91
+ render :workspaces
92
+ end
93
+
94
+ # optimized away
95
+ def is_outdated
96
+ @is_outdated = false
97
+ end
98
+
99
+ def mark_resolved
100
+ in_selected_workspace { current_obj.mark_resolved }
101
+ render_empty_json
102
+ end
103
+
104
+ def copy
105
+ @obj = copy_obj(current_obj, params[:parent_path])
106
+ render :obj
107
+ end
108
+
109
+ def duplicate
110
+ @obj = copy_obj(current_obj, current_obj.parent_path)
111
+ render :obj
112
+ end
113
+
114
+ def page_class_selection
115
+ @page_class_markup = valid_page_classes.map do |page_class_name|
116
+ build_selection_option(page_class_name)
117
+ end
118
+ end
119
+
120
+ def widget_class_selection
121
+ load_obj
122
+
123
+ @widgets_classes = valid_widget_classes.map do |widget_class_name|
124
+ build_selection_option(widget_class_name)
125
+ end
126
+ end
127
+
128
+ def search
129
+ in_selected_workspace do
130
+ @query = MultiJson.decode(params[:query]).with_indifferent_access
131
+ @enumerator = ObjSearchBuilder.new(@query).build
132
+
133
+ if params[:query_action] == 'size'
134
+ render :search_only_size
135
+ elsif @formatter = fetch_formatter(@query[:format])
136
+ render :search
137
+ else
138
+ render :format_missing_error, status: :not_found
139
+ end
140
+ end
141
+ end
142
+
143
+ private
144
+
145
+ def require_identical_selected_and_visible_workspace
146
+ if selected_workspace != editing_context.visible_workspace
147
+ raise ScrivitoError, 'selected and visible workspace are not identical'
148
+ end
149
+ end
150
+
151
+ def require_selected_workspace_write_authorization(&block)
152
+ authorize_workspace_access(:write, selected_workspace, &block)
153
+ end
154
+
155
+ def in_selected_workspace(&block)
156
+ selected_workspace.as_current(&block)
157
+ end
158
+
159
+ def selected_workspace
160
+ editing_context.selected_workspace
161
+ end
162
+
163
+ def current_obj
164
+ @obj || load_obj
165
+ end
166
+ helper_method :current_obj
167
+
168
+ def load_obj
169
+ @obj = Obj.find(params[:id])
170
+ end
171
+
172
+ def current_widget
173
+ @widget || load_widget
174
+ end
175
+ helper_method :current_widget
176
+
177
+ def load_widget
178
+ raise ScrivitoError, 'no widget_id param specified' if params[:widget_id].blank?
179
+ unless @widget = current_obj.widget_from_pool(params[:widget_id])
180
+ raise ResourceNotFound, "widget with ID '#{params[:widget_id]}' not found"
181
+ end
182
+ @widget
183
+ end
184
+
185
+ def copy_obj(obj, parent_path)
186
+ id = SecureRandom.hex(8)
187
+ obj.copy(_id: id, _path: parent_path && "#{parent_path}/#{id}")
188
+ end
189
+
190
+ def fetch_formatter(name)
191
+ name ? Configuration.obj_formats[name] : proc { |obj, _| obj.id }
192
+ end
193
+
194
+ def build_selection_option(class_name)
195
+ template_path = "#{class_name.underscore}/thumbnail"
196
+ markup = begin
197
+ render_to_string(template_path, layout: false, formats: :html)
198
+ rescue ActionView::MissingTemplate
199
+ render_to_string('scrivito/fallback_thumbnail', layout: false, formats: :html,
200
+ locals: {class_name: class_name, template_path: template_path})
201
+ end
202
+ {name: class_name, markup: markup}
203
+ end
204
+
205
+ def valid_page_classes
206
+ without_hidden_classes(page_classes_from_obj).map(&:to_s)
207
+ end
208
+
209
+ def page_classes_from_obj
210
+ Obj.valid_page_ruby_classes_beneath(params[:parent_path])
211
+ end
212
+
213
+ def valid_widget_classes
214
+ widget_classes = current_widget_or_obj.valid_widget_ruby_classes_for(params[:field_name])
215
+
216
+ without_hidden_classes(widget_classes).map(&:to_s)
217
+ end
218
+
219
+ def without_hidden_classes(obj_types)
220
+ obj_types.reject(&:hide_from_editor?)
221
+ end
222
+
223
+ def current_widget_or_obj
224
+ widget_id = params[:widget_id]
225
+ (widget_id && current_obj.widgets[widget_id]) || current_obj
226
+ end
227
+
228
+ def assert_dialog_layout
229
+ view_context.lookup_context.find('layouts/scrivito_dialog')
230
+ rescue ActionView::MissingTemplate
231
+ raise %{
232
+ Missing the Scrivito dialog layout!
233
+
234
+ Scrivito requires a special view layout in order to render the details dialog.
235
+ Normally the install generator places it in `app/views/layouts/scrivito_dialog.html.erb`.
236
+ If upgrading Scrivito, please re-run the install generator: `rails g scrivito:install`.
237
+ }
238
+ end
239
+ end
240
+ end
@@ -0,0 +1,69 @@
1
+ module Scrivito
2
+
3
+ class WebserviceController < ActionController::Base
4
+ rescue_from ClientError do |exception|
5
+ @exception = exception
6
+ render 'scrivito/webservice/error', formats: :json, status: exception.http_code
7
+ end
8
+
9
+ before_filter :merge_correctly_parsed_json_params
10
+ before_filter :authorize
11
+
12
+ private
13
+
14
+ def authorize
15
+ render_forbidden unless allow_access?
16
+ end
17
+
18
+ def editing_context
19
+ EditingContextMiddleware.from_request(request)
20
+ end
21
+
22
+ def scrivito_user
23
+ editing_context.editor
24
+ end
25
+
26
+ # If +true+, allow access to ObjsController, else deny access.
27
+ # See {Scrivito::Configuration.editing_auth} for details.
28
+ # @return [Boolean]
29
+ def allow_access?
30
+ !!scrivito_user
31
+ end
32
+
33
+ # Workaround for https://github.com/rails/rails/issues/8832
34
+ # + support for binary uploads
35
+ def merge_correctly_parsed_json_params
36
+ if request.format.json?
37
+ body = request.body.read
38
+ request.body.rewind
39
+ params.merge!(ActiveSupport::JSON.decode(body)) if body.present? && !request.form_data?
40
+ end
41
+ rescue JSON::ParserError => e
42
+ # Rails TestRequest mixes up arguments, therefore ignore elements here
43
+ raise e unless Rails.env.test?
44
+ end
45
+
46
+ def can_user_access_workspace?(verb, workspace)
47
+ scrivito_user.can?(verb, workspace)
48
+ end
49
+
50
+ def authorize_workspace_access(verb, workspace)
51
+ can_user_access_workspace?(verb, workspace) ? yield : render_forbidden
52
+ end
53
+
54
+ def render_forbidden
55
+ render text: 'Forbidden', status: 403
56
+ end
57
+
58
+ def render_empty_json
59
+ render 'scrivito/webservice/empty', formats: :json
60
+ end
61
+
62
+ def can_user_read_workspace?(workspace)
63
+ can_user_access_workspace?(:read, workspace)
64
+ end
65
+
66
+ helper_method :can_user_read_workspace?
67
+ end
68
+
69
+ end
@@ -43,6 +43,9 @@ module Fiona7OverrideHelper
43
43
 
44
44
  scrivito_tag_list(tag_name, obj, field_name, options) do |list, scrivito_child|
45
45
  fiona_child = children_map[scrivito_child.id]
46
+
47
+ next unless fiona_child.exportable? # suppress_export !
48
+
46
49
  block.call(list, fiona_child)
47
50
  end
48
51
  end
data/lib/fiona7/engine.rb CHANGED
@@ -168,9 +168,6 @@ module Fiona7
168
168
  end
169
169
 
170
170
  initializer "fiona7.runtime_patches" do |app|
171
- require "fiona7/scrivito_patches/cms_dispatch_controller"
172
- require "fiona7/scrivito_patches/webservice_controller"
173
- require "fiona7/scrivito_patches/objs_controller"
174
171
  end
175
172
 
176
173
  initializer "fiona7.preload_cms_type_defs" do |app|
@@ -73,6 +73,8 @@ module Fiona7
73
73
  deserialize_widget_field(@obj.attr_values[real_attribute_name] || [])
74
74
  when :html
75
75
  deserialize_html(@obj[real_attribute_name])
76
+ when :markdown
77
+ nil
76
78
  when :binary
77
79
  if !Fiona7.mode == :legacy || !@obj.binary?
78
80
  deserialize_binary(@obj.attr_values[real_attribute_name].try(:first))
@@ -57,23 +57,25 @@ module Scrivito
57
57
  end
58
58
 
59
59
  # Originally this method refers to the global Obj via ::Obj
60
+ # and does not support shadow classes
60
61
  def self.where(field, operator, value, boost = nil)
61
62
  assert_not_basic_obj('.where')
62
63
  if self == Obj || self == ::Obj
63
64
  Workspace.current.objs.where(field, operator, value, boost)
64
65
  else
65
- Workspace.current.objs.where(:_obj_class, :equals, name)
66
+ Workspace.current.objs.where(:_obj_class, :equals, to_s)
66
67
  .and(field, operator, value, boost)
67
68
  end
68
69
  end
69
70
 
70
71
  # Originally this method refers to the global Obj via ::Obj
72
+ # and does not support shadow classes
71
73
  def self.all
72
74
  assert_not_basic_obj('.all')
73
75
  if self == Obj || self == ::Obj
74
76
  Workspace.current.objs.all
75
77
  else
76
- find_all_by_obj_class(name)
78
+ find_all_by_obj_class(to_s)
77
79
  end
78
80
  end
79
81
 
@@ -29,6 +29,9 @@ module Fiona7
29
29
  #puts "loading #{obj_class}"
30
30
  if Fiona7.mode == :legacy
31
31
  type_definition.add_attr('title', :string, 'title', :string)
32
+ type_definition.add_attr('valid_from', :date, 'valid_from', :date)
33
+ type_definition.add_attr('valid_until', :date, 'valid_until', :date)
34
+
32
35
  if self.rc_obj_class.obj_type == 'publication' || self.rc_obj_class.obj_type == 'document'
33
36
  type_definition.add_attr('body', :html, 'body', :html)
34
37
  elsif self.rc_obj_class.obj_type == 'image' || self.rc_obj_class.obj_type == 'generic'
@@ -1,3 +1,3 @@
1
1
  module Fiona7
2
- VERSION = "0.70.0.1"
2
+ VERSION = "0.70.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_fiona7
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.70.0.1
4
+ version: 0.70.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Przedmojski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-25 00:00:00.000000000 Z
11
+ date: 2015-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -143,6 +143,9 @@ files:
143
143
  - app/controllers/fiona7/release_controller.rb
144
144
  - app/controllers/fiona7/sessions_controller.rb
145
145
  - app/controllers/fiona7_login_page_controller.rb
146
+ - app/controllers/scrivito/cms_dispatch_controller.rb
147
+ - app/controllers/scrivito/objs_controller.rb
148
+ - app/controllers/scrivito/webservice_controller.rb
146
149
  - app/helpers/fiona7_login_helper.rb
147
150
  - app/helpers/fiona7_override_helper.rb
148
151
  - app/models/fiona7/edited_obj.rb
@@ -205,7 +208,6 @@ files:
205
208
  - lib/fiona7/scrivito_patches/binary.rb
206
209
  - lib/fiona7/scrivito_patches/client_config.rb
207
210
  - lib/fiona7/scrivito_patches/cms_backend.rb
208
- - lib/fiona7/scrivito_patches/cms_dispatch_controller.rb
209
211
  - lib/fiona7/scrivito_patches/cms_field_tag.rb
210
212
  - lib/fiona7/scrivito_patches/cms_rest_api.rb
211
213
  - lib/fiona7/scrivito_patches/cms_routing.rb
@@ -213,9 +215,7 @@ files:
213
215
  - lib/fiona7/scrivito_patches/link_parser.rb
214
216
  - lib/fiona7/scrivito_patches/migrator.rb
215
217
  - lib/fiona7/scrivito_patches/obj_class.rb
216
- - lib/fiona7/scrivito_patches/objs_controller.rb
217
218
  - lib/fiona7/scrivito_patches/type_computer.rb
218
- - lib/fiona7/scrivito_patches/webservice_controller.rb
219
219
  - lib/fiona7/scrivito_patches/workspace.rb
220
220
  - lib/fiona7/scrivito_user.rb
221
221
  - lib/fiona7/search_engine.rb
@@ -1,31 +0,0 @@
1
- require 'scrivito/cms_dispatch_controller'
2
- module Scrivito
3
-
4
- class CmsDispatchController
5
- def target_controller(env)
6
- return default_controller if obj_not_found?
7
- controller = "#{loaded_obj.controller_name}Controller".constantize
8
-
9
- if controller.respond_to?(:use_for_obj_dispatch?) && controller.use_for_obj_dispatch? && controller.include?(Scrivito::ControllerActions)
10
- controller
11
- else
12
- default_controller
13
- end
14
- rescue NameError
15
- default_controller
16
- end
17
-
18
- def default_controller
19
- return Fiona7::DefaultScrivitoCmsController if Fiona7.mode == :legacy
20
- CmsController
21
- rescue NameError => e
22
- if e.message.include?('CmsController')
23
- raise 'Your application does not define the "CmsController" needed for Scrivito. '\
24
- 'Did you forget to run "rails generate scrivito:install"?'
25
- else
26
- raise
27
- end
28
- end
29
- end
30
-
31
- end
@@ -1,18 +0,0 @@
1
- module Scrivito
2
- # trigger load
3
- ObjsController
4
- class ObjsController < WebserviceController
5
-
6
- # optimized away
7
- def is_outdated
8
- @is_outdated = false
9
- end
10
-
11
- # optimized away
12
- def conflicting_workspaces
13
- @workspaces = []
14
- render :workspaces
15
- end
16
-
17
- end
18
- end
@@ -1,21 +0,0 @@
1
- module Scrivito
2
-
3
- # trigger load
4
- WebserviceController
5
-
6
- class WebserviceController < ActionController::Base
7
-
8
- # Workaround for https://github.com/rails/rails/issues/8832
9
- def merge_correctly_parsed_json_params
10
- if request.format.json?
11
- body = request.body.read
12
- request.body.rewind
13
- params.merge!(ActiveSupport::JSON.decode(body)) if body.present? && !request.form_data?
14
- end
15
- rescue JSON::ParserError => e
16
- # Rails TestRequest mixes up arguments, therefore ignore elements here
17
- raise e unless Rails.env.test?
18
- end
19
- end
20
-
21
- end