infopark_fiona7 1.2.0.2.3 → 1.5.2.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 +4 -4
- data/Rakefile +33 -0
- data/app/assets/javascripts/fiona7_ui.js +82 -23
- data/app/assets/javascripts/scrivito_patches/ajax.js +222 -0
- data/app/assets/javascripts/scrivito_patches/ajax_error_handling.js +24 -0
- data/app/assets/javascripts/scrivito_patches/attribute_serializer.js +259 -0
- data/app/assets/javascripts/scrivito_patches/base_obj_path.js +17 -0
- data/app/assets/javascripts/scrivito_patches/binary_utils.js +33 -0
- data/app/assets/javascripts/scrivito_patches/cms_rest_api.js +490 -0
- data/app/assets/javascripts/scrivito_patches/models/api/basic_obj.js +650 -0
- data/app/assets/javascripts/scrivito_patches/models/binary_field_element.js +53 -0
- data/app/assets/javascripts/scrivito_patches/models/obj.js +74 -239
- data/app/assets/javascripts/scrivito_patches/obj_serializer.js +91 -0
- data/app/assets/stylesheets/fiona7.css.scss +12 -0
- data/app/assets/stylesheets/fiona7_ui.css.scss +18 -0
- data/app/controllers/fiona7/api_controller.rb +20 -0
- data/app/controllers/fiona7/sessions_controller.rb +2 -10
- data/app/controllers/fiona7_login_page_controller.rb +0 -3
- data/app/controllers/scrivito/obj_class_controller.rb +58 -0
- data/app/controllers/scrivito/objs_controller.rb +2 -38
- data/app/helpers/fiona7_override_helper.rb +25 -0
- data/app/views/fiona7/release/preview.html.erb +1 -1
- data/app/views/fiona7_login_page/index.html.erb +0 -6
- data/app/views/scrivito/ui/index.html.erb +2 -1
- data/app/views/scrivito/webservice/_workspace.json.jbuilder +8 -0
- data/config/locales/errors.yml +18 -0
- data/config/locales/workflow.yml +24 -0
- data/config/precedence_routes.rb +7 -14
- data/infopark_fiona7.gemspec +6 -4
- data/lib/fiona7/assert.rb +2 -2
- data/lib/fiona7/attribute_readers/factory.rb +4 -0
- data/lib/fiona7/attribute_type_mapper.rb +4 -1
- data/lib/fiona7/attribute_writers/binary_as_binary.rb +2 -2
- data/lib/fiona7/attribute_writers/binary_as_linklist.rb +2 -2
- data/lib/fiona7/attribute_writers/factory.rb +4 -0
- data/lib/fiona7/builder/indirect_blob_builder.rb +2 -2
- data/lib/fiona7/builder/lazy_blob_copier.rb +1 -1
- data/lib/fiona7/builder/obj_builder.rb +45 -12
- data/lib/fiona7/controllers/rest_api/error_handler.rb +49 -0
- data/lib/fiona7/controllers/rest_api/obj_controller.rb +34 -20
- data/lib/fiona7/controllers/rest_api/session_controller.rb +13 -0
- data/lib/fiona7/engine.rb +7 -10
- data/lib/fiona7/facet_builder.rb +5 -1
- data/lib/fiona7/naive_search_engine.rb +9 -0
- data/lib/fiona7/routers/rest_api.rb +17 -0
- data/lib/fiona7/scrivito_patches/attribute_content.rb +28 -0
- data/lib/fiona7/scrivito_patches/cms_routing.rb +14 -31
- data/lib/fiona7/scrivito_patches/page_config.rb +1 -0
- data/lib/fiona7/scrivito_user.rb +3 -2
- data/lib/fiona7/type_register.rb +4 -0
- data/lib/fiona7/verity_search_engine.rb +6 -17
- data/lib/fiona7/version.rb +1 -1
- data/lib/fiona7/workspace.rb +2 -0
- metadata +28 -14
- data/app/assets/javascripts/scrivito_patches/models/ajax.js +0 -99
- data/app/assets/javascripts/scrivito_patches/models/blob.js +0 -50
@@ -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
|
+
})();
|
@@ -1,14 +1,8 @@
|
|
1
1
|
(function() {
|
2
|
+
var write_promises = {};
|
3
|
+
|
2
4
|
_.extend(scrivito, {
|
3
5
|
obj: {
|
4
|
-
serialize_value: function(value) {
|
5
|
-
if (_.isDate(value)) {
|
6
|
-
return serialize_date(value);
|
7
|
-
} else {
|
8
|
-
return value;
|
9
|
-
}
|
10
|
-
},
|
11
|
-
|
12
6
|
create_instance: function(params) {
|
13
7
|
var that = {
|
14
8
|
id: function() {
|
@@ -19,6 +13,10 @@
|
|
19
13
|
return params.obj_class;
|
20
14
|
},
|
21
15
|
|
16
|
+
model_class: function() {
|
17
|
+
return scrivito.ObjClass.find(params.obj_class);
|
18
|
+
},
|
19
|
+
|
22
20
|
description_for_editor: function() {
|
23
21
|
return params.description_for_editor;
|
24
22
|
},
|
@@ -73,57 +71,52 @@
|
|
73
71
|
return params.last_changed;
|
74
72
|
},
|
75
73
|
|
76
|
-
provided_path: function() {
|
77
|
-
return params.path;
|
78
|
-
},
|
79
|
-
|
80
74
|
parent_path: function() {
|
81
75
|
return params.parent_path;
|
82
76
|
},
|
83
77
|
|
78
|
+
// -- PATCH BEINGS HERE --
|
79
|
+
provided_path: function() {
|
80
|
+
return params.path;
|
81
|
+
},
|
82
|
+
// -- PATCH ENDS HERE --
|
83
|
+
|
84
84
|
save: function(attrs) {
|
85
|
-
return
|
86
|
-
|
87
|
-
|
85
|
+
return scrivito.ObjSerializer.serialize(that.id(), attrs)
|
86
|
+
.then(function(serialized_attrs) {
|
87
|
+
return that.enqueue_ajax('PUT', 'objs/'+that.id(), {data: {obj: serialized_attrs}});
|
88
|
+
});
|
88
89
|
},
|
89
90
|
|
90
91
|
destroy: function() {
|
91
|
-
return
|
92
|
+
return that.enqueue_ajax('DELETE', 'objs/'+that.id()).then(function(result) {
|
92
93
|
return result.redirect_to;
|
93
94
|
});
|
94
95
|
},
|
95
96
|
|
96
|
-
destroy_widget: function(widget_id) {
|
97
|
-
return scrivito.ajax('PUT',
|
98
|
-
'objs/' + that.id() + '/destroy_widget?widget_id=' + widget_id);
|
99
|
-
},
|
100
|
-
|
101
97
|
revert: function() {
|
102
|
-
return
|
98
|
+
return that.enqueue_ajax('PUT', 'objs/'+that.id()+'/revert');
|
103
99
|
},
|
104
100
|
|
105
101
|
revert_widget: function(widget_id) {
|
106
|
-
return
|
102
|
+
return that.enqueue_ajax('PUT',
|
103
|
+
'objs/'+that.id()+'/revert_widget?widget_id='+widget_id);
|
107
104
|
},
|
108
105
|
|
109
106
|
conflicting_workspaces: function() {
|
110
|
-
return
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
},
|
115
|
-
|
116
|
-
is_outdated: function() {
|
117
|
-
return scrivito.ajax('GET', 'objs/' + that.id() + '/is_outdated').then(
|
118
|
-
function(result) { return result.is_outdated; });
|
107
|
+
return that.enqueue_ajax('GET', 'objs/'+that.id()+'/conflicting_workspaces')
|
108
|
+
.then(function(workspace_datas) {
|
109
|
+
return scrivito.workspace.from_data_collection(workspace_datas);
|
110
|
+
});
|
119
111
|
},
|
120
112
|
|
121
113
|
restore: function() {
|
122
|
-
return
|
114
|
+
return that.enqueue_ajax('PUT', 'objs/'+that.id()+'/restore');
|
123
115
|
},
|
124
116
|
|
125
117
|
restore_widget: function(widget_id) {
|
126
|
-
return
|
118
|
+
return that.enqueue_ajax('PUT',
|
119
|
+
'objs/'+that.id()+'/restore_widget?widget_id='+widget_id);
|
127
120
|
},
|
128
121
|
|
129
122
|
details_src: function() {
|
@@ -131,37 +124,37 @@
|
|
131
124
|
return '/__scrivito/page_details/' + that.id();
|
132
125
|
},
|
133
126
|
|
134
|
-
mark_resolved: function() {
|
135
|
-
return scrivito.ajax('PUT', 'objs/' + that.id() + '/mark_resolved');
|
136
|
-
},
|
137
|
-
|
138
|
-
copy_to: function(path) {
|
139
|
-
var attrs = {data: {parent_path: path}};
|
140
|
-
return scrivito.ajax('POST', 'objs/'+that.id()+'/copy', attrs).then(function(data) {
|
141
|
-
return scrivito.obj.create_instance(data);
|
142
|
-
});
|
143
|
-
},
|
144
|
-
|
145
|
-
duplicate: function() {
|
146
|
-
return scrivito.ajax('POST', 'objs/'+that.id()+'/duplicate').then(function(data) {
|
147
|
-
return scrivito.obj.create_instance(data);
|
148
|
-
});
|
149
|
-
},
|
150
|
-
|
151
127
|
transfer_modifications_to: function(workspace_id) {
|
152
|
-
return
|
128
|
+
return that.enqueue_ajax('PUT', 'objs/'+that.id()+'/transfer_modifications',
|
153
129
|
{data: {workspace_id: workspace_id}});
|
154
130
|
},
|
155
131
|
|
156
132
|
reload: function() {
|
157
|
-
return
|
133
|
+
return that.enqueue_ajax('GET', 'objs/'+that.id()).then(function(data) {
|
158
134
|
params.has_conflict = data.has_conflict;
|
159
135
|
params.modification = data.modification;
|
160
136
|
});
|
161
137
|
},
|
162
138
|
|
163
139
|
reload_widget: function(widget_id) {
|
164
|
-
return
|
140
|
+
return that.enqueue_ajax('GET', 'objs/'+that.id()+'/widget?widget_id='+widget_id);
|
141
|
+
},
|
142
|
+
|
143
|
+
enqueue_ajax: function() {
|
144
|
+
var args = arguments;
|
145
|
+
var ajax = function() { return scrivito.ajax.apply(null, args); };
|
146
|
+
|
147
|
+
if (args[0] === 'GET') { return ajax(); }
|
148
|
+
|
149
|
+
var promise = $.Deferred();
|
150
|
+
(write_promises[that.id()] || $.Deferred().resolve()).always(function() {
|
151
|
+
ajax().then(
|
152
|
+
function() { promise.resolve.apply(promise, arguments); },
|
153
|
+
function() { promise.reject.apply(promise, arguments); }
|
154
|
+
);
|
155
|
+
});
|
156
|
+
write_promises[that.id()] = promise;
|
157
|
+
return promise;
|
165
158
|
}
|
166
159
|
};
|
167
160
|
|
@@ -187,7 +180,8 @@
|
|
187
180
|
return scrivito.ajax('GET', path).then(function(selection) {
|
188
181
|
var names = _.pluck(selection, 'name');
|
189
182
|
var recent = scrivito.obj_class_selection.recent(names);
|
190
|
-
var
|
183
|
+
var all_popular_valid_obj_classes = _.intersection(scrivito.popular_obj_classes, names);
|
184
|
+
var popular = _.take(all_popular_valid_obj_classes, 5);
|
191
185
|
return {
|
192
186
|
all: _.sortBy(selection, 'name'),
|
193
187
|
recent: _.map(recent, function(name) { return _.findWhere(selection, {name: name}); }),
|
@@ -197,21 +191,30 @@
|
|
197
191
|
},
|
198
192
|
|
199
193
|
fetch_page_class_selection: function(params) {
|
200
|
-
if (!params || params === {}) {
|
201
|
-
var current_page = scrivito.application_document().page();
|
202
|
-
var path = (typeof current_page.provided_path === 'function') && current_page.provided_path();
|
203
|
-
params = {};
|
204
|
-
params['parent_path'] = path;
|
205
|
-
}
|
206
194
|
return scrivito.obj.fetch_class_selection('objs/page_class_selection', params);
|
207
195
|
},
|
208
196
|
|
209
197
|
create: function(attrs) {
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
198
|
+
attrs._id = scrivito.random_id();
|
199
|
+
return scrivito.ObjSerializer.serialize(attrs._id, attrs).then(function(serialized_attrs) {
|
200
|
+
// -- PATCH BEGINS HERE --
|
201
|
+
if (!serialized_attrs._path) {
|
202
|
+
var page = scrivito.application_document().page();
|
203
|
+
var path = (typeof page.provided_path === 'function') && page.provided_path();
|
204
|
+
var blobName;
|
205
|
+
if (typeof serialized_attrs.blob === 'object') {
|
206
|
+
blobName = serialized_attrs.blob.name || serialized_attrs.blob.filename;
|
207
|
+
}
|
208
|
+
if (path) {
|
209
|
+
var defaultName = blobName || serialized_attrs._obj_class || serialized_attrs._id;
|
210
|
+
serialized_attrs._path = path + "/" + defaultName;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
// -- PATCH ENDS HERE --
|
214
|
+
var params = {data: {obj: serialized_attrs}};
|
215
|
+
return scrivito.ajax('POST', 'objs', params).then(function(obj_data) {
|
216
|
+
scrivito.obj_class_selection.store(serialized_attrs._obj_class);
|
217
|
+
return scrivito.obj.create_instance(obj_data);
|
215
218
|
});
|
216
219
|
});
|
217
220
|
},
|
@@ -222,180 +225,12 @@
|
|
222
225
|
if (result.status !== 'success') { return {obj: obj, reason: result.reason}; }
|
223
226
|
});
|
224
227
|
})).then(function() { return $.Deferred().resolve(_.compact(arguments)); });
|
225
|
-
}
|
226
|
-
}
|
227
|
-
});
|
228
|
-
|
229
|
-
var provide_default_name = function (attrs) {
|
230
|
-
var default_name = null;
|
231
|
-
|
232
|
-
$.each(attrs, function (key, value) {
|
233
|
-
if (value && value.is_uploaded_binary && value.filename) {
|
234
|
-
default_name = value.filename;
|
235
|
-
} else if (is_file(value)) {
|
236
|
-
default_name = value.name;
|
237
|
-
}
|
238
|
-
});
|
239
|
-
|
240
|
-
if (default_name === null) {
|
241
|
-
default_name = attrs._obj_class;
|
242
|
-
} else {
|
243
|
-
// this removes file extension if present
|
244
|
-
default_name = default_name.replace(/\.[^\.]+$/, '');
|
245
|
-
}
|
246
|
-
|
247
|
-
return default_name;
|
248
|
-
};
|
249
|
-
|
250
|
-
var provide_default_path = function (attrs, default_name) {
|
251
|
-
if (!(attrs._path)) {
|
252
|
-
var current_page = scrivito.application_document().page();
|
253
|
-
var path = (typeof current_page.provided_path === 'function') && current_page.provided_path();
|
254
|
-
|
255
|
-
if (path && path !== "/") {
|
256
|
-
attrs._path = path + "/" + default_name;
|
257
|
-
}
|
258
|
-
}
|
259
|
-
};
|
228
|
+
},
|
260
229
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
url = url + "/" + obj_id;
|
265
|
-
}
|
266
|
-
return url;
|
267
|
-
};
|
268
|
-
|
269
|
-
var persist_obj_data = function (attributes, obj_id) {
|
270
|
-
var has_binary=false;
|
271
|
-
var fd, defer, url, type;
|
272
|
-
|
273
|
-
$.each(attributes, function (key, value) {
|
274
|
-
if (value && value.is_uploaded_binary) {
|
275
|
-
has_binary=true;
|
276
|
-
} else if (is_file(value)) {
|
277
|
-
has_binary=true
|
278
|
-
}
|
279
|
-
});
|
280
|
-
|
281
|
-
// use standard handling for cases without binary upload
|
282
|
-
if (!has_binary) {
|
283
|
-
if (typeof obj_id !== 'undefined') {
|
284
|
-
return scrivito.ajax('PUT', 'objs/'+obj_id, {data: {obj: attributes}});
|
285
|
-
} else {
|
286
|
-
return scrivito.ajax('POST', 'objs', {data: {obj: attributes}});
|
230
|
+
// For test purpose only.
|
231
|
+
clear_write_promises: function() {
|
232
|
+
write_promises = {};
|
287
233
|
}
|
288
234
|
}
|
289
|
-
|
290
|
-
// use special handling for uploads
|
291
|
-
fd = new FormData();
|
292
|
-
url = obj_url(obj_id);
|
293
|
-
type = (typeof obj_id !== 'undefined') ? 'PUT' : 'POST';
|
294
|
-
|
295
|
-
$.each(attributes, function (key, value) {
|
296
|
-
if ((typeof value === 'object') && (key == '_widget_pool')) {
|
297
|
-
$.each(value, function (subkey, subval) {
|
298
|
-
if (typeof value !== 'undefined') {
|
299
|
-
fd.append('obj[' + key + ']' + '[' + subkey + ']', subval);
|
300
|
-
}
|
301
|
-
});
|
302
|
-
} else if (value && value.is_uploaded_binary && value.filename) {
|
303
|
-
fd.append('obj[' + key + ']', value.blob || value.file, value.filename);
|
304
|
-
} else if (typeof value !== 'undefined') {
|
305
|
-
fd.append('obj[' + key + ']', value);
|
306
|
-
}
|
307
|
-
});
|
308
|
-
|
309
|
-
defer = $.Deferred();
|
310
|
-
|
311
|
-
$.ajax({
|
312
|
-
url: url,
|
313
|
-
type: type,
|
314
|
-
data: fd,
|
315
|
-
processData: false,
|
316
|
-
contentType: false
|
317
|
-
})
|
318
|
-
.error(function (xhr, text_status, error) {
|
319
|
-
var error_message;
|
320
|
-
var error_code;
|
321
|
-
try {
|
322
|
-
var error_json = JSON.parse(xhr.responseText);
|
323
|
-
error_message = error_json.error;
|
324
|
-
error_code = error_json.code;
|
325
|
-
} catch (SyntaxError) {}
|
326
|
-
|
327
|
-
if (!error_message) {
|
328
|
-
error_message = error;
|
329
|
-
}
|
330
|
-
scrivito.display_ajax_error(error_message);
|
331
|
-
defer.reject(error_message);
|
332
|
-
})
|
333
|
-
.success(function (new_data) {
|
334
|
-
defer.resolve((new_data));
|
335
|
-
});
|
336
|
-
|
337
|
-
return defer.promise();
|
338
|
-
};
|
339
|
-
|
340
|
-
var is_file = function(object) {
|
341
|
-
return object &&
|
342
|
-
_.isFunction(object.slice) &&
|
343
|
-
_.isDate(object.lastModifiedDate) &&
|
344
|
-
_.isString(object.name);
|
345
|
-
};
|
346
|
-
|
347
|
-
var format_date_number = function(number) {
|
348
|
-
var string = number.toString();
|
349
|
-
return string.length === 1 ? '0' + string : string;
|
350
|
-
};
|
351
|
-
|
352
|
-
var serialize_date = function(date) {
|
353
|
-
return date.getUTCFullYear().toString() +
|
354
|
-
'-' + format_date_number(date.getUTCMonth() + 1) + // Month numbers are starting at 0.
|
355
|
-
'-' + format_date_number(date.getUTCDate()) +
|
356
|
-
'T' + format_date_number(date.getUTCHours()) +
|
357
|
-
':' + format_date_number(date.getUTCMinutes()) +
|
358
|
-
':' + format_date_number(date.getUTCSeconds()) +
|
359
|
-
'Z';
|
360
|
-
};
|
361
|
-
|
362
|
-
var convert_attrs = function(obj_id, attrs) {
|
363
|
-
var collected_promises = _.map(attrs, function(value, field_name) {
|
364
|
-
if (is_file(value)) {
|
365
|
-
return $.Deferred().resolve([field_name, value]);
|
366
|
-
} else if (value && value.is_uploaded_binary) {
|
367
|
-
return $.Deferred().resolve([field_name, value]);
|
368
|
-
}
|
369
|
-
return $.Deferred().resolve([field_name, scrivito.obj.serialize_value(value)]);
|
370
|
-
});
|
371
|
-
|
372
|
-
return $.when.apply(this, collected_promises).then(function() {
|
373
|
-
return _.object(arguments);
|
374
|
-
});
|
375
|
-
};
|
376
|
-
|
377
|
-
var convert_widget_pool = function(obj_id, widget_pool) {
|
378
|
-
if (widget_pool) {
|
379
|
-
var conversion_promises = _.map(widget_pool, function(attrs, widget_id) {
|
380
|
-
return convert_attrs(obj_id, attrs).then(function(converted_attrs) {
|
381
|
-
return [widget_id, converted_attrs];
|
382
|
-
});
|
383
|
-
});
|
384
|
-
|
385
|
-
return $.when.apply(this, conversion_promises).then(function() {
|
386
|
-
return _.object(arguments);
|
387
|
-
});
|
388
|
-
} else {
|
389
|
-
return $.Deferred().resolve(widget_pool);
|
390
|
-
}
|
391
|
-
};
|
392
|
-
|
393
|
-
var prepare_attrs = function(obj_id, attrs) {
|
394
|
-
return convert_widget_pool(obj_id, attrs._widget_pool).then(function(widget_pool) {
|
395
|
-
return convert_attrs(obj_id, attrs).then(function(converted_attrs) {
|
396
|
-
converted_attrs._widget_pool = widget_pool;
|
397
|
-
return converted_attrs;
|
398
|
-
});
|
399
|
-
});
|
400
|
-
};
|
235
|
+
});
|
401
236
|
}());
|