infopark_fiona7 1.2.0.1.1 → 1.2.0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ (function () {
4
+ // -- PATCH BEGINS HERE --
5
+ // remove old scrivito.binaryFieldElement
6
+ var definitions = scrivito.cms_element.definitions;
7
+ for (var i = 0; i < definitions.length; ++i) {
8
+ if (definitions[i] === scrivito.binaryFieldElement) {
9
+ definitions.splice(i, 1);
10
+ break;
11
+ }
12
+ }
13
+ // -- PATCH ENDS HERE --
14
+
15
+ scrivito.binaryFieldElement = {
16
+ create_instance: function create_instance(cmsElement) {
17
+ if (cmsElement.dom_element().attr('data-scrivito-field-type') === 'binary') {
18
+ var that = scrivito.cms_field_element.create_instance(cmsElement);
19
+ // -- PATCH BEGINS HERE --
20
+ /*
21
+ const bufferedWriter = new scrivito.BufferedWriter((value) => {
22
+ if (scrivito.BinaryUtils.isFile(value)) {
23
+ return scrivito.Binary.upload(value).into(that.basic_obj());
24
+ }
25
+ if (value instanceof scrivito.FutureBinary) {
26
+ return value.into(that.basic_obj());
27
+ }
28
+ return scrivito.Promise.resolve(value);
29
+ });
30
+ _.extend(that, {
31
+ preprocess(value) {
32
+ return bufferedWriter.write(value).catch((error) => {
33
+ scrivito.handleAjaxError(error);
34
+ throw error;
35
+ });
36
+ },
37
+ });
38
+ */
39
+
40
+ _.extend(that, {
41
+ preprocess: function preprocess(value) {
42
+ return scrivito.Promise.resolve(value);
43
+ }
44
+ });
45
+ // -- PATCH ENDS HERE --
46
+
47
+ return that;
48
+ }
49
+ }
50
+ };
51
+
52
+ scrivito.cms_element.definitions.push(scrivito.binaryFieldElement);
53
+ })();
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ (function () {
4
+ scrivito.ObjSerializer = {
5
+ serialize: function serialize(objId, attrs) {
6
+ var promise = serializeWidgetPool(objId, attrs._widget_pool).then(function (widgetPool) {
7
+ return serializeAttrs(objId, attrs).then(function (serializedAttrs) {
8
+ if (widgetPool) {
9
+ serializedAttrs._widget_pool = widgetPool;
10
+ }
11
+ return serializedAttrs;
12
+ });
13
+ });
14
+
15
+ return scrivito.promise.wrapInJqueryDeferred(promise);
16
+ },
17
+
18
+ serializeValue: function serializeValue(value) {
19
+ if (_.isDate(value)) {
20
+ return moment.utc(value).toISOString();
21
+ }
22
+
23
+ return value;
24
+ }
25
+ };
26
+
27
+ function serializeWidgetPool(objId, widgetPool) {
28
+ if (widgetPool) {
29
+ var promises = _.map(widgetPool, function (attrs, widgetId) {
30
+ return serializeAttrs(objId, attrs).then(function (serializedAttrs) {
31
+ return [widgetId, serializedAttrs];
32
+ });
33
+ });
34
+
35
+ return scrivito.Promise.all(promises).then(function (serializedWidgetPool) {
36
+ return _.object(serializedWidgetPool);
37
+ });
38
+ }
39
+
40
+ return scrivito.Promise.resolve(widgetPool);
41
+ }
42
+
43
+ function serializeAttrs(objId, attrs) {
44
+ var promises = _.map(attrs, function (attrValue, attrName) {
45
+ return serializeAttr(objId, attrName, attrValue);
46
+ });
47
+
48
+ return scrivito.Promise.all(promises).then(function (serializedAttrs) {
49
+ return _.object(serializedAttrs);
50
+ });
51
+ }
52
+
53
+ function serializeAttr(objId, attrName, attrValue) {
54
+ if (scrivito.BinaryUtils.isFile(attrValue) || scrivito.BinaryUtils.isBlob(attrValue)) {
55
+ return serializeFile(objId, attrName, attrValue);
56
+ }
57
+
58
+ if (attrValue instanceof scrivito.UploadedBlob) {
59
+ return serializeUploadedBlob(objId, attrName, attrValue);
60
+ }
61
+
62
+ if (attrValue instanceof scrivito.FutureBinary) {
63
+ return serializeFutureBinary(objId, attrName, attrValue);
64
+ }
65
+
66
+ return scrivito.Promise.resolve([attrName, scrivito.ObjSerializer.serializeValue(attrValue)]);
67
+ }
68
+
69
+ function serializeFile(objId, attrName, file) {
70
+ return scrivito.Promise.resolve([attrName, file]); // <-- PATCH HERE
71
+ }
72
+
73
+ function serializeUploadedBlob(objId, attrName, uploadedBlob) {
74
+ return serializeFutureBinary(objId, attrName, uploadedBlob.copy());
75
+ }
76
+
77
+ function serializeFutureBinary(objId, attrName, futureBinary) {
78
+ if (futureBinary.idToCopy) {
79
+ // blob copy/rename
80
+ var blob = {
81
+ id_to_copy: futureBinary.idToCopy
82
+ };
83
+ if (futureBinary.filename) blob.filename = futureBinary.filename;
84
+ if (futureBinary.contentType) blob.content_type = futureBinary.contentType;
85
+ return scrivito.Promise.resolve([attrName, blob]);
86
+ } else if (futureBinary.source) {
87
+ // normal upload
88
+ return scrivito.Promise.resolve([attrName, { blob_to_upload: futureBinary.source, filename: futureBinary.filename }]);
89
+ }
90
+ }
91
+ })();
@@ -21,7 +21,8 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency "scrivito_sdk"
22
22
  s.add_dependency "scrivito_editors"
