module.exports = function(qwiki) { qwiki.rule('new', '@@CONTENT@@', function(req, res, instance, next) { var area = req.url; if (area == '') { area = 'new_page'; } else { area = req.url.substr(1) + '/new_page'; } var path = 'wiki/'+req.url+'.qwk'; res.write('
'); next(); }); qwiki.act('new', function(req, res) { // handle POST if ('submit' in req.fields && req.fields['submit'] == 'edit') { if ('page' in req.fields) { res.writeHead(302, {'Location': '/'+req.fields['page']+'/edit'}); res.end(); return; } } res.writeHead(200, "OK", { "Content-Type": "text/html", }); qwiki.parsePage('new', '', req, res); }); };