29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
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('<form action="" method="POST"><div class="edit"><div><label for="page"><span>This is the page name that corresponds to the wiki URL, e.g., my_page => kettek.net/qwiki/my_page</span>Page</label> <input type="text" name="page" value="'+area+'"></div>');
|
|
res.write('</div><div class="prompt"><input type="submit" name="submit" value="edit"></div></form>');
|
|
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);
|
|
});
|
|
};
|