jsharmony-cms 1.14.0 → 1.15.1
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.
- package/clientjs/jsHarmonyCMS.ComponentManager.js +3 -0
- package/doc/page.json +1 -0
- package/models/Branch_Conflicts.ejs +1 -1
- package/models/Branch_Diff.ejs +2 -2
- package/models/_funcs.component.js +7 -1
- package/models/_funcs.deploy.js +40 -22
- package/models/_funcs.media.js +2 -2
- package/models/_funcs.page.js +1 -0
- package/models/js/site.js +1 -1
- package/package.json +2 -2
- package/public/js/jsHarmonyCMS.js +3 -0
- package/views/jsh_cms_editor.ejs +3 -0
|
@@ -423,6 +423,9 @@ exports = module.exports = function(jsh, cms){
|
|
|
423
423
|
isInComponentEditor: false,
|
|
424
424
|
componentRenderClass: 'jsharmony_cms_componentRender_'+XExt.escapeCSSClass((component&&component.id)||'')+'_'+cms.componentManager.getUniqueId().toString(),
|
|
425
425
|
getMediaThumbnails: function(url){ return cms.componentManager.getMediaThumbnails(url); },
|
|
426
|
+
getPageVar: function(key){ return undefined; },
|
|
427
|
+
setPageVar: function(key, val){ },
|
|
428
|
+
hash: function(val){ return Crypto.MD5((val||'').toString()).toString(); },
|
|
426
429
|
items: data.items,
|
|
427
430
|
item: data.item,
|
|
428
431
|
component: properties,
|
package/doc/page.json
CHANGED
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
// jsharmony_cms_editing - Added when currently editing a content element
|
|
52
52
|
// jsharmony_cms_editing_<content_element_id> - Added when currently editing a content element
|
|
53
53
|
},
|
|
54
|
+
"virtual_render": false, // If set to true, page does not export to file system on publish
|
|
54
55
|
},
|
|
55
56
|
|
|
56
57
|
//System Properties
|
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
<# }); #>
|
|
273
273
|
|
|
274
274
|
<div>
|
|
275
|
-
<# if(_.includes(['.jpg','.jpeg','.tif','.tiff','.png','.gif','.svg'], (new_media.ext||'').toLowerCase())){ #>
|
|
275
|
+
<# if(_.includes(['.jpg','.jpeg','.webp','.tif','.tiff','.png','.gif','.svg'], (new_media.ext||'').toLowerCase())){ #>
|
|
276
276
|
<div class="diff_media_preview preview_media" data-media_key="<#=new_media.key#>" data-media_id="<#=new_media.id#>" data-media_ext="<#=new_media.ext#>" data-media_width="<#=new_media.width#>" data-media_height="<#=new_media.height#>">
|
|
277
277
|
<#=desc#>:<br/>
|
|
278
278
|
<img src="<%=jsh._BASEURL%>_funcs/media/<#=new_media.key#>/file_preview?media_id=<#=new_media.id#>" />
|
package/models/Branch_Diff.ejs
CHANGED
|
@@ -116,13 +116,13 @@
|
|
|
116
116
|
|
|
117
117
|
<# if(branch_media.old_media_file_id != branch_media.new_media_file_id){ #>
|
|
118
118
|
<div>
|
|
119
|
-
<# if(_.includes(['.jpg','.jpeg','.tif','.tiff','.png','.gif','.svg'], (branch_media.old_media_ext||'').toLowerCase())){ #>
|
|
119
|
+
<# if(_.includes(['.jpg','.jpeg','.webp','.tif','.tiff','.png','.gif','.svg'], (branch_media.old_media_ext||'').toLowerCase())){ #>
|
|
120
120
|
<div class="diff_media_preview previous_media" data-media_key="<#=branch_media.media_key#>" data-media_id="<#=branch_media.media_orig_id#>" data-media_ext="<#=branch_media.old_media_ext#>" data-media_width="<#=branch_media.old_media_width#>" data-media_height="<#=branch_media.old_media_height#>">
|
|
121
121
|
Prev:<br/>
|
|
122
122
|
<img src="<%=jsh._BASEURL%>_funcs/media/<#=branch_media.media_key#>/file_preview?media_id=<#=branch_media.media_orig_id#>" />
|
|
123
123
|
</div>
|
|
124
124
|
<# } #>
|
|
125
|
-
<# if(_.includes(['.jpg','.jpeg','.tif','.tiff','.png','.gif','.svg'], (branch_media.new_media_ext||'').toLowerCase())){ #>
|
|
125
|
+
<# if(_.includes(['.jpg','.jpeg','.webp','.tif','.tiff','.png','.gif','.svg'], (branch_media.new_media_ext||'').toLowerCase())){ #>
|
|
126
126
|
<div class="diff_media_preview new_media" data-media_key="<#=branch_media.media_key#>" data-media_id="<#=branch_media.media_id#>" data-media_ext="<#=branch_media.new_media_ext#>" data-media_width="<#=branch_media.new_media_width#>" data-media_height="<#=branch_media.new_media_height#>">
|
|
127
127
|
New:<br/>
|
|
128
128
|
<img src="<%=jsh._BASEURL%>_funcs/media/<#=branch_media.media_key#>/file_preview?media_id=<#=branch_media.media_id#>" />
|
|
@@ -20,6 +20,7 @@ along with this package. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20
20
|
var ejs = require('ejs');
|
|
21
21
|
var _ = require('lodash');
|
|
22
22
|
var async = require('async');
|
|
23
|
+
var crypto = require('crypto');
|
|
23
24
|
var Helper = require('jsharmony/Helper');
|
|
24
25
|
var ejsext = require('jsharmony/lib/ejsext.js');
|
|
25
26
|
|
|
@@ -646,6 +647,7 @@ module.exports = exports = function(module, funcs){
|
|
|
646
647
|
templateName: null,
|
|
647
648
|
pageComponents: {},
|
|
648
649
|
component: undefined,
|
|
650
|
+
pageData: undefined,
|
|
649
651
|
}, renderOptions);
|
|
650
652
|
|
|
651
653
|
var defaultProperties = {};
|
|
@@ -655,6 +657,7 @@ module.exports = exports = function(module, funcs){
|
|
|
655
657
|
defaultData = funcs.getComponentDefaultValues(renderOptions.component.data);
|
|
656
658
|
}
|
|
657
659
|
var properties = _.extend({}, defaultProperties, renderOptions.properties);
|
|
660
|
+
var pageData = additionalRenderParams.pageData || {};
|
|
658
661
|
|
|
659
662
|
var renderParams = _.extend({
|
|
660
663
|
baseUrl: '',
|
|
@@ -671,11 +674,14 @@ module.exports = exports = function(module, funcs){
|
|
|
671
674
|
isInEditor: false,
|
|
672
675
|
isInPageEditor: false,
|
|
673
676
|
isInComponentEditor: false,
|
|
674
|
-
componentRenderClass: 'jsharmony_cms_componentRender_'+Helper.escapeCSSClass((renderOptions.templateName)||'')+'_'+((branchData && branchData.component_getUniqueId && branchData.component_getUniqueId())||'').toString(),
|
|
677
|
+
componentRenderClass: 'jsharmony_cms_componentRender_'+Helper.escapeCSSClass((renderOptions.templateName)||'')+'_'+((branchData && branchData.component_getUniqueId && branchData.component_getUniqueId(pageData.uniqueIdSalt, pageData.getMaxUniqueId))||'').toString(),
|
|
675
678
|
items: [],
|
|
676
679
|
item: {},
|
|
677
680
|
component: properties,
|
|
678
681
|
getMediaThumbnails: function(url){ return funcs.getMediaThumbnails(url, branchData); },
|
|
682
|
+
getPageVar: function(key){ if(key=='cmspath') return pageData.cmspath; return pageData.vars && pageData.vars[key]; },
|
|
683
|
+
setPageVar: function(key, val){ if(!pageData.vars) return; pageData.vars[key] = val; },
|
|
684
|
+
hash: function(val){ return crypto.createHash('md5').update(val).digest('hex'); },
|
|
679
685
|
renderPlaceholder: function(){ return ''; },
|
|
680
686
|
renderTemplate: function(locals, templateName, items){
|
|
681
687
|
if(!items || (_.isArray(items) && !items.length)) return '';
|
package/models/_funcs.deploy.js
CHANGED
|
@@ -163,7 +163,7 @@ module.exports = exports = function(module, funcs){
|
|
|
163
163
|
for(var thumbnail_id in branchData.site_config.media_thumbnails){
|
|
164
164
|
var thumbnail_config = branchData.site_config.media_thumbnails[thumbnail_id];
|
|
165
165
|
if(!thumbnail_config || !thumbnail_config.export) continue;
|
|
166
|
-
if(!_.includes(['.jpg','.jpeg','.tif','.tiff','.png','.gif','.svg'], media.media_ext)) continue;
|
|
166
|
+
if(!_.includes(['.jpg','.jpeg','.webp','.tif','.tiff','.png','.gif','.svg'], media.media_ext)) continue;
|
|
167
167
|
if((patharr.length >= 5) && patharr[4]) patharr[4] = thumbnail_id;
|
|
168
168
|
else patharr.splice(4,0,thumbnail_id);
|
|
169
169
|
rslt[thumbnail_id] = urlparts.protocol + '//' + urlparts.host + patharr.join('/') + (urlparts.search||'') + (urlparts.hash||'');
|
|
@@ -638,8 +638,6 @@ module.exports = exports = function(module, funcs){
|
|
|
638
638
|
deployment.publish_params = publish_params;
|
|
639
639
|
|
|
640
640
|
//Branch Data
|
|
641
|
-
var component_maxUniqueId = 0;
|
|
642
|
-
var component_maxUniqueIdSalt = crypto.randomBytes(16).toString('hex');
|
|
643
641
|
var branchData = {
|
|
644
642
|
publish_params: publish_params,
|
|
645
643
|
template_variables: template_variables,
|
|
@@ -655,12 +653,15 @@ module.exports = exports = function(module, funcs){
|
|
|
655
653
|
page_redirects: {},
|
|
656
654
|
page_base_paths: {},
|
|
657
655
|
page_files: {},
|
|
658
|
-
page_data: {},
|
|
656
|
+
page_data: { /* format, output, vars, cmspath, urlpath, basepath, getMaxUniqueId, uniqueIdSalt */ },
|
|
659
657
|
|
|
660
658
|
component_templates: null,
|
|
661
659
|
component_template_html: {},
|
|
662
660
|
component_export_template_html: {},
|
|
663
|
-
component_getUniqueId: function(){
|
|
661
|
+
component_getUniqueId: function(salt, getMaxUniqueId){
|
|
662
|
+
if(!salt || !getMaxUniqueId) return crypto.randomBytes(16).toString('hex');
|
|
663
|
+
return crypto.createHash('md5').update(salt+'.'+(getMaxUniqueId()).toString()).digest('hex');
|
|
664
|
+
},
|
|
664
665
|
|
|
665
666
|
media_keys: {},
|
|
666
667
|
media_items: {},
|
|
@@ -1314,7 +1315,14 @@ module.exports = exports = function(module, funcs){
|
|
|
1314
1315
|
branchData.page_keys[page.page_key] = page_cmspath;
|
|
1315
1316
|
branchData.page_redirects[page_cmspath] = page_urlpath;
|
|
1316
1317
|
branchData.page_base_paths[page.page_key] = page_basepath;
|
|
1317
|
-
branchData.page_data[page.page_key] = {
|
|
1318
|
+
branchData.page_data[page.page_key] = {
|
|
1319
|
+
cmspath: page_cmspath,
|
|
1320
|
+
urlpath: page_urlpath,
|
|
1321
|
+
basepath: page_basepath,
|
|
1322
|
+
getMaxUniqueId: (function(){ var id = 0; return function(){ return ++id; }; })(),
|
|
1323
|
+
uniqueIdSalt: page_basepath,
|
|
1324
|
+
vars: {},
|
|
1325
|
+
};
|
|
1318
1326
|
if(path.basename(page_cmspath)==publish_params.site_default_page_filename){
|
|
1319
1327
|
var base_page_dir = publish_params.url_prefix + publish_params.page_subfolder;
|
|
1320
1328
|
if(!Helper.isNullUndefined(publish_params.url_prefix_page_override)){ base_page_dir = publish_params.url_prefix_page_override; }
|
|
@@ -1430,6 +1438,9 @@ module.exports = exports = function(module, funcs){
|
|
|
1430
1438
|
var includeCode = '<!--#jsharmony_cms_include('+JSON.stringify(path)+')-->';
|
|
1431
1439
|
return includeCode;
|
|
1432
1440
|
};
|
|
1441
|
+
|
|
1442
|
+
if(!(page.page_key in branchData.page_data)) throw new Error('Page '+page.page_path+' not defined in page_data');
|
|
1443
|
+
var pageData = branchData.page_data[page.page_key];
|
|
1433
1444
|
|
|
1434
1445
|
//Merge content with template
|
|
1435
1446
|
var ejsparams = {
|
|
@@ -1479,6 +1490,7 @@ module.exports = exports = function(module, funcs){
|
|
|
1479
1490
|
getMenuImageURL: function(menu_item){ return funcs.getMenuImageUrl(menu_item, branchData); },
|
|
1480
1491
|
|
|
1481
1492
|
include: includePage,
|
|
1493
|
+
pageData: pageData,
|
|
1482
1494
|
};
|
|
1483
1495
|
if(renderOptions.menu_tag){
|
|
1484
1496
|
if(!branchData.menus[renderOptions.menu_tag]) throw new Error('Menu with menu tag "'+Helper.escapeHTML(renderOptions.menu_tag)+'" is not defined in this site');
|
|
@@ -1521,6 +1533,7 @@ module.exports = exports = function(module, funcs){
|
|
|
1521
1533
|
}
|
|
1522
1534
|
renderedContent = funcs.renderComponents(renderedContent, branchData, clientPage.template.components, {
|
|
1523
1535
|
include: includePage,
|
|
1536
|
+
pageData: pageData,
|
|
1524
1537
|
});
|
|
1525
1538
|
renderedContent = funcs.applyRenderTags(renderedContent, { page: ejsparams.page });
|
|
1526
1539
|
renderedContent = funcs.applyResponsiveImg(renderedContent, branchData.site_config.media_thumbnails, branchData.media_items);
|
|
@@ -1541,6 +1554,7 @@ module.exports = exports = function(module, funcs){
|
|
|
1541
1554
|
removeClass: true
|
|
1542
1555
|
};
|
|
1543
1556
|
renderedContent = funcs.replaceBranchURLs(renderedContent, replaceBranchURLsParams);
|
|
1557
|
+
pageData.vars = JSON.parse(funcs.replaceBranchURLs(JSON.stringify(pageData.vars), replaceBranchURLsParams));
|
|
1544
1558
|
pageIncludes = JSON.parse(funcs.replaceBranchURLs(JSON.stringify(pageIncludes), _.extend(replaceBranchURLsParams, {
|
|
1545
1559
|
getPageURL: function(page_key){
|
|
1546
1560
|
if(!(page_key in branchData.page_keys)) throw new Error('Page '+page.page_path+' links to missing Page ID # '+page_key.toString());
|
|
@@ -1552,8 +1566,7 @@ module.exports = exports = function(module, funcs){
|
|
|
1552
1566
|
|
|
1553
1567
|
try{
|
|
1554
1568
|
if(exportJSON){
|
|
1555
|
-
|
|
1556
|
-
branchData.page_data[page.page_key].format = 'json';
|
|
1569
|
+
pageData.format = 'json';
|
|
1557
1570
|
//Flatten Page
|
|
1558
1571
|
var flatPage = funcs.flattenObject(ejsparams.page);
|
|
1559
1572
|
//Render Page
|
|
@@ -1589,18 +1602,24 @@ module.exports = exports = function(module, funcs){
|
|
|
1589
1602
|
branchData.pageIncludes[abskey] = branchData.pageIncludes[abskey].concat(pageIncludes[key]);
|
|
1590
1603
|
}
|
|
1591
1604
|
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1605
|
+
if(clientPage.template.options.virtual_render){
|
|
1606
|
+
pageData.output = page_content;
|
|
1607
|
+
return cb();
|
|
1608
|
+
}
|
|
1609
|
+
else {
|
|
1610
|
+
branchData.site_files[page_fpath] = {
|
|
1611
|
+
md5: crypto.createHash('md5').update(page_content).digest('hex')
|
|
1612
|
+
};
|
|
1613
|
+
branchData.page_files[page.page_key] = page_fpath;
|
|
1614
|
+
page_fpath = path.join(publish_params.publish_path, page_fpath);
|
|
1615
|
+
|
|
1616
|
+
//Create folders for path
|
|
1617
|
+
HelperFS.createFolderRecursive(path.dirname(page_fpath), function(err){
|
|
1618
|
+
if(err) return cb(err);
|
|
1619
|
+
//Save page to publish folder
|
|
1620
|
+
fs.writeFile(page_fpath, page_content, 'utf8', cb);
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1604
1623
|
});
|
|
1605
1624
|
}, cb);
|
|
1606
1625
|
});
|
|
@@ -1633,7 +1652,6 @@ module.exports = exports = function(module, funcs){
|
|
|
1633
1652
|
getMenuURL: function(menu_item){ return funcs.getMenuUrl(menu_item, branchData); },
|
|
1634
1653
|
getMenuImageURL: function(menu_item){ return funcs.getMenuImageUrl(menu_item, branchData); },
|
|
1635
1654
|
|
|
1636
|
-
|
|
1637
1655
|
page_paths: branchData.page_redirects,
|
|
1638
1656
|
site_redirects: branchData.site_redirects,
|
|
1639
1657
|
|
|
@@ -1876,7 +1894,7 @@ module.exports = exports = function(module, funcs){
|
|
|
1876
1894
|
function(generate_cb){
|
|
1877
1895
|
async.eachOf(branchData.site_config.media_thumbnails, function(thumbnail_config, thumbnail_id, thumbnail_cb){
|
|
1878
1896
|
if(!thumbnail_config || !thumbnail_config.export) return thumbnail_cb();
|
|
1879
|
-
if(!_.includes(['.jpg','.jpeg','.tif','.tiff','.png','.gif','.svg'], media.media_ext)) return thumbnail_cb();
|
|
1897
|
+
if(!_.includes(['.jpg','.jpeg','.webp','.tif','.tiff','.png','.gif','.svg'], media.media_ext)) return thumbnail_cb();
|
|
1880
1898
|
|
|
1881
1899
|
funcs.getMediaFile(media.media_file_id, media.media_filename, media.media_ext, thumbnail_id, thumbnail_config, function(err, thumbnail_srcpath, thumbnail_fname, stat){
|
|
1882
1900
|
if(err) return thumbnail_cb('Error getting thumbnail for '+media_fpath+':'+thumbnail_id+' - '+err.toString());
|
package/models/_funcs.media.js
CHANGED
|
@@ -303,7 +303,7 @@ module.exports = exports = function(module, funcs){
|
|
|
303
303
|
|
|
304
304
|
//Get image width / height
|
|
305
305
|
function(cb){
|
|
306
|
-
if(!_.includes(['.jpg','.jpeg','.tif','.tiff','.png','.gif','.svg'], media_ext)) return cb();
|
|
306
|
+
if(!_.includes(['.jpg','.jpeg','.webp','.tif','.tiff','.png','.gif','.svg'], media_ext)) return cb();
|
|
307
307
|
jsh.Extensions.image.size(tmp_file_path, function(err, size){
|
|
308
308
|
if(err || !size || !size.width || !size.height) return cb();
|
|
309
309
|
media_width = size.width;
|
|
@@ -636,7 +636,7 @@ module.exports = exports = function(module, funcs){
|
|
|
636
636
|
|
|
637
637
|
//Get image width / height
|
|
638
638
|
function(media_cb){
|
|
639
|
-
if(!_.includes(['.jpg','.jpeg','.tif','.tiff','.png','.gif','.svg'], media_ext)) return media_cb();
|
|
639
|
+
if(!_.includes(['.jpg','.jpeg','.webp','.tif','.tiff','.png','.gif','.svg'], media_ext)) return media_cb();
|
|
640
640
|
jsh.Extensions.image.size(tmp_file_path, function(err, size){
|
|
641
641
|
if(err || !size || !size.width || !size.height) return media_cb();
|
|
642
642
|
media_width = size.width;
|
package/models/_funcs.page.js
CHANGED
package/models/js/site.js
CHANGED
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
var qs = '';
|
|
114
114
|
if(media_id) qs = 'media_id='+media_id;
|
|
115
115
|
else if(media_file_id) qs = 'media_file_id='+media_file_id;
|
|
116
|
-
if(_.includes(['.jpg','.jpeg','.tif','.tiff','.png','.gif','.pdf','.svg'], media_ext.toLowerCase())){
|
|
116
|
+
if(_.includes(['.jpg','.jpeg','.webp','.tif','.tiff','.png','.gif','.pdf','.svg'], media_ext.toLowerCase())){
|
|
117
117
|
let url = jsh._BASEURL+'_funcs/media/'+media_key+'/'+(qs?'?'+qs:'');
|
|
118
118
|
var ww = 800;
|
|
119
119
|
var wh = 600;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsharmony-cms",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "jsHarmony CMS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"diff2html": "3.4.1",
|
|
31
31
|
"ejs": "2.7.4",
|
|
32
32
|
"js-beautify": "^1.11.0",
|
|
33
|
-
"jsharmony": "^1.
|
|
33
|
+
"jsharmony": "^1.40.15",
|
|
34
34
|
"jsharmony-factory": "^1.2.0",
|
|
35
35
|
"lodash": "^4.17.19",
|
|
36
36
|
"node-forge": "^0.10.0",
|
|
@@ -4791,6 +4791,9 @@ exports = module.exports = function(jsh, cms){
|
|
|
4791
4791
|
isInComponentEditor: false,
|
|
4792
4792
|
componentRenderClass: 'jsharmony_cms_componentRender_'+XExt.escapeCSSClass((component&&component.id)||'')+'_'+cms.componentManager.getUniqueId().toString(),
|
|
4793
4793
|
getMediaThumbnails: function(url){ return cms.componentManager.getMediaThumbnails(url); },
|
|
4794
|
+
getPageVar: function(key){ return undefined; },
|
|
4795
|
+
setPageVar: function(key, val){ },
|
|
4796
|
+
hash: function(val){ return Crypto.MD5((val||'').toString()).toString(); },
|
|
4794
4797
|
items: data.items,
|
|
4795
4798
|
item: data.item,
|
|
4796
4799
|
component: properties,
|
package/views/jsh_cms_editor.ejs
CHANGED
|
@@ -310,6 +310,9 @@ getMenuURL(menu_item)
|
|
|
310
310
|
getMenuImageURL(menu_item)
|
|
311
311
|
renderPlaceholder({ errors: '' })
|
|
312
312
|
getMediaThumbnails(url)
|
|
313
|
+
getPageVar(key)
|
|
314
|
+
setPageVar(key, val)
|
|
315
|
+
hash(val)
|
|
313
316
|
|
|
314
317
|
* Only available for Export Components
|
|
315
318
|
addFile(filePath, fileContent)
|