summaryrefslogtreecommitdiffstats
path: root/lib/api
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-04-27 16:41:17 +0200
committerSamy Pessé <samypesse@gmail.com>2016-04-27 16:41:17 +0200
commit5b342b50ce862a4d60002451e6c1abd09a7b20ce (patch)
treea867e78a06111c24e35ae2f176b334bba23e25b4 /lib/api
parent869822d180f3fa7bf3a263bc29e280789abfed7c (diff)
downloadgitbook-5b342b50ce862a4d60002451e6c1abd09a7b20ce.zip
gitbook-5b342b50ce862a4d60002451e6c1abd09a7b20ce.tar.gz
gitbook-5b342b50ce862a4d60002451e6c1abd09a7b20ce.tar.bz2
Add language property to book for multilingual
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/encodeGlobal.js94
1 files changed, 49 insertions, 45 deletions
diff --git a/lib/api/encodeGlobal.js b/lib/api/encodeGlobal.js
index 20b706e..fa33696 100644
--- a/lib/api/encodeGlobal.js
+++ b/lib/api/encodeGlobal.js
@@ -20,61 +20,65 @@ function encodeGlobal(output) {
var result = {
log: logger,
- config: encodeConfig(output, book.getConfig())
- };
+ config: encodeConfig(output, book.getConfig()),
- result.output = {
- /**
- Name of the generator being used
- {String}
- */
- name: output.getGenerator(),
-
- /**
- Return absolute path to the root folder of output
- @return {String}
- */
- root: function() {
- return outputFolder;
+ isMultilingual: function() {
+ return book.isMultilingual();
},
- /**
- Convert a filepath into an url
- @return {String}
- */
- toURL: function(filePath) {
- return fileToURL(output, filePath);
+ isLanguageBook: function() {
+ return book.isLanguageBook();
},
- /**
- Write a file to the output folder,
- It creates the required folder
-
- @param {String} fileName
- @param {Buffer} content
- @return {Promise}
- */
- writeFile: function(fileName, content) {
- return Promise()
- .then(function() {
- var filePath = PathUtils.resolveInRoot(outputFolder, fileName);
-
- return fs.ensure(filePath)
+ isSubBook: deprecate.method(output, 'this.isSubBook', function() {
+ return book.isLanguageBook();
+ }, '"isSubBook" is deprecated, use "isLanguageBook()" instead'),
+
+ output: {
+ /**
+ Name of the generator being used
+ {String}
+ */
+ name: output.getGenerator(),
+
+ /**
+ Return absolute path to the root folder of output
+ @return {String}
+ */
+ root: function() {
+ return outputFolder;
+ },
+
+ /**
+ Convert a filepath into an url
+ @return {String}
+ */
+ toURL: function(filePath) {
+ return fileToURL(output, filePath);
+ },
+
+ /**
+ Write a file to the output folder,
+ It creates the required folder
+
+ @param {String} fileName
+ @param {Buffer} content
+ @return {Promise}
+ */
+ writeFile: function(fileName, content) {
+ return Promise()
.then(function() {
- return fs.writeFile(filePath, content);
+ var filePath = PathUtils.resolveInRoot(outputFolder, fileName);
+
+ return fs.ensure(filePath)
+ .then(function() {
+ return fs.writeFile(filePath, content);
+ });
});
- });
+ }
}
};
- result.isMultilingual = function() {
- return book.isMultilingual();
- };
-
- result.isLanguageBook = function() {
- return false;
- };
-
deprecate.field(output, 'this.book', result, 'book',
result, '"book" property is deprecated, use "this" directly instead');