summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--lib/generate/index.js3
-rw-r--r--lib/generate/page/index.js10
-rw-r--r--theme/templates/ebook/glossary.html15
-rw-r--r--theme/templates/ebook/summary.html4
5 files changed, 35 insertions, 2 deletions
diff --git a/README.md b/README.md
index 43f35e9..584c04a 100644
--- a/README.md
+++ b/README.md
@@ -132,7 +132,10 @@ You can publish your books to our index by visiting [GitBook.io](http://www.gitb
GitBook can generate your book in the following formats:
* **Static Website**: This is the default format. It generates a complete interactive static website that can be, for example, hosted on GitHub Pages.
-* **eBook**: A complete eBook with exercise solutions at the end of the book. Generate this format using: ```gitbook ebook ./myrepo```. You need to have [ebook-convert](http://manual.calibre-ebook.com/cli/ebook-convert.html) installed. The output format could be **PDF**, **ePub** or **MOBI**.
+* **eBook**: A complete eBook with exercise solutions at the end of the book. You need to have [ebook-convert](http://manual.calibre-ebook.com/cli/ebook-convert.html) installed. You can specify the eBook filename with the `-o` option, otherwise `book` will be used.
+ * Generate a **PDF** using: `gitbook pdf ./myrepo`
+ * Generate a **ePub** using: `gitbook epub ./myrepo`
+ * Generate a **MOBI** using: `gitbook mobi ./myrepo`
* **JSON**: This format is used for debugging or extracting metadata from a book. Generate this format using: ```gitbook build ./myrepo -f json```.
## Book Format
diff --git a/lib/generate/index.js b/lib/generate/index.js
index 2118c46..8cd263d 100644
--- a/lib/generate/index.js
+++ b/lib/generate/index.js
@@ -298,6 +298,9 @@ var generateBook = function(options) {
// Finish generation
.then(function() {
+ return generator.callHook("finish:before");
+ })
+ .then(function() {
return generator.finish();
})
.then(function() {
diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js
index 8e44187..a926d13 100644
--- a/lib/generate/page/index.js
+++ b/lib/generate/page/index.js
@@ -26,6 +26,9 @@ Generator.prototype.loadTemplates = function() {
this.summaryTemplate = swig.compileFile(
this.plugins.template("ebook:sumary") || path.resolve(this.options.theme, 'templates/ebook/summary.html')
);
+ this.glossaryTemplate = swig.compileFile(
+ this.plugins.template("ebook:glossary") || path.resolve(this.options.theme, 'templates/ebook/glossary.html')
+ );
};
// Generate table of contents
@@ -46,7 +49,7 @@ Generator.prototype.finish = function() {
var output = path.join(this.options.output, "index.html");
var progress = parse.progress(this.options.navigation, "README.md");
-
+
return Q()
// Write table of contents
@@ -54,6 +57,11 @@ Generator.prototype.finish = function() {
return that.writeToc();
})
+ // Write glossary
+ .then(function() {
+ return that.writeGlossary();
+ })
+
// Copy cover
.then(function() {
return that.copyCover();
diff --git a/theme/templates/ebook/glossary.html b/theme/templates/ebook/glossary.html
new file mode 100644
index 0000000..8076c4d
--- /dev/null
+++ b/theme/templates/ebook/glossary.html
@@ -0,0 +1,15 @@
+{% extends "./layout.html" %}
+
+{% block title %}Glossary | {{ title }}{% endblock %}
+
+{% block content %}
+<div class="page page-toc">
+ <h1>Glossary</h1>
+ {% for item in glossaryIndex %}
+ <section class="normal glossary" id="{{ item.id }}">
+ <h2><a href="#{{ item.id }}">{{ item.name }}</a></h2>
+ <p>{{ item.description }}</p>
+ </section>
+ {% endfor %}
+</div>
+{% endblock %}
diff --git a/theme/templates/ebook/summary.html b/theme/templates/ebook/summary.html
index 85388f9..dfbba2c 100644
--- a/theme/templates/ebook/summary.html
+++ b/theme/templates/ebook/summary.html
@@ -40,6 +40,10 @@
<h1>Table of Contents</h1>
<ol>
{{ articles(summary.chapters) }}
+
+ {% if glossary.length > 0 %}
+ <li><a href="{{ basePath }}/GLOSSARY.html">Glossary</a></li>
+ {% endif %}
</ol>
</div>
{% endblock %}