Fix parsing of multilingual books

This commit is contained in:
Samy Pessé
2016-04-29 10:58:25 +02:00
parent 93e701f471
commit 73c190891d
6 changed files with 44 additions and 6 deletions
+1 -1
View File
@@ -248,7 +248,7 @@ Book.createFromParent = function createFromParent(parent, language) {
logger: parent.getLogger(),
ignore: Ignore().add(ignore),
language: language,
fs: FS.reduceScope(parent.getFS(), language)
fs: FS.reduceScope(parent.getContentFS(), language)
});
};
+2 -1
View File
@@ -33,7 +33,8 @@ FS.prototype.getRoot = function() {
*/
FS.prototype.isInScope = function(filename) {
var rootPath = this.getRoot();
filename = path.resolve(rootPath, filename);
filename = path.join(rootPath, filename);
return PathUtil.isInRoot(rootPath, filename);
};
+26
View File
@@ -1,6 +1,7 @@
var Immutable = require('immutable');
var File = require('./file');
var Language = require('./language');
var Languages = Immutable.Record({
file: File(),
@@ -34,4 +35,29 @@ Languages.prototype.getLanguage = function(lang) {
return this.getList().get(lang);
};
/**
Create a languages list from a JS object
@param {File}
@param {Array}
@return {Language}
*/
Languages.createFromList = function(file, langs) {
var list = Immutable.OrderedMap();
langs.forEach(function(lang) {
lang = Language({
title: lang.title,
path: lang.path
});
list = list.set(lang.getID(), lang);
});
return Languages({
file: file,
list: list
});
}
module.exports = Languages;