summaryrefslogtreecommitdiffstats
path: root/lib/backbone/page.js
blob: eb3cd611495be58b8b395facaf23e56d2c233054 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var path = require('path');

/*
A page represent a parsable file in the book (Markdown, Asciidoc, etc)
*/

function Page(book, filename) {
    if (!(this instanceof Page)) return new Page(book, filename);

    this.book = book;
    this.filename = filename;
}

// Return the filename of the page with another extension
// "README.md" -> "README.html"
Page.prototype.withExtension = function(ext) {
    return path.join(
        path.dirname(this.filename),
        path.basename(this.filename, path.extname(this.filename)) + ext
    );
};

// Read the page as a string
Page.prototype.read = function() {
    return this.book.readFile(this.filename);
};

// Parse the page and return its content
Page.prototype.parse = function() {

};


module.exports = Page;