diff --git a/models/contest.js b/models/contest.js index edf3cb1..54e82cd 100644 --- a/models/contest.js +++ b/models/contest.js @@ -30,6 +30,7 @@ let ContestPlayer = syzoj.model('contest_player'); let model = db.define('contest', { id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true }, title: { type: Sequelize.STRING(80) }, + subtitle: { type: Sequelize.TEXT }, start_time: { type: Sequelize.INTEGER }, end_time: { type: Sequelize.INTEGER }, @@ -71,6 +72,7 @@ class Contest extends Model { static async create(val) { return Contest.fromRecord(Contest.model.build(Object.assign({ title: '', + subtitle: '', problems: '', information: '', type: 'noi', diff --git a/modules/contest.js b/modules/contest.js index 45773ad..cf24d52 100644 --- a/modules/contest.js +++ b/modules/contest.js @@ -31,7 +31,7 @@ app.get('/contests', async (req, res) => { let paginate = syzoj.utils.paginate(await Contest.count(), req.query.page, syzoj.config.page.contest); let contests = await Contest.query(paginate, null, [['start_time', 'desc']]); - await contests.forEachAsync(async x => x.information = await syzoj.utils.markdown(x.information)); + await contests.forEachAsync(async x => x.subtitle = await syzoj.utils.markdown(x.subtitle)); res.render('contests', { contests: contests, @@ -89,6 +89,7 @@ app.post('/contest/:id/edit', async (req, res) => { if (!req.body.title.trim()) throw new ErrorMessage('比赛名不能为空。'); contest.title = req.body.title; + contest.subtitle = req.body.subtitle; if (!Array.isArray(req.body.problems)) req.body.problems = [req.body.problems]; contest.problems = req.body.problems.join('|'); if (!['noi', 'ioi', 'acm'].includes(req.body.type)) throw new ErrorMessage('无效的赛制。'); @@ -117,6 +118,7 @@ app.get('/contest/:id', async (req, res) => { contest.allowedEdit = await contest.isAllowedEditBy(res.locals.user); contest.running = await contest.isRunning(); + contest.subtitle = await syzoj.utils.markdown(contest.subtitle); contest.information = await syzoj.utils.markdown(contest.information); let problems_id = await contest.getProblems(); diff --git a/views/contest.ejs b/views/contest.ejs index aa6dfe1..3360235 100644 --- a/views/contest.ejs +++ b/views/contest.ejs @@ -8,7 +8,8 @@ <% include header %>
-

<%= contest.title %>

+

<%= contest.title %>

+
<%- contest.subtitle %>
<% let unveiled = (contest.allowedEdit || syzoj.utils.getCurrentDate() >= contest.start_time); %> <% let start = syzoj.utils.formatDate(contest.start_time), end = syzoj.utils.formatDate(contest.end_time); %> <% if (contest.running && start.split(' ')[0] === end.split(' ')[0]) { @@ -36,7 +37,7 @@ <% } %>
-

描述

+

信息与公告

<%- contest.information %>
diff --git a/views/contest_edit.ejs b/views/contest_edit.ejs index 6d2c6d2..acb91b4 100644 --- a/views/contest_edit.ejs +++ b/views/contest_edit.ejs @@ -6,6 +6,10 @@
+
+ + +
diff --git a/views/contests.ejs b/views/contests.ejs index 9a1243f..74d6062 100644 --- a/views/contests.ejs +++ b/views/contests.ejs @@ -37,7 +37,7 @@ <%= contest.title %> <%- tag %> <%= syzoj.utils.formatDate(contest.start_time) %> <%= syzoj.utils.formatDate(contest.end_time) %> - <%- contest.information %> + <%- contest.subtitle %> <% } %>