summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-04-18 12:49:31 +0200
committerSamy Pessé <samypesse@gmail.com>2016-04-18 12:49:31 +0200
commit0791b917f1191861e6320f48be95441102ae9ac7 (patch)
treeb60d5c3160ef1ad8a173da86b5a9b428faeb8028
parentba182ce8e430f08bd8c60865b9c853875a3d6483 (diff)
downloadgitbook-0791b917f1191861e6320f48be95441102ae9ac7.zip
gitbook-0791b917f1191861e6320f48be95441102ae9ac7.tar.gz
gitbook-0791b917f1191861e6320f48be95441102ae9ac7.tar.bz2
Add context for readme
-rw-r--r--docs/templating/variables.md13
-rw-r--r--lib/backbone/readme.js20
-rw-r--r--lib/backbone/summary.js1
-rw-r--r--lib/output/base.js1
4 files changed, 34 insertions, 1 deletions
diff --git a/docs/templating/variables.md b/docs/templating/variables.md
index 8dbab98..9499c8e 100644
--- a/docs/templating/variables.md
+++ b/docs/templating/variables.md
@@ -10,6 +10,8 @@ The following is a reference of the available data during book's parsing and the
| `gitbook` | GitBook specific information |
| `page` | Current page specific information |
| `file` | File associated with the current page specific information |
+| `readme` | Information about the Readme |
+| `glossary` | Information about the Glossary |
| `summary` | Information about the table of contents |
| `languages` | List of languages for multi-lingual books |
| `output` | Information about the output generator |
@@ -71,3 +73,14 @@ Languages are defined by `{ id: 'en', title: 'English' }`.
| `output.name` | Name of the output generator, possible values are `website`, `json`, `ebook` |
| `output.format` | When `output.name == "ebook"`, `format` defines the ebook format that will be generated, possible values are `pdf`, `epub` or `mobi` |
+### Readme Variables
+
+| Variable | Description |
+| -------- | ----------- |
+| `readme.path` | Path to the Readme in the book |
+
+### Glossary Variables
+
+| Variable | Description |
+| -------- | ----------- |
+| `glossary.path` | Path to the Glossary in the book |
diff --git a/lib/backbone/readme.js b/lib/backbone/readme.js
index a4cd9d8..088a942 100644
--- a/lib/backbone/readme.js
+++ b/lib/backbone/readme.js
@@ -11,7 +11,25 @@ util.inherits(Readme, BackboneFile);
Readme.prototype.type = 'readme';
-// Parse the readme content
+/*
+ Return and extension of context to define the readme
+
+ @retrun {Object}
+*/
+Readme.prototype.getContext = function() {
+ return {
+ readme: {
+ path: this.path
+ }
+ };
+};
+
+/*
+ Parse the readme content
+
+ @param {String} content
+ @retrun {Promise}
+*/
Readme.prototype.parse = function(content) {
var that = this;
diff --git a/lib/backbone/summary.js b/lib/backbone/summary.js
index 9c8a38d..2dbcecb 100644
--- a/lib/backbone/summary.js
+++ b/lib/backbone/summary.js
@@ -231,6 +231,7 @@ Summary.prototype.getContext = function() {
return {
summary: {
+ path: this.path,
parts: _.map(this.parts, function(part) {
return part.getContext(onArticle);
})
diff --git a/lib/output/base.js b/lib/output/base.js
index a342c1e..c546061 100644
--- a/lib/output/base.js
+++ b/lib/output/base.js
@@ -248,6 +248,7 @@ Output.prototype.getContext = function() {
},
this.book.getContext(),
(this.book.isLanguageBook()? this.book.parent: this.book).langs.getContext(),
+ this.book.readme.getContext(),
this.book.summary.getContext(),
this.book.glossary.getContext(),
this.book.config.getContext(),