Browse Source

Change some get to post

pull/6/head
Menci 7 years ago
parent
commit
a0bb9c7e58
  1. 4
      modules/discussion.js
  2. 6
      modules/problem.js
  3. 2
      modules/submission.js
  4. 2
      modules/user.js
  5. 13
      static/script.js
  6. 4
      views/article.ejs
  7. 6
      views/footer.ejs
  8. 2
      views/header.ejs
  9. 4
      views/problem.ejs
  10. 2
      views/problem_data.ejs
  11. 2
      views/submission_content.ejs

4
modules/discussion.js

@ -137,7 +137,7 @@ app.post('/article/:id/edit', async (req, res) => {
}
});
app.get('/article/:id/delete', async (req, res) => {
app.post('/article/:id/delete', async (req, res) => {
try {
if (!res.locals.user) throw new ErrorMessage('请登录后继续。', { '登录': syzoj.utils.makeUrl(['login'], { 'url': req.originalUrl }) });
@ -192,7 +192,7 @@ app.post('/article/:id/comment', async (req, res) => {
}
});
app.get('/article/:article_id/comment/:id/delete', async (req, res) => {
app.post('/article/:article_id/comment/:id/delete', async (req, res) => {
try {
if (!res.locals.user) throw new ErrorMessage('请登录后继续。', { '登录': syzoj.utils.makeUrl(['login'], { 'url': req.originalUrl }) });

6
modules/problem.js

@ -549,11 +549,11 @@ async function setPublic(req, res, is_public) {
}
}
app.get('/problem/:id/public', async (req, res) => {
app.post('/problem/:id/public', async (req, res) => {
await setPublic(req, res, true);
});
app.get('/problem/:id/dis_public', async (req, res) => {
app.post('/problem/:id/dis_public', async (req, res) => {
await setPublic(req, res, false);
});
@ -697,7 +697,7 @@ app.post('/problem/:id/testdata/upload', app.multer.array('file'), async (req, r
}
});
app.get('/problem/:id/testdata/delete/:filename', async (req, res) => {
app.post('/problem/:id/testdata/delete/:filename', async (req, res) => {
try {
let id = parseInt(req.params.id);
let problem = await Problem.fromID(id);

2
modules/submission.js

@ -229,7 +229,7 @@ app.get('/submission/:id/ajax', async (req, res) => {
}
});
app.get('/submission/:id/rejudge', async (req, res) => {
app.post('/submission/:id/rejudge', async (req, res) => {
try {
let id = parseInt(req.params.id);
let judge = await JudgeState.fromID(id);

2
modules/user.js

@ -76,7 +76,7 @@ app.get('/sign_up', async (req, res) => {
});
// Logout
app.get('/logout', async (req, res) => {
app.post('/logout', async (req, res) => {
req.session.user_id = null;
res.clearCookie('login');
res.redirect(req.query.url || '/');

13
static/script.js

@ -0,0 +1,13 @@
$(function () {
$('a[href-post]').click(function (e) {
e.preventDefault();
var form = document.createElement('form');
form.style.display = 'none';
form.method = 'post';
form.action = $(this).attr('href-post');
form.target = '_self';
document.body.appendChild(form);
form.submit();
});
});

4
views/article.ejs

@ -25,7 +25,7 @@
<i class="remove icon"></i>
</div>
<a class="ui green ok inverted button" href="<%= syzoj.utils.makeUrl(['article', article.id, 'delete']) %>">
<a class="ui green ok inverted button" href-post="<%= syzoj.utils.makeUrl(['article', article.id, 'delete']) %>">
<i class="checkmark icon"></i>
</a>
@ -65,7 +65,7 @@
<i class="remove icon"></i>
</div>
<a class="ui green ok inverted button" href="<%= syzoj.utils.makeUrl(['article', article.id, 'comment', comment.id, 'delete']) %>">
<a class="ui green ok inverted button" href-post="<%= syzoj.utils.makeUrl(['article', article.id, 'comment', comment.id, 'delete']) %>">
<i class="checkmark icon"></i>
</a>

6
views/footer.ejs

@ -7,10 +7,6 @@
<script src="/libs/semantic-ui/semantic.min.js"></script>
<script src="/libs/Chart.js/Chart.bundle.min.js"></script>
<script type="text/javascript">
$("#logout").click(function () {
window.location.href = <%- JSON.stringify(syzoj.utils.makeUrl(['logout'], { url: req.originalUrl })) %>;
});
</script>
<script src="/script.js?20170708"></script>
</body>
</html>

2
views/header.ejs

@ -34,7 +34,7 @@
<%= user.username %><% if (user.nameplate) { %><%- user.nameplate %><% } %> <i class="dropdown icon"></i>
<div class="menu">
<a class="item" href="<%= syzoj.utils.makeUrl(['user', user.id, 'edit']) %>"><i class="edit icon"></i>修改资料</a>
<a class="item" href="#" id="logout"><i class="power icon"></i>注销</a>
<a class="item" href-post="<%= syzoj.utils.makeUrl(['logout'], { url: req.originalUrl }) %>"><i class="power icon"></i>注销</a>
</div>
</div>
</a>

4
views/problem.ejs

@ -106,9 +106,9 @@ div[class*=ace_br] {
<% } %>
<% if (problem.allowedManage) { %>
<% if (problem.is_public) { %>
<a class="small ui button" id="dis_public" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'dis_public']) %>">取消公开</a>
<a class="small ui button" id="dis_public" href-post="<%= syzoj.utils.makeUrl(['problem', problem.id, 'dis_public']) %>">取消公开</a>
<% } else { %>
<a class="small ui button" id="public" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'public']) %>">公开</a>
<a class="small ui button" id="public" href-post="<%= syzoj.utils.makeUrl(['problem', problem.id, 'public']) %>">公开</a>
<% } %>
<% } %>
</div>

2
views/problem_data.ejs

@ -95,7 +95,7 @@ function getIcon(filename) {
<i class="remove icon"></i>
</div>
<a class="ui green ok inverted button" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'testdata', 'delete', file.filename]) %>">
<a class="ui green ok inverted button" href-post="<%= syzoj.utils.makeUrl(['problem', problem.id, 'testdata', 'delete', file.filename]) %>">
<i class="checkmark icon"></i>
</a>

2
views/submission_content.ejs

@ -92,7 +92,7 @@ else problemUrl = syzoj.utils.makeUrl(['problem', judge.problem_id]);
<% if (judge.problem.type !== 'submit-answer' && judge.allowedSeeCode) { %>
<div class="ui existing segment" style="position: relative; ">
<% if (judge.allowedRejudge) { %>
<a id="rejudge-button" href="<%= syzoj.utils.makeUrl(['submission', judge.id, 'rejudge']) %>" class="ui button" style="position: absolute; top: 0px; right: -4px; border-top-left-radius: 0; border-bottom-right-radius: 0; <% if (judge.pending) { %>display: none; <% } %>">重新评测</a>
<a id="rejudge-button" href-post="<%= syzoj.utils.makeUrl(['submission', judge.id, 'rejudge']) %>" class="ui button" style="position: absolute; top: 0px; right: -4px; border-top-left-radius: 0; border-bottom-right-radius: 0; <% if (judge.pending) { %>display: none; <% } %>">重新评测</a>
<% } %>
<pre style="margin-top: 0; margin-bottom: 0; "><code id="code"><%- judge.code %></code></pre>
</div>

Loading…
Cancel
Save