summaryrefslogtreecommitdiffstats
path: root/lib/models
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-04-28 21:25:58 +0200
committerSamy Pesse <samypesse@gmail.com>2016-04-28 21:25:58 +0200
commit826f90505c1a70ad2a8cf3715bac6d5efaeba22c (patch)
treea35600d555ff0268f6eb2fc1bd9c44c06438eb27 /lib/models
parent7ae36f16c84238340dd6b39a75423f5e95f27bbc (diff)
downloadgitbook-826f90505c1a70ad2a8cf3715bac6d5efaeba22c.zip
gitbook-826f90505c1a70ad2a8cf3715bac6d5efaeba22c.tar.gz
gitbook-826f90505c1a70ad2a8cf3715bac6d5efaeba22c.tar.bz2
Add command "init"
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/book.js10
-rw-r--r--lib/models/file.js11
-rw-r--r--lib/models/readme.js6
-rw-r--r--lib/models/summary.js15
4 files changed, 39 insertions, 3 deletions
diff --git a/lib/models/book.js b/lib/models/book.js
index be055d7..030223f 100644
--- a/lib/models/book.js
+++ b/lib/models/book.js
@@ -191,7 +191,6 @@ Book.prototype.addLanguageBook = function(language, book) {
return this.set('books', books);
};
-
/**
Set the summary for this book
@@ -202,6 +201,15 @@ Book.prototype.setSummary = function(summary) {
return this.set('summary', summary);
};
+/**
+ Set the readme for this book
+
+ @param {Readme}
+ @return {Book}
+*/
+Book.prototype.setReadme = function(readme) {
+ return this.set('readme', readme);
+};
/**
Change log level
diff --git a/lib/models/file.js b/lib/models/file.js
index ff7b899..d1726a7 100644
--- a/lib/models/file.js
+++ b/lib/models/file.js
@@ -74,5 +74,16 @@ File.createFromStat = function createFromStat(filepath, stat) {
});
};
+/**
+ Create a file with only a path
+
+ @param {String} filepath
+ @return {File}
+*/
+File.createWithFilepath = function createWithFilepath(filepath) {
+ return new File({
+ path: filepath
+ });
+};
module.exports = File;
diff --git a/lib/models/readme.js b/lib/models/readme.js
index 4ad3992..c655c82 100644
--- a/lib/models/readme.js
+++ b/lib/models/readme.js
@@ -28,10 +28,12 @@ Readme.prototype.getDescription = function() {
@return {Readme}
*/
Readme.create = function(file, def) {
+ def = def || {};
+
return new Readme({
file: file,
- title: def.title,
- description: def.description
+ title: def.title || '',
+ description: def.description || ''
});
};
diff --git a/lib/models/summary.js b/lib/models/summary.js
index 3b46941..5baebef 100644
--- a/lib/models/summary.js
+++ b/lib/models/summary.js
@@ -151,6 +151,21 @@ Summary.prototype.toText = function(parser) {
};
/**
+ Return all articles as a list
+
+ @return {List<Article>}
+*/
+Summary.prototype.getArticlesAsList = function() {
+ var accu = [];
+
+ this.getArticle(function(article) {
+ accu.push(article);
+ });
+
+ return Immutable.List(accu);
+};
+
+/**
Create a new summary for a list of parts
@param {Lust|Array} parts