summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/book.js10
-rw-r--r--lib/configuration.js12
-rw-r--r--lib/template.js18
-rw-r--r--package.json3
4 files changed, 39 insertions, 4 deletions
diff --git a/lib/book.js b/lib/book.js
index bfe0a17..8c3561a 100644
--- a/lib/book.js
+++ b/lib/book.js
@@ -4,6 +4,7 @@ var path = require("path");
var fs = require("./utils/fs");
var Configuration = require("./configuration");
+var TemplateEngine = require("./template");
var parser = require("./parser");
var Book = function(root, options, parent) {
@@ -21,6 +22,9 @@ var Book = function(root, options, parent) {
}
});
+ // Template
+ this.template = new TemplateEngine(this);
+
// Summary
this.summary = {};
@@ -82,7 +86,7 @@ Book.prototype.generate = function() {
Book.prototype.parseLangs = function() {
var that = this;
- return that.findFile("LANGS")
+ return that.findFile(that.config.getStructure("langs"))
.then(function(langs) {
if (!langs) return [];
@@ -100,7 +104,7 @@ Book.prototype.parseLangs = function() {
Book.prototype.parseSummary = function() {
var that = this;
- return that.findFile("SUMMARY")
+ return that.findFile(that.config.getStructure("summary"))
.then(function(summary) {
if (!summary) throw "No SUMMARY file";
@@ -118,7 +122,7 @@ Book.prototype.parseSummary = function() {
Book.prototype.parseGlossary = function() {
var that = this;
- return that.findFile("GLOSSARY")
+ return that.findFile(that.config.getStructure("glossary"))
.then(function(glossary) {
if (!glossary) return {};
diff --git a/lib/configuration.js b/lib/configuration.js
index 2b470c4..47485af 100644
--- a/lib/configuration.js
+++ b/lib/configuration.js
@@ -28,6 +28,11 @@ Configuration.prototype.load = function() {
});
};
+// Get structure file
+Configuration.prototype.getStructure = function(name) {
+ return this.options.structure[name].split(".").slice(0, -1).join(".");
+};
+
// Default configuration
Configuration.DEFAULT = {
// Options that can't be extend
@@ -41,6 +46,13 @@ Configuration.DEFAULT = {
"isbn": null,
"lang": "en",
+ // Structure
+ "structure": {
+ "readme": "README.md",
+ "glossary": "GLOSSARY.md",
+ "summary": "SUMMARY.md"
+ },
+
// Plugins list, can contain "-name" for removing default plugins
"plugins": [],
diff --git a/lib/template.js b/lib/template.js
new file mode 100644
index 0000000..9576fe9
--- /dev/null
+++ b/lib/template.js
@@ -0,0 +1,18 @@
+var _ = require("lodash");
+var nunjucks = require("nunjucks");
+
+var TemplateEngine = function(book) {
+ this.book = book;
+};
+
+// Render a file from the book
+TemplateEngine.prototype.renderFile = function(filename) {
+ var that = this;
+
+ return this.book.readFile(filename)
+ .then(function(content) {
+
+ });
+};
+
+module.exports = TemplateEngine;
diff --git a/package.json b/package.json
index 5d034e8..dd4a540 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,8 @@
"graceful-fs": "3.0.5",
"fs-extra": "0.14.0",
"fstream-ignore": "1.0.2",
- "gitbook-markdown": "1.0.0"
+ "gitbook-markdown": "1.0.0",
+ "nunjucks": "git+https://github.com/SamyPesse/nunjucks.git#4019d1b7379372336b86ce1b0bf84352a2029747"
},
"devDependencies": {
"mocha": "1.18.2"