-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
executable file
·45 lines (34 loc) · 944 Bytes
/
server.js
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
#! /usr/bin/env node
'use strict';
var path = require('path');
var express = require('express');
var _ = require('lodash');
var ftl = require('./');
var Config = {
"port": 9003,
"defaultFtlOptions": {
"defaultSkin": "classic",
"optjs": "false",
"ie": "1",
"locale": "ru_RU"
},
"forward": []
};
var app = express();
app.get('/', function (req, res) {
res.redirect('/index.ftl');
});
app.engine('ftl', ftl.__express);
app.set('views', path.join(__dirname, './views'));
// замена ftl файлов вьюхами jade
app.use('/*.ftl', function ( req, res ) {
var view = req.params[0] + '.ftl';
var options = {};
options.query = _.extend({}, Config.defaultFtlOptions, req.query);
res.set('Content-Type', 'text/html');
res.render(view, options, function(err, html) {
err && console.log(err);
res.send(html);
});
});
app.listen(Config.port);