diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-25 11:05:06 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-25 11:05:06 +0200 |
commit | 814b6ff489bc1f0bfd03db6409d49185e8c7b93e (patch) | |
tree | dd00993c84667e222d4699e8e1ac933b853b9a3a /lib/json | |
parent | 3aa17ab1f4a25a9bcfd8babdcf98a37ac6c2496c (diff) | |
download | gitbook-814b6ff489bc1f0bfd03db6409d49185e8c7b93e.zip gitbook-814b6ff489bc1f0bfd03db6409d49185e8c7b93e.tar.gz gitbook-814b6ff489bc1f0bfd03db6409d49185e8c7b93e.tar.bz2 |
Complete json format
Diffstat (limited to 'lib/json')
-rw-r--r-- | lib/json/encodeBook.js | 4 | ||||
-rw-r--r-- | lib/json/encodeConfig.js | 12 | ||||
-rw-r--r-- | lib/json/encodeFile.js | 7 | ||||
-rw-r--r-- | lib/json/encodeSummaryArticle.js | 3 | ||||
-rw-r--r-- | lib/json/index.js | 3 |
5 files changed, 11 insertions, 18 deletions
diff --git a/lib/json/encodeBook.js b/lib/json/encodeBook.js index eed5e5f..6c1b023 100644 --- a/lib/json/encodeBook.js +++ b/lib/json/encodeBook.js @@ -1,7 +1,6 @@ var encodeSummary = require('./encodeSummary'); var encodeGlossary = require('./encodeGlossary'); var encodeReadme = require('./encodeReadme'); -var encodeConfig = require('./encodeConfig'); /** Encode a book to JSON @@ -13,8 +12,7 @@ function encodeBookToJson(book) { return { summary: encodeSummary(book.getSummary()), glossary: encodeGlossary(book.getGlossary()), - readme: encodeReadme(book.getReadme()), - config: encodeConfig(book.getConfig()) + readme: encodeReadme(book.getReadme()) }; } diff --git a/lib/json/encodeConfig.js b/lib/json/encodeConfig.js deleted file mode 100644 index 195d43b..0000000 --- a/lib/json/encodeConfig.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - Encode configuration to JSON - - @param {Config} - @return {Object} -*/ -function encodeConfig(config) { - var values = config.getValues(); - return values.toJS(); -} - -module.exports = encodeConfig; diff --git a/lib/json/encodeFile.js b/lib/json/encodeFile.js index 03b3450..d2c9e8a 100644 --- a/lib/json/encodeFile.js +++ b/lib/json/encodeFile.js @@ -6,8 +6,13 @@ @return {Object} */ function encodeFileToJson(file) { + var filePath = file.getPath(); + if (!filePath) { + return undefined; + } + return { - path: file.getPath(), + path: filePath, mtime: file.getMTime(), type: file.getType() }; diff --git a/lib/json/encodeSummaryArticle.js b/lib/json/encodeSummaryArticle.js index 485d209..b3f977a 100644 --- a/lib/json/encodeSummaryArticle.js +++ b/lib/json/encodeSummaryArticle.js @@ -10,6 +10,9 @@ function encodeSummaryArticle(article) { title: article.getTitle(), level: article.getLevel(), depth: article.getDepth(), + anchor: article.getAnchor(), + url: article.getUrl(), + path: article.getPath(), articles: article.getArticles() .map(encodeSummaryArticle).toJS() }; diff --git a/lib/json/index.js b/lib/json/index.js index a026a7f..92b105a 100644 --- a/lib/json/index.js +++ b/lib/json/index.js @@ -5,6 +5,5 @@ module.exports = { encodeFile: require('./encodeFile'), encodePage: require('./encodePage'), encodeSummary: require('./encodeSummary'), - encodeReadme: require('./encodeReadme'), - encodeConfig: require('./encodeConfig') + encodeReadme: require('./encodeReadme') }; |