diff --git a/build/development.js b/build/development.js index efabfb975..43e47641c 100644 --- a/build/development.js +++ b/build/development.js @@ -1,3 +1,4 @@ +global.DEBUG = true; require('./index.js')('development').catch((e) => { console.error(e); }); diff --git a/build/index.js b/build/index.js index 23d37ce90..bb90f8660 100644 --- a/build/index.js +++ b/build/index.js @@ -85,9 +85,3 @@ async function build(type) { } module.exports = build; - -if (!module.parent) { - build('development').catch((e) => { - console.error(e); - }); -} diff --git a/build/template.js b/build/template.js index 14515a134..57ff42adc 100644 --- a/build/template.js +++ b/build/template.js @@ -25,7 +25,7 @@ const build = (dirOrObject) => { } } else templates = dirOrObject; for (const i in templates) { - if (i.endsWith('.html') && !templates[i].includes('No Compression')) { + if (i.endsWith('.html') && !global.DEBUG && !templates[i].includes('No Compression')) { templates[i] = templates[i] .trim() .replace(/ *\n */gmi, ' ') diff --git a/hydro/handler/contest.js b/hydro/handler/contest.js index 8817b70e0..c86549e13 100644 --- a/hydro/handler/contest.js +++ b/hydro/handler/contest.js @@ -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; diff --git a/hydro/handler/discussion.js b/hydro/handler/discussion.js index b75b1de5c..ac1a64175 100644 --- a/hydro/handler/discussion.js +++ b/hydro/handler/discussion.js @@ -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; diff --git a/hydro/handler/domain.js b/hydro/handler/domain.js index 6ff052e45..eaae0840b 100644 --- a/hydro/handler/domain.js +++ b/hydro/handler/domain.js @@ -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; diff --git a/hydro/handler/home.js b/hydro/handler/home.js index 67d175502..e9e9ab1f2 100644 --- a/hydro/handler/home.js +++ b/hydro/handler/home.js @@ -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; diff --git a/hydro/handler/homework.js b/hydro/handler/homework.js index 96e6f08c2..90b6a0ee4 100644 --- a/hydro/handler/homework.js +++ b/hydro/handler/homework.js @@ -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; diff --git a/hydro/handler/import.js b/hydro/handler/import.js index 17a05aa2d..1715d3b32 100644 --- a/hydro/handler/import.js +++ b/hydro/handler/import.js @@ -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; diff --git a/hydro/handler/judge.js b/hydro/handler/judge.js index f6d70156e..800ed36ff 100644 --- a/hydro/handler/judge.js +++ b/hydro/handler/judge.js @@ -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; diff --git a/hydro/handler/manage.js b/hydro/handler/manage.js index 64be29ad3..88e352e42 100644 --- a/hydro/handler/manage.js +++ b/hydro/handler/manage.js @@ -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; diff --git a/hydro/handler/misc.js b/hydro/handler/misc.js index 3478cb498..6d383621f 100644 --- a/hydro/handler/misc.js +++ b/hydro/handler/misc.js @@ -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) { diff --git a/hydro/handler/notfound.js b/hydro/handler/notfound.js index a8ece11c3..9ef3108d5 100644 --- a/hydro/handler/notfound.js +++ b/hydro/handler/notfound.js @@ -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; diff --git a/hydro/handler/problem.js b/hydro/handler/problem.js index 3d3d86150..ae0d3a7ee 100644 --- a/hydro/handler/problem.js +++ b/hydro/handler/problem.js @@ -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; diff --git a/hydro/handler/record.js b/hydro/handler/record.js index b34119cca..c6e4f6a5f 100644 --- a/hydro/handler/record.js +++ b/hydro/handler/record.js @@ -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; diff --git a/hydro/handler/system.js b/hydro/handler/system.js index 58894791a..3340b7720 100644 --- a/hydro/handler/system.js +++ b/hydro/handler/system.js @@ -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; diff --git a/hydro/handler/training.js b/hydro/handler/training.js index f9786f7cb..d9da22c86 100644 --- a/hydro/handler/training.js +++ b/hydro/handler/training.js @@ -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; diff --git a/hydro/handler/user.js b/hydro/handler/user.js index 72e006d54..0283fe38b 100644 --- a/hydro/handler/user.js +++ b/hydro/handler/user.js @@ -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; diff --git a/hydro/handler/wiki.js b/hydro/handler/wiki.js index 2c859fb77..ab865cce9 100644 --- a/hydro/handler/wiki.js +++ b/hydro/handler/wiki.js @@ -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; diff --git a/hydro/service/server.js b/hydro/service/server.js index de8da7182..f2c42a865 100644 --- a/hydro/service/server.js +++ b/hydro/service/server.js @@ -130,6 +130,7 @@ class Handler { this.hasPerm = (perm) => this.user.hasPerm(perm); const res = await template.render(name, Object.assign(context, { handler: this, + url: (...args) => this.url(...args), _: (str) => (str ? str.toString().translate(this.user.viewLang || this.session.viewLang) : ''), user: this.user, })); @@ -183,6 +184,20 @@ class Handler { this.response.disposition = `attachment; filename="${name}"`; } + url(name, kwargs = {}) { // eslint-disable-line class-methods-use-this + delete kwargs.__keywords; + let res; + const { anchor } = kwargs; + if (kwargs.query) { + const { query } = kwargs; + delete kwargs.query; + res = router.url(name, kwargs, { query }); + } + res = router.url(name, kwargs); + if (anchor) return `${res}#${anchor}`; + return res; + } + async ___prepare({ domainId }) { this.response.body = {}; this.now = new Date(); @@ -296,8 +311,8 @@ class Handler { } } -function Route(route, RouteHandler, permission = null) { - router.all(route, async (ctx) => { +function Route(name, route, RouteHandler, permission = null) { + router.all(name, route, async (ctx) => { const h = new RouteHandler(ctx); try { const method = ctx.method.toLowerCase(); @@ -399,7 +414,7 @@ class ConnectionHandler { } } -function Connection(prefix, RouteConnHandler) { +function Connection(name, prefix, RouteConnHandler) { const sock = sockjs.createServer({ prefix }); sock.on('connection', async (conn) => { const h = new RouteConnHandler(conn); diff --git a/module/migrate-vijos/handler.js b/module/migrate-vijos/handler.js index d8b01c053..033971b36 100644 --- a/module/migrate-vijos/handler.js +++ b/module/migrate-vijos/handler.js @@ -1,7 +1,6 @@ const { Route, Handler } = global.Hydro.service.server; const { PERM_MANAGE } = global.Hydro.permission; const { message } = global.Hydro.model; -const migrate = global.Hydro.script.migrateVijos; class MigrateVijosHandler extends Handler { async prepare() { @@ -20,7 +19,7 @@ class MigrateVijosHandler extends Handler { async post({ host, port, name, username, password, }) { - migrate({ + global.Hydro.script.migrateVijos({ host, port, name, username, password, }, (data) => message.send(1, 1, data)); this.response.redirect = '/manage/log'; @@ -28,9 +27,7 @@ class MigrateVijosHandler extends Handler { } async function apply() { - Route('/migrate/vijos', module.exports.MigrateVijosHandler); + Route('migrate_vijos', '/migrate/vijos', MigrateVijosHandler); } -global.Hydro.handler.pastebin = module.exports = { - MigrateVijosHandler, apply, -}; +global.Hydro.handler.migrateVijos = module.exports = apply; diff --git a/module/module-pastebin/handler.js b/module/module-pastebin/handler.js index 394551b51..158bd1060 100644 --- a/module/module-pastebin/handler.js +++ b/module/module-pastebin/handler.js @@ -42,8 +42,8 @@ class PasteCreateHandler extends Handler { } async function apply() { - Route('/paste/create', PasteCreateHandler); - Route('/paste/:docId', PasteShowHandler); + Route('paste_create', '/paste/create', PasteCreateHandler); + Route('paste_show', '/paste/:docId', PasteShowHandler); nav('/paste/create', 'pastebin', 'pastebin', PERM_LOGGEDIN); } diff --git a/package.json b/package.json index c40a19f44..fe740953a 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "webpack": "^4.42.1" }, "scripts": { - "build": "node build/index.js", + "build": "node build/development.js", "build:development": "node build/development.js", "build:production": "node build/production.js", "build:all": "cd ui && yarn && yarn build:production && cd .. && yarn && yarn build:production", @@ -49,4 +49,4 @@ ".build/module/**" ] } -} +} \ No newline at end of file diff --git a/templates/components/comments_discussion.html b/templates/components/comments_discussion.html index 50c60f7e5..cd1ef801e 100644 --- a/templates/components/comments_discussion.html +++ b/templates/components/comments_discussion.html @@ -14,7 +14,7 @@ {{ reply_operations(doc, rdoc) }} -
+
{{ rdoc['content']|markdown|safe }}
@@ -133,7 +133,7 @@ {% endif %}
-
+
{{ doc['content']|markdown|safe }}
diff --git a/templates/components/comments_solution.html b/templates/components/comments_solution.html index cd1482512..5747e17f6 100644 --- a/templates/components/comments_solution.html +++ b/templates/components/comments_solution.html @@ -130,7 +130,7 @@ {% endif %}
-
+
{{ doc['content']|markdown|safe }}
@@ -160,7 +160,7 @@ {% endif %}
-
+
{{ rdoc['content']|markdown|safe }}
diff --git a/templates/components/problem.html b/templates/components/problem.html index 3b74e05d6..723c8a820 100644 --- a/templates/components/problem.html +++ b/templates/components/problem.html @@ -2,9 +2,10 @@ {%- if not invalid %} {%- endif %} diff --git a/templates/components/record.html b/templates/components/record.html index 4573925d8..8df2e5ed7 100644 --- a/templates/components/record.html +++ b/templates/components/record.html @@ -2,7 +2,7 @@
- + {{ model.builtin.STATUS_TEXTS[rdoc['status']] }}
diff --git a/templates/components/user.html b/templates/components/user.html index 41279e8dd..1af29920b 100644 --- a/templates/components/user.html +++ b/templates/components/user.html @@ -8,11 +8,11 @@ {% if avatar %} {% endif %} - + {{ udoc['uname'] }} {% if badge %} - LV {{ udoc['level']|default(0) }} + LV {{ udoc['level']|default(0) }} {% if modbadge and udoc.hasPerm(perm.PERM_MOD_BADGE) %} MOD {% endif %} diff --git a/templates/contest_detail.html b/templates/contest_detail.html index 54f651dc7..3dcb906f3 100644 --- a/templates/contest_detail.html +++ b/templates/contest_detail.html @@ -48,7 +48,7 @@ {% if handler.canShowRecord(tdoc) %} {{ record.render_status_td(rdoc) }} {% else %} - {{ _('Submitted') }} + {{ _('Submitted') }} {% endif %} {{ datetimeSpan(rdoc._id)|safe }} {% else %} diff --git a/templates/contest_main.html b/templates/contest_main.html index 0b8b11747..74f719a06 100644 --- a/templates/contest_main.html +++ b/templates/contest_main.html @@ -31,7 +31,7 @@
- {{ _('View Details') }} + {{ _('View Details') }}
{% if tsdict[tdoc.docId].attend %}

{{ _('Attended') }}

@@ -87,7 +87,7 @@
-

{{ tdoc.title }}

+

{{ tdoc.title }}

-

{{ _('Create a contest') }}

+

{{ _('Create a contest') }}

{% endif %} diff --git a/templates/contest_scoreboard.html b/templates/contest_scoreboard.html index 59e2f1434..87f1ba001 100644 --- a/templates/contest_scoreboard.html +++ b/templates/contest_scoreboard.html @@ -3,10 +3,10 @@
@@ -22,7 +22,7 @@ {%- for column in rows[0] -%} {% if column.type == 'problem_detail' %} - {{ column['value'] }} + {{ column['value'] }} {% else %} {{ column.value }} {% endif %} @@ -38,7 +38,7 @@ {% if column.type == 'user' %} {{ user.render_inline(column.raw, badge=false) }} {% elif column.type == 'record' and column.raw %} - {{ column.value }} + {{ column.value }} {% else %} {{ column.value }} {% endif %} diff --git a/templates/discussion_detail.html b/templates/discussion_detail.html index 12b7281c1..70c7ef039 100644 --- a/templates/discussion_detail.html +++ b/templates/discussion_detail.html @@ -7,10 +7,10 @@ diff --git a/templates/discussion_main_or_node.html b/templates/discussion_main_or_node.html index 8c06a9f8f..65a8718ff 100644 --- a/templates/discussion_main_or_node.html +++ b/templates/discussion_main_or_node.html @@ -24,7 +24,7 @@
{% if vnode %} {% if handler.hasPerm(perm.PERM_CREATE_DISCUSSION) %} -

{{ _('Create a Discussion') }}

+

{{ _('Create a Discussion') }}

{% else %} {% if not handler.hasPerm(perm.PERM_LOGGEDIN) %}

{{ _('Login to Create a Discussion') }}

diff --git a/templates/home_file.html b/templates/home_file.html index e6ef58680..e55b61c82 100644 --- a/templates/home_file.html +++ b/templates/home_file.html @@ -7,7 +7,7 @@ {% if handler.has_priv(vj4.model.builtin.PRIV_CREATE_FILE) %} {{ _('Upload File') }} {% endif %} - {{ _("What's file?") }} + {{ _("What's file?") }}
diff --git a/templates/homework_detail.html b/templates/homework_detail.html index b842b4550..4bf11abb3 100644 --- a/templates/homework_detail.html +++ b/templates/homework_detail.html @@ -47,7 +47,7 @@ {% if handler.canShowRecord(tdoc) %} {{ record.render_status_td(rdoc) }} {% else %} - {{ _('Submitted') }} + {{ _('Submitted') }} {% endif %} {{ datetimeSpan(rdoc['_id'])|safe }} {% else %} diff --git a/templates/homework_main.html b/templates/homework_main.html index 908363256..777abdc1f 100644 --- a/templates/homework_main.html +++ b/templates/homework_main.html @@ -19,7 +19,7 @@ {% if handler.hasPerm(perm.PERM_CREATE_HOMEWORK) %} - {{ _('Create Homework') }} + {{ _('Create Homework') }} {% endif %}
@@ -38,7 +38,7 @@
-

{{ tdoc.title }}

+

{{ tdoc.title }}

-

{{ tdoc.title }}

+

{{ tdoc.title }}

-

{{ tdoc['title'] }}

+

{{ tdoc['title'] }}

-

{{ tdoc.title }}

+

{{ tdoc.title }}

{{ tdoc['content'] }}

diff --git a/templates/manage_module.html b/templates/manage_module.html index ab5fe8366..fa7c0669d 100644 --- a/templates/manage_module.html +++ b/templates/manage_module.html @@ -20,7 +20,7 @@

{{ _('Installed Modules') }}

- {{ _("What's module?") }} + {{ _("What's module?") }}
diff --git a/templates/manage_script.html b/templates/manage_script.html index 4f0b5df86..b813c148f 100644 --- a/templates/manage_script.html +++ b/templates/manage_script.html @@ -19,7 +19,7 @@

{{ _('Scripts') }}

diff --git a/templates/partials/contest_sidebar.html b/templates/partials/contest_sidebar.html index 1a3688ccc..e374d7add 100644 --- a/templates/partials/contest_sidebar.html +++ b/templates/partials/contest_sidebar.html @@ -2,7 +2,7 @@ {% import "components/contest.html" as contest with context %}
{% if page_name != 'contest_detail' %} - +

{{ tdoc.title }}

@@ -18,14 +18,14 @@
@@ -45,16 +45,16 @@ diff --git a/templates/record_detail.html b/templates/record_detail.html index 2fc7059fa..da8613cf1 100644 --- a/templates/record_detail.html +++ b/templates/record_detail.html @@ -31,7 +31,7 @@
@@ -25,7 +25,7 @@
@@ -47,7 +47,7 @@
{% if not rdocs %} - {% if not filter_uid_or_name and not filter_pid and not filter_tid %} + {% if not filter_uidOrName and not filter_pid and not filter_tid %} {{ nothing.render('Oh, there is no task in the queue!') }} {% else %} {{ nothing.render('Oh, there is no task that matches the filter!') }} diff --git a/templates/record_main_tr.html b/templates/record_main_tr.html index 81b738791..74dcf9816 100644 --- a/templates/record_main_tr.html +++ b/templates/record_main_tr.html @@ -4,7 +4,7 @@ {{ record.render_status_td(rdoc) }} {% if handler.hasPerm(perm.PERM_REJUDGE) %} - +
-

{{ tdoc.title }}

+

{{ tdoc.title }}

{{ tdoc['content'] }}

@@ -66,7 +66,7 @@
-

{{ tdict[tsdoc['docId']]['title'] }}

+

{{ tdict[tsdoc['docId']]['title'] }}

{{ _('Complete') }} {{ (100 * tsdoc['donePids']|length / handler.getPids(tdict[tsdoc.docId])|length)|round|int }}%
@@ -83,7 +83,7 @@
diff --git a/templates/user_detail.html b/templates/user_detail.html index 3d3af5060..1953dcb91 100644 --- a/templates/user_detail.html +++ b/templates/user_detail.html @@ -32,11 +32,11 @@

{{ _('Solved {0} problems, RP: {1} (No. {2})').format(udoc.nAccept|default(0), udoc['rp']|default(0.0)|round(2), udoc['rank']|default('?')) }}

{% if is_self_profile %} - + {% endif %} - + {% if udoc['mail'] %} @@ -99,7 +99,7 @@
{% for pdoc in pdocs %} -

{{ pdoc['title'] }}

+

{{ pdoc['title'] }}

{% endfor %}
{% endif %} diff --git a/templates/user_login.html b/templates/user_login.html index f7256c791..f18b22278 100644 --- a/templates/user_login.html +++ b/templates/user_login.html @@ -28,7 +28,7 @@
diff --git a/ui/pages/record_main.page.js b/ui/pages/record_main.page.js index 41a8b7036..7339d44f6 100644 --- a/ui/pages/record_main.page.js +++ b/ui/pages/record_main.page.js @@ -24,7 +24,7 @@ const page = new NamedPage('record_main', async () => { $newTr.trigger('vjContentNew'); } }; - UserSelectAutoComplete.getOrConstruct($('.filter-user [name="uid_or_name"]'), { + UserSelectAutoComplete.getOrConstruct($('.filter-user [name="uidOrName"]'), { clearDefaultValue: false, }); });