Permalink
Browse files

seperate settings out to it's own file

  • Loading branch information...
1 parent d99ca85 commit f75b418b12d309b4e7c41d3673f9fd4f76da6083 @aaronjorbin committed Mar 24, 2012
Showing with 63 additions and 57 deletions.
  1. +3 −57 bin/slidedown.js
  2. +60 −0 src/settings.js
View
@@ -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 = '';
View
@@ -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.