summaryrefslogtreecommitdiffstats
path: root/lib/generate/page
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-10-30 17:52:31 +0100
committerSamy Pessé <samypesse@gmail.com>2014-10-30 17:52:39 +0100
commit38c750101c479940d94759bd820d00f90a03f14d (patch)
treeb6d27691b6871d39070c858cd7123e4bcc242000 /lib/generate/page
parentba0f379a89dd44fc6d291e03ea69a92773a7ea1a (diff)
downloadgitbook-38c750101c479940d94759bd820d00f90a03f14d.zip
gitbook-38c750101c479940d94759bd820d00f90a03f14d.tar.gz
gitbook-38c750101c479940d94759bd820d00f90a03f14d.tar.bz2
Fix #487: Use generated toc as base for ebook generation
Diffstat (limited to 'lib/generate/page')
-rw-r--r--lib/generate/page/index.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js
index fb7c59d..068358c 100644
--- a/lib/generate/page/index.js
+++ b/lib/generate/page/index.js
@@ -21,10 +21,25 @@ util.inherits(Generator, BaseGenerator);
Generator.prototype.loadTemplates = function() {
this.template = swig.compileFile(
- this.plugins.template("page") || path.resolve(this.options.theme, 'templates/page.html')
+ this.plugins.template("page") || path.resolve(this.options.theme, 'templates/page/page.html')
+ );
+ this.summaryTemplate = swig.compileFile(
+ this.plugins.template("page/sumary") || path.resolve(this.options.theme, 'templates/page/summary.html')
);
};
+// Generate table of contents
+Generator.prototype.writeToc = function() {
+ var that = this;
+ var basePath = ".";
+
+ return this._writeTemplate(this.summaryTemplate, {
+ toc: parse.progress(this.options.navigation, "README.md").chapters,
+ basePath: basePath,
+ staticBase: path.join(basePath, "gitbook"),
+ }, path.join(this.options.output, "SUMMARY.html"));
+};
+
Generator.prototype.finish = function() {
var that = this;
var basePath = ".";
@@ -34,6 +49,11 @@ Generator.prototype.finish = function() {
return Q()
+ // Write table of contents
+ .then(function() {
+ return that.writeToc();
+ })
+
// Copy cover
.then(function() {
return that.copyCover();