You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/hydro/handler/wiki.js

25 lines
698 B
JavaScript

4 years ago
const { Route, Handler } = require('../service/server');
const { NotFoundError } = require('../error');
5 years ago
5 years ago
class WikiHandler extends Handler {
4 years ago
async get({ page }) {
if (!global.Hydro.wiki[page]) throw new NotFoundError(page);
const contents = global.Hydro.wiki[page];
5 years ago
const path = [
4 years ago
['Hydro', 'homepage'],
['wiki', null],
[`wiki_${page}`, null],
5 years ago
];
5 years ago
this.response.body = {
path, contents, page_name: `wiki_${page}`,
5 years ago
};
this.response.template = 'wiki.html';
5 years ago
}
}
async function apply() {
Route('wiki', '/wiki/:page', WikiHandler);
5 years ago
}
4 years ago
global.Hydro.handler.wiki = module.exports = apply;