更新wiki

This commit is contained in:
undefined committed 2020-06-23 12:54:04 +08:00
1 parent d7c9b695b0
commit 62ac2f52c9
8 files changed
+27 -9

No files matched your search

+8 -3
View File
@@ -2,10 +2,13 @@ const fs = require('fs');
const { root } = require('./utils'); const { root } = require('./utils');
module.exports = () => { module.exports = () => {
const pages = fs.readdirSync(root('wiki')); const categories = fs.readdirSync(root('wiki'));
const r = {};
for (const category of categories) {
const pages = fs.readdirSync(root(`wiki/${category}`));
const res = {}; const res = {};
for (const page of pages) { for (const page of pages) {
const c = fs.readFileSync(root(`wiki/${page}`)).toString().split('\n'); const c = fs.readFileSync(root(`wiki/${category}/${page}`)).toString().split('\n');
const pagename = page.split('.')[0]; const pagename = page.split('.')[0];
res[pagename] = []; res[pagename] = [];
let content = null; let content = null;
@@ -22,5 +25,7 @@ module.exports = () => {
} }
} }
} }
return res; r[category] = res;
}
return r;
}; };
+8 -6
View File
@@ -2,16 +2,17 @@ const { Route, Handler } = require('../service/server');
const { NotFoundError } = require('../error'); const { NotFoundError } = require('../error');
class WikiHandler extends Handler { class WikiHandler extends Handler {
async get({ page }) { async get({ category = 'wiki', page }) {
if (!global.Hydro.wiki[page]) throw new NotFoundError(page); if (!global.Hydro.wiki[category]) throw new NotFoundError(category);
const contents = global.Hydro.wiki[page]; if (!global.Hydro.wiki[category][page]) throw new NotFoundError(category, page);
const contents = global.Hydro.wiki[category][page];
const path = [ const path = [
['Hydro', 'homepage'], ['Hydro', 'homepage'],
['wiki', null], [`wiki_${category}`, null],
[`wiki_${page}`, null], [`wiki_${category}_${page}`, null],
]; ];
this.response.body = { this.response.body = {
path, contents, page_name: `wiki_${page}`, path, contents, page_name: `wiki_${category}_${page}`,
}; };
this.response.template = 'wiki.html'; this.response.template = 'wiki.html';
} }
@@ -19,6 +20,7 @@ class WikiHandler extends Handler {
async function apply() { async function apply() {
Route('wiki', '/wiki/:page', WikiHandler); Route('wiki', '/wiki/:page', WikiHandler);
Route('wiki_with_category', '/wiki/:category/:page', WikiHandler);
} }
global.Hydro.handler.wiki = module.exports = apply; global.Hydro.handler.wiki = module.exports = apply;
File renamed without changes.
+7
View File
@@ -0,0 +1,7 @@
# Judge
评测机配置:
可直接安装 Judger 模块。相关配置可在系统设置中修改。
或者参照 [HydroJudger](https://github.com/hydro-dev/HydroJudger) 部署。
+4
View File
@@ -0,0 +1,4 @@
# OAuth
Hydro 支持使用 Github 和 Google 登录。申请相应 API Key 填入系统设置。
p.s. 由于众所周知的原因,需要设置 proxy 设置项。
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.