mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
使用url()来构建url
This commit is contained in:
1 parent
0efac48bde
commit
86f67a0ec3
61 files changed
+262
-275
No files matched your search
@@ -304,14 +304,14 @@ class ContestCreateHandler extends ContestHandler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/c', ContestListHandler);
|
||||
Route('/c/:tid', ContestDetailHandler);
|
||||
Route('/c/:tid/edit', ContestEditHandler);
|
||||
Route('/c/:tid/scoreboard', ContestScoreboardHandler);
|
||||
Route('/c/:tid/export/:ext', ContestScoreboardDownloadHandler);
|
||||
Route('/c/:tid/p/:pid', ContestProblemHandler);
|
||||
Route('/c/:tid/p/:pid/submit', ContestProblemSubmitHandler);
|
||||
Route('/contest/create', ContestCreateHandler, PERM_CREATE_CONTEST);
|
||||
Route('contest_main', '/contest', ContestListHandler);
|
||||
Route('contest_detail', '/contest/:tid', ContestDetailHandler);
|
||||
Route('contest_edit', '/contest/:tid/edit', ContestEditHandler);
|
||||
Route('contest_scoreboard', '/contest/:tid/scoreboard', ContestScoreboardHandler);
|
||||
Route('contest_scoreboard_download', '/contest/:tid/export/:ext', ContestScoreboardDownloadHandler);
|
||||
Route('contest_detail_problem', '/contest/:tid/p/:pid', ContestProblemHandler);
|
||||
Route('contest_detail_problem_submit', '/contest/:tid/p/:pid/submit', ContestProblemSubmitHandler);
|
||||
Route('contest_create', '/contest/create', ContestCreateHandler, PERM_CREATE_CONTEST);
|
||||
}
|
||||
|
||||
global.Hydro.handler.contest = module.exports = apply;
|
||||
@@ -283,14 +283,14 @@ class DiscussionEditHandler extends DiscussionHandler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/discuss', DiscussionMainHandler);
|
||||
Route('/discuss/:did', DiscussionDetailHandler);
|
||||
Route('/discuss/:did/edit', DiscussionEditHandler);
|
||||
Route('/discuss/:did/raw', DiscussionDetailRawHandler);
|
||||
Route('/discuss/:did/:drid/raw', DiscussionReplyRawHandler);
|
||||
Route('/discuss/:did/:drid/:drrid/raw', DiscussionTailReplyRawHandler);
|
||||
Route('/discuss/:type/:name', DiscussionNodeHandler);
|
||||
Route('/discuss/:type/:name/create', DiscussionCreateHandler);
|
||||
Route('discussion_main', '/discuss', DiscussionMainHandler);
|
||||
Route('discussion_detail', '/discuss/:did', DiscussionDetailHandler);
|
||||
Route('discussion_edit', '/discuss/:did/edit', DiscussionEditHandler);
|
||||
Route('discussion_detail', '/discuss/:did/raw', DiscussionDetailRawHandler);
|
||||
Route('discission_reply_raw', '/discuss/:did/:drid/raw', DiscussionReplyRawHandler);
|
||||
Route('discussion_tail_reply_raw', '/discuss/:did/:drid/:drrid/raw', DiscussionTailReplyRawHandler);
|
||||
Route('discussion_node', '/discuss/:type/:name', DiscussionNodeHandler);
|
||||
Route('discussion_create', '/discuss/:type/:name/create', DiscussionCreateHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.discussion = module.exports = apply;
|
||||
+9
-10
@@ -14,9 +14,8 @@ class DomainRankHandler extends Handler {
|
||||
100,
|
||||
);
|
||||
let udocs = [];
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
for (const uid of dudocs.map((dudoc) => dudoc.uid)) {
|
||||
udocs.push(user.getById(domainId, uid));
|
||||
for (const dudoc of dudocs) {
|
||||
udocs.push(user.getById(domainId, dudoc.uid));
|
||||
}
|
||||
udocs = await Promise.all(udocs);
|
||||
const path = [
|
||||
@@ -189,13 +188,13 @@ class DomainRoleHandler extends ManageHandler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/ranking', DomainRankHandler);
|
||||
Route('/domain/create', DomainCreateHandler);
|
||||
Route('/domain/dashboard', DomainDashboardHandler);
|
||||
Route('/domain/edit', DomainEditHandler);
|
||||
Route('/domain/user', DomainUserHandler);
|
||||
Route('/domain/permission', DomainPermissionHandler);
|
||||
Route('/domain/role', DomainRoleHandler);
|
||||
Route('ranking', '/ranking', DomainRankHandler);
|
||||
Route('domain_create', '/domain/create', DomainCreateHandler);
|
||||
Route('domain_dashboard', '/domain/dashboard', DomainDashboardHandler);
|
||||
Route('domain_edit', '/domain/edit', DomainEditHandler);
|
||||
Route('domain_user', '/domain/user', DomainUserHandler);
|
||||
Route('domain_permission', '/domain/permission', DomainPermissionHandler);
|
||||
Route('domain_role', '/domain/role', DomainRoleHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.domain = module.exports = apply;
|
||||
@@ -290,12 +290,12 @@ class HomeMessagesConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/', HomeHandler);
|
||||
Route('/home/security', HomeSecurityHandler);
|
||||
Route('/home/changeMail/:code', UserChangemailWithCodeHandler);
|
||||
Route('/home/settings/:category', HomeSettingsHandler);
|
||||
Route('/home/messages', HomeMessagesHandler);
|
||||
Connection('/home/messages-conn', HomeMessagesConnectionHandler);
|
||||
Route('homepage', '/', HomeHandler);
|
||||
Route('home_security', '/home/security', HomeSecurityHandler);
|
||||
Route('user_changemail_with_code', '/home/changeMail/:code', UserChangemailWithCodeHandler);
|
||||
Route('home_settings', '/home/settings/:category', HomeSettingsHandler);
|
||||
Route('home_messages', '/home/messages', HomeMessagesHandler);
|
||||
Connection('home_messages_conn', '/home/messages-conn', HomeMessagesConnectionHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.home = module.exports = apply;
|
||||
|
||||
@@ -451,13 +451,13 @@ async function apply() {
|
||||
},
|
||||
rank: (tsdocs) => ranked(tsdocs, (a, b) => a.score === b.score),
|
||||
};
|
||||
Route('/homework', HomeworkMainHandler, PERM_VIEW_HOMEWORK);
|
||||
Route('/homework/create', HomeworkCreateHandler, PERM_CREATE_HOMEWORK);
|
||||
Route('/homework/:tid', HomeworkDetailHandler, PERM_VIEW_HOMEWORK);
|
||||
Route('/homework/:tid/scoreboard', HomeworkScoreboardHandler, PERM_VIEW_HOMEWORK_SCOREBOARD);
|
||||
Route('/homework/:tid/p/:pid', HomeworkDetailProblemHandler, PERM_VIEW_HOMEWORK);
|
||||
Route('/homework/:tid/p/:pid/submit', HomeworkDetailProblemSubmitHandler, PERM_SUBMIT_PROBLEM);
|
||||
Route('/homework/:tid/edit', HomeworkEditHandler);
|
||||
Route('homework_main', '/homework', HomeworkMainHandler, PERM_VIEW_HOMEWORK);
|
||||
Route('homework_create', '/homework/create', HomeworkCreateHandler, PERM_CREATE_HOMEWORK);
|
||||
Route('homework_detail', '/homework/:tid', HomeworkDetailHandler, PERM_VIEW_HOMEWORK);
|
||||
Route('homework_scoreboard', '/homework/:tid/scoreboard', HomeworkScoreboardHandler, PERM_VIEW_HOMEWORK_SCOREBOARD);
|
||||
Route('homework_problem', '/homework/:tid/p/:pid', HomeworkDetailProblemHandler, PERM_VIEW_HOMEWORK);
|
||||
Route('homework_problem_submit', '/homework/:tid/p/:pid/submit', HomeworkDetailProblemSubmitHandler, PERM_SUBMIT_PROBLEM);
|
||||
Route('homework_edit', '/homework/:tid/edit', HomeworkEditHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.homework = module.exports = apply;
|
||||
|
||||
@@ -36,7 +36,7 @@ class ProblemImportHandler extends Handler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/problem/import', ProblemImportHandler);
|
||||
Route('problem_import', '/problem/import', ProblemImportHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.import = module.exports = apply;
|
||||
+2
-10
@@ -83,10 +83,6 @@ async function end(body) {
|
||||
}
|
||||
|
||||
class JudgeHandler extends Handler {
|
||||
async prepare() {
|
||||
this.checkPerm(PERM_JUDGE);
|
||||
}
|
||||
|
||||
async get({ check = false }) {
|
||||
if (check) return;
|
||||
const tasks = [];
|
||||
@@ -109,10 +105,6 @@ class JudgeHandler extends Handler {
|
||||
}
|
||||
|
||||
class JudgeConnectionHandler extends ConnectionHandler {
|
||||
async prepare() {
|
||||
this.checkPerm(PERM_JUDGE);
|
||||
}
|
||||
|
||||
async message(msg) {
|
||||
if (msg.key === 'next') await next(msg);
|
||||
else if (msg.key === 'end') {
|
||||
@@ -133,8 +125,8 @@ class JudgeConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/judge', JudgeHandler);
|
||||
Connection('/judge/conn', JudgeConnectionHandler);
|
||||
Route('judge', '/judge', JudgeHandler, PERM_JUDGE);
|
||||
Connection('judge_conn', '/judge/conn', JudgeConnectionHandler, PERM_JUDGE);
|
||||
}
|
||||
|
||||
apply.next = next;
|
||||
|
||||
@@ -102,11 +102,11 @@ class SystemSettingHandler extends SystemHandler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/manage', SystemMainHandler);
|
||||
Route('/manage/dashboard', SystemDashboardHandler);
|
||||
Route('/manage/script', SystemScriptHandler);
|
||||
Route('/manage/module', SystemModuleHandler);
|
||||
Route('/manage/setting', SystemSettingHandler);
|
||||
Route('manage', '/manage', SystemMainHandler);
|
||||
Route('manage_dashboard', '/manage/dashboard', SystemDashboardHandler);
|
||||
Route('manage_script', '/manage/script', SystemScriptHandler);
|
||||
Route('manage_module', '/manage/module', SystemModuleHandler);
|
||||
Route('manage_setting', '/manage/setting', SystemSettingHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.manage = module.exports = apply;
|
||||
@@ -55,11 +55,11 @@ class SwitchLanguageHandler extends Handler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/fs/:id/:secret', FileDownloadHandler);
|
||||
Route('/fs/:id/:name/:secret', FileDownloadHandler);
|
||||
Route('/status', StatusHandler);
|
||||
Route('/status/update', StatusUpdateHandler);
|
||||
Route('/language/:lang', SwitchLanguageHandler);
|
||||
Route('file_download', '/fs/:id/:secret', FileDownloadHandler);
|
||||
Route('file_download_with_name', '/fs/:id/:name/:secret', FileDownloadHandler);
|
||||
Route('status', '/status', StatusHandler);
|
||||
Route('status_update', '/status/update', StatusUpdateHandler);
|
||||
Route('switch_language', '/language/:lang', SwitchLanguageHandler);
|
||||
}
|
||||
|
||||
apply.updateStatus = function updateStatus(args) {
|
||||
|
||||
@@ -8,12 +8,7 @@ class NotFoundHandler extends Handler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/:param1', NotFoundHandler);
|
||||
Route('/:param1/:param2', NotFoundHandler);
|
||||
Route('/:param1/:param2/:param3', NotFoundHandler);
|
||||
Route('/:param1/:param2/:param3/:param4', NotFoundHandler);
|
||||
Route('/:param1/:param2/:param3/:param4/:param5', NotFoundHandler);
|
||||
Route('/:param1/:param2/:param3/:param4/:param5/:param6', NotFoundHandler);
|
||||
Route('notfound', '*', NotFoundHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.notfound = module.exports = apply;
|
||||
+16
-16
@@ -443,22 +443,22 @@ class ProblemCreateHandler extends Handler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/p', ProblemHandler);
|
||||
Route('/p/category/:category', ProblemCategoryHandler);
|
||||
Route('/problem/random', ProblemRandomHandler);
|
||||
Route('/p/:pid', ProblemDetailHandler);
|
||||
Route('/p/:pid/submit', ProblemSubmitHandler);
|
||||
Route('/p/:pid/pretest', ProblemPretestHandler);
|
||||
Route('/p/:pid/settings', ProblemSettingsHandler);
|
||||
Route('/p/:pid/statistics', ProblemStatisticsHandler);
|
||||
Route('/p/:pid/edit', ProblemEditHandler);
|
||||
Route('/p/:pid/upload', ProblemDataUploadHandler);
|
||||
Route('/p/:pid/data', ProblemDataDownloadHandler);
|
||||
Route('/p/:pid/solution', ProblemSolutionHandler);
|
||||
Route('/p/:pid/solution/:psid/raw', ProblemSolutionRawHandler);
|
||||
Route('/p/:pid/solution/:psid/:psrid/raw', ProblemSolutionReplyRawHandler);
|
||||
Route('/problem/create', ProblemCreateHandler);
|
||||
Connection('/p/:pid/pretest-conn', ProblemPretestConnectionHandler);
|
||||
Route('problem_main', '/p', ProblemHandler);
|
||||
Route('problem_category', '/p/category/:category', ProblemCategoryHandler);
|
||||
Route('problem_random', '/problem/random', ProblemRandomHandler);
|
||||
Route('problem_detail', '/p/:pid', ProblemDetailHandler);
|
||||
Route('problem_submit', '/p/:pid/submit', ProblemSubmitHandler);
|
||||
Route('problem_pretest', '/p/:pid/pretest', ProblemPretestHandler);
|
||||
Route('problem_settings', '/p/:pid/settings', ProblemSettingsHandler);
|
||||
Route('problem_statistics', '/p/:pid/statistics', ProblemStatisticsHandler);
|
||||
Route('problem_edit', '/p/:pid/edit', ProblemEditHandler);
|
||||
Route('problem_upload', '/p/:pid/upload', ProblemDataUploadHandler);
|
||||
Route('problem_data', '/p/:pid/data', ProblemDataDownloadHandler);
|
||||
Route('problem_solution', '/p/:pid/solution', ProblemSolutionHandler);
|
||||
Route('problem_solution_raw', '/p/:pid/solution/:psid/raw', ProblemSolutionRawHandler);
|
||||
Route('problem_solution_reply_raw', '/p/:pid/solution/:psid/:psrid/raw', ProblemSolutionReplyRawHandler);
|
||||
Route('problem_create', '/problem/create', ProblemCreateHandler);
|
||||
Connection('problem_pretest_conn', '/p/:pid/pretest-conn', ProblemPretestConnectionHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.problem = module.exports = apply;
|
||||
+9
-12
@@ -14,14 +14,14 @@ const RecordHandler = contest.ContestHandlerMixin(Handler);
|
||||
|
||||
class RecordListHandler extends RecordHandler {
|
||||
async get({
|
||||
domainId, page = 1, tid, uname_or_uid,
|
||||
domainId, page = 1, tid, uidOrName,
|
||||
}) {
|
||||
this.response.template = 'record_main.html';
|
||||
const q = { tid };
|
||||
if (uname_or_uid) {
|
||||
if (uidOrName) {
|
||||
q.$or = [
|
||||
{ unameLower: uname_or_uid.toLowerCase() },
|
||||
{ _id: parseInt(uname_or_uid) },
|
||||
{ unameLower: uidOrName.toLowerCase() },
|
||||
{ _id: parseInt(uidOrName) },
|
||||
];
|
||||
}
|
||||
const rdocs = await record.getMany(domainId, q, { _id: -1 }, page, await system.get('RECORD_PER_PAGE'));
|
||||
@@ -150,14 +150,11 @@ class RecordDetailConnectionHandler extends contest.ContestHandlerMixin(Connecti
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/r', RecordListHandler);
|
||||
Route('/r/:rid', RecordDetailHandler);
|
||||
Route('/r/:rid/rejudge', RecordRejudgeHandler);
|
||||
Route('/record', RecordListHandler);
|
||||
Route('/record/:rid', RecordDetailHandler);
|
||||
Route('/record/:rid/rejudge', RecordRejudgeHandler);
|
||||
Connection('/record-conn', RecordMainConnectionHandler);
|
||||
Connection('/record-detail-conn', RecordDetailConnectionHandler);
|
||||
Route('record_main', '/record', RecordListHandler);
|
||||
Route('record_detail', '/record/:rid', RecordDetailHandler);
|
||||
Route('record_rejudge', '/record/:rid/rejudge', RecordRejudgeHandler);
|
||||
Connection('record_conn', '/record-conn', RecordMainConnectionHandler);
|
||||
Connection('record_detail_conn', '/record-detail-conn', RecordDetailConnectionHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.record = module.exports = apply;
|
||||
@@ -78,9 +78,9 @@ class SystemSettingHandler extends SystemHandler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/system', SystemDashboardHandler);
|
||||
Route('/system/module', SystemModuleHandler);
|
||||
Route('/system/setting', SystemSettingHandler);
|
||||
Route('system_dashboard', '/system', SystemDashboardHandler);
|
||||
Route('system_module', '/system/module', SystemModuleHandler);
|
||||
Route('system_setting', '/system/setting', SystemSettingHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.manage = module.exports = apply;
|
||||
@@ -153,11 +153,6 @@ class TrainingDetailHandler extends TrainingHandler {
|
||||
}
|
||||
|
||||
class TrainingCreateHandler extends TrainingHandler {
|
||||
async prepare() {
|
||||
this.checkPerm(PERM_LOGGEDIN);
|
||||
this.checkPerm(PERM_CREATE_TRAINING);
|
||||
}
|
||||
|
||||
async get() {
|
||||
const path = [
|
||||
['Hydro', '/'],
|
||||
@@ -248,10 +243,10 @@ class TrainingEditHandler extends TrainingHandler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/t', TrainingMainHandler);
|
||||
Route('/t/:tid', TrainingDetailHandler);
|
||||
Route('/t/:tid/edit', TrainingEditHandler);
|
||||
Route('/training/create', TrainingCreateHandler);
|
||||
Route('training_main', '/training', TrainingMainHandler);
|
||||
Route('training_create', '/training/create', TrainingCreateHandler, PERM_CREATE_TRAINING);
|
||||
Route('training_detail', '/training/:tid', TrainingDetailHandler);
|
||||
Route('training_edit', '/training/:tid/edit', TrainingEditHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.training = module.exports = apply;
|
||||
@@ -161,14 +161,14 @@ class UserSearchHandler extends Handler {
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/login', UserLoginHandler);
|
||||
Route('/register', UserRegisterHandler);
|
||||
Route('/register/:code', UserRegisterWithCodeHandler);
|
||||
Route('/logout', UserLogoutHandler);
|
||||
Route('/lostpass', UserLostPassHandler);
|
||||
Route('/lostpass/:code', UserLostPassWithCodeHandler);
|
||||
Route('/user/search', UserSearchHandler);
|
||||
Route('/user/:uid', UserDetailHandler);
|
||||
Route('user_login', '/login', UserLoginHandler);
|
||||
Route('user_register', '/register', UserRegisterHandler);
|
||||
Route('user_register_with_code', '/register/:code', UserRegisterWithCodeHandler);
|
||||
Route('user_logout', '/logout', UserLogoutHandler);
|
||||
Route('user_lostpass', '/lostpass', UserLostPassHandler);
|
||||
Route('user_lostpass_with_code', '/lostpass/:code', UserLostPassWithCodeHandler);
|
||||
Route('user_search', '/user/search', UserSearchHandler);
|
||||
Route('user_detail', '/user/:uid', UserDetailHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.user = module.exports = apply;
|
||||
@@ -2,23 +2,23 @@ const { Route, Handler } = require('../service/server');
|
||||
const { NotFoundError } = require('../error');
|
||||
|
||||
class WikiHandler extends Handler {
|
||||
async get({ name }) {
|
||||
if (!global.Hydro.wiki[name]) throw new NotFoundError(name);
|
||||
const contents = global.Hydro.wiki[name];
|
||||
async get({ name: page }) {
|
||||
if (!global.Hydro.wiki[page]) throw new NotFoundError(page);
|
||||
const contents = global.Hydro.wiki[page];
|
||||
const path = [
|
||||
['Hydro', '/'],
|
||||
['wiki', '/wiki'],
|
||||
[`wiki_${name}`, null],
|
||||
[`wiki_${page}`, null],
|
||||
];
|
||||
this.response.body = {
|
||||
path, contents, page_name: `wiki_${name}`,
|
||||
path, contents, page_name: `wiki_${page}`,
|
||||
};
|
||||
this.response.template = 'wiki.html';
|
||||
}
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('/wiki/:name', WikiHandler);
|
||||
Route('wiki', '/wiki/:page', WikiHandler);
|
||||
}
|
||||
|
||||
global.Hydro.handler.wiki = module.exports = apply;
|
||||
Reference in new issue
Block a user