Browse Source

Rename some URLs to follow UOJ

pull/6/head
Menci 7 years ago
parent
commit
b70c3ed059
  1. 6
      modules/contest.js
  2. 36
      modules/legacy.js
  3. 18
      modules/problem.js
  4. 16
      modules/submission.js
  5. 6
      modules/user.js
  6. 0
      views/article_edit.ejs
  7. 4
      views/contest.ejs
  8. 0
      views/contest_edit.ejs
  9. 4
      views/contest_ranklist.ejs
  10. 0
      views/contests.ejs
  11. 2
      views/header.ejs
  12. 8
      views/problem.ejs
  13. 2
      views/problem_data.ejs
  14. 0
      views/problem_edit.ejs
  15. 2
      views/problems.ejs
  16. 8
      views/statistics.ejs
  17. 2
      views/submission.ejs
  18. 12
      views/submission_content.ejs
  19. 2
      views/submissions.ejs
  20. 12
      views/submissions_item.ejs
  21. 0
      views/user_edit.ejs

6
modules/contest.js

@ -26,14 +26,14 @@ let Problem = syzoj.model('problem');
let JudgeState = syzoj.model('judge_state');
let User = syzoj.model('user');
app.get('/contest', async (req, res) => {
app.get('/contests', async (req, res) => {
try {
let paginate = syzoj.utils.paginate(await Contest.count(), req.query.page, syzoj.config.page.contest);
let contests = await Contest.query(paginate);
await contests.forEachAsync(async x => x.information = await syzoj.utils.markdown(x.information));
res.render('contest_list', {
res.render('contests', {
contests: contests,
paginate: paginate
})
@ -59,7 +59,7 @@ app.get('/contest/:id/edit', async (req, res) => {
let problems = [];
if (contest.problems) problems = await contest.problems.split('|').mapAsync(async id => await Problem.fromID(id));
res.render('edit_contest', {
res.render('contest_edit', {
contest: contest,
problems: problems
});

36
modules/legacy.js

@ -0,0 +1,36 @@
/*
* This file is part of SYZOJ.
*
* Copyright (c) 2016 Menci <huanghaorui301@gmail.com>
*
* SYZOJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* SYZOJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with SYZOJ. If not, see <http://www.gnu.org/licenses/>.
*/
'use strict';
app.get('/problem', async (req, res) => {
res.redirect('/problems');
});
app.get('/contest', async (req, res) => {
res.redirect('/contests');
});
app.get('/judge_state', async (req, res) => {
res.redirect('/submissions');
});
app.get('/judge_detail/:id', async (req, res) => {
res.redirect('/submission/' + req.params.id);
});

18
modules/problem.js

@ -24,7 +24,7 @@ let JudgeState = syzoj.model('judge_state');
let WaitingJudge = syzoj.model('waiting_judge');
let Contest = syzoj.model('contest');
app.get('/problem', async (req, res) => {
app.get('/problems', async (req, res) => {
try {
let paginate = syzoj.utils.paginate(await Problem.count(), req.query.page, syzoj.config.page.problem);
let problems = await Problem.query(paginate);
@ -34,7 +34,7 @@ app.get('/problem', async (req, res) => {
problem.judge_state = await problem.getJudgeState(res.locals.user, true);
});
res.render('problem_set', {
res.render('problems', {
problems: problems,
paginate: paginate
});
@ -92,7 +92,7 @@ app.get('/problem/:id/edit', async (req, res) => {
problem.allowedEdit = await problem.isAllowedEditBy(res.locals.user);
}
res.render('edit_problem', {
res.render('problem_edit', {
problem: problem
});
} catch (e) {
@ -134,7 +134,7 @@ app.post('/problem/:id/edit', async (req, res) => {
}
});
app.get('/problem/:id/upload', async (req, res) => {
app.get('/problem/:id/data', async (req, res) => {
try {
let id = parseInt(req.params.id);
let problem = await Problem.fromID(id);
@ -144,7 +144,7 @@ app.get('/problem/:id/upload', async (req, res) => {
await problem.loadRelationships();
res.render('upload_testdata', {
res.render('problem_data', {
problem: problem
});
} catch (e) {
@ -155,7 +155,7 @@ app.get('/problem/:id/upload', async (req, res) => {
}
});
app.post('/problem/:id/upload', app.multer.single('testdata'), async (req, res) => {
app.post('/problem/:id/data', app.multer.single('testdata'), async (req, res) => {
try {
let id = parseInt(req.params.id);
let problem = await Problem.fromID(id);
@ -176,7 +176,7 @@ app.post('/problem/:id/upload', app.multer.single('testdata'), async (req, res)
await problem.save();
res.redirect(syzoj.utils.makeUrl(['problem', id, 'upload']));
res.redirect(syzoj.utils.makeUrl(['problem', id, 'data']));
} catch (e) {
syzoj.log(e);
res.render('error', {
@ -185,7 +185,7 @@ app.post('/problem/:id/upload', app.multer.single('testdata'), async (req, res)
}
});
app.post('/submit/:id', async (req, res) => {
app.post('/problem/:id/submit', async (req, res) => {
try {
let id = parseInt(req.params.id);
let problem = await Problem.fromID(id);
@ -228,7 +228,7 @@ app.post('/submit/:id', async (req, res) => {
if (contest_id) {
res.redirect(syzoj.utils.makeUrl(['contest', contest_id]));
} else {
res.redirect(syzoj.utils.makeUrl(['judge_detail', judge_state.id]));
res.redirect(syzoj.utils.makeUrl(['submissions', judge_state.id]));
}
} catch (e) {
syzoj.log(e);

16
modules/judge.js → modules/submission.js

@ -22,7 +22,7 @@
let JudgeState = syzoj.model('judge_state');
let User = syzoj.model('user');
app.get('/judge_state', async (req, res) => {
app.get('/submissions', async (req, res) => {
try {
let user = await User.fromName(req.query.submitter || '');
let where = {};
@ -35,7 +35,7 @@ app.get('/judge_state', async (req, res) => {
await judge_state.forEachAsync(async obj => obj.hidden = !(await obj.isAllowedSeeResultBy(res.locals.user)));
await judge_state.forEachAsync(async obj => obj.allowedSeeCode = await obj.isAllowedSeeCodeBy(res.locals.user));
res.render('judge_state', {
res.render('submissions', {
judge_state: judge_state,
paginate: paginate,
form: {
@ -51,7 +51,7 @@ app.get('/judge_state', async (req, res) => {
}
});
app.get('/judge_state/:id/ajax', async (req, res) => {
app.get('/submissions/:id/ajax', async (req, res) => {
try {
let judge_state = await JudgeState.fromID(req.params.id);
if (!judge_state) throw 'No such judge state';
@ -59,7 +59,7 @@ app.get('/judge_state/:id/ajax', async (req, res) => {
judge_state.hidden = !(await judge_state.isAllowedSeeResultBy(res.locals.user));
judge_state.allowedSeeCode = await judge_state.isAllowedSeeCodeBy(res.locals.user);
res.render('judge_state_item', {
res.render('submissions_item', {
judge: judge_state
});
} catch (e) {
@ -70,7 +70,7 @@ app.get('/judge_state/:id/ajax', async (req, res) => {
}
});
app.get('/judge_detail/:id', async (req, res) => {
app.get('/submission/:id', async (req, res) => {
try {
let id = parseInt(req.params.id);
let judge = await JudgeState.fromID(id);
@ -81,7 +81,7 @@ app.get('/judge_detail/:id', async (req, res) => {
judge.allowedSeeResult = await judge.isAllowedSeeResultBy(res.locals.user);
judge.allowedSeeCode = await judge.isAllowedSeeCodeBy(res.locals.user);
res.render('judge_detail', {
res.render('submission', {
judge: judge
});
} catch (e) {
@ -92,7 +92,7 @@ app.get('/judge_detail/:id', async (req, res) => {
}
});
app.get('/judge_detail/:id/ajax', async (req, res) => {
app.get('/submission/:id/ajax', async (req, res) => {
try {
let id = parseInt(req.params.id);
let judge = await JudgeState.fromID(id);
@ -103,7 +103,7 @@ app.get('/judge_detail/:id/ajax', async (req, res) => {
judge.allowedSeeResult = await judge.isAllowedSeeResultBy(res.locals.user);
judge.allowedSeeCode = await judge.isAllowedSeeCodeBy(res.locals.user);
res.render('judge_detail_item', {
res.render('submission_content', {
judge: judge
});
} catch (e) {

6
modules/user.js

@ -116,7 +116,7 @@ app.get('/user/:id/edit', async (req, res) => {
throw 'Permission denied';
}
res.render('edit_user', {
res.render('user_edit', {
edited_user: user,
error_info: null
});
@ -148,12 +148,12 @@ app.post('/user/:id/edit', async (req, res) => {
await user.save();
res.render('edit_user', {
res.render('user_edit', {
edited_user: user,
error_info: 'Success'
});
} catch (e) {
res.render('edit_user', {
res.render('user_edit', {
edited_user: user,
error_info: e
});

0
views/edit_article.ejs → views/article_edit.ejs

4
views/contest.ejs

@ -42,7 +42,7 @@
<tr>
<td class="center aligned" style="white-space: nowrap; ">
<% if (problem.judge_id) { %>
<a href="<%= syzoj.utils.makeUrl(['judge_detail', problem.judge_id]) %>">
<a href="<%= syzoj.utils.makeUrl(['submission', problem.judge_id]) %>">
<% if (problem.status === true) { %>
<i class="black checkmark icon"></i>
<% } else if (problem.status !== false) { %>
@ -55,7 +55,7 @@
<td><a href="<%= syzoj.utils.makeUrl(['contest', contest.id, i]) %>"><%= syzoj.utils.removeTitleTag(problem.problem.title) %></a></td>
<td class="center aligned">
<% if (problem.judge_id) { %>
<a href="<%= syzoj.utils.makeUrl(['judge_detail', problem.judge_id]) %>"><i style="color: #000;" class="code icon"></i></a>
<a href="<%= syzoj.utils.makeUrl(['submission', problem.judge_id]) %>"><i style="color: #000;" class="code icon"></i></a>
<% } %>
</td>
</tr>

0
views/edit_contest.ejs → views/contest_edit.ejs

4
views/contest_ranklist.ejs

@ -1,4 +1,4 @@
<%= this.title = '排名 - ' + contest.title %>
<% this.title = '排名 - ' + contest.title %>
<% include header %>
<style>
.submit_time {
@ -44,7 +44,7 @@
<td><a href="<%= syzoj.utils.makeUrl(['user', item.user.id]) %>"><%= item.user.username %></a><% if (item.user.nameplate) { %><%- item.user.nameplate %><% } %></td>
<% for (let problem of problems) { %>
<% if (item.player.score_details[problem.id]) { %>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', item.player.score_details[problem.id].judge_id]) %>">
<td><a href="<%= syzoj.utils.makeUrl(['submission', item.player.score_details[problem.id].judge_id]) %>">
<span class="score score_<%= parseInt((item.player.score_details[problem.id].score / 10) || 0) %>">
<%= item.player.score_details[problem.id].score %>
</span>

0
views/contest_list.ejs → views/contests.ejs

2
views/header.ejs

@ -20,7 +20,7 @@
<a class="item<% if (active === '') { %> active<% } %>" href="/"><i class="home icon"></i> 首页</a>
<a class="item<% if (active === 'problem') { %> active<% } %>" href="/problem"><i class="list icon"></i> 题库</a>
<a class="item<% if (active === 'contest') { %> active<% } %>" href="/contest"><i class="calendar icon"></i> 比赛</a>
<a class="item<% if (active.startsWith('judge')) { %> active<% } %>" href="/judge_state"><i class="tasks icon"></i> 评测</a>
<a class="item<% if (active.startsWith('judge')) { %> active<% } %>" href="/submissions"><i class="tasks icon"></i> 评测</a>
<a class="item<% if (active === 'ranklist') { %> active<% } %>" href="/ranklist"><i class="signal icon"></i> 排名</a>
<a class="item<% if (active === 'discussion' || active === 'article') { %> active<% } %>" href="/discussion"><i class="comments icon"></i> 讨论</a>
<a class="item<% if (active === 'help') { %> active<% } %>" href="/help"><i class="help circle icon"></i> 帮助</a>

8
views/problem.ejs

@ -49,7 +49,7 @@ if (contest) {
<% if (contest) { %>
<a href="<%= syzoj.utils.makeUrl(['contest', contest.id]) %>" class="ui positive button">返回比赛</a>
<% } else { %>
<a class="small ui positive button" href="<%= syzoj.utils.makeUrl(['judge_state'], { problem_id: problem.id }) %>">提交记录</a>
<a class="small ui positive button" href="<%= syzoj.utils.makeUrl(['submissions'], { problem_id: problem.id }) %>">提交记录</a>
<a class="small ui orange button" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'statistics', 'fastest']) %>">统计</a>
<a class="small ui yellow button" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'download']) %>">下载测试数据</a>
<% } %>
@ -58,7 +58,7 @@ if (contest) {
<div class="ui buttons right floated">
<% if (problem.allowedEdit) { %>
<a class="small ui button" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'edit']) %>">编辑</a>
<a class="small ui button" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'upload']) %>">管理测试数据</a>
<a class="small ui button" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'data']) %>">管理测试数据</a>
<% } %>
<% if (user && user.is_admin) { %>
<% if (problem.is_public) { %>
@ -105,8 +105,8 @@ if (contest) {
<div class="column">
<%
let formUrl;
if (contest) formUrl = syzoj.utils.makeUrl(['submit', problem.id], { contest_id: contest.id });
else formUrl = syzoj.utils.makeUrl(['submit', problem.id]);
if (contest) formUrl = syzoj.utils.makeUrl(['problem', problem.id, 'submit'], { contest_id: contest.id });
else formUrl = syzoj.utils.makeUrl(['problem', problem.id, 'submit', problem.id]);
%>
<form class="ui form" action="<%= formUrl %>" method="post" onsubmit="return submit_code()" id="submit_code">
<input name="language" type="hidden" id="form">

2
views/upload_testdata.ejs → views/problem_data.ejs

@ -39,7 +39,7 @@
<% } %>
</div>
<div class="nine wide column">
<form class="ui form" action="<%= syzoj.utils.makeUrl(['problem', problem.id, 'upload']) %>" method="post" enctype="multipart/form-data">
<form class="ui form" method="post" enctype="multipart/form-data">
<div class="two fields">
<div class="field">
<label for="doc-ds-ipt-1">时间限制(单位: ms)</label>

0
views/edit_problem.ejs → views/problem_edit.ejs

2
views/problem_set.ejs → views/problems.ejs

@ -28,7 +28,7 @@
<% if (user) { %>
<td>
<% if (problem.judge_state) { %>
<a href="<%= syzoj.utils.makeUrl(['judge_detail', problem.judge_state.id]) %>">
<a href="<%= syzoj.utils.makeUrl(['submission', problem.judge_state.id]) %>">
<span class="status <%= problem.judge_state.status.toLowerCase().split(' ').join('_') %>">
<i class="<%= icon[problem.judge_state.status] || 'remove' %> icon"></i>
</span>

8
views/statistics.ejs

@ -65,18 +65,18 @@ function getColorOfScore(score) {
<% for (let judge of statistics.judge_state) { %>
<% include util %>
<tr>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>">#<%= judge.id %></a></td>
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>">#<%= judge.id %></a></td>
<td><a href="<%= syzoj.utils.makeUrl(['problem', judge.problem_id]) %>">#<%= judge.problem_id %>. <%= judge.problem.title %></a></td>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>">
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>">
<span class="status <%= getStatusMeta(judge.status).toLowerCase().split(' ').join('_') %>">
<i class="<%= icon[getStatusMeta(judge.status)] || 'remove' %> icon"></i>
<%= judge.status %>
</span>
</a></td>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>"><span class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></span></a></td>
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>"><span class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></span></a></td>
<td><%= judge.result.total_time %> ms</td>
<td><%= parseInt(judge.result.max_memory) || 0 %> K</td>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>"><%= syzoj.config.languages[judge.language].show %></a> / <%= syzoj.utils.formatSize(judge.code.length) %></td>
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>"><%= syzoj.config.languages[judge.language].show %></a> / <%= syzoj.utils.formatSize(judge.code.length) %></td>
<td><a href="<%= syzoj.utils.makeUrl(['user', judge.user_id]) %>"><%= judge.user.username %></a><% if (judge.user.nameplate) { %><%- judge.user.nameplate %><% } %></td>
<td><%= syzoj.utils.formatDate(judge.submit_time) %></td>
</tr>

2
views/judge_detail.ejs → views/submission.ejs

@ -1,4 +1,4 @@
<% this.title = '评测详细信息' %>
<% include header %>
<span id="judge_detail_item"><% include judge_detail_item %></span>
<span id="submission_content"><% include submission_content %></span>
<% include footer %>

12
views/judge_detail_item.ejs → views/submission_content.ejs

@ -122,10 +122,10 @@ $(function() {
<% if (!isPending(judge.status)) { %><div><div id="stop_ajax"></div></div><% } %>
<script>
<% if (isPending(judge.status) && judge.allowedSeeResult) { %>
function update_judge_detail() {
function update_submission() {
setTimeout(function () {
$.get('/judge_detail/<%= judge.id %>/ajax', function (data) {
var e = $('#judge_detail_item'), x = $($.parseHTML(data));
$.get('/submission/<%= judge.id %>/ajax', function (data) {
var e = $('#submission_content'), x = $($.parseHTML(data));
if (e.find('td.status').text().trim() != x.find('td.status').text().trim()) {
var a = e.find('#testcases_list > div');
if (!a.length) {
@ -139,13 +139,13 @@ function update_judge_detail() {
if (!$(b[i]).attr('style')) $(a[i]).attr('style', '');
}
if (!x.find('#stop_ajax').length) update_judge_detail();
if (!x.find('#stop_ajax').length) update_submission();
}
}
else if (!x.find('#stop_ajax').length) update_judge_detail();
else if (!x.find('#stop_ajax').length) update_submission();
});
}, 500);
}
update_judge_detail();
update_submission();
<% } %>
</script>

2
views/judge_state.ejs → views/submissions.ejs

@ -31,7 +31,7 @@
</thead>
<tbody>
<% for (let judge of judge_state) { %>
<tr id="judge_state_<%= judge.id %>"><% include judge_state_item %></tr>
<tr id="submissions_<%= judge.id %>"><% include submissions_item %></tr>
<% } %>
</tbody>
</table>

12
views/judge_state_item.ejs → views/submissions_item.ejs

@ -1,17 +1,17 @@
<% include util %>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>">#<%= judge.id %></a></td>
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>">#<%= judge.id %></a></td>
<td><a href="<%= syzoj.utils.makeUrl(['problem', judge.problem_id]) %>">#<%= judge.problem_id %>. <%= judge.problem.title %></a></td>
<% if (!judge.hidden) { %>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>">
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>">
<span class="status <%= getStatusMeta(judge.status).toLowerCase().split(' ').join('_') %>">
<i class="<%= icon[getStatusMeta(judge.status)] || 'remove' %> icon"></i>
<%= judge.status %>
</span>
</a></td>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>"><span class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></span></a></td>
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>"><span class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></span></a></td>
<td><%= judge.result.total_time %> ms</td>
<td><%= parseInt(judge.result.max_memory) || 0 %> K</td>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>"><%= syzoj.config.languages[judge.language].show %></a> / <%= syzoj.utils.formatSize(judge.code.length) %></td>
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>"><%= syzoj.config.languages[judge.language].show %></a> / <%= syzoj.utils.formatSize(judge.code.length) %></td>
<% } else { %>
<td>隐藏</td>
<td>隐藏</td>
@ -25,8 +25,8 @@
<script>
function update_judge_<%= judge.id %>() {
setTimeout(function () {
$.get('/judge_state/<%= judge.id %>/ajax', function (data) {
var e = $('#judge_state_<%= judge.id %>');
$.get('/submissions/<%= judge.id %>/ajax', function (data) {
var e = $('#submissions_<%= judge.id %>');
if (e.html() != data) e.html(data);
else update_judge_<%= judge.id %>();
});

0
views/edit_user.ejs → views/user_edit.ejs

Loading…
Cancel
Save