mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
更新wiki
This commit is contained in:
1 parent
d7c9b695b0
commit
62ac2f52c9
8 files changed
+42
-24
No files matched your search
+23
-18
@@ -2,25 +2,30 @@ 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 res = {};
|
const r = {};
|
||||||
for (const page of pages) {
|
for (const category of categories) {
|
||||||
const c = fs.readFileSync(root(`wiki/${page}`)).toString().split('\n');
|
const pages = fs.readdirSync(root(`wiki/${category}`));
|
||||||
const pagename = page.split('.')[0];
|
const res = {};
|
||||||
res[pagename] = [];
|
for (const page of pages) {
|
||||||
let content = null;
|
const c = fs.readFileSync(root(`wiki/${category}/${page}`)).toString().split('\n');
|
||||||
for (let i = 0; i < c.length; i++) {
|
const pagename = page.split('.')[0];
|
||||||
const line = c[i];
|
res[pagename] = [];
|
||||||
if (line.startsWith('# ')) {
|
let content = null;
|
||||||
if (content) res[pagename].push(content);
|
for (let i = 0; i < c.length; i++) {
|
||||||
content = {};
|
const line = c[i];
|
||||||
const t = line.split('# ')[1].split('|');
|
if (line.startsWith('# ')) {
|
||||||
[content.title, content.id] = t.map((q) => q.trim());
|
if (content) res[pagename].push(content);
|
||||||
content.content = '';
|
content = {};
|
||||||
} else {
|
const t = line.split('# ')[1].split('|');
|
||||||
content.content = `${content.content}${line}\n`;
|
[content.title, content.id] = t.map((q) => q.trim());
|
||||||
|
content.content = '';
|
||||||
|
} else {
|
||||||
|
content.content = `${content.content}${line}\n`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
r[category] = res;
|
||||||
}
|
}
|
||||||
return res;
|
return r;
|
||||||
};
|
};
|
||||||
@@ -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.
@@ -0,0 +1,7 @@
|
|||||||
|
# Judge
|
||||||
|
|
||||||
|
评测机配置:
|
||||||
|
|
||||||
|
可直接安装 Judger 模块。相关配置可在系统设置中修改。
|
||||||
|
|
||||||
|
或者参照 [HydroJudger](https://github.com/hydro-dev/HydroJudger) 部署。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# OAuth
|
||||||
|
|
||||||
|
Hydro 支持使用 Github 和 Google 登录。申请相应 API Key 填入系统设置。
|
||||||
|
p.s. 由于众所周知的原因,需要设置 proxy 设置项。
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user