Skip to content

Commit

Permalink
Adding disableAutoOpen flag to use this module seamlessly in a docker…
Browse files Browse the repository at this point in the history
… container
  • Loading branch information
jossemarGT committed Oct 13, 2015
1 parent 1e772f2 commit ad4ed09
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"env": {
"node": true
},
"rules": {
"strict": 0,
"quotes": [1, "single"],
"semi": [1, "always"]
}
}
8 changes: 5 additions & 3 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ program
.option('-r, --print [filename]', 'Print')
.option('-s, --separator [separator]', 'Slide separator')
.option('-v, --verticalSeparator [vertical separator]', 'Vertical slide separator')
.option('--disableAutoOpen', 'Disable to automatically open your web browser')
.parse(process.argv);

if(program.args.length > 2) {
Expand All @@ -35,7 +36,7 @@ var pathArg = program.args[0];
// TODO: fix user can have own demo file/directory
if(pathArg === 'demo') {

basePath = __dirname + '/../demo';
basePath = path.join(__dirname, '../demo');

} else if(pathArg) {

Expand Down Expand Up @@ -79,7 +80,7 @@ var manifestPath = path.join(basePath, 'reveal.json');
if(fs.existsSync(manifestPath) && fs.statSync(manifestPath).isFile(manifestPath)) {
try {
var options = require(manifestPath);
if(typeof options === "object") {
if(typeof options === 'object') {
revealOptions = options;
}
} catch(err) {
Expand Down Expand Up @@ -107,5 +108,6 @@ server.start({
separator: program.separator,
verticalSeparator: program.verticalSeparator,
printFile: program.print,
revealOptions: revealOptions
revealOptions: revealOptions,
openWebBrowser: !program.disableAutoOpen
});
9 changes: 6 additions & 3 deletions bin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var startMarkdownServer = function(options) {
opts.verticalSeparator = options.verticalSeparator || opts.verticalSeparator;
opts.printMode = typeof printFile !== 'undefined' && printFile || opts.printMode;
opts.revealOptions = options.revealOptions || {};
opts.openWebBrowser = options.openWebBrowser;

app.use('/lib/css/' + opts.highlightTheme + '.css',
staticDir(path.join(serverBasePath, 'node_modules', 'highlight.js', 'styles', opts.highlightTheme + '.css')));
Expand Down Expand Up @@ -86,7 +87,9 @@ var startMarkdownServer = function(options) {
});
} else {
console.log('Reveal-server started, opening at http://' + opts.host + ':' + opts.port);
open(initialFilePath);
if(opts.openWebBrowser){
open(initialFilePath);
}
}
};

Expand Down Expand Up @@ -140,9 +143,9 @@ var render = function(res, markdown) {
var generateMarkdownListing = function(userBasePath) {
var list = [];

glob.sync("**/*.md", {
glob.sync('**/*.md', {
cwd: userBasePath || opts.userBasePath
}).forEach(function(file) {
}).forEach(function(file) {
list.push('<a href="' + file + '">' + file + '</a>');
});

Expand Down

0 comments on commit ad4ed09

Please sign in to comment.