diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-29 15:09:11 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-29 15:09:11 +0200 |
commit | 07a5daefb025868ecf41054713a18d50e01511c0 (patch) | |
tree | 1a90b356589c0e23797ce8a06a33ae06596e75ab /lib/output/ebook/onFinish.js | |
parent | 0ed524bce508f3f9ebb475d06c662cad948e224a (diff) | |
download | gitbook-07a5daefb025868ecf41054713a18d50e01511c0.zip gitbook-07a5daefb025868ecf41054713a18d50e01511c0.tar.gz gitbook-07a5daefb025868ecf41054713a18d50e01511c0.tar.bz2 |
Generate SUMMARY.html for ebook output
Diffstat (limited to 'lib/output/ebook/onFinish.js')
-rw-r--r-- | lib/output/ebook/onFinish.js | 25 |
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); }); } |