diff --git a/hydro/handler/contest.js b/hydro/handler/contest.js index c86549e13..6d13a0ec4 100644 --- a/hydro/handler/contest.js +++ b/hydro/handler/contest.js @@ -35,7 +35,7 @@ class ContestListHandler extends ContestHandler { for (const tdoc of tdocs) tids.push(tdoc.docId); const tsdict = await contest.getListStatus(domainId, this.user._id, tids); const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['contest_main', null], ]; this.response.body = { @@ -71,9 +71,9 @@ class ContestDetailHandler extends ContestHandler { } else attended = false; const udict = await user.getList(domainId, [this.tdoc.owner]); const path = [ - ['Hydro', '/'], - ['contest_main', '/c'], - [this.tdoc.title, null, true], + ['Hydro', 'homepage'], + ['contest_main', 'contest_main'], + [this.tdoc.title, null, null, true], ]; this.response.body = { path, tdoc: this.tdoc, tsdoc, attended, udict, pdict, psdict, rdict, page, @@ -91,9 +91,9 @@ class ContestScoreboardHandler extends ContestDetailHandler { async get({ domainId, tid }) { const [tdoc, rows, udict] = await this.getScoreboard(domainId, tid); const path = [ - ['Hydro', '/'], - ['contest_main', '/c'], - [tdoc.title, `/c/${tid}`, true], + ['Hydro', 'homepage'], + ['contest_main', 'contest_main'], + [tdoc.title, 'contest_detail', { tid }, true], ['contest_scoreboard', null], ]; this.response.template = 'contest_scoreboard.html'; @@ -128,9 +128,9 @@ class ContestEditHandler extends ContestDetailHandler { } const duration = (this.tdoc.endAt.getTime() - this.tdoc.beginAt.getTime()) / 3600 / 1000; const path = [ - ['Hydro', '/'], - ['contest_main', '/c'], - [this.tdoc.title, `/c/${this.tdoc.docId}`, true], + ['Hydro', 'homepage'], + ['contest_main', 'contest_main'], + [this.tdoc.title, 'contest_detail', { tid: this.tdoc.docId }, true], ['contest_edit', null], ]; const dt = this.tdoc.beginAt; @@ -192,10 +192,10 @@ class ContestProblemHandler extends ContestDetailHandler { async get({ tid }) { const path = [ - ['Hydro', '/'], - ['contest_main', '/c'], - [this.tdoc.title, `/c/${tid}`, true], - [this.pdoc.title, null, true], + ['Hydro', 'homepage'], + ['contest_main', 'contest_main'], + [this.tdoc.title, 'contest_detail', { tid }, true], + [this.pdoc.title, null, null, true], ]; this.response.body = { tdoc: this.tdoc, @@ -219,10 +219,10 @@ class ContestProblemSubmitHandler extends ContestProblemHandler { } this.response.template = 'problem_submit.html'; const path = [ - ['Hydro', '/'], - ['contest_main', '/c'], - [this.tdoc.title, `/c/${tid}`, true], - [this.pdoc.title, `/c/${tid}/p/${pid}`, true], + ['Hydro', 'homepage'], + ['contest_main', 'contest_main'], + [this.tdoc.title, 'contest_detail', { tid }, true], + [this.pdoc.title, 'contest_detail_problem', { tid, pid }, true], ['contest_detail_problem_submit', null], ]; this.response.body = { @@ -269,8 +269,8 @@ class ContestCreateHandler extends ContestHandler { ts = ts - (ts % (15 * 60 * 1000)) + 15 * 60 * 1000; const dt = new Date(ts); const path = [ - ['Hydro', '/'], - ['contest_main', '/c'], + ['Hydro', 'homepage'], + ['contest_main', 'contest_main'], ['contest_create', null], ]; this.response.body = { diff --git a/hydro/handler/discussion.js b/hydro/handler/discussion.js index ac1a64175..74d3c788e 100644 --- a/hydro/handler/discussion.js +++ b/hydro/handler/discussion.js @@ -67,7 +67,7 @@ class DiscussionMainHandler extends Handler { ); const udict = await user.getList(domainId, ddocs.map((ddoc) => ddoc.owner)); const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['discussion_main', null], ]; const vndict = await discussion.getListVnodes(domainId, ddocs, this); @@ -89,8 +89,8 @@ class DiscussionNodeHandler extends DiscussionHandler { ); const udict = await user.getList(domainId, ddocs.map((ddoc) => ddoc.owner)); const path = [ - ['Hydro', '/'], - ['discussion_main', '/discuss'], + ['Hydro', 'homepage'], + ['discussion_main', 'discussion_main'], [this.vnode.title, null, true], ]; const vndict = { [typeMapper[type]]: { [name]: this.vnode } }; @@ -116,9 +116,9 @@ class DiscussionCreateHandler extends DiscussionHandler { async get({ type, name }) { const path = [ - ['Hydro', '/'], - ['discussion_main', '/discuss'], - [this.vnode.title, `/discuss/${type}/${name}`, true], + ['Hydro', 'homepage'], + ['discussion_main', 'discussion_main'], + [this.vnode.title, 'discussion_node', { type, name }, true], ['discussion_create', null], ]; this.response.template = 'discussion_create.html'; @@ -161,10 +161,10 @@ class DiscussionDetailHandler extends DiscussionHandler { } const udict = await user.getList(domainId, uids); const path = [ - ['Hydro', '/'], - ['discussion_main', '/discuss'], - [this.vnode.title, `/discuss/${discussion.typeDisplay[this.ddoc.parentType]}/${this.ddoc.parentId}`, true], - [this.ddoc.title, null, true], + ['Hydro', 'homepage'], + ['discussion_main', 'discussion_main'], + [this.vnode.title, 'discussion_node', { type: discussion.typeDisplay[this.ddoc.parentType], name: this.ddoc.parentId }, true], + [this.ddoc.title, null, null, true], ]; this.response.template = 'discussion_detail.html'; this.response.body = { @@ -253,10 +253,10 @@ class DiscussionEditHandler extends DiscussionHandler { async get() { if (this.ddoc.owner !== this.user._id) this.checkPerm(PERM_EDIT_DISCUSSION); const path = [ - ['Hydro', '/'], - ['discussion_main', '/discuss'], - [this.vnode.title, `/discuss/${this.ddoc.parentType}`, true], - [this.ddoc.title, `/discuss/${this.ddoc.docId}`, true], + ['Hydro', 'homepage'], + ['discussion_main', 'discussion_main'], + [this.vnode.title, 'discussion_node', { type: discussion.typeDisplay[this.ddoc.parentType], name: this.ddoc.parentId }, true], + [this.ddoc.title, 'discussion_detail', { did: this.ddoc.docId }, true], ['discussion_edit', null], ]; this.response.template = 'discussion_edit.html'; @@ -278,7 +278,7 @@ class DiscussionEditHandler extends DiscussionHandler { if (this.ddoc.owner !== this.user._id) this.checkPerm(PERM_DELETE_DISCUSSION); await discussion.delete(domainId, did); this.response.body = { type: this.ddoc.parentType, parent: this.ddoc.parentId }; - this.response.redirect = `/discuss/${this.ddoc.type}/${this.ddoc.parent}`; + this.response.redirect = `/discuss/${this.ddoc.parentType}/${this.ddoc.parentId}`; } } diff --git a/hydro/handler/domain.js b/hydro/handler/domain.js index 158a2a81f..6fa4c2107 100644 --- a/hydro/handler/domain.js +++ b/hydro/handler/domain.js @@ -19,7 +19,7 @@ class DomainRankHandler extends Handler { } udocs = await Promise.all(udocs); const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['ranking', null], ]; this.response.template = 'ranking.html'; @@ -38,7 +38,7 @@ class DomainCreateHandler extends Handler { async get() { const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['domain_create', null], ]; this.response.body = { path }; @@ -62,8 +62,8 @@ class ManageHandler extends Handler { class DomainEditHandler extends ManageHandler { async get() { const path = [ - ['Hydro', '/'], - ['domain', '/domain'], + ['Hydro', 'homepage'], + ['domain', null], ['domain_edit', null], ]; this.response.template = 'domain_edit.html'; @@ -81,8 +81,8 @@ class DomainEditHandler extends ManageHandler { class DomainDashboardHandler extends ManageHandler { async get() { const path = [ - ['Hydro', '/'], - ['domain', '/domain'], + ['Hydro', 'homepage'], + ['domain', null], ['domain_dashboard', null], ]; this.response.template = 'domain_dashboard.html'; @@ -115,8 +115,8 @@ class DomainUserHandler extends ManageHandler { const rolesSelect = roles.map((role) => [role._id, role._id]); const udict = await user.getList(domainId, uids); const path = [ - ['Hydro', '/'], - ['domain', '/domain'], + ['Hydro', 'homepage'], + ['domain', null], ['domain_user', null], ]; this.response.template = 'domain_user.html'; @@ -135,8 +135,8 @@ class DomainPermissionHandler extends ManageHandler { async get({ domainId }) { const roles = await user.getRoles(domainId); const path = [ - ['Hydro', '/'], - ['domain', '/domain'], + ['Hydro', 'homepage'], + ['domain', null], ['domain_permission', null], ]; this.response.template = 'domain_permission.html'; @@ -159,8 +159,8 @@ class DomainRoleHandler extends ManageHandler { async get({ domainId }) { const roles = await user.getRoles(domainId); const path = [ - ['Hydro', '/'], - ['domain', '/domain'], + ['Hydro', 'homepage'], + ['domain', null], ['domain_role', null], ]; this.response.template = 'domain_role.html'; diff --git a/hydro/handler/home.js b/hydro/handler/home.js index e9e9ab1f2..84041a048 100644 --- a/hydro/handler/home.js +++ b/hydro/handler/home.js @@ -28,6 +28,7 @@ class HomeHandler extends Handler { async homework(domainId) { if (this.user.hasPerm(PERM_VIEW_HOMEWORK)) { const tdocs = await contest.getMulti(domainId, {}, document.TYPE_HOMEWORK) + .sort('beginAt', -1) .limit(await system.get('HOMEWORK_ON_MAIN')) .toArray(); const tsdict = await contest.getListStatus( @@ -42,6 +43,7 @@ class HomeHandler extends Handler { async contest(domainId) { if (this.user.hasPerm(PERM_VIEW_CONTEST)) { const tdocs = await contest.getMulti(domainId) + .sort('beginAt', -1) .limit(await system.get('CONTESTS_ON_MAIN')) .toArray(); const tsdict = await contest.getListStatus( @@ -159,7 +161,7 @@ class HomeSettingsHandler extends Handler { async get({ category }) { const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], [`home_${category}`, null], ]; this.response.template = 'home_settings.html'; @@ -245,7 +247,7 @@ class HomeMessagesHandler extends Handler { } } const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['home_messages', null], ]; this.response.body = { messages, udict, path }; diff --git a/hydro/handler/homework.js b/hydro/handler/homework.js index 90b6a0ee4..4d5c63731 100644 --- a/hydro/handler/homework.js +++ b/hydro/handler/homework.js @@ -38,7 +38,7 @@ class HomeworkMainHandler extends HomeworkHandler { calendar.push(cal); } const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['homework_main', null], ]; this.response.body = { tdocs, calendar, path }; @@ -80,9 +80,9 @@ class HomeworkDetailHandler extends HomeworkHandler { uids.push(tdoc.owner); const udict = await user.getList(domainId, uids); const path = [ - ['Hydro', '/'], - ['homework_main', '/homework'], - [tdoc.title, null, true], + ['Hydro', 'homepage'], + ['homework_main', 'homework_main'], + [tdoc.title, null, null, true], ]; this.response.template = 'homework_detail.html'; this.response.body = { @@ -118,10 +118,10 @@ class HomeworkDetailProblemHandler extends HomeworkHandler { } if (!this.tdoc.pids.includes(pid)) throw new ProblemNotFoundError(domainId, pid, tid); const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['homework_main', '/homework'], - [this.tdoc.title, `/homework/${tid}`, true], - [this.pdoc.title, null, true], + [this.tdoc.title, 'homework_detail', { tid }, true], + [this.pdoc.title, null, null, true], ]; this.response.template = 'problem_detail.html'; this.response.body = { @@ -142,10 +142,10 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler { .sort('_id', -1).limit(10).toArray() : []; const path = [ - ['Hydro', '/'], - ['homework_main', '/homework'], - [this.tdoc.title, `/homework/${tid}`, true], - [this.pdoc.title, `/homework/${tid}/p/${pid}`, true], + ['Hydro', 'homepage'], + ['homework_main', 'homework_main'], + [this.tdoc.title, 'homework_detail', { tid }, true], + [this.pdoc.title, 'homework_detail_problem', { tid, pid }, true], ['homework_detail_problem_submit', null], ]; this.response.template = 'problem_submit.html'; @@ -178,8 +178,8 @@ class HomeworkCreateHandler extends HomeworkHandler { const beginAt = moment().add(1, 'day'); const penaltySince = beginAt.add(7, 'days'); const path = [ - ['Hydro', '/'], - ['homework_main', '/homework'], + ['Hydro', 'homepage'], + ['homework_main', 'homework_main'], ['homework_create', null], ]; this.response.template = 'homework_edit.html'; @@ -233,9 +233,9 @@ class HomeworkEditHandler extends HomeworkHandler { (tdoc.endAt.getTime() - tdoc.penaltySince.getTime()) / 36000 / 24, ) / 100; const path = [ - ['Hydro', '/'], - ['homework_main', '/homework'], - [tdoc.title, `/homework/${tid}`, true], + ['Hydro', 'homepage'], + ['homework_main', 'homework_main'], + [tdoc.title, 'homework_detail', { tid }, true], ['homework_edit', null], ]; const beginAt = moment(tdoc.beginAt).tz(this.user.timeZone); @@ -299,8 +299,9 @@ class HomeworkScoreboardHandler extends HomeworkHandler { domainId, tid, false, document.TYPE_HOMEWORK, ); const path = [ - ['homework_main', '/homework'], - [tdoc.title, `/homework/${tid}`, true], + ['Hydro', 'homepage'], + ['homework_main', 'homework_main'], + [tdoc.title, 'homework_detail', { tid }, true], ['homework_scoreboard', null], ]; this.response.template = 'contest_scoreboard.html'; diff --git a/hydro/handler/import.js b/hydro/handler/import.js index 1715d3b32..474d82e5e 100644 --- a/hydro/handler/import.js +++ b/hydro/handler/import.js @@ -12,8 +12,8 @@ class ProblemImportHandler extends Handler { this.response.template = 'problem_import.html'; this.response.body = { path: [ - ['Hydro', '/'], - ['problem_main', '/p'], + ['Hydro', 'homepage'], + ['problem_main', 'problem_main'], ['problem_import', null], ], }; diff --git a/hydro/handler/manage.js b/hydro/handler/manage.js index 88e352e42..e7b4b750f 100644 --- a/hydro/handler/manage.js +++ b/hydro/handler/manage.js @@ -10,8 +10,8 @@ class SystemHandler extends Handler { if (!this.user.priv) throw new PermissionError('???'); this.response.body = { path: [ - ['Hydro', '/'], - ['manage_main', '/manage'], + ['Hydro', 'homepage'], + ['manage_main', null], ], }; } diff --git a/hydro/handler/misc.js b/hydro/handler/misc.js index 659188d04..8d60efd76 100644 --- a/hydro/handler/misc.js +++ b/hydro/handler/misc.js @@ -28,7 +28,8 @@ class StatusHandler extends Handler { stats[i].status = desc; } const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], + ['status', null], ]; this.response.body = { stats, path }; this.response.template = 'status.html'; diff --git a/hydro/handler/problem.js b/hydro/handler/problem.js index ae0d3a7ee..c4a7ae521 100644 --- a/hydro/handler/problem.js +++ b/hydro/handler/problem.js @@ -45,7 +45,7 @@ class ProblemHandler extends Handler { ); } const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['problem_main', null], ]; this.response.body = { @@ -95,8 +95,8 @@ class ProblemCategoryHandler extends ProblemHandler { ); } const path = [ - ['Hydro', '/'], - ['problem_main', '/p'], + ['Hydro', 'homepage'], + ['problem_main', 'problem_main'], [category, null, true], ]; this.response.body = { @@ -119,11 +119,9 @@ class ProblemRandomHandler extends ProblemHandler { class ProblemDetailHandler extends ProblemHandler { async _prepare({ domainId, pid }) { this.response.template = 'problem_detail.html'; - this.uid = this.user._id; - this.pid = pid; if (pid) { - this.pdoc = await problem.get(domainId, pid, this.uid); - if (this.pdoc.hidden && this.pdoc.owner !== this.uid) { + this.pdoc = await problem.get(domainId, pid, this.user._id); + if (this.pdoc.hidden && this.pdoc.owner !== this.user._id) { this.checkPerm(PERM_VIEW_PROBLEM_HIDDEN); } if (this.pdoc) this.udoc = await user.getById(domainId, this.pdoc.owner); @@ -137,8 +135,8 @@ class ProblemDetailHandler extends ProblemHandler { async get() { this.response.body.path = [ - ['Hydro', '/'], - ['problem_main', '/p'], + ['Hydro', 'homepage'], + ['problem_main', 'problem_main'], [this.pdoc.title, null, true], ]; } @@ -149,17 +147,17 @@ class ProblemSubmitHandler extends ProblemDetailHandler { this.checkPerm(PERM_SUBMIT_PROBLEM); } - async get({ domainId }) { + async get({ domainId, pid }) { this.response.template = 'problem_submit.html'; - const rdocs = await record.getUserInProblemMulti(domainId, this.uid, this.pdoc.docId) + const rdocs = await record.getUserInProblemMulti(domainId, this.user._id, this.pdoc.docId) .sort({ _id: -1 }) .limit(10) .toArray(); this.response.body = { path: [ - ['Hydro', '/'], - ['problem_main', '/p'], - [this.pdoc.title, `/p/${this.pid}`, true], + ['Hydro', 'homepage'], + ['problem_main', 'problem_main'], + [this.pdoc.title, 'problem_detail', { pid }, true], ['problem_submit', null], ], pdoc: this.pdoc, @@ -172,7 +170,7 @@ class ProblemSubmitHandler extends ProblemDetailHandler { async post({ domainId }) { const { lang, code } = this.request.body; const rid = await record.add(domainId, { - uid: this.uid, lang, code, pid: this.pdoc.docId, + uid: this.user._id, lang, code, pid: this.pdoc.docId, }); await Promise.all([ record.judge(domainId, rid), @@ -189,7 +187,7 @@ class ProblemPretestHandler extends ProblemDetailHandler { }) { this.limitRate('add_record', 60, 100); const rid = await record.add(domainId, { - uid: this.uid, lang, code, pid: this.pdoc.docId, input, + uid: this.user._id, lang, code, pid: this.pdoc.docId, input, }); await record.judge(domainId, rid); this.response.body = { rid }; @@ -223,8 +221,8 @@ class ProblemStatisticsHandler extends ProblemDetailHandler { async get({ domainId }) { const udoc = await user.getById(domainId, this.pdoc.owner); const path = [ - ['problem_main', '/p'], - [this.pdoc.title, `/p/${this.pdoc.pid}`, true], + ['problem_main', 'problem_main'], + [this.pdoc.title, 'problem_detail', { pid: this.pdoc.pid }, true], ['problem_statistics', null], ]; this.response.template = 'problem_statistics.html'; @@ -234,17 +232,17 @@ class ProblemStatisticsHandler extends ProblemDetailHandler { class ProblemManageHandler extends ProblemDetailHandler { async prepare() { - if (this.pdoc.owner !== this.uid) this.checkPerm(PERM_EDIT_PROBLEM); + if (this.pdoc.owner !== this.user._id) this.checkPerm(PERM_EDIT_PROBLEM); } } class ProblemSettingsHandler extends ProblemManageHandler { - async get() { + async get({ pid }) { this.response.template = 'problem_settings.html'; this.response.body.path = [ - ['Hydro', '/'], - ['problem_main', '/p'], - [this.pdoc.title, `/p/${this.pid}`, true], + ['Hydro', 'homepage'], + ['problem_main', 'problem_main'], + [this.pdoc.title, 'problem_detail', { pid }, true], ['problem_settings', null], ]; } @@ -259,9 +257,9 @@ class ProblemEditHandler extends ProblemManageHandler { async get({ pid }) { this.response.template = 'problem_edit.html'; this.response.body.path = [ - ['Hydro', '/'], - ['problem_main', '/p'], - [this.pdoc.title, `/p/${pid}`, true], + ['Hydro', 'homepage'], + ['problem_main', 'problem_main'], + [this.pdoc.title, 'problem_detail', { pid }, true], ['problem_edit', null], ]; this.response.body.page_name = 'problem_edit'; @@ -302,7 +300,7 @@ class ProblemDataUploadHandler extends ProblemManageHandler { class ProblemDataDownloadHandler extends ProblemDetailHandler { async get({ pid }) { - if (this.uid !== this.pdoc.owner) this.checkPerm([PERM_READ_PROBLEM_DATA, PERM_JUDGE]); + if (this.user._id !== this.pdoc.owner) this.checkPerm([PERM_READ_PROBLEM_DATA, PERM_JUDGE]); if (!this.pdoc.data) throw new ProblemDataNotFoundError(pid); else if (typeof this.pdoc.data === 'string') [, this.response.redirect] = this.pdoc.data.split('from:'); this.response.redirect = file.url(this.pdoc.data, this.pdoc.title); @@ -328,10 +326,10 @@ class ProblemSolutionHandler extends ProblemDetailHandler { } } const udict = await user.getList(uids); - const pssdict = solution.getListStatus(domainId, docids, this.uid); + const pssdict = solution.getListStatus(domainId, docids, this.user._id); const path = [ - ['problem_main', '/p'], - [this.pdoc.title, `/p/${this.pdoc.pid}`, true], + ['problem_main', 'problem_main'], + [this.pdoc.title, 'problem_detail', { pid: this.pdoc.pid }, true], ['problem_solution', null], ]; this.response.body = { @@ -345,19 +343,19 @@ class ProblemSolutionHandler extends ProblemDetailHandler { async postSubmit({ domainId, content }) { this.checkPerm(PERM_CREATE_PROBLEM_SOLUTION); - await solution.add(domainId, this.pdoc.docId, this.uid, content); + await solution.add(domainId, this.pdoc.docId, this.user._id, content); this.back(); } async postEditSolution({ domainId, content }) { - if (this.psdoc.owner !== this.uid) this.checkPerm(PERM_EDIT_PROBLEM_SOLUTION); + if (this.psdoc.owner !== this.user._id) this.checkPerm(PERM_EDIT_PROBLEM_SOLUTION); this.psdoc = await solution.edit(domainId, this.psdoc.docId, content); this.ctx.body.psdoc = this.psdoc; this.back(); } async postDeleteSolution({ domainId }) { - if (this.psdoc.owner !== this.uid) this.checkPerm(PERM_DELETE_PROBLEM_SOLUTION); + if (this.psdoc.owner !== this.user._id) this.checkPerm(PERM_DELETE_PROBLEM_SOLUTION); await solution.del(domainId, this.psdoc.docId); this.back(); } @@ -365,7 +363,7 @@ class ProblemSolutionHandler extends ProblemDetailHandler { async postReply({ domainId, psid, content }) { this.checkPerm(PERM_REPLY_PROBLEM_SOLUTION); const psdoc = await solution.get(domainId, psid); - await solution.reply(domainId, psdoc.docId, this.uid, content); + await solution.reply(domainId, psdoc.docId, this.user._id, content); } async postEditReply({ @@ -373,26 +371,26 @@ class ProblemSolutionHandler extends ProblemDetailHandler { }) { const [psdoc, psrdoc] = await solution.getReply(domainId, psid, psrid); if ((!psdoc) || psdoc.pid !== this.pdoc.docId) throw new SolutionNotFoundError(psid); - if (psrdoc.owner !== this.uid) this.checkPerm(PERM_EDIT_PROBLEM_SOLUTION_REPLY); + if (psrdoc.owner !== this.user._id) this.checkPerm(PERM_EDIT_PROBLEM_SOLUTION_REPLY); await solution.editReply(domainId, psid, psrid, content); } async postDeleteReply({ domainId, psid, psrid }) { const [psdoc, psrdoc] = await solution.getReply(domainId, psid, psrid); if ((!psdoc) || psdoc.pid !== this.pdoc.docId) throw new SolutionNotFoundError(psid); - if (psrdoc.owner !== this.uid) this.checkPerm(PERM_EDIT_PROBLEM_SOLUTION_REPLY); + if (psrdoc.owner !== this.user._id) this.checkPerm(PERM_EDIT_PROBLEM_SOLUTION_REPLY); await solution.delReply(domainId, psid, psrid); this.back(); } async postUpvote({ domainId }) { - const [psdoc, pssdoc] = await solution.vote(domainId, this.psdoc.docId, this.uid, 1); + const [psdoc, pssdoc] = await solution.vote(domainId, this.psdoc.docId, this.user._id, 1); this.response.body = { vote: psdoc.vote, user_vote: pssdoc.vote }; this.back(); } async postDownvote({ domainId }) { - const [psdoc, pssdoc] = await solution.vote(domainId, this.psdoc.docId, this.uid, -1); + const [psdoc, pssdoc] = await solution.vote(domainId, this.psdoc.docId, this.user._id, -1); this.response.body = { vote: psdoc.vote, user_vote: pssdoc.vote }; this.back(); } @@ -423,8 +421,8 @@ class ProblemCreateHandler extends Handler { this.checkPerm(PERM_CREATE_PROBLEM); this.response.body = { path: [ - ['Hydro', '/'], - ['problem_main', '/p'], + ['Hydro', 'homepage'], + ['problem_main', 'problem_main'], ['problem_create', null], ], page_name: 'problem_create', diff --git a/hydro/handler/record.js b/hydro/handler/record.js index 3b25680ce..cdbf03d60 100644 --- a/hydro/handler/record.js +++ b/hydro/handler/record.js @@ -31,7 +31,7 @@ class RecordListHandler extends RecordHandler { problem.getList(domainId, rdocs.map((rdoc) => rdoc.pid), false), ]); const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['record_main', null], ]; this.response.body = { @@ -64,7 +64,7 @@ class RecordDetailHandler extends RecordHandler { ]); this.response.body = { path: [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['record_detail', null], ], udoc, diff --git a/hydro/handler/system.js b/hydro/handler/system.js index 3340b7720..46650f02e 100644 --- a/hydro/handler/system.js +++ b/hydro/handler/system.js @@ -16,8 +16,8 @@ class SystemHandler extends Handler { class SystemDashboardHandler extends SystemHandler { async get() { const path = [ - ['Hydro', '/'], - ['manage', '/manage'], + ['Hydro', 'homepage'], + ['manage', null], ['manage_dashboard', null], ]; this.response.template = 'manage_dashboard.html'; @@ -29,8 +29,8 @@ class SystemModuleHandler extends SystemHandler { async get() { const installed = await hpm.getInstalled(); const path = [ - ['Hydro', '/'], - ['manage', '/manage'], + ['Hydro', 'homepage'], + ['manage', null], ['manage_module', null], ]; this.response.body = { installed, active: loader.active, path }; diff --git a/hydro/handler/training.js b/hydro/handler/training.js index 5ad2b0645..066b9070c 100644 --- a/hydro/handler/training.js +++ b/hydro/handler/training.js @@ -87,7 +87,7 @@ class TrainingMainHandler extends TrainingHandler { } for (const tdoc in tdocs) tdict[tdoc.docId] = tdoc; const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['training_main', null], ]; this.response.template = 'training_main.html'; @@ -139,8 +139,9 @@ class TrainingDetailHandler extends TrainingHandler { done: doneNids.size === tdoc.dag.length, }); const path = [ + ['Hydro', 'homepage'], ['training_main', 'training_main'], - [tdoc.title, null, true], + [tdoc.title, null, null, true], ]; this.response.template = 'training_detail.html'; this.response.body = { @@ -159,9 +160,9 @@ class TrainingDetailHandler extends TrainingHandler { class TrainingCreateHandler extends TrainingHandler { async get() { const path = [ - ['Hydro', '/'], - ['problem_main', '/t'], - ['problem_create', null], + ['Hydro', 'homepage'], + ['training_main', 'training_main'], + ['training_create', null], ]; this.response.template = 'training_edit.html'; this.response.body = { page_name: 'training_create', path }; @@ -201,8 +202,9 @@ class TrainingEditHandler extends TrainingHandler { if (tdoc.owner !== this.user._id) this.checkPerm(PERM_EDIT_TRAINING); const dag = JSON.stringify(tdoc.dag, null, 2); const path = [ - ['training_main', '/t'], - [tdoc.title, `/t/${tdoc.docId}`, true], + ['Hydro', 'homepage'], + ['training_main', 'training_main'], + [tdoc.title, 'training_detail', { tid: tdoc.docId }, true], ['training_edit', null], ]; this.response.template = 'training_edit.html'; diff --git a/hydro/handler/wiki.js b/hydro/handler/wiki.js index dabb5dd0d..084b48109 100644 --- a/hydro/handler/wiki.js +++ b/hydro/handler/wiki.js @@ -6,8 +6,8 @@ class WikiHandler extends Handler { if (!global.Hydro.wiki[page]) throw new NotFoundError(page); const contents = global.Hydro.wiki[page]; const path = [ - ['Hydro', '/'], - ['wiki', '/wiki'], + ['Hydro', 'homepage'], + ['wiki', null], [`wiki_${page}`, null], ]; this.response.body = { diff --git a/module/module-pastebin/handler.js b/module/module-pastebin/handler.js index 256fd7bd3..ae1797ef3 100644 --- a/module/module-pastebin/handler.js +++ b/module/module-pastebin/handler.js @@ -13,7 +13,7 @@ class PasteShowHandler extends Handler { async get({ docId }) { const doc = await pastebin.get(docId); const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['paste_show', null], [doc.title, null, true], ]; @@ -29,7 +29,7 @@ class PasteCreateHandler extends Handler { async get() { const path = [ - ['Hydro', '/'], + ['Hydro', 'homepage'], ['paste_create', null], ]; this.response.body = { path }; diff --git a/templates/partials/path.html b/templates/partials/path.html index d3ee93d6c..66cadbc05 100644 --- a/templates/partials/path.html +++ b/templates/partials/path.html @@ -5,7 +5,7 @@