hoewerkt/app.js

33 lines
991 B
JavaScript
Raw Normal View History

2015-06-24 12:30:43 +02:00
//web.js
var express = require('express');
var less = require('express-less');
var markdown = require('express-markdown');
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');
app.locals.articles = fs.readdirSync(__dirname + '/markdown');
2015-06-24 12:30:43 +02:00
//Set up all static directories for getting resources.
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'));
app.use('/images', express.static(__dirname + '/resources/images'));
app.use('/other', express.static(__dirname + '/resources/other'));
//Setup markdown middleware.
app.use(markdown({directory: __dirname + '/markdown', view: 'article'}));
2015-06-24 12:30:43 +02:00
app.get('/', function (req, res) {
res.redirect('/home.md');
});
2015-06-24 12:30:43 +02:00
function start(port) {
app.listen(port);
}
module.exports = start;
if (process.argv[2] == 'standalone') start(1024);