infopark_fiona7 0.70.0.3 → 0.71.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b1fc78f3cf18fd7616540dacdafd60cd8029a88
4
- data.tar.gz: 8775edf24d77b6b9b1e2f07eb63ea48b5cb1f37a
3
+ metadata.gz: b01a9b4b8f32420a4dbc9a71b7715e4b435064fe
4
+ data.tar.gz: 52cd4e1ead233d6687abea23efc30c8356a34fcd
5
5
  SHA512:
6
- metadata.gz: 7d2850182f8a7602e2bfa9636b7f2151e6bcecf314168d42bb6ce5a35fa6cea4b005b826acffe6f98ea804c9bc10ac1cf176771c00978a5334a9e8bdd2df72af
7
- data.tar.gz: 1934ad1d509bf4bc3c21a01317f416f654649491ee5e620a5b41291d237d8044740a676edf3e1495d0f74d2a0ee804398942b50cda52ca26a57bd513638161ee
6
+ metadata.gz: 43a8472b368e2b0c97215dc78a9695b3b163b20fbda466b5be8661bbbe1ee245ad265b475758c78b1595d43964c34f9d450e4d1faf42272bd33b0e439f973b03
7
+ data.tar.gz: 7f7076b7cc9d09f4fb082b9a19776ceb98132c78c1d425cc17e021091f229056aee960cf222604ee97895e4ea390f2598e4c85bd36b66f1b5a8be7f5a465f9e4
@@ -1,114 +1,6 @@
1
- /* obj.js, patch create & upload */
2
- (function() {
3
- var scrivito = window.scrivito;
4
- var _ = window._;
5
- var $ = window.$;
6
-
7
- var format_date = function(date) {
8
- return date.getUTCFullYear().toString() +
9
- format_date_number(date.getUTCMonth() + 1) + // Month numbers are starting at 0.
10
- format_date_number(date.getUTCDate()) +
11
- format_date_number(date.getUTCHours()) +
12
- format_date_number(date.getUTCMinutes()) +
13
- format_date_number(date.getUTCSeconds());
14
- };
15
-
16
- var format_date_number = function(number) {
17
- var string = number.toString();
18
- return string.length === 1 ? '0' + string : string;
19
- };
20
-
21
- var convert_attributes = function(data) {
22
- var collected_promises = _.map(data, function(value, field_name) {
23
- if (value instanceof Date) {
24
- return $.Deferred().resolve([field_name, format_date(value)]);
25
- } else if (value instanceof window.File) {
26
- return $.Deferred().resolve([field_name, value]);
27
- return scrivito.blob.create(value).then(function(value) {
28
- return [field_name, value];
29
- });
30
- } else {
31
- return $.Deferred().resolve([field_name, value]);
32
- }
33
- });
34
-
35
- return $.when.apply(this, collected_promises).then(function() {
36
- return _.object(arguments);
37
- });
38
- };
39
-
40
- var convert_widget_pool = function(widget_pool) {
41
- if(widget_pool) {
42
- var conversion_promises = _.map(widget_pool, function(attributes, widget_id) {
43
- return convert_attributes(attributes).then(function(attributes) {
44
- return [widget_id, attributes];
45
- });
46
- });
47
-
48
- return $.when.apply(this, conversion_promises).then(function() {
49
- return _.object(arguments);
50
- });
51
- } else {
52
- return $.Deferred().resolve(widget_pool);
53
- }
54
- };
55
-
56
- var prepare_attributes = function(data) {
57
- return convert_widget_pool(data._widget_pool).then(function(widget_pool) {
58
- return convert_attributes(data).then(function(attributes) {
59
- attributes._widget_pool = widget_pool;
60
- return attributes;
61
- });
62
- });
63
- };
64
-
65
- scrivito.obj.create_original = scrivito.obj.create;
66
- scrivito.obj.create = function (data) {
67
- var blob;
68
-
69
- if (data['blob']) {
70
- blob = data['blob'];
71
- delete data['blob'];
72
- }
73
- return prepare_attributes(data).then(function(attributes) {
74
- var fd, defer, url, base_url = window.location.protocol + '//' + window.location.host + '/__scrivito/';
75
- url = base_url + 'objs';
76
-
77
- fd = new FormData();
78
-
79
- $.each(attributes, function (key, value) {
80
- if (typeof value !== 'undefined') {
81
- fd.append('obj[' + key + ']', value);
82
- }
83
- });
84
-
85
- if (typeof blob !== 'undefined') {
86
- fd.append('obj[blob]', blob);
87
- }
88
-
89
- defer = $.Deferred();
90
-
91
- $.ajax({
92
- url: url,
93
- type: 'POST',
94
- data: fd,
95
- processData: false,
96
- contentType: false
97
- })
98
- .error(function (xhr, text, error) {
99
- scrivito.alert(text);
100
- defer.reject(text);
101
- })
102
- .success(function (new_data) {
103
- defer.resolve(scrivito.obj.create_instance(new_data));
104
- });
105
-
106
- return defer.promise();
107
- });
108
- };
109
-
110
- }());
111
-
1
+ //= require scrivito_patches/models/blob
2
+ //= require scrivito_patches/models/obj
3
+ //= require_self
112
4
 
