Skip to content

Commit

Permalink
jdan#7 - fixed issue with loading templates and styles outside of cle…
Browse files Browse the repository at this point in the history
…aver directory
  • Loading branch information
jdan committed Nov 30, 2012
1 parent 2c7c111 commit da10363
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
var fs = require('fs'),
path = require('path'),
render = require('./render').render;

CLEAVER_ROOT = path.normalize(__dirname + '/../');

exports.init = function(argv) {
if (!argv.file) {
console.log('Please specify a file with the --file option');
Expand Down
8 changes: 4 additions & 4 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ exports.render = function(json, options) {
}

// load default style
fs.readFile('styles/default.css', 'utf8', function(err, data) {
fs.readFile(CLEAVER_ROOT + 'styles/default.css', 'utf8', function(err, data) {
if (err) throw err;
styles.push(data);
});

// load user-defined styles
if (options.style) {
fs.readFile(options.style, 'utf8', function(err, data) {
fs.readFile(CLEAVER_ROOT + options.style, 'utf8', function(err, data) {
if (err) throw err;
styles.push(data);
});
}

json.slides.forEach(function(v, i) {
fs.readFile('templates/_' + v.type + '.mustache', 'utf8', function(err, data) {
fs.readFile(CLEAVER_ROOT + 'templates/_' + v.type + '.mustache', 'utf8', function(err, data) {
if (err) throw err;
if (v.type == 'text')
v.content = md(v.content.replace(/>>/g,'</p><p>'));
Expand All @@ -40,7 +40,7 @@ exports.render = function(json, options) {
});
});

fs.readFile('templates/layout.mustache', 'utf8', function(err, data) {
fs.readFile(CLEAVER_ROOT + 'templates/layout.mustache', 'utf8', function(err, data) {
if (err) throw err;

var output = mustache.render(data, { slides: renders, title: json.name, styles: styles, controls: !(options.nocontrols) });
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cleaver",
"version": "0.0.4-1",
"version": "0.0.5",
"description": "plug-n-play HTML slideshows",
"author": "Jordan Scales",
"keywords":[
Expand Down

0 comments on commit da10363

Please sign in to comment.