23
23
  s.add_dependency "infopark_fiona_connector", "= 7.0.1.beta2"
24
- s.add_dependency "infopark_reactor", ">= 1.22.4"
24
+ s.add_dependency "infopark_reactor", ">= 1.23.1"
25
25
  s.add_dependency "mini_magick"
26
+ s.add_dependency "jquery-ui-rails", "< 6.0.0"
26
27
  #s.add_development_dependency "ruby-prof"
27
28
  end
@@ -1,4 +1,6 @@
1
1
  require 'fiona7/assert'
2
+ require 'fiona7/attribute_type_mapper'
3
+ require 'fiona7/obj_class_name_demangler'
2
4
 
3
5
  module Fiona7
4
6
  module Builder
@@ -41,8 +43,13 @@ module Fiona7
41
43
  cms_attribute = RailsConnector::Attribute.find_by_attribute_name(attribute[:real_name])
42
44
  raw_attribute = Reactor::Cm::Attribute.get(attribute[:real_name].to_s)
43
45
 
46
+ expected_real_type = Fiona7::AttributeTypeMapper.new(
47
+ Fiona7::ObjClassNameDemangler.new(@values[:name]).demangle
48
+ ).call(attribute[:name].to_sym, attribute[:type].to_sym)
49
+
44
50
  if attribute[:type] == :reference || attribute[:type] == :referencelist || attribute[:type] == :link || attribute[:type] == :widgetlist
45
- if cms_attribute.attribute_type == "linklist"
51
+ if cms_attribute.attribute_type == expected_real_type.to_s
52
+ # FIXME: it is not neccessary to write this information for each sync
46
53
  raw_attribute.set(:helpText, ::ActiveSupport::JSON.encode({type: attribute[:type]}))
47
54
  raw_attribute.save!
48
55
  else
@@ -69,6 +76,7 @@ module Fiona7
69
76
  # Nothing to do.
70
77
  Rails.logger.warn("TYPE SYNCHRONIZATION: Type #{attribute[:type]} requested for #{attribute[:real_name]}, but is #{cms_attribute.attribute_type}, this may cause errors.")
71
78
  elsif attribute[:type] == :enum || attribute[:type] == :multienum
79
+ # TODO: AttributeTypeMapper
72
80
  if cms_attribute.attribute_type == "multienum" || cms_attribute.attribute_type == "enum"
73
81
  if attribute[:values]
74
82
  # do not remove values
@@ -82,11 +90,7 @@ module Fiona7
82
90
  Assert.constraint(false, "Type #{attribute[:type]} requested for #{attribute[:real_name]}, but is #{cms_attribute.attribute_type}")
83
91
  end
84
92
  end
85
- elsif cms_attribute.attribute_type == "text"
86
- if attribute[:type] != :string && attribute[:type] != :stringlist
87
- Assert.constraint(false, "Type #{attribute[:type]} requested for #{attribute[:real_name]}, but is #{cms_attribute.attribute_type}")
88
- end
89
- elsif attribute[:real_type].to_s != cms_attribute.attribute_type
93
+ elsif attribute[:real_type].to_s != expected_real_type.to_s
90
94
  Assert.constraint(false, "Type #{attribute[:type]} requested for #{attribute[:real_name]}, but is #{cms_attribute.attribute_type}")
91
95
  end
92
96
  end
data/lib/fiona7/engine.rb CHANGED
@@ -157,16 +157,21 @@ module Fiona7
157
157
  config.editing_auth do |env|
158
158
  request = ActionDispatch::Request.new(env)
159
159
  session = request.session
