summaryrefslogtreecommitdiffstats
path: root/lib/output/ebook/onFinish.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/ebook/onFinish.js')
-rw-r--r--lib/output/ebook/onFinish.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/output/ebook/onFinish.js b/lib/output/ebook/onFinish.js
index 81fa45d..e82f679 100644
--- a/lib/output/ebook/onFinish.js
+++ b/lib/output/ebook/onFinish.js
@@ -1,20 +1,29 @@
-var websiteGenerator = require('../website');
+var WebsiteGenerator = require('../website');
+var JSONUtils = require('../../json');
+var Templating = require('../../templating');
+var writeFile = require('../helper/writeFile');
/**
- Finish the generation, generate the ebook file using ebook-convert
+ Finish the generation, generates the SUMMARY.html
@param {Output}
@return {Output}
*/
function onFinish(output) {
- return websiteGenerator.onFinish(output)
- .then(function(resultOutput) {
+ var book = output.getBook();
+ var options = output.getOptions();
+ var prefix = options.get('prefix');
- // todo:
- // - render SUMMARY.html
- // - Build ebook using ebook-convert
+ var filePath = 'SUMMARY.html';
+ var engine = WebsiteGenerator.createTemplateEngine(output, filePath);
+ var context = JSONUtils.encodeOutput(output);
- return resultOutput;
+ // Render the theme
+ return Templating.renderFile(engine, prefix + '/SUMMARY.html', context)
+
+ // Write it to the disk
+ .then(function(html) {
+ return writeFile(output, filePath, html);
});
}