diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-07-04 18:08:44 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-07-04 18:08:44 +0200 |
commit | e105983cf84f9d1d843a6efe34a6c0af3be76018 (patch) | |
tree | f6536efe78d3c2683793557e96e41ab1dfdb202f /lib/json | |
parent | ea3afbed75585b40e8108f1fa83cd5660b9ce198 (diff) | |
download | gitbook-e105983cf84f9d1d843a6efe34a6c0af3be76018.zip gitbook-e105983cf84f9d1d843a6efe34a6c0af3be76018.tar.gz gitbook-e105983cf84f9d1d843a6efe34a6c0af3be76018.tar.bz2 |
Add back property "output" to page/template context
Diffstat (limited to 'lib/json')
-rw-r--r-- | lib/json/encodeBookWithPage.js | 12 | ||||
-rw-r--r-- | lib/json/encodeOutput.js | 10 | ||||
-rw-r--r-- | lib/json/encodeOutputWithPage.js | 23 | ||||
-rw-r--r-- | lib/json/index.js | 1 |
4 files changed, 35 insertions, 11 deletions
diff --git a/lib/json/encodeBookWithPage.js b/lib/json/encodeBookWithPage.js index 5600a82..1c5c7a3 100644 --- a/lib/json/encodeBookWithPage.js +++ b/lib/json/encodeBookWithPage.js @@ -3,12 +3,12 @@ var encodePage = require('./encodePage'); var encodeFile = require('./encodeFile'); /** - Return a JSON representation of a book with a specific file - - @param {Book} output - @param {Page} page - @return {Object} -*/ + * Return a JSON representation of a book with a specific file + * + * @param {Book} output + * @param {Page} page + * @return {Object} + */ function encodeBookWithPage(book, page) { var file = page.getFile(); diff --git a/lib/json/encodeOutput.js b/lib/json/encodeOutput.js index 9054124..7347e57 100644 --- a/lib/json/encodeOutput.js +++ b/lib/json/encodeOutput.js @@ -1,11 +1,11 @@ var encodeBook = require('./encodeBook'); /** - Encode an output to JSON - - @param {Output} - @return {Object} -*/ + * Encode an output to JSON + * + * @param {Output} + * @return {Object} + */ function encodeOutputToJson(output) { var book = output.getBook(); var generator = output.getGenerator(); diff --git a/lib/json/encodeOutputWithPage.js b/lib/json/encodeOutputWithPage.js new file mode 100644 index 0000000..8b21e3d --- /dev/null +++ b/lib/json/encodeOutputWithPage.js @@ -0,0 +1,23 @@ +var encodeOutput = require('./encodeOutput'); +var encodePage = require('./encodePage'); +var encodeFile = require('./encodeFile'); + +/** + * Return a JSON representation of a book with a specific file + * + * @param {Book} output + * @param {Page} page + * @return {Object} + */ +function encodeOutputWithPage(output, page) { + var file = page.getFile(); + var book = output.getBook(); + + var result = encodeOutput(output); + result.page = encodePage(page, book.getSummary()); + result.file = encodeFile(file); + + return result; +} + +module.exports = encodeOutputWithPage; diff --git a/lib/json/index.js b/lib/json/index.js index 4387ae0..3b68f5e 100644 --- a/lib/json/index.js +++ b/lib/json/index.js @@ -2,6 +2,7 @@ module.exports = { encodeOutput: require('./encodeOutput'), encodeBookWithPage: require('./encodeBookWithPage'), + encodeOutputWithPage: require('./encodeOutputWithPage'), encodeBook: require('./encodeBook'), encodeFile: require('./encodeFile'), encodePage: require('./encodePage'), |