summaryrefslogtreecommitdiffstats
path: root/lib/generators/site.js
blob: 6caf372b02551c83ab05cd6f197fa704b975e26b (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var util = require("util");
var path = require("path");
var Q = require("q");
var _ = require("lodash");
var nunjucks = require("nunjucks");

var fs = require("../utils/fs");
var BaseGenerator = require("../generator");
var links = require("../utils/links");
var pageUtil = require("../utils/page");

var Generator = function() {
    BaseGenerator.apply(this, arguments);

    // Style to integrates i nthe output
    this.styles = ["website"];

    // base folder for templates
    this.templatesRoot = path.resolve(__dirname, "../../theme/templates/website")
};
util.inherits(Generator, BaseGenerator);

// Prepare the genertor
BaseGenerator.prototype.load = function() {
    var that = this;

    return BaseGenerator.prototype.load.apply(this)
    .then(function() {
        return that.loadTemplates();
    });
};

// Load all styles
Generator.prototype.loadStyles = function() {
    var that = this;
    this.styles = _.chain(this.styles)
        .map(function(style) {
            var stylePath = that.options.styles[style];
            if (fs.existsSync(path.resolve(that.book.root, stylePath))) {
                return stylePath;
            }
            return null;
        })
        .compact()
        .value();
};

// Load template engine
Generator.prototype.loadTemplates = function() {
	this.env = new nunjucks.Environment(
		new nunjucks.FileSystemLoader(this.templatesRoot),
		{
			autoescape: true
		}
	);

	return Q();
};

// Ignore some methods
Generator.prototype.transferFile = function(input) {

};


Generator.prototype.finish = function() {

};

// Convert an input file
Generator.prototype.writeParsedFile = function(page, input) {

};


Generator.prototype.langsIndex = function(langs) {

};

module.exports = Generator;