infopark_fiona7 0.71.0.0 → 0.71.0.1

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: b01a9b4b8f32420a4dbc9a71b7715e4b435064fe
4
- data.tar.gz: 52cd4e1ead233d6687abea23efc30c8356a34fcd
3
+ metadata.gz: 63d211ac7f8286b5fac42e153b9910ebab860441
4
+ data.tar.gz: ec3f22cb8839b5f4678de0ec2ecf2573ebf1fa91
5
5
  SHA512:
6
- metadata.gz: 43a8472b368e2b0c97215dc78a9695b3b163b20fbda466b5be8661bbbe1ee245ad265b475758c78b1595d43964c34f9d450e4d1faf42272bd33b0e439f973b03
7
- data.tar.gz: 7f7076b7cc9d09f4fb082b9a19776ceb98132c78c1d425cc17e021091f229056aee960cf222604ee97895e4ea390f2598e4c85bd36b66f1b5a8be7f5a465f9e4
6
+ metadata.gz: 880363e8a0a340d748e40cb70f9b705bb953408ecb3771a6439aac33c2db56de9dda6db9c81025da442d6ba15805f2599154abbf692c4fdaf30174982583621f
7
+ data.tar.gz: da276d868c7e1b8f9380621a1bcaa512664d6e74bd6aec57bf90bc2615f0211d6f5d61b2bed8a21d6a01befaeb62181660d50446b843b1df525bad6fe31b4197
@@ -157,7 +157,7 @@
157
157
  icon: icons[action],
158
158
 
159
159
  present: function() {
160
- return scrivito.editing_context.selected_workspace.is_editable() && obj && !obj.is_deleted() && scrivito.user_permissions.can(action + '_obj');
160
+ return scrivito.editing_context.selected_workspace.is_editable() && obj;// && !obj.is_deleted() && scrivito.user_permissions.can(action + '_obj');
161
161
  },
162
162
 
163
163
  disabled: function() {
@@ -184,9 +184,9 @@
184
184
  });
185
185
 
186
186
 
187
- var menu = cms_document.menu();
188
- menu.push(scrivito.command_separator.create_instance({id: 'fiona7.zz_sparator'}));
189
- cms_document.set_menu(menu);
187
+ //var menu = cms_document.menu();
188
+ //menu.push(scrivito.command_separator.create_instance({id: 'fiona7.zz_sparator'}));
189
+ //cms_document.set_menu(menu);
190
190
 
191
191
  //scrivito.configure_menu_order(['fiona7.*', '*']);
192
192
  });
@@ -73,6 +73,10 @@
73
73
  return params.last_changed;
74
74
  },
75
75
 
76
+ provided_path: function() {
77
+ return params.path;
78
+ },
79
+
76
80
  parent_path: function() {
77
81
  return params.parent_path;
78
82
  },
@@ -198,6 +202,7 @@
198
202
 
