summaryrefslogtreecommitdiffstats
path: root/lib/output
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-03-09 15:50:38 +0100
committerSamy Pessé <samypesse@gmail.com>2016-03-09 15:50:38 +0100
commitc499a8a13a3059e3953727866beb7c986e46dd78 (patch)
tree173ee93cb957446855d8519335ad5dba0f7cc332 /lib/output
parent64a6de751d0f2bd8910ce36e2e8aa4049316e2c7 (diff)
downloadgitbook-c499a8a13a3059e3953727866beb7c986e46dd78.zip
gitbook-c499a8a13a3059e3953727866beb7c986e46dd78.tar.gz
gitbook-c499a8a13a3059e3953727866beb7c986e46dd78.tar.bz2
Add back gitbook.generator property as deprecated
Diffstat (limited to 'lib/output')
-rw-r--r--lib/output/base.js15
-rw-r--r--lib/output/json.js3
-rw-r--r--lib/output/website.js2
3 files changed, 16 insertions, 4 deletions
diff --git a/lib/output/base.js b/lib/output/base.js
index 201eade..d513d71 100644
--- a/lib/output/base.js
+++ b/lib/output/base.js
@@ -5,8 +5,10 @@ var path = require('path');
var Promise = require('../utils/promise');
var pathUtil = require('../utils/path');
var location = require('../utils/location');
+var error = require('../utils/error');
var PluginsManager = require('../plugins');
var TemplateEngine = require('../template');
+var gitbook = require('../gitbook');
/*
Output is like a stream interface for a parsed book
@@ -37,6 +39,9 @@ function Output(book, opts, parent) {
this.ignore = Ignore();
}
+// Default name for generator
+Output.prototype.name = 'base';
+
// Default extension for output
Output.prototype.defaultExtension = '.html';
@@ -230,7 +235,7 @@ Output.prototype.getSelfContext = function() {
// Return a default context for templates
Output.prototype.getContext = function() {
- return _.extend(
+ var ctx = _.extend(
{
output: this.getSelfContext()
},
@@ -238,8 +243,14 @@ Output.prototype.getContext = function() {
this.book.langs.getContext(),
this.book.summary.getContext(),
this.book.glossary.getContext(),
- this.book.config.getContext()
+ this.book.config.getContext(),
+ gitbook.getContext()
);
+
+ // Deprecated fields
+ error.deprecateField(ctx.gitbook, 'generator', this.name, '"gitbook.generator" property is deprecated, use "output.name" instead');
+
+ return ctx;
};
// Resolve a file path in the context of a specific page
diff --git a/lib/output/json.js b/lib/output/json.js
index 3246407..b66e593 100644
--- a/lib/output/json.js
+++ b/lib/output/json.js
@@ -1,3 +1,4 @@
+var _ = require('lodash');
var conrefsLoader = require('./conrefs');
var JSONOutput = conrefsLoader();
@@ -16,7 +17,7 @@ JSONOutput.prototype.onPage = function(page) {
// Write as json
.then(function() {
- var json = page.getContext();
+ var json = page.getOutputContext(that);
// Delete some private properties
delete json.config;
diff --git a/lib/output/website.js b/lib/output/website.js
index ae3d7af..e298b69 100644
--- a/lib/output/website.js
+++ b/lib/output/website.js
@@ -190,7 +190,7 @@ WebsiteOutput.prototype.onPage = function(page) {
// Render the page template with the same context as the json output
.then(function() {
- return that.render('page', page.getContext());
+ return that.render('page', page.getOutputContext(that));
})
// Write the HTML file