epubstream
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -6,2 +6,3 @@ var stream = require('stream'), | ||
zipstream = require('zipstream-contentment'), | ||
async = require('async'), | ||
ncx = require('./ncx'), | ||
@@ -77,3 +78,11 @@ opf = require('./opf'), | ||
Epub.prototype._addTOCFile = function(cover, next) { | ||
var tocTemplate = fs.readFileSync(this.opts.tocTemplate, 'utf8'), | ||
contents = stache.render(tocTemplate, {nav: this.opts.nav, cover: this.opts.cover}); | ||
this.addFile(contents, this.opts.tocFile, next); | ||
}; | ||
Epub.prototype.finalize = function(callback) { | ||
this.addFile(ncx(this.opts), this.opts.ncx, (function() { | ||
@@ -84,18 +93,23 @@ var displayTemplate = fs.readFileSync(this.opts.displaytemplate, 'utf8'); | ||
this.addFile(ocf(this.opts), this.opts.ocf, (function() { | ||
if(this.opts.cover) { | ||
var covertemplate = fs.readFileSync(this.opts.covertemplate, 'utf8'); | ||
this.addFile(stache.render(covertemplate, this.opts), this.opts.coverpage, (function() { | ||
var self = this; | ||
var tocTemplate = fs.readFileSync(this.opts.tocTemplate, 'utf8'); | ||
this.addFile(stache.render(tocTemplate, {nav: this.opts.nav, cover: this.opts.cover}), this.opts.tocFile, (function(){ | ||
this._zip.finalize(callback); | ||
}).bind(this)); | ||
async.series([ | ||
function addCover(next) { | ||
if (self.opts.cover) { | ||
var covertemplate = fs.readFileSync(self.opts.covertemplate, 'utf8'); | ||
return self.addFile(stache.render(covertemplate, self.opts), self.opts.coverpage, next); | ||
} | ||
}).bind(this)); | ||
} else { | ||
var tocTemplate = fs.readFileSync(this.opts.tocTemplate, 'utf8'); | ||
this.addFile(stache.render(tocTemplate, {nav: this.opts.nav}), this.opts.tocFile, (function(){ | ||
this._zip.finalize(callback); | ||
}).bind(this)); | ||
} | ||
next(); | ||
}, | ||
function addTOC(next) { | ||
if (self.opts.epubVersion == 'epup3') { return self._addTOCFile(null, next); } | ||
next(); | ||
} | ||
], function(err) { | ||
self._zip.finalize(callback); | ||
}); | ||
}).bind(this)); | ||
@@ -102,0 +116,0 @@ }).bind(this)); |
{ | ||
"name" : "epubstream", | ||
"version" : "0.0.5", | ||
"description" : "Epub", | ||
"author": "Danny Amey <danny@dannyamey.com>", | ||
"main": "./index.js", | ||
"dependencies": { | ||
"genx": "0.9.0", | ||
"zipstream-contentment": "0.2.1", | ||
"stache": "0.1.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/contentment/node-epubstream.git" | ||
} | ||
"name": "epubstream", | ||
"version": "0.0.6", | ||
"description": "Epub", | ||
"author": "Danny Amey <danny@dannyamey.com>", | ||
"main": "./index.js", | ||
"dependencies": { | ||
"genx": "0.9.0", | ||
"zipstream-contentment": "0.2.1", | ||
"stache": "0.1.0", | ||
"async": "~0.2.5" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/contentment/node-epubstream.git" | ||
} | ||
} |
104998
416
4
+ Addedasync@~0.2.5
+ Addedasync@0.2.10(transitive)