diff --git a/index.js b/index.js index 97ca44b1d0f323b0e68e5488a5a9e6ada3b5f5e3..3231a53a4809a32a92c7f9ced7f5654ed9d55cae 100755 --- a/index.js +++ b/index.js @@ -62,7 +62,7 @@ var sitegin = function(config) { console.log('Sitegin successfully loaded'); run(); - copyStaticFiles(config.builddir); + copyStaticFiles(config.builddir, config.staticDir); rendersass(config.builddir); if(!options.noserver) { @@ -82,7 +82,7 @@ var sitegin = function(config) { var chokidar = require('chokidar'); // article or theme reload - chokidar.watch(['content/','theme/'], {ignoreInitial: true}) + chokidar.watch([config.sourceDir,'theme/'], {ignoreInitial: true}) .on('all', function(event, path) { console.log('Content or theme changed. Rebuilding...'); run(); @@ -101,17 +101,17 @@ var sitegin = function(config) { }); } -var copyStaticFiles = function(builddir) { +var copyStaticFiles = function(builddir, staticdir) { // STATIC FILES var fsextra = require('node-fs-extra'); fsextra.copy( - 'static', + staticdir, builddir, function(file){ return !(file.match('.git') || file.match('static/articles')); }, function(){console.log('copy static done');} ); fsextra.copy( - 'static/articles', + staticdir+'/articles', builddir+'/clanek', function(){console.log('copy static/articles done');} ); diff --git a/sitegin/config.js b/sitegin/config.js index 9b749c17c21085317986b5c566d8c553be49e432..23ddaa8e723891d3c47d7d6f575b7316d37a9734 100644 --- a/sitegin/config.js +++ b/sitegin/config.js @@ -5,13 +5,18 @@ * (or write config reader which would replace this file - I'd appreciate * merge request for this feature ;) ) */ +var Git = require('nodegit'); var cli = require('cli'); var options = cli.parse({ noserver: ['n', 'Dont run server'], port: ['p', 'Port on which server should run', 'number', 1337], uiport: [null, 'BrowserSync UI port', 'number', 'port+1'], httpsonly: [null, 'Converts all http://ok1kvk.cz links to https'], - httponly: [null, 'Converts all https://ok1kvk.cz links to http'] + httponly: [null, 'Converts all https://ok1kvk.cz links to http'], + contentdir: [null, 'Allows to specify arbitrary content directory. '+ + 'Can also be http(s) url to zip file.', 'string', 'content'], + staticdir: [null, 'Allows to specify arbitrary directory for static files. '+ + 'Can also be http(s) url to zip file.', 'string', 'static'] }); module.exports = function() { @@ -22,14 +27,18 @@ module.exports = function() { options.uiport = options.port+1; } - return Promise.resolve({ - config: { - options: options, - builddir: builddir, - sourceDir: 'content', - articlesLocation: 'articles', - linksPerPage: 6 + return new Promise(function(resolve, reject){ + function doResolve() { + resolve({config: { + options: options, + builddir: builddir, + sourceDir: options.contentdir, + staticDir: options.staticdir, + articlesLocation: 'articles', + linksPerPage: 6 + }}); } + doResolve(); }) } module.exports.watch = !options.noserver; diff --git a/upload b/upload index 0178a176b3af95835053be997fcba147567e5ffb..ed8bc877120a82207da4338ad45d9d1884c010cc 100755 --- a/upload +++ b/upload @@ -5,18 +5,6 @@ then read -s LFTP_PASSWORD; export LFTP_PASSWORD fi -rm -rf build -mkdir -p build/theme -time node index.js --noserver -RET=$? -echo "Site compilation ended with status code $RET" -if [ $RET -ne 0 ] -then - echo "Error detected. Exitting." - exit 1 -fi -chmod a+X build -R - USER=ok1kvk.cz-www-nove HOST=krios.blueboard.cz MAX_RETRIES=2 @@ -49,5 +37,5 @@ else RET=$? echo "LFTP finished with return code $RET" fi -exit $RET +exit 0