Skip to content

Commit

Permalink
seperate settings out to it's own file
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjorbin committed Mar 24, 2012
1 parent d99ca85 commit f75b418
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 57 deletions.
60 changes: 3 additions & 57 deletions bin/slidedown.js
Expand Up @@ -17,65 +17,11 @@ var fs = require('fs.extra')
, path = require('path')
, md = require("node-markdown").Markdown
, _ = require('underscore')
, static = require('node-static');
, static = require('node-static')
, settings = require( __dirname + '/../src/settings.js');


// This is the default config object. defaults will be overridden by slidedown.json
var settings = function(){
this.projectdir = process.cwd();
var slidedownDir = this.slidedownDir = path.resolve(__dirname + '/..' );
var templatedir;
// Attempt to load the
try{
this,slideshowConfig = JSON.parse( fs.readFileSync( this.projectdir + '/slidedown.json', 'ascii') );
} catch(err) {
// If the file doesn't exist, we will just use defaults
this.slideshowConfig = {};
}
this.template = this.slideshowConfig.template || 'remies';
templatedir = this.templatedir = this.slideshowConfig.templatedir || this.slidedownDir + '/template/' + this.template;
this.title = this.slideshowConfig.title || 'A slidedown.js presentation';
this.source = this.slideshowConfig.source || 'slides.md'
this.port = this.slideshowConfig.port || 9000;
this.publicDir = this.slideshowConfig.publicDir || this.projectdir + '/public';
this.header = this.slideshowConfig.header || this.templatedir + '/header.html';
this.footer = this.slideshowConfig.footer || this.templatedir + '/footer.html';

// JS AND CSS
this.jsfiles = [ ];
this.cssfiles = [ ];

this.templateConfig = JSON.parse( fs.readFileSync( this.templatedir + '/config.json', 'ascii' ) )
if ( _.isArray( this.templateConfig.extensions ) )
{
this.jsfiles = _.map( this.templateConfig.extensions , function(name){
return slidedownDir + '/deck.js/extensions/' + name + '/deck.' + name + '.js';
});
this.cssfiles = _.map( this.templateConfig.extensions , function(name){
return slidedownDir + '/deck.js/extensions/' + name + '/deck.' + name + '.css';
});
}
if ( _.isArray( this.slideshowConfig.extensions ) )
{
this.jsfiles = _.map( this.slideshowConfig.extensions , function(name){
return slidedownDir + '/deck.js/extensions/' + name + '/deck.' + name + '.js';
});
this.cssfiles = _.map( this.slideshowConfig.extensions , function(name){
return slidedownDir + '/deck.js/extensions/' + name + '/deck.' + name + '.css';
});
}
if ( _.isArray( this.templateConfig.css ) )
{
_.extend(this.cssfiles , _.map( this.templateConfig.css , function(name){
return templatedir + '/css/' + name ;
}));
}
if ( _.isArray( this.templateConfig.js ) )
{
_.extend(this.jsfiles , _.map( this.templateConfig.js , function(name){
return templatedir + '/js/' + name ;
}));
}
};

var slidedown = function(){
var header = footer = source = '';
Expand Down
60 changes: 60 additions & 0 deletions src/settings.js
@@ -0,0 +1,60 @@
var fs = require('fs.extra')
, path = require('path')
, _ = require('underscore');

module.exports = function(){
this.projectdir = process.cwd();
var slidedownDir = this.slidedownDir = path.resolve(__dirname + '/..' );
var templatedir;
// Attempt to load the
try{
this,slideshowConfig = JSON.parse( fs.readFileSync( this.projectdir + '/slidedown.json', 'ascii') );
} catch(err) {
// If the file doesn't exist, we will just use defaults
this.slideshowConfig = {};
}
this.template = this.slideshowConfig.template || 'remies';
templatedir = this.templatedir = this.slideshowConfig.templatedir || this.slidedownDir + '/template/' + this.template;
this.title = this.slideshowConfig.title || 'A slidedown.js presentation';
this.source = this.slideshowConfig.source || 'slides.md'
this.port = this.slideshowConfig.port || 9000;
this.publicDir = this.slideshowConfig.publicDir || this.projectdir + '/public';
this.header = this.slideshowConfig.header || this.templatedir + '/header.html';
this.footer = this.slideshowConfig.footer || this.templatedir + '/footer.html';

// JS AND CSS
this.jsfiles = [ ];
this.cssfiles = [ ];

this.templateConfig = JSON.parse( fs.readFileSync( this.templatedir + '/config.json', 'ascii' ) )
if ( _.isArray( this.templateConfig.extensions ) )
{
this.jsfiles = _.map( this.templateConfig.extensions , function(name){
return slidedownDir + '/deck.js/extensions/' + name + '/deck.' + name + '.js';
});
this.cssfiles = _.map( this.templateConfig.extensions , function(name){
return slidedownDir + '/deck.js/extensions/' + name + '/deck.' + name + '.css';
});
}
if ( _.isArray( this.slideshowConfig.extensions ) )
{
this.jsfiles = _.map( this.slideshowConfig.extensions , function(name){
return slidedownDir + '/deck.js/extensions/' + name + '/deck.' + name + '.js';
});
this.cssfiles = _.map( this.slideshowConfig.extensions , function(name){
return slidedownDir + '/deck.js/extensions/' + name + '/deck.' + name + '.css';
});
}
if ( _.isArray( this.templateConfig.css ) )
{
_.extend(this.cssfiles , _.map( this.templateConfig.css , function(name){
return templatedir + '/css/' + name ;
}));
}
if ( _.isArray( this.templateConfig.js ) )
{
_.extend(this.jsfiles , _.map( this.templateConfig.js , function(name){
return templatedir + '/js/' + name ;
}));
}
};

0 comments on commit f75b418

Please sign in to comment.