From 649f65b17df41021d978227ad5ca16c79d1a2031 Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 4 May 2020 10:59:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=89=AA=E8=B4=B4=E6=9D=BF=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=9D=A2=E5=8C=85=E5=B1=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/index.js | 1 - hydro/lib/axios.js | 2 +- hydro/lib/download.js | 2 +- module/module-pastebin/handler.js | 12 +++++++++++- module/module-pastebin/locale/en.yaml | 2 ++ module/module-pastebin/locale/zh_CN.yaml | 4 +++- module/problem-import-syzoj/handler.js | 4 ++-- templates/partials/path.html | 2 +- ui/pages/home_messages.page.js | 3 +++ ui/pages/judge_playground.page.js | 2 +- ui/pages/problem_detail.page.js | 3 +++ 11 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 module/module-pastebin/locale/en.yaml diff --git a/build/index.js b/build/index.js index 2ece9623f..60d97369d 100644 --- a/build/index.js +++ b/build/index.js @@ -4,7 +4,6 @@ const ignoreFailure = require('./ignoreFailure'); async function build(type) { if (!['development', 'production'].includes(type)) throw new Error(`Unknown type: ${type}`); - ignoreFailure(fs.mkdirSync, root('.cache')); ignoreFailure(fs.mkdirSync, root('.build')); await require('./locales')(type); await require('./buildModule')(type); diff --git a/hydro/lib/axios.js b/hydro/lib/axios.js index 1714e373d..c3c65b353 100644 --- a/hydro/lib/axios.js +++ b/hydro/lib/axios.js @@ -20,4 +20,4 @@ async function post(url, data, options) { return res; } -global.Hydro['lib.axios'] = module.exports = { get, post }; +global.Hydro.lib.axios = module.exports = { get, post }; diff --git a/hydro/lib/download.js b/hydro/lib/download.js index 23dd26d3f..033ec1b3c 100644 --- a/hydro/lib/download.js +++ b/hydro/lib/download.js @@ -20,4 +20,4 @@ async function download(url, path, retry = 3) { return r; } -global.Hydro['lib.download'] = module.exports = download; +global.Hydro.lib.download = module.exports = download; diff --git a/module/module-pastebin/handler.js b/module/module-pastebin/handler.js index a6c838ea2..36205fb07 100644 --- a/module/module-pastebin/handler.js +++ b/module/module-pastebin/handler.js @@ -6,7 +6,12 @@ const { nav } = global.Hydro.lib; class PasteShowHandler extends Handler { async get({ docId }) { const doc = await pastebin.get(docId); - this.response.body = { doc }; + const path = [ + ['Hydro', '/'], + ['paste_show', null], + [doc.title, null, true], + ]; + this.response.body = { path, doc }; this.response.template = 'paste_show.html'; } } @@ -17,6 +22,11 @@ class PasteCreateHandler extends Handler { } async get() { + const path = [ + ['Hydro', '/'], + ['paste_create', null], + ]; + this.response.body = { path }; this.response.template = 'paste_create.html'; } diff --git a/module/module-pastebin/locale/en.yaml b/module/module-pastebin/locale/en.yaml new file mode 100644 index 000000000..f26525ef6 --- /dev/null +++ b/module/module-pastebin/locale/en.yaml @@ -0,0 +1,2 @@ +paste_create: Create a paste +paste_show: Read a paste diff --git a/module/module-pastebin/locale/zh_CN.yaml b/module/module-pastebin/locale/zh_CN.yaml index bbf1830ef..353817be6 100644 --- a/module/module-pastebin/locale/zh_CN.yaml +++ b/module/module-pastebin/locale/zh_CN.yaml @@ -1 +1,3 @@ -pastebin: 剪贴板 \ No newline at end of file +pastebin: 剪贴板 +paste_create: 创建新内容 +paste_show: 查看内容 diff --git a/module/problem-import-syzoj/handler.js b/module/problem-import-syzoj/handler.js index 46e1c65cd..4e67112f8 100644 --- a/module/problem-import-syzoj/handler.js +++ b/module/problem-import-syzoj/handler.js @@ -1,7 +1,7 @@ const assert = require('assert'); -const download = global.Hydro['lib.download']; -const axios = global.Hydro['lib.axios']; +const { download } = global.Hydro.lib; +const { axios } = global.Hydro.lib; const { ValidationError, RemoteOnlineJudgeError } = global.Hydro.error; async function syzoj(url) { diff --git a/templates/partials/path.html b/templates/partials/path.html index d6b57b449..d3ee93d6c 100644 --- a/templates/partials/path.html +++ b/templates/partials/path.html @@ -5,7 +5,7 @@
{% for c in path %} - / {% if c[1] %}{{ c[0] if c[2] else _(c[0]) }}{% endif %} + / {% if loop.index < path.length %}{{ c[0] if c[2] else _(c[0]) }}{% endif %} {%- endfor %}

{{ path[path.length - 1][0] if path[path.length - 1][2] else _(path[path.length - 1][0]) }}

diff --git a/ui/pages/home_messages.page.js b/ui/pages/home_messages.page.js index a23af7425..10564245f 100644 --- a/ui/pages/home_messages.page.js +++ b/ui/pages/home_messages.page.js @@ -36,6 +36,9 @@ const page = new NamedPage('home_messages', () => { reduxStore = store; const sock = new SockJs('/home/messages-conn'); + sock.onopen = () => { + sock.send(document.cookie); + }; sock.onmessage = (message) => { const msg = JSON.parse(message.data); store.dispatch({ diff --git a/ui/pages/judge_playground.page.js b/ui/pages/judge_playground.page.js index aaa0ff7c5..7288184b0 100644 --- a/ui/pages/judge_playground.page.js +++ b/ui/pages/judge_playground.page.js @@ -6,8 +6,8 @@ const page = new NamedPage('judge_playground', async () => { const { default: SockJs } = await import('sockjs-client'); const sock = new SockJs('/judge/consume-conn'); - sock.onopen = () => { + sock.send(document.cookie); const div = $('
').appendTo('#messages'); $('

Connection opened.

') .appendTo(div); diff --git a/ui/pages/problem_detail.page.js b/ui/pages/problem_detail.page.js index bb67c186d..77611115e 100644 --- a/ui/pages/problem_detail.page.js +++ b/ui/pages/problem_detail.page.js @@ -168,6 +168,9 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor } = await loadReactRedux(ScratchpadReducer); const sock = new SockJs(Context.socketUrl); + sock.onopen = () => { + sock.send(document.cookie); + }; sock.onmessage = (message) => { const msg = JSON.parse(message.data); store.dispatch({