diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index c0efe5f81..ef44e77cf 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "3.10.1", + "version": "3.10.2", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 1ad497dcc..4d8251858 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -362,10 +362,11 @@ export class ProblemDetailHandler extends ProblemHandler { } @query('tid', Types.ObjectID, true) + @query('pjax', Types.Boolean, true) async get(...args: any[]) { // Navigate to current additional file download // e.g. ![img](a.jpg) will navigate to ![img](./pid/file/a.jpg) - if (!this.request.json) { + if (!this.request.json || args[2]) { if (args[1]) { this.response.body.pdoc.content = this.response.body.pdoc.content .replace(/\(file:\/\/(.+?)\)/g, (str) => { @@ -387,6 +388,16 @@ export class ProblemDetailHandler extends ProblemHandler { ? 'homework_detail_problem' : 'contest_detail_problem' : 'problem_detail'; + if (args[2]) { + const data = { pdoc: this.pdoc, tdoc: this.tdoc }; + this.response.body = { + title: this.renderTitle(this.response.body.page_name), + fragments: [ + { html: await this.renderHTML('partials/problem_description.html', data) }, + ], + raw: data, + }; + } if (!this.response.body.tdoc) { if (this.psdoc?.rid) { this.response.body.rdoc = await record.get(this.domainId, this.psdoc.rid); diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index 5c5e5a6e5..71dde1744 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.34.15", + "version": "4.34.16", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js", diff --git a/packages/ui-default/pages/problem_detail.page.jsx b/packages/ui-default/pages/problem_detail.page.jsx index edf0e6ba5..f0eadd5d1 100644 --- a/packages/ui-default/pages/problem_detail.page.jsx +++ b/packages/ui-default/pages/problem_detail.page.jsx @@ -4,6 +4,7 @@ import { NamedPage } from 'vj/misc/Page'; import { downloadProblemSet } from 'vj/components/zipDownloader'; import loadReactRedux from 'vj/utils/loadReactRedux'; import delay from 'vj/utils/delay'; +import pjax from 'vj/utils/pjax'; class ProblemPageExtender { constructor() { @@ -266,6 +267,14 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor ev.preventDefault(); }); + $(document).on('click', '[data-lang]', (ev) => { + ev.preventDefault(); + const url = new URL(window.location.href); + url.searchParams.set('lang', ev.currentTarget.dataset.lang); + $('[data-lang]').removeClass('tab--active'); + pjax.request({ url: url.toString() }); + $(ev.currentTarget).addClass('tab--active'); + }); $(document).on('click', '[name="show_tags"]', (ev) => { $(ev.currentTarget).hide(); $('span.tags').css('display', 'inline-block'); diff --git a/packages/ui-default/pages/problem_detail.page.styl b/packages/ui-default/pages/problem_detail.page.styl index 814020d97..f93d3b90a 100644 --- a/packages/ui-default/pages/problem_detail.page.styl +++ b/packages/ui-default/pages/problem_detail.page.styl @@ -11,6 +11,7 @@ transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); margin-right: 0; color: #182026 !important; + text-decoration: none; &:hover border-color: #5f9fd6; diff --git a/packages/ui-default/templates/partials/problem_description.html b/packages/ui-default/templates/partials/problem_description.html new file mode 100644 index 000000000..631e3a9bb --- /dev/null +++ b/packages/ui-default/templates/partials/problem_description.html @@ -0,0 +1,18 @@ +
+ {% if not pdoc.data.length and not pdoc.reference %} +
+

{{ _('No testdata at current.') }}

+
+ {% endif %} + {% if typeof(pdoc.config) == 'string' %} +
+

{{ pdoc.config }}

+
+ {% endif %} + {% if tdoc and tdoc.docType == model.document.TYPE_CONTEST and model.contest.isDone(tdoc) %} +
+

{{ _('You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.') }}

+
+ {% endif %} + {{ pdoc.content|content(handler.request.query.lang or handler.user.viewLang or handler.session.viewLang, pdoc.html)|safe }} +
\ No newline at end of file diff --git a/packages/ui-default/templates/problem_detail.html b/packages/ui-default/templates/problem_detail.html index 126aa8b89..80d17f30d 100644 --- a/packages/ui-default/templates/problem_detail.html +++ b/packages/ui-default/templates/problem_detail.html @@ -75,10 +75,10 @@

{{ pdoc.title }}

- {% if pdoc.content|contentLang %} + {% if pdoc.content|contentLang|length %}
{% endif %} -
- {% if not pdoc.data.length and not pdoc.reference %} -
-

{{ _('No testdata at current.') }}

-
- {% endif %} - {% if typeof(pdoc.config) == 'string' %} -
-

{{ pdoc.config }}

-
- {% endif %} - {% if tdoc and tdoc.docType == model.document.TYPE_CONTEST and model.contest.isDone(tdoc) %} -
-

{{ _('You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.') }}

-
- {% endif %} - {{ pdoc.content|content(handler.request.query.lang or handler.user.viewLang or handler.session.viewLang, pdoc.html)|safe }} -
+ {% include "partials/problem_description.html" %}