diff --git a/config-example.json b/config-example.json index 05a2515..67ebe62 100644 --- a/config-example.json +++ b/config-example.json @@ -29,12 +29,32 @@ "contest": 10, "edit_contest_problem_list": 10 }, - "languages": [ - "C++", - "C#", - "C", - "Pascal" - ], + "languages": { + "cpp": { + "show": "C++", + "highlight": "cpp" + }, + "cpp11": { + "show": "C++11", + "highlight": "cpp" + }, + "csharp": { + "show": "C#", + "highlight": "csharp" + }, + "c": { + "show": "C", + "highlight": "c" + }, + "pascal": { + "show": "Pascal", + "highlight": "pascal" + }, + "vbnet": { + "show": "Visual Basic", + "highlight": "vbnet" + } + }, "notices": [ { "type": "// article", diff --git a/modules/judge.js b/modules/judge.js index f83e7a7..8509d03 100644 --- a/modules/judge.js +++ b/modules/judge.js @@ -75,7 +75,7 @@ app.get('/judge_detail/:id', async (req, res) => { let id = parseInt(req.params.id); let judge = await JudgeState.fromID(id); - judge.code = await syzoj.utils.highlight(judge.code, judge.language); + judge.code = await syzoj.utils.highlight(judge.code, syzoj.config.languages[judge.language].highlight); if (judge.result.compiler_output) judge.result.compiler_output = syzoj.utils.ansiToHTML(judge.result.compiler_output); judge.allowedSeeResult = await judge.isAllowedSeeResultBy(res.locals.user); judge.allowedSeeCode = await judge.isAllowedSeeCodeBy(res.locals.user); @@ -96,7 +96,7 @@ app.get('/judge_detail/:id/ajax', async (req, res) => { let id = parseInt(req.params.id); let judge = await JudgeState.fromID(id); - judge.code = await syzoj.utils.highlight(judge.code, judge.language); + judge.code = await syzoj.utils.highlight(judge.code, syzoj.config.languages[judge.language].highlight); if (judge.result.compiler_output) judge.result.compiler_output = syzoj.utils.ansiToHTML(judge.result.compiler_output); judge.allowedSeeResult = await judge.isAllowedSeeResultBy(res.locals.user); judge.allowedSeeCode = await judge.isAllowedSeeCodeBy(res.locals.user); diff --git a/modules/problem.js b/modules/problem.js index 0f2e3d9..a38a7e1 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -208,6 +208,7 @@ app.post('/submit/:id', async (req, res) => { let problem = await Problem.fromID(id); if (!problem) throw 'No such problem.'; + if (!syzoj.config.languages[req.body.language]) throw 'No such language.' if (!res.locals.user) throw 'Please login.'; if (!await problem.isAllowedUseBy(res.locals.user)) throw 'Permission denied.'; diff --git a/views/contest_problem.ejs b/views/contest_problem.ejs index e04f829..7fc4fca 100644 --- a/views/contest_problem.ejs +++ b/views/contest_problem.ejs @@ -63,8 +63,8 @@
diff --git a/views/judge_detail_item.ejs b/views/judge_detail_item.ejs index b02d2c2..d7d6095 100644 --- a/views/judge_detail_item.ejs +++ b/views/judge_detail_item.ejs @@ -25,7 +25,7 @@ <%= judge.result.score %> <%= judge.result.total_time %> ms <%= judge.result.max_memory %> KiB - <%= judge.language %> + <%= syzoj.config.languages[judge.language].show %> <% } else { %> 隐藏 隐藏 diff --git a/views/judge_state_item.ejs b/views/judge_state_item.ejs index 0fa8c84..33bb249 100644 --- a/views/judge_state_item.ejs +++ b/views/judge_state_item.ejs @@ -11,7 +11,7 @@ <%= judge.result.score %> <%= judge.result.total_time %> ms <%= judge.result.max_memory %> KiB -<%= judge.language %> +<%= syzoj.config.languages[judge.language].show %> <% } else { %> 隐藏 隐藏 diff --git a/views/submit.ejs b/views/submit.ejs index 6fb6604..09774ce 100644 --- a/views/submit.ejs +++ b/views/submit.ejs @@ -6,8 +6,8 @@