summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/json/encodeBook.js4
-rw-r--r--lib/json/encodeConfig.js12
-rw-r--r--lib/json/encodeFile.js7
-rw-r--r--lib/json/encodeSummaryArticle.js3
-rw-r--r--lib/json/index.js3
-rw-r--r--lib/models/summaryArticle.js15
-rw-r--r--lib/plugins/validateConfig.js4
7 files changed, 27 insertions, 21 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')
};
diff --git a/lib/models/summaryArticle.js b/lib/models/summaryArticle.js
index e3d85ef..945a16c 100644
--- a/lib/models/summaryArticle.js
+++ b/lib/models/summaryArticle.js
@@ -54,6 +54,10 @@ SummaryArticle.prototype.getByLevel = function(level) {
@return {String}
*/
SummaryArticle.prototype.getPath = function() {
+ if (this.isExternal()) {
+ return undefined;
+ }
+
var ref = this.getRef();
var parts = ref.split('#');
@@ -64,6 +68,15 @@ SummaryArticle.prototype.getPath = function() {
};
/**
+ Return url if article is external
+
+ @return {String}
+*/
+SummaryArticle.prototype.getUrl = function() {
+ return this.isExternal()? this.getRef() : undefined;
+};
+
+/**
Get anchor for this article (or undefined)
@return {String}
@@ -72,7 +85,7 @@ SummaryArticle.prototype.getAnchor = function() {
var ref = this.getRef();
var parts = ref.split('#');
- var anchor = (parts.length > 1? '#' + parts[parts.length - 1] : null);
+ var anchor = (parts.length > 1? '#' + parts[parts.length - 1] : undefined);
return anchor;
};
diff --git a/lib/plugins/validateConfig.js b/lib/plugins/validateConfig.js
index fc32344..cb6c38a 100644
--- a/lib/plugins/validateConfig.js
+++ b/lib/plugins/validateConfig.js
@@ -32,7 +32,7 @@ function validatePluginConfig(book, plugin) {
// Validate and throw if invalid
var v = new jsonschema.Validator();
- var result = v.validate(config, schema, {
+ var result = v.validate(pluginConfig, schema, {
propertyName: configKey
});
@@ -43,7 +43,7 @@ function validatePluginConfig(book, plugin) {
// Insert default values
var defaults = jsonSchemaDefaults(schema);
- pluginConfig = mergeDefaults(config, defaults);
+ pluginConfig = mergeDefaults(pluginConfig, defaults);
// Update configuration