Permalink
Browse files

seperate out Template Tags

  • Loading branch information...
1 parent 2e49634 commit 53b0e2937f96e53b23e0ecbf4410fcf86497e7a1 @aaronjorbin committed Apr 2, 2012
Showing with 45 additions and 20 deletions.
  1. +35 −19 bin/slidedown.js
  2. +4 −1 src/settings.js
  3. +6 −0 src/templateTags.js
View
@@ -12,25 +12,24 @@ var debug = false;
/**
* Module dependencies.
*/
-
var fs = require('fs.extra')
, path = require('path')
, md = require("node-markdown").Markdown
, _ = require('underscore')
, static = require('node-static')
- , settings = require( __dirname + '/../src/settings.js');
-
+ , settings = require( __dirname + '/../src/settings.js')
+ , templateTags = require( __dirname + '/../src/templateTags.js');
-// This is the default config object. defaults will be overridden by slidedown.json
var slidedown = function(){
var header = footer = source = '';
- // load slidedown.json. Create if neccessary.
var config = new settings;
-
// Add the file that converts our UL to slides last
+ if (debug)
+ console.log( config);
+
var sourceFilename = config.source;
// If public doesn't exist as a sibling to sourceFilenam, try to create it,
@@ -41,28 +40,46 @@ var slidedown = function(){
if (! path.existsSync( config.publicDir + '/js' ) )
fs.mkdirSync(config.publicDir + '/js', '0775');
- // Add Modernizor
+ if (config.modernizr){
+ // Add Modernizor if it's not there already
+ try{
+ fs.readFileSync( config.publicDir + '/js/modernizr.custom.js');
+ } catch(error)
+ {
+ // copy Modernizor
+ fs.copy( config.slidedownDir + '/deck.js/modernizr.custom.js' , config.publicDir + '/js/modernizr.custom.js', function(err)
+ {
+ if ( err != undefined)
+ console.log(err);
+ });
+ }
+ }
+
+ // Add jQuery if it's not already there
try{
- fs.readFileSync( config.publicDir + '/js//modernizr.custom.js');
+ fs.readFileSync( config.publicDir + '/js/jquery.js');
} catch(error)
{
// copy Modernizor
- fs.copy( config.slidedownDir + '/deck.js/modernizr.custom.js' , config.publicDir + '/js/modernizr.custom.js', function(err)
+ fs.copy( config.slidedownDir + '/deck.js/jquery-1.7.min.js' , config.publicDir + '/js/jquery.js', function(err)
{
if ( err != undefined)
console.log(err);
});
}
+
+ function loadFile(which) {
+ console.log(which + ' loaded');
+ return templateTags( fs.readFileSync(config[which] , 'ascii'),config );
+ }
+
function loadHeader(){
- header = fs.readFileSync(config.header, 'ascii');
- header = header.replace(/\%\=title\=\%/gi , config.title);
- console.log('header loaded');
+ header = loadFile('header');
}
function loadFooter(){
- footer = fs.readFileSync(config.footer, 'ascii');
- console.log('footer loaded');
+ footer = loadFile('footer');
}
@@ -84,11 +101,12 @@ var slidedown = function(){
})
fs.watchFile(config.footer, function(curr,prev){
if ( Date.parse( curr.mtime )!= Date.parse( prev.mtime ) )
+ {
+ loadFooter();
writeFile('html');
+ }
});
- // watch slides.md sibling dir images. Create if needed.
- if (debug)
- console.log( config);
+
// Watch our CSS Files
_.each(config.cssfiles, function(css){
@@ -163,5 +181,3 @@ var slidedown = function(){
}
slidedown();
-// var config = new settings;
-//console.log(config);
View
@@ -9,6 +9,7 @@ var deckJsConfig = function(templateConfig , slideshowConfig )
this.cssfiles = [ slidedownDir +'/deck.js/core/deck.core.css'];
this.latejsfiles = [ slidedownDir +'/src/public_deckjs_slidedown.js'];
this.latecssfiles = [ ];
+ this.modernizor = true;
if ( _.isArray( templateConfig.extensions ) )
{
@@ -31,7 +32,6 @@ var deckJsConfig = function(templateConfig , slideshowConfig )
}
}
-// Each base will map to it's own config function that returns a jsfiles array and a cssfiles array
var basemap = {
'deck.js' : deckJsConfig
};
@@ -68,6 +68,9 @@ module.exports = function(){
this.jsfiles = baseFiles.jsfiles;
this.cssfiles = baseFiles.cssfiles;
+ // register if our base requires modernizor
+ this.modernizor = baseFiles.modernizor || false;
+
// Template specific css and js
if ( _.isArray( this.templateConfig.css ) )
{
View
@@ -0,0 +1,6 @@
+module.exports = function( input, config ) {
+ // Title
+ input = input.replace(/\%\=title\=\%/gi , config.title);
+
+ return input;
+};

0 comments on commit 53b0e29

Please sign in to comment.