summaryrefslogtreecommitdiffstats
path: root/lib/models/page.js
blob: 1b0e9f82ae26c4d110f6c824f7cecc10b326a647 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var Immutable = require('immutable');

var File = require('./file');

var Page = Immutable.Record({
    file:           File(),

    // Attributes extracted from the YAML header
    attributes:     Immutable.Map(),

    // Content of the page
    content:        String(),

    // Direction of the text
    dir:            String('ltr')
});

Page.prototype.getFile = function() {
    return this.get('file');
};

Page.prototype.getAttributes = function() {
    return this.get('attributes');
};

Page.prototype.getContent = function() {
    return this.get('content');
};

Page.prototype.getDir = function() {
    return this.get('dir');
};

/**
 * Return path of the page
 * @return {String}
*/
Page.prototype.getPath = function() {
    return this.getFile().getPath();
};

/**
 * Create a page for a file
 * @param {File} file
 * @return {Page}
*/
Page.createForFile = function(file) {
    return new Page({
        file: file
    });
};

module.exports = Page;