mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +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');
|
||||
|
||||
module.exports = () => {
|
||||
const pages = fs.readdirSync(root('wiki'));
|
||||
const res = {};
|
||||
for (const page of pages) {
|
||||
const c = fs.readFileSync(root(`wiki/${page}`)).toString().split('\n');
|
||||
const pagename = page.split('.')[0];
|
||||
res[pagename] = [];
|
||||
let content = null;
|
||||
for (let i = 0; i < c.length; i++) {
|
||||
const line = c[i];
|
||||
if (line.startsWith('# ')) {
|
||||
if (content) res[pagename].push(content);
|
||||
content = {};
|
||||
const t = line.split('# ')[1].split('|');
|
||||
[content.title, content.id] = t.map((q) => q.trim());
|
||||
content.content = '';
|
||||
} else {
|
||||
content.content = `${content.content}${line}\n`;
|
||||
const categories = fs.readdirSync(root('wiki'));
|
||||
const r = {};
|
||||
for (const category of categories) {
|
||||
const pages = fs.readdirSync(root(`wiki/${category}`));
|
||||
const res = {};
|
||||
for (const page of pages) {
|
||||
const c = fs.readFileSync(root(`wiki/${category}/${page}`)).toString().split('\n');
|
||||
const pagename = page.split('.')[0];
|
||||
res[pagename] = [];
|
||||
let content = null;
|
||||
for (let i = 0; i < c.length; i++) {
|
||||
const line = c[i];
|
||||
if (line.startsWith('# ')) {
|
||||
if (content) res[pagename].push(content);
|
||||
content = {};
|
||||
const t = line.split('# ')[1].split('|');
|
||||
[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');
|
||||
|
||||
class WikiHandler extends Handler {
|
||||
async get({ page }) {
|
||||
if (!global.Hydro.wiki[page]) throw new NotFoundError(page);
|
||||
const contents = global.Hydro.wiki[page];
|
||||
async get({ category = 'wiki', page }) {
|
||||
if (!global.Hydro.wiki[category]) throw new NotFoundError(category);
|
||||
if (!global.Hydro.wiki[category][page]) throw new NotFoundError(category, page);
|
||||
const contents = global.Hydro.wiki[category][page];
|
||||
const path = [
|
||||
['Hydro', 'homepage'],
|
||||
['wiki', null],
|
||||
[`wiki_${page}`, null],
|
||||
[`wiki_${category}`, null],
|
||||
[`wiki_${category}_${page}`, null],
|
||||
];
|
||||
this.response.body = {
|
||||
path, contents, page_name: `wiki_${page}`,
|
||||
path, contents, page_name: `wiki_${category}_${page}`,
|
||||
};
|
||||
this.response.template = 'wiki.html';
|
||||
}
|
||||
@@ -19,6 +20,7 @@ class WikiHandler extends Handler {
|
||||
|
||||
async function apply() {
|
||||
Route('wiki', '/wiki/:page', WikiHandler);
|
||||
Route('wiki_with_category', '/wiki/:category/:page', WikiHandler);
|
||||
}
|
||||
|
||||
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