cedar 0.2.7.pre → 0.2.71.pre
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696cc2ffba4ca376b32859a715257eb2aa25fea0
|
4
|
+
data.tar.gz: 3be314db6d0c8210e48a4c7a76e6b44bb12950b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7793c6d630eff653866a244c436a69c95a2a7ad39955fa76d3f3ea98715427f16e38ff2fc11b984ddb6e84d434386058964f78d095c0f48cd017ddc892554958
|
7
|
+
data.tar.gz: 10ff6451e258e2e9631bcb948d3e903e180cb3325c95c10433b681befcbf79f83182e3f3e31e4359b6ab3820996d02dc79948a2cca1c0893a3606a7fe1c17d61
|
@@ -63,7 +63,9 @@ Handlebars.registerHelper('cedar', function(options) {
|
|
63
63
|
|
64
64
|
var output = '';
|
65
65
|
|
66
|
-
|
66
|
+
var type = options.hash.type || 'ContentEntry';
|
67
|
+
|
68
|
+
new window.Cedar[type]({ cedarId: options.hash.id }).load().then(function(contentEntry){
|
67
69
|
if (blockHelperStyle()) {
|
68
70
|
if (Cedar.auth.isEditMode()) {
|
69
71
|
output += contentEntry.getEditOpen();
|
@@ -73,7 +75,7 @@ Handlebars.registerHelper('cedar', function(options) {
|
|
73
75
|
output += contentEntry.getEditClose();
|
74
76
|
}
|
75
77
|
} else {
|
76
|
-
output = contentEntry.
|
78
|
+
output = contentEntry.toString();
|
77
79
|
}
|
78
80
|
|
79
81
|
replaceElement(outputEl.id, output);
|
@@ -205,7 +205,11 @@ Cedar.Auth.prototype.removeURLParameter = function(url, parameter) {
|
|
205
205
|
Cedar.Store = function() {
|
206
206
|
this.loaded = false;
|
207
207
|
|
208
|
-
|
208
|
+
try {
|
209
|
+
this.cache = window.localStorage;
|
210
|
+
} catch (e) {
|
211
|
+
this.cache = {};
|
212
|
+
}
|
209
213
|
|
210
214
|
if (Cedar.config.fetch) {
|
211
215
|
this.refresh();
|
@@ -225,11 +229,22 @@ Cedar.Store = function() {
|
|
225
229
|
* @param <json> 'item'
|
226
230
|
*/
|
227
231
|
Cedar.Store.prototype.put = function ( key, item ) {
|
228
|
-
this.cache[key] = JSON.stringify(item);
|
232
|
+
this.cache[key] = typeof item === "string" ? item : JSON.stringify(item);
|
229
233
|
};
|
230
234
|
|
231
|
-
// Return
|
235
|
+
// Return promise of parsed content from local or remote storage
|
232
236
|
Cedar.Store.prototype.get = function(key) {
|
237
|
+
return this.getDeferred(key).then(function(data) {
|
238
|
+
try {
|
239
|
+
return JSON.parse(data);
|
240
|
+
} catch (e) {
|
241
|
+
return data;
|
242
|
+
}
|
243
|
+
});
|
244
|
+
};
|
245
|
+
|
246
|
+
// Return local content immediately if possible. Otherwise return deferred remote content
|
247
|
+
Cedar.Store.prototype.getDeferred = function(key) {
|
233
248
|
var cachedDeferred = this.cachedDeferred(key);
|
234
249
|
var remoteDeferred = this.remoteDeferred(key);
|
235
250
|
|
@@ -368,156 +383,107 @@ Cedar.Store.prototype.lockedRequest = function(options) {
|
|
368
383
|
}.bind(this)));
|
369
384
|
};
|
370
385
|
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
*
|
378
|
-
* {
|
379
|
-
* el (element or jQuery selector)
|
380
|
-
* }
|
381
|
-
*/
|
382
|
-
Cedar.ContentEntry = function(options) {
|
386
|
+
|
387
|
+
/*
|
388
|
+
Cedar.ContentObject
|
389
|
+
Parent class for all Cedar content object types
|
390
|
+
*/
|
391
|
+
Cedar.ContentObject = function(options) {
|
383
392
|
var defaults = {
|
384
393
|
el: '<div />'
|
385
394
|
};
|
386
|
-
|
387
|
-
this
|
388
|
-
|
389
|
-
this.cedarId = this.options.cedarId;
|
390
|
-
this.el = this.options.el;
|
391
|
-
this.$el = $(this.el);
|
392
|
-
};
|
393
|
-
|
394
|
-
Cedar.ContentEntry.prototype.apiGet = function() {
|
395
|
-
return '/objects/contententries/';
|
396
|
-
};
|
397
|
-
|
398
|
-
Cedar.ContentEntry.prototype.apiQuery = function() {
|
399
|
-
return '/queries/contententries/';
|
400
|
-
};
|
401
|
-
|
402
|
-
Cedar.ContentEntry.prototype.apiFilter = function() {
|
403
|
-
return 'guidfilter';
|
404
|
-
};
|
405
|
-
|
406
|
-
Cedar.ContentEntry.prototype.apiList = function() {
|
407
|
-
return 'guidlist';
|
395
|
+
this.options = $.extend({}, defaults, options);
|
396
|
+
this.$el = $(this.options.el);
|
408
397
|
};
|
409
398
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
if (typeof data === 'string') {
|
417
|
-
data = JSON.parse(data);
|
418
|
-
}
|
399
|
+
Cedar.ContentObject.prototype = {
|
400
|
+
render: function() {
|
401
|
+
this.load().then(function() {
|
402
|
+
this.$el.html(this.toString());
|
403
|
+
}.bind(this));
|
404
|
+
},
|
419
405
|
|
420
|
-
|
421
|
-
this.
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
Cedar.debug('Cedar Error: Unable to parse json');
|
427
|
-
}
|
428
|
-
};
|
406
|
+
load: function() {
|
407
|
+
return Cedar.store.get(this.options.cedarId).then(function(data) {
|
408
|
+
this.setContent(data);
|
409
|
+
return this;
|
410
|
+
}.bind(this));
|
411
|
+
},
|
429
412
|
|
430
|
-
|
431
|
-
* return the object's content - takes into account edit mode styling
|
432
|
-
*
|
433
|
-
* @return <HTML>
|
434
|
-
*/
|
435
|
-
Cedar.ContentEntry.prototype.getContent = function(){
|
436
|
-
if (Cedar.auth.isEditMode()) {
|
437
|
-
return this.getEditOpen() + this.content + this.getEditClose();
|
438
|
-
}
|
439
|
-
else {
|
413
|
+
getContent: function() {
|
440
414
|
return this.content;
|
415
|
+
},
|
416
|
+
|
417
|
+
setContent: function(data) {
|
418
|
+
this.content = data;
|
419
|
+
},
|
420
|
+
|
421
|
+
getContentWithEditTools: function() {
|
422
|
+
return this.getEditOpen() + this.getContent() + this.getEditClose();
|
423
|
+
},
|
424
|
+
|
425
|
+
toString: function() {
|
426
|
+
return Cedar.auth.isEditMode() ? this.getContentWithEditTools() : this.getContent();
|
427
|
+
},
|
428
|
+
|
429
|
+
toJSON: function() {
|
430
|
+
return {
|
431
|
+
content: this.getContent()
|
432
|
+
};
|
433
|
+
},
|
434
|
+
|
435
|
+
getEditOpen: function() {
|
436
|
+
var jsString = "if(event.stopPropagation){event.stopPropagation();}" +
|
437
|
+
"event.cancelBubble=true;" +
|
438
|
+
"window.location.href=this.attributes.href.value + \'&referer=' + encodeURIComponent(window.location.href) + '\';" +
|
439
|
+
"return false;";
|
440
|
+
|
441
|
+
var block = '<span class="cedar-cms-editable clearfix">';
|
442
|
+
block += '<span class="cedar-cms-edit-tools">';
|
443
|
+
block += '<a onclick="' + jsString + '" href="' + Cedar.config.server +
|
444
|
+
'/cmsadmin/EditData?cdr=1&t=ContentEntry&o=' +
|
445
|
+
encodeURIComponent(this.options.cedarId) +
|
446
|
+
'" class="cedar-cms-edit-icon cedar-js-edit" >';
|
447
|
+
block += '<i class="cedar-cms-icon cedar-cms-icon-right cedar-cms-icon-edit"></i></a>';
|
448
|
+
block += '</span>';
|
449
|
+
return block;
|
450
|
+
},
|
451
|
+
|
452
|
+
getEditClose: function() {
|
453
|
+
return '</span>';
|
441
454
|
}
|
442
455
|
};
|
443
456
|
|
444
|
-
|
445
|
-
* is this a content entry json structure?
|
446
|
-
*
|
447
|
-
* @param <json>
|
448
|
-
* @return <bool>
|
449
|
-
*/
|
450
|
-
Cedar.ContentEntry.prototype.isContentEntry = function (json) {
|
451
|
-
if (json === undefined) {
|
452
|
-
return false;
|
453
|
-
}
|
454
|
-
if (json.hasOwnProperty('settings') && json.settings.hasOwnProperty('content')) {
|
455
|
-
return false;
|
456
|
-
}
|
457
|
-
|
458
|
-
return true;
|
459
|
-
};
|
460
|
-
|
461
|
-
/**
|
462
|
-
* @return <json>
|
463
|
-
*/
|
464
|
-
Cedar.ContentEntry.prototype.toJSON = function(){
|
465
|
-
return {
|
466
|
-
content: this.content
|
467
|
-
};
|
468
|
-
};
|
457
|
+
Cedar.ContentObject.prototype.constructor = Cedar.ContentObject;
|
469
458
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
Cedar.
|
476
|
-
if (element !== undefined) {
|
477
|
-
$(element).html(this.getContent());
|
478
|
-
} else if (this.$el instanceof jQuery) {
|
479
|
-
this.$el.html(this.getContent());
|
480
|
-
}
|
459
|
+
/*
|
460
|
+
Cedar.ContentEntry
|
461
|
+
basic content block class
|
462
|
+
*/
|
463
|
+
Cedar.ContentEntry = function(options) {
|
464
|
+
Cedar.ContentObject.call(this, options);
|
481
465
|
};
|
466
|
+
Cedar.ContentEntry.prototype = Object.create(Cedar.ContentObject.prototype);
|
467
|
+
Cedar.ContentEntry.prototype.constructor = Cedar.ContentEntry;
|
482
468
|
|
483
|
-
|
484
|
-
|
485
|
-
*/
|
486
|
-
Cedar.ContentEntry.prototype.retrieve = function() {
|
487
|
-
return Cedar.store.get(this.cedarId).then(function(response) {
|
488
|
-
this.setContent(response);
|
489
|
-
return this;
|
490
|
-
}.bind(this));
|
469
|
+
Cedar.ContentEntry.prototype.setContent = function(data) {
|
470
|
+
this.content = (data && (data.settings && data.settings.content)) || '';
|
491
471
|
};
|
492
472
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
}.bind(this));
|
473
|
+
/*
|
474
|
+
Cedar.Program
|
475
|
+
program object class
|
476
|
+
*/
|
477
|
+
Cedar.Program = function(options) {
|
478
|
+
Cedar.ContentObject.call(this, options);
|
500
479
|
};
|
480
|
+
Cedar.Program.prototype = Object.create(Cedar.ContentObject.prototype);
|
481
|
+
Cedar.Program.prototype.constructor = Cedar.Program;
|
501
482
|
|
502
|
-
|
503
|
-
|
504
|
-
*/
|
505
|
-
Cedar.ContentEntry.prototype.getEditOpen = function() {
|
506
|
-
var jsString = "if(event.stopPropagation){event.stopPropagation();}" +
|
507
|
-
"event.cancelBubble=true;" +
|
508
|
-
"window.location.href=this.attributes.href.value + \'&referer=' + encodeURIComponent(window.location.href) + '\';" +
|
509
|
-
"return false;";
|
510
|
-
|
511
|
-
var block = '<span class="cedar-cms-editable clearfix">';
|
512
|
-
block += '<span class="cedar-cms-edit-tools">';
|
513
|
-
block += '<a onclick="' + jsString + '" href="' + Cedar.config.server +
|
514
|
-
'/cmsadmin/EditData?cdr=1&t=ContentEntry&o=' + encodeURIComponent(this.cedarId) +
|
515
|
-
'" class="cedar-cms-edit-icon cedar-js-edit" >';
|
516
|
-
block += '<i class="cedar-cms-icon cedar-cms-icon-right cedar-cms-icon-edit"></i></a>';
|
517
|
-
block += '</span>';
|
518
|
-
return block;
|
483
|
+
Cedar.Program.prototype.setContent = function(data) {
|
484
|
+
this.content = (data && (data.settings && JSON.parse(data.settings.content))) || '';
|
519
485
|
};
|
520
486
|
|
521
|
-
Cedar.
|
522
|
-
return
|
487
|
+
Cedar.Program.prototype.toJSON = function(data) {
|
488
|
+
return this.content;
|
523
489
|
};
|
File without changes
|
data/lib/cedar/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cedar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.71.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jed Murdock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -51,7 +51,7 @@ files:
|
|
51
51
|
- lib/assets/javascripts/cedar.handlebars.js
|
52
52
|
- lib/assets/javascripts/cedar.js
|
53
53
|
- lib/assets/stylesheets/cedar.scss
|
54
|
-
- lib/assets/stylesheets/cedar_source.
|
54
|
+
- lib/assets/stylesheets/cedar_source.css
|
55
55
|
- lib/cedar.rb
|
56
56
|
- lib/cedar/version.rb
|
57
57
|
homepage: http://plyinteractive.com
|