2015-06-24 12:30:43 +02:00
|
|
|
//web.js
|
|
|
|
var express = require('express');
|
|
|
|
var less = require('express-less');
|
2015-06-24 13:01:17 +02:00
|
|
|
var markdown = require('express-markdown');
|
2015-06-29 23:40:40 +02:00
|
|
|
var fs = require('fs');
|
2015-06-24 12:30:43 +02:00
|
|
|
var app = express();
|
|
|
|
|
|
|
|
//Set up jade rendering engine.
|
|
|
|
app.set('view engine', 'jade');
|
|
|
|
app.disable('view cache');
|
|
|
|
app.set('views', __dirname + '/resources/jade');
|
2015-06-29 23:40:40 +02:00
|
|
|
app.locals.articles = fs.readdirSync(__dirname + '/markdown');
|
2015-06-24 12:30:43 +02:00
|
|
|
|
|
|
|
//Set up all static directories for getting resources.
|
2015-06-29 23:40:40 +02:00
|
|
|
app.use('/css', less(__dirname + '/resources/less', {debug : true}));
|
2015-06-24 12:30:43 +02:00
|
|
|
// app.use('/js', express.static(__dirname + '/resources/js'));
|
2015-06-29 23:40:40 +02:00
|
|
|
app.use('/images', express.static(__dirname + '/resources/images'));
|
2015-06-30 11:25:25 +02:00
|
|
|
app.use('/other', express.static(__dirname + '/resources/other'));
|
2015-06-24 13:01:17 +02:00
|
|
|
//Setup markdown middleware.
|
|
|
|
app.use(markdown({directory: __dirname + '/markdown', view: 'article'}));
|
2015-06-24 12:30:43 +02:00
|
|
|
|
2015-06-26 11:43:38 +02:00
|
|
|
app.get('/', function (req, res) {
|
|
|
|
res.redirect('/home.md');
|
|
|
|
});
|
2015-06-24 12:30:43 +02:00
|
|
|
|
2015-06-26 12:05:05 +02:00
|
|
|
function start(port) {
|
|
|
|
app.listen(port);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = start;
|
2015-06-29 18:31:46 +02:00
|
|
|
|
|
|
|
if (process.argv[2] == 'standalone') start(1024);
|