diff options
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; |