diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-27 16:41:17 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-27 16:41:17 +0200 |
commit | 5b342b50ce862a4d60002451e6c1abd09a7b20ce (patch) | |
tree | a867e78a06111c24e35ae2f176b334bba23e25b4 /lib/models | |
parent | 869822d180f3fa7bf3a263bc29e280789abfed7c (diff) | |
download | gitbook-5b342b50ce862a4d60002451e6c1abd09a7b20ce.zip gitbook-5b342b50ce862a4d60002451e6c1abd09a7b20ce.tar.gz gitbook-5b342b50ce862a4d60002451e6c1abd09a7b20ce.tar.bz2 |
Add language property to book for multilingual
Diffstat (limited to 'lib/models')
-rw-r--r-- | lib/models/book.js | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/models/book.js b/lib/models/book.js index 1835032..50276fa 100644 --- a/lib/models/book.js +++ b/lib/models/book.js @@ -29,9 +29,8 @@ var Book = Immutable.Record({ glossary: Glossary(), languages: Languages(), - - // Parent of this book, if multilingual - parent: null, + // ID of the language for language books + language: String(), // List of children, if multilingual (String -> Book) books: Immutable.OrderedMap() @@ -69,14 +68,14 @@ Book.prototype.getLanguages = function() { return this.get('languages'); }; -Book.prototype.getParent = function() { - return this.get('parent'); -}; - Book.prototype.getBooks = function() { return this.get('books'); }; +Book.prototype.getLanguage = function() { + return this.get('language'); +}; + /** Return FS instance to access the content @@ -162,6 +161,15 @@ Book.prototype.isMultilingual = function() { }; /** + Return true if book is associated to a language + + @return {Boolean} +*/ +Book.prototype.isLanguageBook = function() { + return Boolean(this.getLanguage()); +}; + +/** Add a new language book @param {String} language @@ -203,14 +211,14 @@ Book.createForFS = function createForFS(fs) { Create a language book from a parent @param {Book} parent - @param {String} basePath: folder o the book in the parent + @param {String} language @return {Book} */ -Book.createFromParent = function createFromParent(parent, basePath) { +Book.createFromParent = function createFromParent(parent, language) { return new Book({ logger: parent.getLogger(), - parent: parent, - fs: FS.reduceScope(parent.getFS(), basePath) + language: language, + fs: FS.reduceScope(parent.getFS(), language) }); }; |