ui: fix link display

This commit is contained in:
undefined committed 2021-05-31 23:27:20 +08:00
1 parent 43d589c84d
commit 385b8f4fe6
4 files changed
+16 -8

No files matched your search

+8 -1
View File
@@ -11,7 +11,7 @@ const markdown = require('./markdown');
const { misc, buildContent, avatar } = global.Hydro.lib;
let template = argv.options.template;
let { template } = argv.options;
if (template && typeof template !== 'string') template = findFileSync('@hydrooj/ui-default/templates');
else if (template) template = findFileSync(template);
@@ -139,6 +139,13 @@ env.addGlobal('set', (obj, key, val) => {
env.addGlobal('findSubModule', (prefix) => {
filter(Object.keys(global.Hydro.ui.template), (n) => n.startsWith(prefix));
});
env.addGlobal('parseContestProblemId', (pdoc, tdoc) => {
if (tdoc.pids[parseInt(pdoc.pid, 36) - 10]) return pdoc.pid;
let cur = tdoc.pids.indexOf(pdoc.docId);
if (cur !== -1) return (cur + 10).toString(36).toUpperCase();
cur = tdoc.pids.indexOf(`${pdoc.domainId}:${pdoc.docId}`);
return (cur + 10).toString(36).toUpperCase();
});
async function render(name, state) {
// eslint-disable-next-line no-return-await
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.11.7",
"version": "4.11.8",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -1,11 +1,12 @@
{% macro render_problem_title(pdoc, tdoc=none, show_tags=true, show_invisible_flag=true, invalid=false) %}
{%- if not invalid %}
<a
{%- if tdoc and tdoc.docType == model.document.TYPE_CONTEST %}
href="{{ url('contest_detail_problem', tid=tdoc.docId, pid=pdoc.pid|default(pdoc.docId)) }}"
{%- elif tdoc and tdoc.docType == model.document.TYPE_HOMEWORK %}
href="{{ url('homework_detail_problem', tid=tdoc.docId, pid=pdoc.pid|default(pdoc.docId)) }}"
{%- else %}
{% if tdoc -%}
href="{{ url(
'contest_detail_problem' if tdoc.docType == model.document.TYPE_CONTEST else 'homework_detail_problem',
tid=tdoc.docId, pid=parseContestProblemId(pdoc, tdoc)
) }}"
{%- else -%}
href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}"
{%- endif %}
>
@@ -58,7 +58,7 @@
{% if tdoc %}
<dt>{{ _('Contest') if tdoc.docType == model.document.TYPE_CONTEST else _('Homework') }}</dt>
<dd>
<a href="{{ url('contest_detail', tid=tdoc.docId) if tdoc.docType == model.document.TYPE_CONTEST else url('homework_detail', tid=tdoc.docId) }}">{{ tdoc.title }}</a>
<a href="{{ url('contest_detail' if tdoc.docType == model.document.TYPE_CONTEST else 'homework_detail', tid=tdoc.docId) }}">{{ tdoc.title }}</a>
</dd>
{% endif %}
<dt>{{ _('Language') }}</dt>