diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-01-28 23:42:00 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-01-28 23:42:00 +0100 |
commit | e83d63c2aa5e30c26ada888990b263e6b786d3f6 (patch) | |
tree | af460422630bfbaa9016c51d5ec384fa3923d01d /lib/backbone | |
parent | ff30ba62ba694658d1575b0cf3a0fbf3d5e00d62 (diff) | |
download | gitbook-e83d63c2aa5e30c26ada888990b263e6b786d3f6.zip gitbook-e83d63c2aa5e30c26ada888990b263e6b786d3f6.tar.gz gitbook-e83d63c2aa5e30c26ada888990b263e6b786d3f6.tar.bz2 |
Index page of summary when parsing
Diffstat (limited to 'lib/backbone')
-rw-r--r-- | lib/backbone/page.js | 7 | ||||
-rw-r--r-- | lib/backbone/summary.js | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/backbone/page.js b/lib/backbone/page.js index a17e413..bf3494a 100644 --- a/lib/backbone/page.js +++ b/lib/backbone/page.js @@ -5,7 +5,7 @@ A page represent a parsable file in the book (Markdown, Asciidoc, etc) */ function Page(book, filename) { - if (!(this instanceof Page)) return new Page(); + if (!(this instanceof Page)) return new Page(book, filename); this.book = book; this.filename = filename; @@ -20,5 +20,10 @@ Page.prototype.withExtension = function(ext) { ); }; +// Read the page as a string +Page.prototype.read = function() { + return this.book.readFile(this.filename); +}; + module.exports = Page; diff --git a/lib/backbone/summary.js b/lib/backbone/summary.js index 43a373a..009fb76 100644 --- a/lib/backbone/summary.js +++ b/lib/backbone/summary.js @@ -39,6 +39,11 @@ TOCArticle.prototype.walk = function(iter) { }); }; +// Return true if is pointing to a file +TOCArticle.prototype.hasLocation = function() { + return Boolean(this.filename); +}; + // Return true if has children TOCArticle.prototype.hasChildren = function() { return this.articles.length > 0; |