summaryrefslogtreecommitdiffstats
path: root/lib/backbone/page.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/backbone/page.js')
-rw-r--r--lib/backbone/page.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/backbone/page.js b/lib/backbone/page.js
index 7872181..c75c434 100644
--- a/lib/backbone/page.js
+++ b/lib/backbone/page.js
@@ -16,10 +16,18 @@ function Page(book, filename) {
this.book = book;
this.log = this.book.log;
+ // Current content
this.content = '';
+
+ // Relative path to the page
this.path = filename;
+
+ // Absolute path to the page
this.rawPath = this.book.resolve(filename);
+ // Last modification date
+ this.mtime = 0;
+
// Can we parse it?
extension = path.extname(this.path);
this.parser = parsers.get(extension);
@@ -44,8 +52,14 @@ Page.prototype.update = function(content) {
// Read the page as a string
Page.prototype.read = function() {
- return this.book.readFile(this.path)
- .then(this.update);
+ var that = this;
+
+ return this.book.statFile(this.path)
+ .then(function(stat) {
+ that.mtime = stat.mtime;
+ return that.book.readFile(that.path);
+ })
+ .then(this.update);
};
// Parse the page and return its content
@@ -67,7 +81,7 @@ Page.prototype.parse = function() {
return that.book.template.renderString(that.content, {
file: {
path: that.path,
- mtime: 0 //todo: stat.mtime
+ mtime: that.mtime
}
}, {
file: that.path