199
203
  create: function(attrs) {
200
204
  return prepare_attrs(scrivito.random_id(), attrs).then(function(prepared_attrs) {
205
+ provide_default_path(prepared_attrs, prepared_attrs._obj_class);
201
206
  return persist_obj_data(prepared_attrs).then(function (data) {
202
207
  scrivito.obj_class_selection.store(prepared_attrs._obj_class);
203
208
  return scrivito.obj.create_instance(data);
@@ -215,6 +220,17 @@
215
220
  }
216
221
  });
217
222
 
223
+ var provide_default_path = function (attrs, default_name) {
224
+ if (!(attrs._path)) {
225
+ var current_page = scrivito.application_document().page();
226
+ var path = (typeof current_page.provided_path === 'function') && current_page.provided_path();
227
+
228
+ if (path && path !== "/") {
229
+ attrs._path = path + "/" + default_name;
230
+ }
231
+ }
232
+ };
233
+
218
234
  var obj_url = function (obj_id) {
219
235
  var url = window.location.protocol + '//' + window.location.host + '/__scrivito/objs';
220
236
  if (typeof obj_id !== 'undefined') {
@@ -14,9 +14,11 @@ module Fiona7
14
14
  end
15
15
  else
16
16
  # suppress_export can be misused in legacy mode
17
+ # also valid_from and valid_until should be handled
18
+ # by the application
17
19
  default_scope do
18
20
  now = Time.now.utc.to_iso
19
- where("is_released = 1").where('obj_class NOT IN (?)', ['X_Generic', 'X_Image', 'X_Container']).where("(valid_from IS NULL or valid_from <= :now) and (valid_until IS NULL or valid_until >= :now)", :now => now)
21
+ where("is_released = 1").where('obj_class NOT IN (?)', ['X_Generic', 'X_Image', 'X_Container'])#.where("(valid_from IS NULL or valid_from <= :now) and (valid_until IS NULL or valid_until >= :now)", :now => now)
20
22
  end
21
23
  end
22
24
 
@@ -99,6 +99,7 @@ module Fiona7
99
99
  end
100
100
 
101
101
  end
102
+
102
103
  end
103
104
  end
104
105
 
@@ -253,6 +254,7 @@ module Fiona7
253
254
  raise Scrivito::ClientError.new("Unknown attribute type: #{virtual_type}", 418)
254
255
  end
255
256
  end
257
+ @obj.set(:X_full_text, rewrite_full_text) if @new_widget_pool
256
258
  @obj.set(:X_widget_pool, @new_widget_pool) if @new_widget_pool
257
259
  @obj.set(:permalink, @permalink) if @permalink
258
260
 
@@ -283,8 +285,12 @@ module Fiona7
283
285
  end
284
286
  end
285
287
 
286
-
287
-
288
+ def rewrite_full_text
289
+ full_text = ::JSON.parse(@obj.attr_values["X_full_text"]) rescue {}
290
+ full_text["_widget_pool"] ||= {}
291
+ full_text["_widget_pool"].deep_merge!(@widget_pool)
292
+ full_text.to_json
293
+ end
288
294
 
289
295
  def upload_file(file)
290
296
  # only publication type can contain children (code = "5")
@@ -78,7 +78,7 @@ module Fiona7
78
78
  @raw_obj_class = Reactor::Cm::ObjClass.create(@values[:name].to_s, @values[:type].to_s)
79
79
  user_attributes = @attributes.map {|a| a[:real_name] }
80
80
  user_attributes ||= []
81
- built_in_attributes = ['X_widget_pool']
81
+ built_in_attributes = Fiona7::Initializer::ATTRIBUTES_MAP.keys
82
82
  @raw_obj_class.attributes = user_attributes + built_in_attributes
83
83
  end
84
84
 
@@ -19,7 +19,7 @@ module Fiona7
19
19
  user_attributes ||= []
20
20
 
21
21
  existing_attributes = @raw_obj_class.attributes
22
- built_in_attributes = ['X_widget_pool']
22
+ built_in_attributes = Fiona7::Initializer::ATTRIBUTES_MAP.keys
23
23
 
24
24
  # NOTE: removing attributes is now impossible
25
25
  new_attributes = (existing_attributes + built_in_attributes + user_attributes).map(&:to_s).uniq
@@ -0,0 +1,20 @@
1
+ module Fiona7
2
+ module ControllerHelper
3
+ def editing_context
4
+ Scrivito::EditingContextMiddleware.from_request(request)
5
+ end
6
+
7
+ def scrivito_in_editable_view?
8
+ editing_context.editable_display_mode?
9
+ end
10
+
11
+ def fiona7_in_editable_view?
12
+ scrivito_in_editable_view?
13
+ end
14
+
15
+ def self.included(base)
16
+ base.send(:helper_method, :scrivito_in_editable_view?)
17
+ base.send(:helper_method, :fiona7_in_editable_view?)
18
+ end
19
+ end
20
+ end
@@ -4,7 +4,7 @@ module Fiona7
4
4
  class BlobController
5
5
  def fetch(blob_id, transformation=false)
6
6
  public_get_url = BinaryHandling::UrlGenerator.new(blob_id, 'public_access', 'get', transformation).generate
7
- # all URLs are identic!
7
+ # all URLs are identical!
8
8
  # private_get_url = BinaryHandling::UrlGenerator.new(blob_id, 'private_access', 'get', false).generate
9
9
  # public_head_url = BinaryHandling::UrlGenerator.new(blob_id, 'public_access', 'head', false).generate
10
10
  # private_head_url = BinaryHandling::UrlGenerator.new(blob_id, 'private_access', 'head', false).generate
@@ -33,8 +33,14 @@ module Fiona7
33
33
  meta_binary = BinaryHandling::MetaBinary.new(blob_id)
34
34
  content_type = meta_binary.mime_type
35
35
  content_length = meta_binary.length
36
- width = meta_binary.width
37
- height = meta_binary.height
36
+
37
+ if meta_binary.image?
38
+ width = meta_binary.width
39
+ height = meta_binary.height
40
+ else
41
+ width = 0
42
+ height = 0
43
+ end
38
44
  {
39
45
  'meta_data' => {
40
46
  'content_type' => ['string', content_type],
data/lib/fiona7/engine.rb CHANGED
@@ -13,21 +13,26 @@ require "infopark_fiona_connector"
13
13
  #require "rails_connector/fiona_engine"
14
14
  require "infopark_reactor"
15
15
 
16
+ require "fiona7/initializer"
16
17
  require "fiona7/mode_switch"
18
+ require "fiona7/controller_helper"
17
19
  require "fiona7/scrivito_patches/attribute_content"
18
20
  require "fiona7/scrivito_patches/attribute_serializer"
19
21
  require "fiona7/scrivito_patches/basic_obj"
20
22
  require "fiona7/scrivito_patches/basic_widget"
21
23
  require "fiona7/scrivito_patches/binary"
22
24
  require "fiona7/scrivito_patches/cms_backend"
25
+ require "fiona7/scrivito_patches/child_list_tag"
23
26
  require "fiona7/scrivito_patches/cms_field_tag"
24
27
  require "fiona7/scrivito_patches/controller_actions"
25
28
  # different load order !!
26
29
  #require "fiona7/scrivito_patches/cms_dispatch_controller"
27
30
  require "fiona7/scrivito_patches/cms_rest_api"
28
31
  require "fiona7/scrivito_patches/cms_routing"
32
+ require "fiona7/scrivito_patches/layout_tags"
29
33
  require "fiona7/scrivito_patches/link_parser"
30
34
  require "fiona7/scrivito_patches/migrator"
35
+ require "fiona7/scrivito_patches/page_config"
31
36
  require "fiona7/scrivito_patches/type_computer"
32
37
  require "fiona7/scrivito_patches/workspace"
33
38
 
@@ -115,7 +120,6 @@ module Fiona7
115
120
 
116
121
  config.to_prepare do
117
122
  # TODO: do some smart optimizations
118
- require "fiona7/initializer"
119
123
  initializer = Fiona7::Initializer.new
120
124
  initializer.initialize_system
121
125
  end
@@ -155,7 +159,6 @@ module Fiona7
155
159
  end
156
160
 
157
161
  initializer "fiona7.authorize_reactor" do |app|
158
-
159
162
  ActionController::Base.__send__(:define_method, :rsession_auth) do
160
163
  if !Fiona7.login
161
164
  rsession.user_name = Fiona7.root unless rsession.user_name == Fiona7.root
@@ -6,8 +6,20 @@ module Fiona7
6
6
  'X_Container' => 'publication'
7
7
  }
8
8
 
9
+ CLASSES_TITLE_MAP = {
10
+ 'X_Generic' => {'Binärdatei (Systemvorlage)' => {'lang' => 'de'}, 'Binary file (system class)' => {'lang' => 'en'}},
11
+ 'X_Image' => {'Bilddatei (Systemvorlage)' => {'lang' => 'de'}, 'Image file (system class)' => {'lang' => 'en'}},
12
+ 'X_Container' => {'Container (Systemvorlage)' => {'lang' => 'de'}, 'Contaienr (system class)' => {'lang' => 'en'}}
13
+ }
14
+
9
15
  ATTRIBUTES_MAP = {
10
- 'X_widget_pool' => 'linklist'
16
+ 'X_widget_pool' => 'linklist',
17
+ 'X_full_text' => 'text'
18
+ }
19
+
20
+ ATTRIBUTES_TITLE_MAP = {
21
+ 'X_widget_pool' => {'Verlinkte Widgets (Systemfeld)' => {'lang' => 'de'}, 'Linked widgets (system field)' => {'lang' => 'en'}},
22
+ 'X_full_text' => {'Hauptinhalt für die Suchmaschine (Systemfeld)' => {'lang' => 'de'}, 'Body for search engine (system field)' => {'lang' => 'en'}}
11
23
  }
12
24
 
13
25
  def initialize_system
@@ -36,18 +48,26 @@ module Fiona7
36
48
  any_attribute_present ||= attribute && attribute.attribute_type == type
37
49
  end
38
50
 
39
- any_class_present && raise("Misconfiguration of attributes detected")
51
+ any_attribute_present && raise("Misconfiguration of attributes detected")
40
52
 
41
53
  return true
42
54
  end
43
55
 
44
56
  def classes_and_attributes
45
57
  CLASSES_MAP.each do |name, type|
46
- Reactor::Cm::ObjClass.create(name, type)
58
+ obj_class = Reactor::Cm::ObjClass.create(name, type)
59
+ obj_class.set(:title, CLASSES_TITLE_MAP[name])
60
+ obj_class.save!
47
61
  end
48
62
 
49
63
  ATTRIBUTES_MAP.each do |name, type|
50
- Reactor::Cm::Attribute.create(name, type)
64
+ attribute = Reactor::Cm::Attribute.create(name, type)
65
+ attribute.set(:title, ATTRIBUTES_TITLE_MAP[name])
66
+ if (type == 'text')
67
+ attribute.set(:isSearchableInCM, 1)
68
+ attribute.set(:isSearchableInTE, 1)
69
+ end
70
+ attribute.save!
51
71
  end
52
72
  end
53
73
 
@@ -56,7 +76,7 @@ module Fiona7
56
76
  valid_sub_obj_classes = read_valid_sub_obj_classes(obj_class)
57
77
 
58
78
  # empty valid_sub_obj_classes = allow all
59
- unless valid_sub_obj_classes.empty?
79
+ unless valid_sub_obj_classes.empty? || CLASSES_MAP.keys.all? {|obj_class| valid_sub_obj_classes.include?(obj_class) }
60
80
  valid_sub_obj_classes += CLASSES_MAP.keys
61
81
  cm_class = Reactor::Cm::ObjClass.get(obj_class.name)
62
82
  cm_class.set(:validSubObjClasses, valid_sub_obj_classes)
@@ -0,0 +1,28 @@
1
+ module Fiona7
2
+ class PermissionVolatileCache
3
+ PERMISSION_KEY = "F7PERMISSION_CACHE"
4
+
5
+ def initialize(request)
6
+ request[PERMISSION_KEY] ||= {}
7
+ self.storage = request[PERMISSION_KEY]
8
+ end
9
+
10
+ def permitted?(user_name, obj_id, action)
11
+ self.storage["#{user_name}:#{obj_id}:#{action}"] ||= lookup(user_name, obj_id, action)
12
+ end
13
+
14
+ protected
15
+ attr_accessor :storage
16
+
17
+ def lookup(user_name, obj_id, action)
18
+ return false unless user_name && obj_id && action
19
+
20
+ obj = Fiona7::EditedObj.new
21
+ obj.obj_id = obj_id.to_i
22
+ return obj.permission.send(:"#{action}?", user_name)
23
+ rescue Reactor::Cm::XmlSingleRequestError => e
24
+ Rails.logger.error("Error looking up the permission of #{user_name} for obj #{obj_id} for action #{action}:\n#{e.message}")
25
+ return false
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ require 'fiona7/permission_volatile_cache'
2
+
3
+ module Fiona7
4
+ module PermittedMixin
5
+ protected
6
+ def permitted?(user_name, obj_id, action)
7
+ @permission_cache ||= Fiona7::PermissionVolatileCache.new(view.request)
8
+ @permission_cache.permitted?(user_name, obj_id, action)
9
+ end
10
+ end
11
+ end
@@ -73,6 +73,10 @@ module Fiona7
73
73
  self.obj.body_length
74
74
  end
75
75
 
76
+ def image?
77
+ self.obj.image?
78
+ end
79
+
76
80
  def width
77
81
  self.cache("#{self.last_changed}-width") do
78
82
  if self.image
@@ -213,7 +217,7 @@ module Fiona7
213
217
  delegate :valid?, :present?,
214
218
  :filename, :filepath,
215
219
  :mime_type, :length, :last_changed,
216
- :width, :height,
220
+ :image?, :width, :height,
217
221
  :to => :implementation
218
222
 
219
223
  def initialize(binary_id, transformation=false)
@@ -0,0 +1,16 @@
1
+ require 'scrivito/child_list_tag'
2
+ require 'fiona7/permitted_mixin'
3
+
4
+ module Scrivito
5
+ class ChildListTag
6
+ include Fiona7::PermittedMixin
7
+
8
+ private
9
+ # add permission checking
10
+ def user_present?
11
+ view.scrivito_user.present? &&
12
+ (permitted?(view.scrivito_user.id, obj.id, :root) ||
13
+ permitted?(view.scrivito_user.id, obj.id, :create_children))
14
+ end
15
+ end
16
+ end
@@ -1,7 +1,10 @@
1
1
  require 'scrivito/cms_field_tag'
2
+ require 'fiona7/permitted_mixin'
2
3
 
3
4
  module Scrivito
4
5
  class CmsFieldTag
6
+ include Fiona7::PermittedMixin
7
+
5
8
  # support shadowclassing
6
9
  def build_valid_widget_classes
7
10
  obj_or_widget.valid_widget_ruby_classes_for(field_name).map do |widget_class|
@@ -14,6 +17,26 @@ module Scrivito
14
17
  }
15
18
  end
16
19
  end
20
+
21
+
22
+ private
23
+ # add permission checking
24
+ def authenticated_editor?
25
+ editing_context.authenticated_editor? &&
26
+ (permitted?(editing_context.editor.id, obj_not_widget_id, :root) ||
27
+ permitted?(editing_context.editor.id, obj_not_widget_id, :write))
28
+ end
29
+
30
+ def obj_not_widget_id
31
+ case obj_or_widget
32
+ when Scrivito::BasicObj
33
+ obj_or_widget.id
34
+ when Scrivito::BasicWidget
35
+ obj_or_widget.obj.id
36
+ else
37
+ raise ScrivitoError, "Expected an Obj or Widget to be passed to scrivito_tag, but #{obj_or_widget.class.name} received"
38
+ end
39
+ end
17
40
  end
18
41
  end
19
42
 
@@ -0,0 +1,10 @@
1
+ require 'scrivito/layout_tags'
2
+
3
+ module Scrivito
4
+ class LayoutTags
5
+ def generator_meta_tag
6
+ content = 'Fiona 7 by Infopark AG (infopark.de)'
7
+ view.tag(:meta, name: 'generator', content: content)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ require 'scrivito/page_config'
2
+
3
+ module Scrivito
4
+ class PageConfig
5
+ def current_page_config
6
+ # TODO: add permission info
7
+ return {} unless obj
8
+ {
9
+ id: obj.id,
10
+ path: obj.path,
11
+ obj_class: obj.obj_class,
12
+ has_children: obj.children.any?,
13
+ has_conflict: obj.has_conflict?,
14
+ has_details_view: obj_has_details_view?,
15
+ modification: modification(obj),
16
+ parent_path: obj.parent_path,
17
+ restriction_messages: editor.restriction_messages_for(obj),
18
+ }
19
+ end
20
+ end
21
+ end
@@ -40,7 +40,7 @@ module Fiona7
40
40
  end
41
41
 
42
42
  self.rc_obj_class.custom_attributes.each do |real_name, cms_attribute|
43
- next if real_name == 'X_widget_pool'
43
+ next if Fiona7::Initializer::ATTRIBUTES_MAP.key?(real_name)
44
44
 
45
45
  # TODO: move this to a better place
46
46
  if Fiona7.mode == :standalone
@@ -204,6 +204,11 @@ module Fiona7
204
204
  true
205
205
  when [:text, :string]
206
206
  true
207
+ when [:string, :enum]
208
+ # this case can occur when an enum
209
+ # was initially ad-hoc created, but now
210
+ # has a proper definition
211
+ true
207
212
  else
208
213
  #raise "Attribute types for #{attr_name} incompatible: CMS uses #{cms_type} but the application provided #{usr_type}"
209
214
  puts "Attribute types for #{attr_name} incompatible: CMS uses #{cms_type} but the application provided #{usr_type}"
@@ -1,3 +1,3 @@
1
1
  module Fiona7
2
- VERSION = "0.71.0.0"
2
+ VERSION = "0.71.0.1"
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.71.0.0
4
+ version: 0.71.0.1
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-10-21 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -174,6 +174,7 @@ files:
174
174
  - lib/fiona7/builder/widget_builder.rb
175
175
  - lib/fiona7/builder/widget_building.rb
176
176
  - lib/fiona7/builder/widget_updater.rb
177
+ - lib/fiona7/controller_helper.rb
177
178
  - lib/fiona7/controllers/content_service/obj_controller.rb
178
179
  - lib/fiona7/controllers/content_service/workspace_controller.rb
179
180
  - lib/fiona7/controllers/rest_api/blob_controller.rb
@@ -199,6 +200,8 @@ files:
199
200
  - lib/fiona7/mode_switch/composite.rb
200
201
  - lib/fiona7/mode_switch/views.rb
201
202
  - lib/fiona7/naive_search_engine.rb
203
+ - lib/fiona7/permission_volatile_cache.rb
204
+ - lib/fiona7/permitted_mixin.rb
202
205
  - lib/fiona7/recursive_link_resolver.rb
203
206
  - lib/fiona7/routers/content_service.rb
204
207
  - lib/fiona7/routers/rest_api.rb
@@ -208,15 +211,18 @@ files:
208
211
  - lib/fiona7/scrivito_patches/basic_obj.rb
209
212
  - lib/fiona7/scrivito_patches/basic_widget.rb
210
213
  - lib/fiona7/scrivito_patches/binary.rb
214
+ - lib/fiona7/scrivito_patches/child_list_tag.rb
211
215
  - lib/fiona7/scrivito_patches/client_config.rb
212
216
  - lib/fiona7/scrivito_patches/cms_backend.rb
213
217
  - lib/fiona7/scrivito_patches/cms_field_tag.rb
214
218
  - lib/fiona7/scrivito_patches/cms_rest_api.rb
215
219
  - lib/fiona7/scrivito_patches/cms_routing.rb
216
220
  - lib/fiona7/scrivito_patches/controller_actions.rb
221
+ - lib/fiona7/scrivito_patches/layout_tags.rb
217
222
  - lib/fiona7/scrivito_patches/link_parser.rb
218
223
  - lib/fiona7/scrivito_patches/migrator.rb
219
224
  - lib/fiona7/scrivito_patches/obj_class.rb
225
+ - lib/fiona7/scrivito_patches/page_config.rb
220
226
  - lib/fiona7/scrivito_patches/type_computer.rb
221
227
  - lib/fiona7/scrivito_patches/workspace.rb
222
228
  - lib/fiona7/scrivito_user.rb