160
- rsession = session[:rsession]
160
+ rsession = Reactor::SessionHelper::RsessionHelper.from_session(session)
161
161
  if rsession && rsession.user?
162
162
  Fiona7::ScrivitoUser.define(rsession.user)
163
163
  end
164
164
  end
165
165
 
166
166
  config.find_user do |user_id|
167
- user = Reactor::Cache::User.instance.get(user_id)
168
-
169
- Fiona7::ScrivitoUser.define(user)
167
+ begin
168
+ user = Reactor::Cache::User.instance.get(user_id)
169
+ Fiona7::ScrivitoUser.define(user)
170
+ rescue Reactor::Cm::XmlSingleRequestError => e
171
+ # this is the error code for entry (possibly user) not found
172
+ # other errors we want to pass on (unauthorized, etc)
173
+ raise e unless e.message =~ /060001/
174
+ end
170
175
  end
171
176
  end
172
177
  end
@@ -237,7 +242,7 @@ module Fiona7
237
242
  # for the current user (root most likely), which is not
238
243
  # really a thing that we want - being root by default
239
244
  # should only happen in the root mode
240
- if !session[:rsession]
245
+ if !rsession.user?
241
246
  rsession.destroy
242
247
  end
243
248
  end
@@ -1,3 +1,3 @@
1
1
  module Fiona7
2
- VERSION = "1.2.0.1.1"
2
+ VERSION = "1.2.0.1.3"
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: 1.2.0.1.1
4
+ version: 1.2.0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Przedmojski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-02 00:00:00.000000000 Z
11
+ date: 2017-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 1.22.4
89
+ version: 1.23.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 1.22.4
96
+ version: 1.23.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: mini_magick
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: jquery-ui-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "<"
116
+ - !ruby/object:Gem::Version
117
+ version: 6.0.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "<"
123
+ - !ruby/object:Gem::Version
124
+ version: 6.0.0
111
125
  description: scrivito-compatible interface for classic Fiona
112
126
  email:
113
127
  - tomasz.przedmojski@infopark.de
@@ -120,10 +134,18 @@ files:
120
134
  - app/assets/images/fiona7-logo.png
121
135
  - app/assets/images/fiona7-marker.png
122
136
  - app/assets/javascripts/fiona7.js
137
+ - app/assets/javascripts/fiona7/templates.js
123
138
  - app/assets/javascripts/fiona7_ui.js
139
+ - app/assets/javascripts/scrivito_patches/ajax_error_handling.js
140
+ - app/assets/javascripts/scrivito_patches/attribute_serializer.js
141
+ - app/assets/javascripts/scrivito_patches/binary_utils.js
142
+ - app/assets/javascripts/scrivito_patches/cms_rest_api.js
124
143
  - app/assets/javascripts/scrivito_patches/models/ajax.js
144
+ - app/assets/javascripts/scrivito_patches/models/api/basic_obj.js
145
+ - app/assets/javascripts/scrivito_patches/models/binary_field_element.js
125
146
  - app/assets/javascripts/scrivito_patches/models/blob.js
126
147
  - app/assets/javascripts/scrivito_patches/models/obj.js
148
+ - app/assets/javascripts/scrivito_patches/obj_serializer.js
127
149
  - app/assets/stylesheets/fiona7-login.css.scss
128
150
  - app/assets/stylesheets/fiona7.css.scss
129
151
  - app/assets/stylesheets/fiona7_ui.css.scss
@@ -267,7 +289,6 @@ files:
267
289
  - lib/fiona7/scrivito_patches/cms_field_tag.rb
268
290
  - lib/fiona7/scrivito_patches/cms_rest_api.rb
269
291
  - lib/fiona7/scrivito_patches/cms_routing.rb
270
- - lib/fiona7/scrivito_patches/date_attribute.rb
271
292
  - lib/fiona7/scrivito_patches/layout_tags.rb
272
293
  - lib/fiona7/scrivito_patches/link_parser.rb
273
294
  - lib/fiona7/scrivito_patches/log_subscriber.rb
@@ -319,4 +340,3 @@ signing_key:
319
340
  specification_version: 4
320
341
  summary: scrivito-compatible interface for classic Fiona
321
342
  test_files: []
322
- has_rdoc:
@@ -1,16 +0,0 @@
1
- require 'scrivito/date_attribute'
2
-
3
- module Scrivito
4
- module DateAttribute
5
- def self.deserialize_from_backend(iso_date_time)
6
- return nil unless iso_date_time
7
- #return nil if iso_date.to_s.blank?
8
-
9
- if iso_date_time.to_s =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/
10
- Time.utc($1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i).in_time_zone
11
- else
12
- raise "The value is not a valid ISO date time: #{iso_date_time.inspect}"
13
- end
14
- end
15
- end
16
- end