From cba57fc6c453e7abe17d2549c1e8663a156bce30 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 21 Sep 2016 14:21:44 +0200 Subject: [PATCH] main: add example switch to displayu examples on heroku demo --- Procfile | 2 +- main/callbacks.js | 6 ++++++ main/settings.js | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Procfile b/Procfile index ca8f8479..602ee82e 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: node index.js -n $PORT +web: node index.js -n $PORT --examples diff --git a/main/callbacks.js b/main/callbacks.js index 3f62930c..a0d6e558 100644 --- a/main/callbacks.js +++ b/main/callbacks.js @@ -8,6 +8,12 @@ module.exports = function(settings,fs,ipc,osc,dialog) { if (settings.read('theme')) ipc.send('applyStyle',settings.read('theme'),clientId) if (settings.read('sessionFile')) this.sessionOpen({path:settings.read('sessionFile')},clientId) var recentSessions = settings.read('recentSessions') + + if (settings.read('examples')) { + recentSessions = fs.readdirSync('examples') + recentSessions = recentSessions.map(function(file){return 'examples/' + file}) + } + ipc.send('sessionList',recentSessions,clientId) }, diff --git a/main/settings.js b/main/settings.js index a85a37ea..af06b409 100644 --- a/main/settings.js +++ b/main/settings.js @@ -12,7 +12,8 @@ var argv = require('yargs') 'p':{alias:'port',describe:'osc input port (for synchronization)'}, 'd':{alias:'debug',describe:'log received osc messages in the console'}, 'n':{alias:'nogui',describe:'disable default gui and makes the app availabe through http on specified port'}, - 't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'} + 't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'}, + 'examples':{describe:'list examples instead of recent sessions'} }) .check(function(a,x){if(a.p==undefined || !isNaN(a.p)&&a.p>1023&&parseInt(a.p)===a.p){return true}else{throw 'Error: Port must be an integer >= 1024'}}) .check(function(a,x){if(a.n==undefined || !isNaN(a.n)&&a.n>1023&&parseInt(a.n)===a.n){return true}else{throw 'Error: Port must be an integer >= 1024'}}) @@ -33,6 +34,7 @@ module.exports = function(fs) { debug: argv.d || false, sessionFile: argv.l || false, noGui: argv.n || false, + examples: argv.examples, theme: function(){ if (!argv.t) return var style = []