Browse Source

Merge branch 'master' into typeorm

master
Menci 6 years ago committed by GitHub
parent
commit
7563694a68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      README.en.md
  2. 4
      README.md
  3. 3
      config-example.json
  4. 12
      libs/code_formatter.js
  5. 13
      static/self/monaco-editor.js
  6. 2
      utility.js
  7. 9
      views/user_edit.ejs

4
README.en.md

@ -4,9 +4,7 @@
An online judge system for algorithm competition. An online judge system for algorithm competition.
This project is the **official** successor and rewritten version of the original Python/Flask version of SYZOJ, which is authorized by the original author [@Chenyao2333](https://github.com/Chenyao2333). This project is based on [@Chenyao2333](https://github.com/Chenyao2333)'s [SYZOJ](https://github.com/Zhengzhou-11-Highschool/syzoj). Currently maintained by [LibreOJ](https://loj.ac).
Currently maintained by [LibreOJ](https://loj.ac).
# Deploying # Deploying
Currently, the tutorial for deploying is only available in Chinese. It's [部署指南](https://github.com/syzoj/syzoj/wiki/%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97) in this project's wiki. Currently, the tutorial for deploying is only available in Chinese. It's [部署指南](https://github.com/syzoj/syzoj/wiki/%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97) in this project's wiki.

4
README.md

@ -4,9 +4,7 @@
一个用于算法竞赛的在线评测系统。 一个用于算法竞赛的在线评测系统。
此项目为重写过的、原 Python/Flask 版 SYZOJ 的**官方**后继版本,由原作者 [@Chenyao2333](https://github.com/Chenyao2333) 授权。 本项目继承自 [@Chenyao2333](https://github.com/Chenyao2333) 的 [SYZOJ](https://github.com/Zhengzhou-11-Highschool/syzoj),目前由 [LibreOJ](https://loj.ac) 维护。
目前由 [LibreOJ](https://loj.ac) 维护。
# 部署 # 部署
见本项目 Wiki 中的 [部署指南](https://github.com/syzoj/syzoj/wiki/%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)。 见本项目 Wiki 中的 [部署指南](https://github.com/syzoj/syzoj/wiki/%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)。

3
config-example.json

@ -124,5 +124,6 @@
"url": "https://fonts.loli.net" "url": "https://fonts.loli.net"
}, },
"no_cdn": false, "no_cdn": false,
"submissions_page_fast_pagination": false "submissions_page_fast_pagination": false,
"username_regex": "^[a-zA-Z0-9\\-\\_]+$"
} }

12
libs/code_formatter.js

@ -35,16 +35,16 @@ module.exports = async (code, lang) => {
} }
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
let exit = code => { let exit = () => {
if (code === 0) resolve(); if (process.exitCode === 0) resolve();
else reject(code); else reject(process.exitCode);
} }
if (process.exitCode !== null) exit(process.exitCode); if (process.exitCode !== null) exit();
else process.on('close', exit); else process.on('close', () => exit());
}); });
} catch (e) { } catch (e) {
console.log(e.stack); console.log(e);
result = null; result = null;
} }

13
static/self/monaco-editor.js

@ -584,10 +584,16 @@ require(['vs/editor/editor.main'], function () {
}); });
} }
function autoLayout(editor) {
window.addEventListener('resize', function () {
editor.layout();
});
}
$.getScript(window.pathSelfLib + "monaco-editor-tomorrow.js", function () { $.getScript(window.pathSelfLib + "monaco-editor-tomorrow.js", function () {
window.createCodeEditor = function (editorElement, langauge, content) { window.createCodeEditor = function (editorElement, langauge, content) {
editorElement.innerHTML = ''; editorElement.innerHTML = '';
return monaco.editor.create(editorElement, { var editor = monaco.editor.create(editorElement, {
value: content, value: content,
language: langauge, language: langauge,
multicursorModifier: 'ctrlCmd', multicursorModifier: 'ctrlCmd',
@ -608,6 +614,9 @@ require(['vs/editor/editor.main'], function () {
hideCursorInOverviewRuler: true, hideCursorInOverviewRuler: true,
contextmenu: false contextmenu: false
}); });
autoLayout(editor);
return editor;
}; };
window.createMarkdownEditor = function (wrapperElement, content, input) { window.createMarkdownEditor = function (wrapperElement, content, input) {
@ -653,6 +662,8 @@ require(['vs/editor/editor.main'], function () {
input.value = editor.getValue(); input.value = editor.getValue();
}); });
autoLayout(editor);
return editor; return editor;
}; };

2
utility.js

@ -268,7 +268,7 @@ module.exports = {
return md5.digest('hex'); return md5.digest('hex');
}, },
isValidUsername(s) { isValidUsername(s) {
return /^[a-zA-Z0-9\-\_]+$/.test(s); return RegExp(syzoj.config.username_regex).test(s);
}, },
locks: [], locks: [],
lock(key, cb) { lock(key, cb) {

9
views/user_edit.ejs

@ -44,7 +44,7 @@
<div class="field"> <div class="field">
<label for="information">个性签名</label> <label for="information">个性签名</label>
</div> </div>
</div> </div>
<div class="editor editor-with-border" id="information" style="width: 100%; height: 100px; margin-bottom: 1em; "> <div class="editor editor-with-border" id="information" style="width: 100%; height: 100px; margin-bottom: 1em; ">
<%- this.showLoadingEditor(); %> <%- this.showLoadingEditor(); %>
@ -94,7 +94,14 @@
</form> </form>
</div> </div>
</div> </div>
<script>
var bakDefine = define;
define = undefined;
</script>
<script src="<%- lib('blueimp-md5/2.10.0/js/md5.min.js') %>"></script> <script src="<%- lib('blueimp-md5/2.10.0/js/md5.min.js') %>"></script>
<script>
define = bakDefine;
</script>
<script type="text/javascript"> <script type="text/javascript">
var editors = { var editors = {
information: { defaultValue: <%- serializejs(edited_user.information) %> }, information: { defaultValue: <%- serializejs(edited_user.information) %> },

Loading…
Cancel
Save