diff --git a/.gitignore b/.gitignore index fa76cfa..a40eeac 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,11 @@ build/Release # Dependency directory # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules +public/img/final_ld/* +public/img/final/* +public/img/final_ld/* +public/img/original/* +public/img/prebuilt/* # Debug log from npm npm-debug.log diff --git a/app.js b/app.js index 89299db..8eb7cc6 100644 --- a/app.js +++ b/app.js @@ -1,4 +1,5 @@ var BOB_mod_path = require('path'); +var BOB_mod_mkdirp = require('mkdirp'); var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); @@ -81,7 +82,7 @@ module.exports = app; function BOB_initConfig() { // Config var cfgConfig = { - background : '#ffffff', + background : '#fff0ff', margins : 0.01, style : 'default', nbPicture : 4, @@ -105,6 +106,12 @@ function BOB_initConfig() { cfgConfig.paths.prebuilt = BOB_mod_path.resolve(__dirname, './public/img/prebuilt'); cfgConfig.paths.template = BOB_mod_path.resolve(__dirname, './public/img/template'); cfgConfig.paths.original = BOB_mod_path.resolve(__dirname, './public/img/original'); + + BOB_mod_mkdirp.sync(cfgConfig.paths.final); + BOB_mod_mkdirp.sync(cfgConfig.paths.final_ld); + BOB_mod_mkdirp.sync(cfgConfig.paths.prebuilt); + BOB_mod_mkdirp.sync(cfgConfig.paths.original); + // Init pinctures names for( var index = 0; index < cfgConfig.nbPicture; index ++ ) { (function(pId) { diff --git a/public/css/cover.css b/public/css/cover.css new file mode 100644 index 0000000..f4d789e --- /dev/null +++ b/public/css/cover.css @@ -0,0 +1,163 @@ +/* + * Globals + */ + +/* Links */ +a, +a:focus, +a:hover { + color: #fff; +} + +/* Custom default button */ +.btn-default, +.btn-default:hover, +.btn-default:focus { + color: #333; + text-shadow: none; /* Prevent inheritence from `body` */ + background-color: #fff; + border: 1px solid #fff; +} + + +/* + * Base structure + */ + +html, +body { + height: 100%; + background-color: #333; +} +body { + color: #fff; + text-align: center; + text-shadow: 0 1px 3px rgba(0,0,0,.5); +} + +/* Extra markup and styles for table-esque vertical and horizontal centering */ +.site-wrapper { + display: table; + width: 100%; + height: 100%; /* For at least Firefox */ + min-height: 100%; + -webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5); + box-shadow: inset 0 0 100px rgba(0,0,0,.5); +} +.site-wrapper-inner { + display: table-cell; + vertical-align: top; +} +.cover-container { + margin-right: auto; + margin-left: auto; +} + +/* Padding for spacing */ +.inner { + padding: 30px; +} + + +/* + * Header + */ +.masthead-brand { + margin-top: 10px; + margin-bottom: 10px; +} + +.masthead-nav > li { + display: inline-block; +} +.masthead-nav > li + li { + margin-left: 20px; +} +.masthead-nav > li > a { + padding-right: 0; + padding-left: 0; + font-size: 16px; + font-weight: bold; + color: #fff; /* IE8 proofing */ + color: rgba(255,255,255,.75); + border-bottom: 2px solid transparent; +} +.masthead-nav > li > a:hover, +.masthead-nav > li > a:focus { + background-color: transparent; + border-bottom-color: #a9a9a9; + border-bottom-color: rgba(255,255,255,.25); +} +.masthead-nav > .active > a, +.masthead-nav > .active > a:hover, +.masthead-nav > .active > a:focus { + color: #fff; + border-bottom-color: #fff; +} + +@media (min-width: 768px) { + .masthead-brand { + float: left; + } + .masthead-nav { + float: right; + } +} + + +/* + * Cover + */ + +.cover { + padding: 0 20px; +} +.cover .btn-lg { + padding: 10px 20px; + font-weight: bold; +} + + +/* + * Footer + */ + +.mastfoot { + color: #999; /* IE8 proofing */ + color: rgba(255,255,255,.5); +} + + +/* + * Affix and center + */ + +@media (min-width: 768px) { + /* Pull out the header and footer */ + .masthead { + position: fixed; + top: 0; + } + .mastfoot { + position: fixed; + bottom: 0; + } + /* Start the vertical centering */ + .site-wrapper-inner { + vertical-align: middle; + } + /* Handle the widths */ + .masthead, + .mastfoot, + .cover-container { + width: 100%; /* Must be percentage or pixels for horizontal alignment */ + } +} + +@media (min-width: 992px) { + .masthead, + .mastfoot, + .cover-container { + width: 700px; + } +} \ No newline at end of file diff --git a/public/css/style.css b/public/css/style.css new file mode 100644 index 0000000..30e047d --- /dev/null +++ b/public/css/style.css @@ -0,0 +1,8 @@ +body { + padding: 50px; + font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; +} + +a { + color: #00B7FF; +} \ No newline at end of file diff --git a/public/css/view.css b/public/css/view.css new file mode 100644 index 0000000..d224def --- /dev/null +++ b/public/css/view.css @@ -0,0 +1,10 @@ +html, +body { + height: 100%; + background-color: #333; +} +body { + color: #fff; + text-align: center; + text-shadow: 0 1px 3px rgba(0,0,0,.5); +} \ No newline at end of file diff --git a/public/img/common/294.GIF b/public/img/common/294.GIF new file mode 100644 index 0000000..6bbc5ae Binary files /dev/null and b/public/img/common/294.GIF differ diff --git a/public/img/template/default.jpg b/public/img/template/default.jpg new file mode 100644 index 0000000..e373bfc Binary files /dev/null and b/public/img/template/default.jpg differ diff --git a/routes/index.js b/routes/index.js index 106c35b..1da36bd 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,22 +2,23 @@ var BOB_mod_express = require('express'); var BOB_mod_router = BOB_mod_express.Router(); var BOB_mod_path = require('path'); var BOB_mod_mkdirp = require('mkdirp'); +var BOB_mod_os = require('os'); var BOB_tol_gphotos = null; var BOB_tol_booth = null; var BOB_cfg_config = null; var BOB_var_boothInProgress = 0; - var BOB_var_gamepad = require("gamepad"); +var BOB_var_ipAddress = '127.0.0.1'; /* GET home page. */ BOB_mod_router.get('/bobinoscope', function(req, res, next) { - res.render('index', { title: 'Express' }); + res.render('index', {serverIpAddress: BOB_var_ipAddress}); }); /* GET view page. */ BOB_mod_router.get('/', function(req, res, next) { - res.render('view', {}); + res.render('view', {serverIpAddress: BOB_var_ipAddress}); }); BOB_mod_router.get('/booth/build/:boothId', function(req, res, next) { @@ -68,6 +69,29 @@ BOB_var_gamepad.on("down", function (pId, pNum) { }); }) +// Get local server ip address +var ifaces = BOB_mod_os.networkInterfaces(); +Object.keys(ifaces).forEach(function (ifname) { + var alias = 0; + + ifaces[ifname].forEach(function (iface) { + if ('IPv4' !== iface.family || iface.internal !== false) { + // skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses + return; + } + + BOB_var_ipAddress = iface.address; + + if (alias >= 1) { + // this single interface has multiple ipv4 addresses + console.log(ifname + ':' + alias, iface.address); + } else { + // this interface has only one ipv4 adress + console.log(ifname, iface.address); + } + }); +}); + module.exports = function(pConfig) { BOB_cfg_config = pConfig; diff --git a/tools/tools-photobooth.js b/tools/tools-photobooth.js index e5b50af..349fec4 100644 --- a/tools/tools-photobooth.js +++ b/tools/tools-photobooth.js @@ -10,7 +10,7 @@ var BOB_module = {}; BOB_module.getBoothList = function(pFrom, pCallback) { BOB_mod_fs.readdir(BOB_cfg_config.paths.final, function(pErr, pBoothList) { - var boothList = pBoothList.sort(); + var boothList = pBoothList ? pBoothList.sort() : []; boothList = boothList.splice(boothList.indexOf(pFrom) + 1); @@ -73,7 +73,7 @@ function BOB_generateBooth(pBoothId, pType, pCallback) { cmdDraw += ','+BOB_cfg_config.booths[pType].layout[pIndex].y; cmdDraw += ' '+BOB_cfg_config.booths[pType].layout[pIndex].width; cmdDraw += ','+BOB_cfg_config.booths[pType].layout[pIndex].height; - cmdDraw += ' '+BOB_mod_path.join(prebuiltPath, pPictName); + cmdDraw += ' \''+BOB_mod_path.join(prebuiltPath, pPictName)+'\''; console.log(cmdDraw); outPict.draw(cmdDraw); @@ -84,11 +84,17 @@ function BOB_generateBooth(pBoothId, pType, pCallback) { outPict.draw('text 1900,3850 "'+printedDate.toUTCString()+'"'); outPict.write(finalPict, function (pErr) { - BOB_mod_gm(finalPict) - .resize(600, null) - .write(finalLdPict, function(pErr) { - pCallback(pErr); - }) + if( pErr ) { + console.log("Write outfile") + console.log(pErr) + pCallback(pErr); + } else { + BOB_mod_gm(finalPict) + .resize(600, null) + .write(finalLdPict, function(pErr) { + pCallback(pErr); + }) + } }); } diff --git a/views/index.ejs b/views/index.ejs index 3623cb8..fb2546f 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -60,7 +60,7 @@