113
5
  (function() {
114
6
  var scrivito = window.scrivito;
@@ -256,6 +148,7 @@
256
148
  actions = ["release"];
257
149
 
258
150
  scrivito.gui.on('document', function(cms_document) {
151
+ console.log('adding release button');
259
152
  var obj = cms_document.page();
260
153
 
261
154
  _.each(actions, function(action,idx) {
@@ -295,7 +188,7 @@
295
188
  menu.push(scrivito.command_separator.create_instance({id: 'fiona7.zz_sparator'}));
296
189
  cms_document.set_menu(menu);
297
190
 
298
- scrivito.configure_menu_order(['fiona7.*', '*']);
191
+ //scrivito.configure_menu_order(['fiona7.*', '*']);
299
192
  });
300
193
 
301
194
  return;
@@ -0,0 +1,29 @@
1
+ (function() {
2
+ _.extend(scrivito, {
3
+ blob: {
4
+ create: function(obj_id, binary) {
5
+ var uploaded_binary = binary.is_uploaded_binary ? binary : scrivito.blob.upload_binary(binary);
6
+ return $.Deferred().resolve(uploaded_binary);
7
+ },
8
+
9
+ // For testing purpose only.
10
+ get_form_data: function() {
11
+ return new FormData();
12
+ },
13
+
14
+ upload_binary: function(params) {
15
+ var blob = params.blob || params.file;
16
+ if (!blob) { $.error('need blob or file'); }
17
+ if (!params.content_type) { params.content_type = blob.type; }
18
+ if (!params.filename) {
19
+ if (params.blob) { $.error('blob needs a filename'); }
20
+ params.filename = blob.name;
21
+ }
22
+ params.filename = params.filename.replace(/[^\w\-_\.$]/g, '-');
23
+
24
+ return $.extend(params, {is_uploaded_binary: true});
25
+ }
26
+ }
27
+ });
28
+
29
+ }());
@@ -0,0 +1,369 @@
1
+ (function() {
2
+ _.extend(scrivito, {
3
+ obj: {
4
+ serialize_value: function(value) {
5
+ if (_.isDate(value)) {
6
+ return serialize_date(value);
7
+ } else {
8
+ return value;
9
+ }
10
+ },
11
+
12
+ create_instance: function(params) {
13
+ var that = {
14
+ id: function() {
15
+ return params.id;
16
+ },
17
+
18
+ obj_class: function() {
19
+ return params.obj_class;
20
+ },
21
+
22
+ description_for_editor: function() {
23
+ return params.description_for_editor;
24
+ },
25
+
26
+ modification: function() {
27
+ return params.modification;
28
+ },
29
+
30
+ is_new: function() {
31
+ return that.modification() === 'new';
32
+ },
33
+
34
+ is_edited: function() {
35
+ return that.modification() === 'edited';
36
+ },
37
+
38
+ is_deleted: function() {
39
+ return that.modification() === 'deleted';
40
+ },
41
+
42
+ has_children: function() {
43
+ return !!params.has_children;
44
+ },
45
+
46
+ has_conflict: function() {
47
+ return !!params.has_conflict;
48
+ },
49
+
50
+ has_restriction : function() {
51
+ return that.restriction_messages().length > 0;
52
+ },
53
+
54
+ restriction_messages: function() {
55
+ return params.restriction_messages || [];
56
+ },
57
+
58
+ is_binary: function() {
59
+ return !!params.is_binary;
60
+ },
61
+
62
+ has_details_view: function() {
63
+ return !!params.has_details_view;
64
+ },
65
+
66
+ tooltip: function() {
67
+ if (editing_state()) {
68
+ return scrivito.t('obj.tooltip.' + editing_state());
69
+ }
70
+ },
71
+
72
+ last_changed: function() {
73
+ return params.last_changed;
74
+ },
75
+
76
+ parent_path: function() {
77
+ return params.parent_path;
78
+ },
79
+
80
+ save: function(attrs) {
81
+ return prepare_attrs(that.id(), attrs).then(function(prepared_attrs) {
82
+ return persist_obj_data(prepared_attrs, that.id());
83
+ });
84
+ },
85
+
86
+ destroy: function() {
87
+ return scrivito.ajax('DELETE', 'objs/' + that.id()).then(function(result) {
88
+ return result.redirect_to;
89
+ });
90
+ },
91
+
92
+ destroy_widget: function(widget_id) {
93
+ return scrivito.ajax('PUT',
94
+ 'objs/' + that.id() + '/destroy_widget?widget_id=' + widget_id);
95
+ },
96
+
97
+ revert: function() {
98
+ return scrivito.ajax('PUT', 'objs/' + that.id() + '/revert');
99
+ },
100
+
101
+ revert_widget: function(widget_id) {
102
+ return scrivito.ajax('PUT', 'objs/'+that.id()+'/revert_widget?widget_id='+widget_id);
103
+ },
104
+
105
+ conflicting_workspaces: function() {
106
+ return scrivito.ajax('GET', 'objs/' + that.id() + '/conflicting_workspaces').then(
107
+ function(workspace_datas) {
108
+ return scrivito.workspace.from_data_collection(workspace_datas);
109
+ });
110
+ },
111
+
112
+ is_outdated: function() {
113
+ return scrivito.ajax('GET', 'objs/' + that.id() + '/is_outdated').then(
114
+ function(result) { return result.is_outdated; });
115
+ },
116
+
117
+ restore: function() {
118
+ return scrivito.ajax('PUT', 'objs/' + that.id() + '/restore');
119
+ },
120
+
121
+ restore_widget: function(widget_id) {
122
+ return scrivito.ajax('PUT', 'objs/'+that.id()+'/restore_widget?widget_id='+widget_id);
123
+ },
124
+
125
+ details_src: function() {
126
+ // TODO unify with ajax url generation
127
+ return '/__scrivito/page_details/' + that.id();
128
+ },
129
+
130
+ mark_resolved: function() {
131
+ return scrivito.ajax('PUT', 'objs/' + that.id() + '/mark_resolved');
132
+ },
133
+
134
+ copy_to: function(path) {
135
+ var attrs = {data: {parent_path: path}};
136
+ return scrivito.ajax('POST', 'objs/'+that.id()+'/copy', attrs).then(function(data) {
137
+ return scrivito.obj.create_instance(data);
138
+ });
139
+ },
140
+
141
+ duplicate: function() {
142
+ return scrivito.ajax('POST', 'objs/'+that.id()+'/duplicate').then(function(data) {
143
+ return scrivito.obj.create_instance(data);
144
+ });
145
+ },
146
+
147
+ transfer_modifications_to: function(workspace_id) {
148
+ return scrivito.ajax('PUT', 'objs/'+that.id()+'/transfer_modifications',
149
+ {data: {workspace_id: workspace_id}});
150
+ },
151
+
152
+ reload: function() {
153
+ return scrivito.ajax('GET', 'objs/'+that.id()).then(function(data) {
154
+ params.has_conflict = data.has_conflict;
155
+ params.modification = data.modification;
156
+ });
157
+ },
158
+
159
+ reload_widget: function(widget_id) {
160
+ return scrivito.ajax('GET', 'objs/'+that.id()+'/widget?widget_id='+widget_id);
161
+ }
162
+ };
163
+
164
+ var editing_state = function() {
165
+ if (that.is_new()) {
166
+ return 'is_new';
167
+ }
168
+
169
+ if (that.is_edited()) {
170
+ return 'is_edited';
171
+ }
172
+
173
+ if (that.is_deleted()) {
174
+ return 'is_deleted';
175
+ }
176
+ };
177
+
178
+ return that;
179
+ },
180
+
181
+ fetch_class_selection: function(path, params) {
182
+ if (params) { path += '?'+$.param(params); }
183
+ return scrivito.ajax('GET', path).then(function(selection) {
184
+ var names = _.pluck(selection, 'name');
185
+ var recent = scrivito.obj_class_selection.recent(names);
186
+ var popular = _.intersection(scrivito.popular_obj_classes, names);
187
+ return {
188
+ all: _.sortBy(selection, 'name'),
189
+ recent: _.map(recent, function(name) { return _.findWhere(selection, {name: name}); }),
190
+ popular: _.map(popular, function(name) { return _.findWhere(selection, {name: name}); })
191
+ };
192
+ });
193
+ },
194
+
195
+ fetch_page_class_selection: function(params) {
196
+ return scrivito.obj.fetch_class_selection('objs/page_class_selection', params);
197
+ },
198
+
199
+ create: function(attrs) {
200
+ return prepare_attrs(scrivito.random_id(), attrs).then(function(prepared_attrs) {
201
+ return persist_obj_data(prepared_attrs).then(function (data) {
202
+ scrivito.obj_class_selection.store(prepared_attrs._obj_class);
203
+ return scrivito.obj.create_instance(data);
204
+ });
205
+ });
206
+ },
207
+
208
+ transfer_modifications: function(objs, workspace_id) {
209
+ return $.when.apply(null, _.map(objs, function(obj) {
210
+ return obj.transfer_modifications_to(workspace_id).then(function(result) {
211
+ if (result.status !== 'success') { return {obj: obj, reason: result.reason}; }
212
+ });
213
+ })).then(function() { return $.Deferred().resolve(_.compact(arguments)); });
214
+ }
215
+ }
216
+ });
217
+
218
+ var obj_url = function (obj_id) {
219
+ var url = window.location.protocol + '//' + window.location.host + '/__scrivito/objs';
220
+ if (typeof obj_id !== 'undefined') {
221
+ url = url + "/" + obj_id;
222
+ }
223
+ return url;
224
+ };
225
+
226
+ var persist_obj_data = function (attributes, obj_id) {
227
+ var has_binary=false;
228
+ var fd, defer, url, type;
229
+
230
+ $.each(attributes, function (key, value) {
231
+ if (value && value.is_uploaded_binary) {
232
+ has_binary=true;
233
+ } else if (instance_of_anywhere(value, 'File')) {
234
+ has_binary=true
235
+ }
236
+ });
237
+
238
+ // use standard handling for cases without binary upload
239
+ if (!has_binary) {
240
+ if (typeof obj_id !== 'undefined') {
241
+ return scrivito.ajax('PUT', 'objs/'+obj_id, {data: {obj: attributes}});
242
+ } else {
243
+ return scrivito.ajax('POST', 'objs', {data: {obj: attributes}});
244
+ }
245
+ }
246
+
247
+ // use special handling for uploads
248
+ fd = new FormData();
249
+ url = obj_url(obj_id);
250
+ type = (typeof obj_id !== 'undefined') ? 'PUT' : 'POST';
251
+
252
+ $.each(attributes, function (key, value) {
253
+ if ((typeof value === 'object') && (key == '_widget_pool')) {
254
+ $.each(value, function (subkey, subval) {
255
+ if (typeof value !== 'undefined') {
256
+ fd.append('obj[' + key + ']' + '[' + subkey + ']', subval);
257
+ }
258
+ });
259
+ } else if (value && value.is_uploaded_binary && value.filename) {
260
+ fd.append('obj[' + key + ']', value.blob || value.file, value.filename);
261
+ } else if (typeof value !== 'undefined') {
262
+ fd.append('obj[' + key + ']', value);
263
+ }
264
+ });
265
+
266
+ defer = $.Deferred();
267
+
268
+ $.ajax({
269
+ url: url,
270
+ type: type,
271
+ data: fd,
272
+ processData: false,
273
+ contentType: false
274
+ })
275
+ .error(function (xhr, text_status, error) {
276
+ var error_message;
277
+ var error_code;
278
+ try {
279
+ var error_json = JSON.parse(xhr.responseText);
280
+ error_message = error_json.error;
281
+ error_code = error_json.code;
282
+ } catch (SyntaxError) {}
283
+
284
+ if (!error_message) {
285
+ error_message = error;
286
+ }
287
+ scrivito.display_ajax_error(error_message);
288
+ defer.reject(error_message);
289
+ })
290
+ .success(function (new_data) {
291
+ defer.resolve((new_data));
292
+ });
293
+
294
+ return defer.promise();
295
+ };
296
+
297
+ var is_file = function(object) {
298
+ return object &&
299
+ _.isFunction(object.slice) &&
300
+ _.isDate(object.lastModifiedDate) &&
301
+ _.isString(object.name);
302
+ };
303
+
304
+ var instance_of_anywhere = function (object, ctor_name) {
305
+ var i, val=false, possible_ctor;
306
+ for (i=0; i < window.frames.length; ++i) {
307
+ possible_ctor = window.frames[i][ctor_name];
308
+ if ((typeof possible_ctor === 'function') && (object instanceof possible_ctor)) {
309
+ val = true;
310
+ }
311
+ }
312
+ return val;
313
+ };
314
+
315
+ var format_date_number = function(number) {
316
+ var string = number.toString();
317
+ return string.length === 1 ? '0' + string : string;
318
+ };
319
+
320
+ var serialize_date = function(date) {
321
+ return date.getUTCFullYear().toString() +
322
+ '-' + format_date_number(date.getUTCMonth() + 1) + // Month numbers are starting at 0.
323
+ '-' + format_date_number(date.getUTCDate()) +
324
+ 'T' + format_date_number(date.getUTCHours()) +
325
+ ':' + format_date_number(date.getUTCMinutes()) +
326
+ ':' + format_date_number(date.getUTCSeconds()) +
327
+ 'Z';
328
+ };
329
+
330
+ var convert_attrs = function(obj_id, attrs) {
331
+ var collected_promises = _.map(attrs, function(value, field_name) {
332
+ if (is_file(value)) {
333
+ return $.Deferred().resolve([field_name, value]);
334
+ } else if (value && value.is_uploaded_binary) {
335
+ return $.Deferred().resolve([field_name, value]);
336
+ }
337
+ return $.Deferred().resolve([field_name, scrivito.obj.serialize_value(value)]);
338
+ });
339
+
340
+ return $.when.apply(this, collected_promises).then(function() {
341
+ return _.object(arguments);
342
+ });
343
+ };
344
+
345
+ var convert_widget_pool = function(obj_id, widget_pool) {
346
+ if (widget_pool) {
347
+ var conversion_promises = _.map(widget_pool, function(attrs, widget_id) {
348
+ return convert_attrs(obj_id, attrs).then(function(converted_attrs) {
349
+ return [widget_id, converted_attrs];
350
+ });
351
+ });
352
+
353
+ return $.when.apply(this, conversion_promises).then(function() {
354
+ return _.object(arguments);
355
+ });
356
+ } else {
357
+ return $.Deferred().resolve(widget_pool);
358
+ }
359
+ };
360
+
361
+ var prepare_attrs = function(obj_id, attrs) {
362
+ return convert_widget_pool(obj_id, attrs._widget_pool).then(function(widget_pool) {
363
+ return convert_attrs(obj_id, attrs).then(function(converted_attrs) {
364
+ converted_attrs._widget_pool = widget_pool;
365
+ return converted_attrs;
366
+ });
367
+ });
368
+ };
369
+ }());
@@ -5,12 +5,16 @@ module Fiona7
5
5
 
6
6
  @obj = WriteObj.find(params[:id])
7
7
 
8
+
9
+ @releasable.merge(referenced_objects(@obj))
8
10
  @releasable.merge(widgets(@obj))
9
11
  @releasable << @obj
10
12
 
11
13
  @releasable.each do |obj|
12
- obj.take
13
- obj.release! if obj.really_edited?
14
+ if obj.really_edited?
15
+ obj.take
16
+ obj.release!
17
+ end
14
18
  end
15
19
 
16
20
  render json: {}
@@ -21,5 +25,22 @@ module Fiona7
21
25
  links = @obj[:X_widget_pool] || []
22
26
  WriteObj.where(obj_id: links.map {|l| l.destination_object_id }).to_a
23
27
  end
28
+
29
+ def referenced_objects(obj)
30
+ referenced = Set.new
31
+
32
+ type_definition = Fiona7::TypeRegister.instance.read_mangled(obj.obj_class)
33
+ type_definition.attributes.each do |attribute|
34
+ if attribute.type == :reference || attribute.type == :referencelist
35
+ (obj[attribute.real_name] || []).each do |link|
36
+ if link.internal?
37
+ referenced << link.destination_object
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ referenced
44
+ end
24
45
  end
25
46
  end
@@ -3,7 +3,7 @@ module Scrivito
3
3
  class CmsDispatchController < ActionController::Metal
4
4
  include ActionController::Redirecting
5
5
  include Rails.application.routes.url_helpers
6
- include Scrivito::RoutingHelper
6
+ include Scrivito::ControllerHelper
7
7
 
8
8
  def process(action)
9
9
  CmsEnv.new(env).load
@@ -106,6 +106,10 @@ module Scrivito
106
106
  render :obj
107
107
  end
108
108
 
109
+ # optimized away
110
+ def transfer_modifications
111
+ end
112
+
109
113
  def duplicate
110
114
  @obj = copy_obj(current_obj, current_obj.parent_path)
111
115
  render :obj
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.files = Dir["{app,config,db,lib}/**/*", "Rakefile", "README.md", "infopark_fiona7.gemspec"]
18
18
 
19
19
  s.add_dependency "rails", "~> 4.2.2"
20
- s.add_dependency "scrivito", "= 0.70.0.rc1"
20
+ s.add_dependency "scrivito", "= 0.71"
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"
@@ -117,7 +117,7 @@ module Fiona7
117
117
  (claimed_type, value) = *possible_pair
118
118
  attribute = type_definition.find_attribute(attribute_name)
119
119
  if attribute.nil?
120
- debugger
120
+ #debugger
121
121
  raise "Attribute #{attribute_name} not found in #{@obj_class}"
122
122
  end
123
123
 
@@ -215,7 +215,11 @@ module Fiona7
215
215
  @obj.set(attribute_name.to_s, value)
216
216
  #end
217
217
  when :stringlist
218
- @obj.set(attribute_name.to_s, value.to_json)
218
+ if Fiona7.mode == :legacy && attribute_name.to_s == "channels"
219
+ @obj.set(:channels, value || [])
220
+ else
221
+ @obj.set(attribute_name.to_s, value.to_json)
222
+ end
219
223
  when :html
220
224
  converted_links = LinkConverter::ScrivitoToFiona.new(WriteObj, value.to_s).convert
221
225
  @obj.set(attribute_name.to_s, converted_links)
@@ -1,3 +1,4 @@
1
+ require 'fiona7/assert'
1
2
 
2
3
  module Fiona7
3
4
  module Builder
@@ -36,6 +37,38 @@ module Fiona7
36
37
  raw_attribute.set(:helpText, ::ActiveSupport::JSON.encode({type: attribute[:type]}))
37
38
  raw_attribute.set(:values, attribute[:values]) if attribute[:values]
38
39
  raw_attribute.save!
40
+ else
41
+ cms_attribute = RailsConnector::Attribute.find_by_attribute_name(attribute[:real_name])
42
+ raw_attribute = Reactor::Cm::Attribute.get(attribute[:real_name].to_s)
43
+
44
+ if attribute[:type] == :reference || attribute[:type] == :referencelist
45
+ if cms_attribute.attribute_type == "linklist"
46
+ raw_attribute.set(:helpText, ::ActiveSupport::JSON.encode({type: attribute[:type]}))
47
+ raw_attribute.save!
48
+ else
49
+ Assert.constraint(false, "Type #{attribute[:type]} requested for #{attribute[:real_name]}, but is #{cms_attribute.attribute_type}")
50
+ end
51
+ elsif attribute[:type] == :enum || attribute[:type] == :multienum
52
+ if cms_attribute.attribute_type == "multienum" || cms_attribute.attribute_type == "enum"
53
+ if attribute[:values]
54
+ # do not remove values
55
+ values = cms_attribute.values + attribute[:values]
56
+ raw_attribute.set(:values, values)
57
+ raw_attribute.save!
58
+ end
59
+ else
60
+ if !((attribute[:type] == :enum && cms_attribute.attribute_type == "string") ||
61
+ (attribute[:type] == :multienum && cms_attribute.attribute_type == "text"))
62
+ Assert.constraint(false, "Type #{attribute[:type]} requested for #{attribute[:real_name]}, but is #{cms_attribute.attribute_type}")
63
+ end
64
+ end
65
+ elsif cms_attribute.attribute_type == "text"
66
+ if attribute[:type] != :string && attribute[:type] != :stringlist
67
+ Assert.constraint(false, "Type #{attribute[:type]} requested for #{attribute[:real_name]}, but is #{cms_attribute.attribute_type}")
68
+ end
69
+ elsif attribute[:real_type].to_s != cms_attribute.attribute_type
70
+ Assert.constraint(false, "Type #{attribute[:type]} requested for #{attribute[:real_name]}, but is #{cms_attribute.attribute_type}")
71
+ end
39
72
  end
40
73
  end
41
74
  end
@@ -96,6 +96,7 @@ module Fiona7
96
96
  end
97
97
 
98
98
  def find_by_path(path)
99
+ return [] if path.nil?
99
100
  return [] if path =~ /^\/_orphaned/
100
101
  path = path.gsub('.', '_')
101
102
  @klass.where(path: path).limit(1).to_a
@@ -20,6 +20,7 @@ module Fiona7
20
20
  raise "Unexpected workspace_id: #{id}" unless id.to_s == "rtc"
21
21
  WriteObj.where(is_edited: 1).each do |obj|
22
22
  begin
23
+ obj.take
23
24
  obj.release!
24
25
  rescue => e
25
26
  raise "Release impossible of: #{obj.path} because: #{e.message}"
@@ -89,8 +89,12 @@ module Fiona7
89
89
  when :enum, :multienum, :text, :string
90
90
  @obj[real_attribute_name]
91
91
  when :stringlist
92
- # TODO: get rid of this rescue nil
93
- ::JSON.parse(@obj[real_attribute_name]) rescue nil
92
+ if Fiona7.mode == :legacy && real_attribute_name == "channels"
93
+ @obj["channels"] || []
94
+ else
95
+ # TODO: get rid of this rescue nil
96
+ ::JSON.parse(@obj[real_attribute_name]) rescue nil
97
+ end
94
98
  else
95
99
  Assert.success(
96
100
  false,
@@ -98,6 +102,10 @@ module Fiona7
98
102
  )
99
103
  end
100
104
 
105
+ # TODO: better handling for attribute types
106
+ if virtual_attribute_type == :text
107
+ virtual_attribute_type = :string
108
+ end
101
109
  attrs[virtual_attribute_name] = [val, virtual_attribute_type]
102
110
  end
103
111
  end
@@ -126,7 +126,11 @@ module Fiona7
126
126
  end
127
127
  end
128
128
  when :prefix, :prefix_search
129
- @all = @all.to_a.select {|o| o.send(:[], resolve_field_name(o,field)).to_s.start_with?(value) }
129
+ if !@all.is_a?(Array) && field.to_sym == :_path
130
+ @all = @all.where("path LIKE ?", "#{value}%")
131
+ else
132
+ @all = @all.to_a.select {|o| o.send(:[], resolve_field_name(o,field)).to_s.start_with?(value) }
133
+ end
130
134
  when :greater_than
131
135
  @all = @all.to_a.select {|o| o.send(:[], resolve_field_name(o,field)).to_s > (value) }
132
136
  when :less_than
@@ -10,7 +10,21 @@ module Scrivito
10
10
  orig_attribute(name, type, options)
11
11
  ensure
12
12
  if self.name.present?
13
- Fiona7::TypeRegister.instance.add_usr_attr(self.name, name, type, options[:values])
13
+ # to_s is friendly to shadowclassing
14
+ Fiona7::TypeRegister.instance.add_usr_attr(self.to_s, name, type, options[:values])
15
+ end
16
+ end
17
+
18
+ # support shadow classes
19
+ def description_for_editor
20
+ to_s
21
+ end
22
+
23
+ def register_attribute_definitions(obj_class)
24
+ type_register = Fiona7::TypeRegister.instance
25
+ self.attribute_definitions.each do |attribute_definition|
26
+ # to_s instead of name for shadowclassing
27
+ type_register.add_usr_attr(obj_class, attribute_definition.name, attribute_definition.type, attribute_definition.values.presence)
14
28
  end
15
29
  end
16
30
  end
@@ -5,6 +5,7 @@ module Scrivito
5
5
  def serialize_binary_value(attribute_value, attribute_definition)
6
6
  case attribute_value
7
7
  when File then attribute_value
8
+ when FutureBinary then attribute_value.file_to_be_uploaded
8
9
  when UploadedBinary then attribute_value.params
9
10
  else
10
11
  raise_validation_error(attribute_definition.name,
@@ -14,10 +14,18 @@ module Scrivito
14
14
  id.to_s
15
15
  end
16
16
 
17
+ # optimized away
17
18
  def outdated?
18
19
  false
19
20
  end
20
21
 
22
+ # optimized away
23
+ def transfer_modifications_to(target_workspace)
24
+ return unless modification
25
+ raise TransferModificationsModifiedError,
26
+ "Already modified in workspace #{target_workspace.id}"
27
+ end
28
+
21
29
  def copy_binaries(attributes)
22
30
  # TODO: what to do?
23
31
  attributes
@@ -88,13 +96,9 @@ module Scrivito
88
96
  end
89
97
  ensure
90
98
  if subclass.name.present?
91
- type_register = Fiona7::TypeRegister.instance
92
- subclass.attribute_definitions.each do |attribute_definition|
93
- type_register.add_usr_attr(subclass.name, attribute_definition.name, attribute_definition.type, attribute_definition.values.presence)
94
- end
99
+ subclass.register_attribute_definitions(subclass.to_s)
95
100
  end
96
101
  end
97
-
98
102
  end
99
103
  end
100
104
  end
@@ -35,9 +35,15 @@ module Fiona7
35
35
  protected
36
36
  attr_accessor :binary_id, :transformation, :obj
37
37
 
38
+ def cache(key, &block)
39
+ # TODO: make path this configurable
40
+ @@cache = ActiveSupport::Cache::FileStore.new(Rails.root + '/tmp/cache') unless defined?(@@cache)
41
+ @@cache.fetch("#{self.binary_id}-#{key}", &block)
42
+ end
43
+
38
44
  def load_obj
39
45
  if Fiona7.mode == :legacy
40
- Fiona7::WriteObj.find(self.binary_id)
46
+ Fiona7::EditedObj.find(self.binary_id)
41
47
  else
42
48
  Fiona7::InternalReleasedObj.find(self.binary_id)
43
49
  end
@@ -68,19 +74,27 @@ module Fiona7
68
74
  end
69
75
 
70
76
  def width
71
- if self.image
72
- self.image[:width]
73
- else
74
- 0
77
+ self.cache("#{self.last_changed}-width") do
78
+ if self.image
79
+ self.image[:width]
80
+ else
81
+ 0
82
+ end
75
83
  end
84
+ rescue
85
+ 0
76
86
  end
77
87
 
78
88
  def height
79
- if self.image
80
- self.image[:height]
81
- else
82
- 0
89
+ self.cache("#{self.last_changed}-height") do
90
+ if self.image
91
+ self.image[:height]
92
+ else
93
+ 0
94
+ end
83
95
  end
96
+ rescue
97
+ 0
84
98
  end
85
99
 
86
100
  def mime_type
@@ -412,7 +426,7 @@ module Fiona7
412
426
  attr_writer :blob_id, :access_type, :verb, :transformation
413
427
  def blob
414
428
  if Fiona7.mode == :legacy
415
- @blob ||= Fiona7::WriteObj.find(blob_id.to_i)
429
+ @blob ||= Fiona7::EditedObj.find(blob_id.to_i)
416
430
  else
417
431
  @blob ||= Fiona7::InternalReleasedObj.find(blob_id.to_i)
418
432
  end
@@ -459,7 +473,7 @@ module Fiona7
459
473
  end
460
474
 
461
475
  def validate_transformation!
462
- MetaBinary.new(self.blob_id, self.transformation).valid? || raise(Scrivito::TransformationDefinitionError.new("Invalid transformation", "binary.unprocessable.image.transform.invalid_config"))
476
+ MetaBinary.new(self.blob_id, self.transformation).valid? || raise(Scrivito::TransformationDefinitionError.new("Invalid transformation", "binary.unprocessable.image.transform.config.invalid"))
463
477
  end
464
478
  end
465
479
  end
@@ -2,8 +2,9 @@ require 'scrivito/cms_rest_api.rb'
2
2
 
3
3
  module Scrivito
4
4
  class CmsRestApi
5
- # Stub upload_file since the uploads are handled directly in ruby.
6
- def self.upload_file(file, obj_id)
5
+ # Stub upload_future_binary since the uploads are handled directly in ruby.
6
+ def self.upload_future_binary(future_binary, obj_id)
7
+ file = future_binary.file_to_be_uploaded
7
8
  # TODO: code deduplication with obj builder
8
9
  parent = Fiona7::WriteObj.find(obj_id.to_i)
9
10
  ext = ::File.extname(file.path).to_s[1..-1]
@@ -5,6 +5,8 @@ module Scrivito
5
5
  private
6
6
 
7
7
  def load_class(obj_class_name)
8
+ return nil if obj_class_name.nil?
9
+
8
10
  begin
9
11
  klass = obj_class_name.constantize
10
12
  klass = nil if !inherits_from_base?(klass)
@@ -11,5 +11,15 @@ module Scrivito
11
11
  def outdated?
12
12
  false
13
13
  end
14
+
15
+ # fix silly assumptions
16
+ def self.use(id_or_title)
17
+ self.current = if id_or_title =~ /(published|rtc)/
18
+ find(id_or_title)
19
+ else
20
+ find_by_title(id_or_title) or
21
+ raise ResourceNotFound, "Could not find #{self} with title #{id_or_title}"
22
+ end
23
+ end
14
24
  end
15
25
  end
@@ -45,7 +45,9 @@ module ShadowClasses
45
45
  Class.new(scrivito_obj_class) do
46
46
  include ::ShadowClassesSupport
47
47
  end
48
- )
48
+ ).tap do |klass|
49
+ klass.register_attribute_definitions(name)
50
+ end
49
51
  end
50
52
  elsif type == 'Widget'
51
53
  parent_class = 'Widget'.safe_constantize || Scrivito::BasicWidget
@@ -54,7 +56,9 @@ module ShadowClasses
54
56
  Class.new(parent_class) do
55
57
  include ::ShadowClassesSupport
56
58
  end
57
- )
59
+ ).tap do |klass|
60
+ klass.register_attribute_definitions(name)
61
+ end
58
62
  end
59
63
 
60
64
  end
@@ -26,11 +26,11 @@ module Fiona7
26
26
  end
27
27
 
28
28
  def load(type_definition)
29
- #puts "loading #{obj_class}"
30
29
  if Fiona7.mode == :legacy
31
30
  type_definition.add_attr('title', :string, 'title', :string)
32
31
  type_definition.add_attr('valid_from', :date, 'valid_from', :date)
33
32
  type_definition.add_attr('valid_until', :date, 'valid_until', :date)
33
+ type_definition.add_attr('channels', :stringlist, 'channels', :stringlist)
34
34
 
35
35
  if self.rc_obj_class.obj_type == 'publication' || self.rc_obj_class.obj_type == 'document'
36
36
  type_definition.add_attr('body', :html, 'body', :html)
@@ -103,7 +103,6 @@ module Fiona7
103
103
 
104
104
  def type_definition
105
105
  type_definition = TypeDefinition.new(self.obj_class)
106
- pp values
107
106
  values.each do |name, possible_pair|
108
107
  next if name =~ /\A_/ # built-in attribute
109
108
  next unless possible_pair.kind_of?(Array) && possible_pair.length == 2
@@ -158,7 +157,7 @@ module Fiona7
158
157
  end
159
158
 
160
159
  def ad_hoc_synchronize(type_definition)
161
- puts "Ad hoc synchronize of #{type_definition.name}"
160
+ #puts "Ad hoc synchronize of #{type_definition.name}"
162
161
  obj_class = type_definition.name
163
162
 
164
163
  existing_definition = self.usr_defs[obj_class]
@@ -187,6 +186,32 @@ module Fiona7
187
186
  self.cms_defs[obj_class].present?
188
187
  end
189
188
 
189
+ def type_compatible?(attr_name, cms_type, usr_type)
190
+ if cms_type == usr_type
191
+ true
192
+ else
193
+ case [cms_type, usr_type]
194
+ when [:multienum, :stringlist]
195
+ # this case can occur when a multienum
196
+ # was properly created, but is only ad-hoc written
197
+ # the API provides stringlist as a valid type
198
+ true
199
+ when [:stringlist, :multienum]
200
+ # this case can occur when a multienum
201
+ # was initially ad-hoc created, but now
202
+ # has a proper definition
203
+ # also: channels in legacy mode
204
+ true
205
+ when [:text, :string]
206
+ true
207
+ else
208
+ #raise "Attribute types for #{attr_name} incompatible: CMS uses #{cms_type} but the application provided #{usr_type}"
209
+ puts "Attribute types for #{attr_name} incompatible: CMS uses #{cms_type} but the application provided #{usr_type}"
210
+ false
211
+ end
212
+ end
213
+ end
214
+
190
215
  def defs_compatible?(cms_def, usr_def)
191
216
  cms_attr_map = {}
192
217
  cms_def.attrs.each do |attr|
@@ -195,7 +220,7 @@ module Fiona7
195
220
 
196
221
  usr_def.attrs.each do |attr|
197
222
  return false if !cms_attr_map[attr.name]
198
- return false if attr.type != cms_attr_map[attr.name].type
223
+ return false if !type_compatible?(attr.name, cms_attr_map[attr.name].type, attr.type)
199
224
  end
200
225
 
201
226
  return true
@@ -45,7 +45,7 @@ module Fiona7
45
45
 
46
46
  def builder_attributes
47
47
  self.type_definition.attrs.map do |attribute_definition|
48
- next if ['title', 'body'].include?(attribute_definition.real_name)
48
+ next if ['title', 'body', 'valid_from', 'valid_until', 'channels'].include?(attribute_definition.real_name)
49
49
 
50
50
  desc = {
51
51
  real_name: attribute_definition.real_name,
@@ -1,3 +1,3 @@
1
1
  module Fiona7
2
- VERSION = "0.70.0.3"
2
+ VERSION = "0.71.0.0"
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.3
4
+ version: 0.71.0.0
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-06 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.70.0.rc1
33
+ version: '0.71'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.70.0.rc1
40
+ version: '0.71'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: scrivito_sdk
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -135,6 +135,8 @@ files:
135
135
  - app/assets/images/fiona7-marker.png
136
136
  - app/assets/javascripts/fiona7.js
137
137
  - app/assets/javascripts/fiona7_ui.js
138
+ - app/assets/javascripts/scrivito_patches/models/blob.js
139
+ - app/assets/javascripts/scrivito_patches/models/obj.js
138
140
  - app/assets/stylesheets/fiona7-login.css.scss
139
141
  - app/assets/stylesheets/fiona7.css.scss
140
142
  - app/assets/stylesheets/fiona7_ui.css.scss
@@ -254,3 +256,4 @@ signing_key:
254
256
  specification_version: 4
255
257
  summary: scrivito-compatible interface for classic Fiona
256
258
  test_files: []
259
+ has_rdoc: