jsharmony-cms 1.1.16 → 1.3.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.
- package/doc/site_config.json +7 -0
- package/jsHarmonyCMSSFTPServer.js +1 -1
- package/models/Site_Deployment_Target_IntegrationCode.ejs +4 -4
- package/models/_funcs.branch.js +2 -2
- package/models/_funcs.deploy.ftp.driver.sftp.js +1 -1
- package/models/_funcs.deploy.js +75 -25
- package/models/_funcs.media.js +393 -379
- package/models/_funcs.template.js +41 -26
- package/models/sql/_menu.mssql.json +4 -0
- package/models/sql/_menu.pgsql.json +4 -0
- package/models/sql/_menu.sqlite.json +4 -0
- package/package.json +2 -2
- package/public/js/jsHarmonyCMS.Controller.page.js +4 -4
package/doc/site_config.json
CHANGED
|
@@ -12,5 +12,12 @@
|
|
|
12
12
|
},
|
|
13
13
|
"template_variables": { // Default values for Template Variables
|
|
14
14
|
"key": "value"
|
|
15
|
+
},
|
|
16
|
+
"media_thumbnails": {
|
|
17
|
+
"file_tile": { "resize": [150, 150], "format": "jpg" },
|
|
18
|
+
"file_preview": { "resize": [300, 300], "format": "jpg" },
|
|
19
|
+
"small": { "resize": [512, 384], "export": true },
|
|
20
|
+
"medium": { "resize": [1024, 768], "export": true },
|
|
21
|
+
"large": { "resize": [2048, 1538] }
|
|
15
22
|
}
|
|
16
23
|
}
|
|
@@ -22,7 +22,7 @@ var async = require('async');
|
|
|
22
22
|
var fs = require('fs');
|
|
23
23
|
var ftppath = require('path').posix;
|
|
24
24
|
var fspath = require('path');
|
|
25
|
-
var ssh2 = require('ssh2');
|
|
25
|
+
var ssh2 = require('ssh2-classic');
|
|
26
26
|
var crypto = require('crypto');
|
|
27
27
|
var moment = require('moment');
|
|
28
28
|
var Helper = require('jsharmony/Helper');
|
|
@@ -112,8 +112,8 @@ app.get('/standalone_page', async function(req, res, next){
|
|
|
112
112
|
require_once __DIR__.'/vendor/autoload.php';
|
|
113
113
|
|
|
114
114
|
// Initialize the jsHarmony CMS Router
|
|
115
|
-
use apHarmony\jsHarmonyCms\
|
|
116
|
-
$cmsRouter = new
|
|
115
|
+
use apHarmony\jsHarmonyCms\CmsRouter;
|
|
116
|
+
$cmsRouter = new CmsRouter(%%%INTEGRATION_PARAMS_CMS_SERVER_URLS%%%);
|
|
117
117
|
|
|
118
118
|
// Serve CMS content for the current URL
|
|
119
119
|
if(!$cmsRouter->serve()){
|
|
@@ -144,8 +144,8 @@ jsHarmonyCmsEditor({"access_keys":%%%ACCESS_KEYS%%%});
|
|
|
144
144
|
require_once __DIR__.'/vendor/autoload.php';
|
|
145
145
|
|
|
146
146
|
// Initialize the jsHarmony CMS Router
|
|
147
|
-
use apHarmony\jsHarmonyCms\
|
|
148
|
-
$cmsRouter = new
|
|
147
|
+
use apHarmony\jsHarmonyCms\CmsRouter;
|
|
148
|
+
$cmsRouter = new CmsRouter(%%%INTEGRATION_PARAMS_CMS_SERVER_URLS%%%);
|
|
149
149
|
|
|
150
150
|
// Get the CMS content for this page
|
|
151
151
|
$page = $cmsRouter->getStandalone();
|
package/models/_funcs.branch.js
CHANGED
|
@@ -219,7 +219,7 @@ module.exports = exports = function(module, funcs){
|
|
|
219
219
|
verrors = _.merge(verrors, validate.Validate('B', sql_params));
|
|
220
220
|
if (!_.isEmpty(verrors)) { Helper.GenError(req, res, -2, verrors[''].join('\n')); return; }
|
|
221
221
|
|
|
222
|
-
funcs.validateSiteAccess(req, res, P.site_id, ['PUBLISHER'], function(){
|
|
222
|
+
funcs.validateSiteAccess(req, res, P.site_id, ['PUBLISHER','WEBMASTER'], function(){
|
|
223
223
|
|
|
224
224
|
var baseurl = req.baseurl;
|
|
225
225
|
if(baseurl.indexOf('//')<0) baseurl = req.protocol + '://' + req.get('host') + baseurl;
|
|
@@ -1150,7 +1150,7 @@ module.exports = exports = function(module, funcs){
|
|
|
1150
1150
|
}
|
|
1151
1151
|
appsrv.ExecRecordset(req._DBContext, funcs.replaceSchema(sql), sql_ptypes, sql_params, function (err, rslt) {
|
|
1152
1152
|
if (err != null) { err.sql = sql; appsrv.AppDBError(req, res, err); return; }
|
|
1153
|
-
if (rslt[0].length!=1) return Helper.GenError(req, res, -11, 'No access to target
|
|
1153
|
+
if (rslt[0].length!=1) return Helper.GenError(req, res, -11, 'No '+(site_access&&site_access.length?site_access.join(' / ')+' ':'')+'access to target site');
|
|
1154
1154
|
callback(null);
|
|
1155
1155
|
});
|
|
1156
1156
|
}
|
|
@@ -17,7 +17,7 @@ You should have received a copy of the GNU Lesser General Public License
|
|
|
17
17
|
along with this package. If not, see <http://www.gnu.org/licenses/>.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
var ssh2 = require('ssh2');
|
|
20
|
+
var ssh2 = require('ssh2-classic');
|
|
21
21
|
var path = require('path');
|
|
22
22
|
var fs = require('fs');
|
|
23
23
|
var Helper = require('jsharmony/Helper');
|
package/models/_funcs.deploy.js
CHANGED
|
@@ -119,11 +119,20 @@ module.exports = exports = function(module, funcs){
|
|
|
119
119
|
return page_fpath;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
exports.getMediaRelativePath = function(media, publish_params){
|
|
122
|
+
exports.getMediaRelativePath = function(media, publish_params, thumbnail_name){
|
|
123
123
|
var media_fpath = media.media_path||'';
|
|
124
124
|
if(!media_fpath) return '';
|
|
125
125
|
while(media_fpath.substr(0,1)=='/') media_fpath = media_fpath.substr(1);
|
|
126
126
|
|
|
127
|
+
if(thumbnail_name){
|
|
128
|
+
var lastDot = media_fpath.lastIndexOf('.');
|
|
129
|
+
var lastSlash = Math.max(media_fpath.lastIndexOf('/'),media_fpath.lastIndexOf('\\'));
|
|
130
|
+
if((lastDot < 0) || (lastDot < lastSlash)) media_fpath += '.'+thumbnail_name;
|
|
131
|
+
else {
|
|
132
|
+
media_fpath = media_fpath.substr(0, lastDot) + '.' + thumbnail_name + media_fpath.substr(lastDot);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
127
136
|
var is_folder = (media_fpath[media_fpath.length-1]=='/');
|
|
128
137
|
if(is_folder) throw new Error('Media path:'+media.media_path+' cannot be a folder');
|
|
129
138
|
if(path.isAbsolute(media_fpath)) throw new Error('Media path:'+media.media_path+' cannot be absolute');
|
|
@@ -1735,7 +1744,7 @@ module.exports = exports = function(module, funcs){
|
|
|
1735
1744
|
//For each media
|
|
1736
1745
|
// Save media to file
|
|
1737
1746
|
var sql = 'select \
|
|
1738
|
-
m.media_key,media_file_id,media_path,media_ext \
|
|
1747
|
+
m.media_key,media_file_id,media_path,media_ext,media_filename \
|
|
1739
1748
|
from '+(module.schema?module.schema+'.':'')+'media m \
|
|
1740
1749
|
inner join '+(module.schema?module.schema+'.':'')+'branch_media bm on bm.media_id = m.media_id\
|
|
1741
1750
|
inner join '+(module.schema?module.schema+'.':'')+'deployment d on d.branch_id = bm.branch_id and d.deployment_id=@deployment_id\
|
|
@@ -1746,32 +1755,73 @@ module.exports = exports = function(module, funcs){
|
|
|
1746
1755
|
appsrv.ExecRecordset('deployment', sql, sql_ptypes, sql_params, function (err, rslt) {
|
|
1747
1756
|
if (err != null) { err.sql = sql; return cb(err); }
|
|
1748
1757
|
if(!rslt || !rslt.length || !rslt[0]){ return cb(new Error('Error loading deployment media')); }
|
|
1749
|
-
async.eachSeries(rslt[0], function(media,
|
|
1750
|
-
var srcpath = funcs.
|
|
1751
|
-
|
|
1752
|
-
|
|
1758
|
+
async.eachSeries(rslt[0], function(media, item_cb){
|
|
1759
|
+
var srcpath = funcs.getMediaFilename(media.media_file_id, media.media_ext);
|
|
1760
|
+
var media_fpath = '';
|
|
1761
|
+
async.waterfall([
|
|
1762
|
+
//Export primary media file
|
|
1763
|
+
function(generate_cb){
|
|
1764
|
+
fs.readFile(srcpath, null, function(err, media_content){
|
|
1765
|
+
if(err) return generate_cb(err);
|
|
1753
1766
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
if(!media_fpath) return cb(new Error('Media has no path: '+media.media_key));
|
|
1767
|
+
try{
|
|
1768
|
+
media_fpath = funcs.getMediaRelativePath(media, publish_params);
|
|
1769
|
+
}
|
|
1770
|
+
catch(ex){
|
|
1771
|
+
return generate_cb(ex);
|
|
1772
|
+
}
|
|
1773
|
+
if(!media_fpath) return generate_cb(new Error('Media has no path: '+media.media_key));
|
|
1762
1774
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1775
|
+
branchData.site_files[media_fpath] = {
|
|
1776
|
+
md5: crypto.createHash('md5').update(media_content).digest("hex")
|
|
1777
|
+
};
|
|
1778
|
+
media_fpath = path.join(publish_params.publish_path, media_fpath);
|
|
1767
1779
|
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1780
|
+
//Create folders for path
|
|
1781
|
+
HelperFS.createFolderRecursive(path.dirname(media_fpath), function(err){
|
|
1782
|
+
if(err) return generate_cb(err);
|
|
1783
|
+
//Save media to publish folder
|
|
1784
|
+
HelperFS.copyFile(srcpath, media_fpath, generate_cb);
|
|
1785
|
+
});
|
|
1786
|
+
});
|
|
1787
|
+
},
|
|
1788
|
+
//Export thumbnails
|
|
1789
|
+
function(generate_cb){
|
|
1790
|
+
async.eachOfSeries(branchData.site_config.media_thumbnails, function(thumbnail_config, thumbnail_name, thumbnail_cb){
|
|
1791
|
+
if(!thumbnail_config || !thumbnail_config.export) return thumbnail_cb();
|
|
1792
|
+
if(!_.includes(['.jpg','.jpeg','.tif','.tiff','.png','.gif','.svg'], media.media_ext)) return cb();
|
|
1793
|
+
|
|
1794
|
+
funcs.getMediaFile(media.media_file_id, media.media_filename, media.media_ext, thumbnail_name, thumbnail_config, function(err, thumbnail_srcpath, stat){
|
|
1795
|
+
if(err) return thumbnail_cb('Error getting thumbnail for '+media_fpath+':'+thumbnail_name+' - '+err.toString());
|
|
1796
|
+
|
|
1797
|
+
fs.readFile(thumbnail_srcpath, null, function(err, thumbnail_content){
|
|
1798
|
+
if(err) return thumbnail_cb(err);
|
|
1799
|
+
|
|
1800
|
+
var thumbnail_fpath = '';
|
|
1801
|
+
try{
|
|
1802
|
+
thumbnail_fpath = funcs.getMediaRelativePath(media, publish_params, thumbnail_name);
|
|
1803
|
+
}
|
|
1804
|
+
catch(ex){
|
|
1805
|
+
return thumbnail_cb(ex);
|
|
1806
|
+
}
|
|
1807
|
+
if(!thumbnail_fpath) return thumbnail_cb(new Error('Thumbnail deployment path could not be generated for: '+media.media_fpath+':'+thumbnail_name));
|
|
1808
|
+
|
|
1809
|
+
branchData.site_files[thumbnail_fpath] = {
|
|
1810
|
+
md5: crypto.createHash('md5').update(thumbnail_content).digest("hex")
|
|
1811
|
+
};
|
|
1812
|
+
thumbnail_fpath = path.join(publish_params.publish_path, thumbnail_fpath);
|
|
1813
|
+
|
|
1814
|
+
//Create folders for path
|
|
1815
|
+
HelperFS.createFolderRecursive(path.dirname(thumbnail_fpath), function(err){
|
|
1816
|
+
if(err) return thumbnail_cb(err);
|
|
1817
|
+
//Save thumbnail to publish folder
|
|
1818
|
+
HelperFS.copyFile(thumbnail_srcpath, thumbnail_fpath, thumbnail_cb);
|
|
1819
|
+
});
|
|
1820
|
+
});
|
|
1821
|
+
});
|
|
1822
|
+
}, generate_cb);
|
|
1823
|
+
},
|
|
1824
|
+
], item_cb);
|
|
1775
1825
|
}, cb);
|
|
1776
1826
|
});
|
|
1777
1827
|
}
|