mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core&ui: update homepage config
This commit is contained in:
1 parent
c5dd6af8c1
commit
d25952c02f
18 files changed
+179
-134
No files matched your search
@@ -57,6 +57,14 @@ const replacer = (k, v) => {
|
||||
class Nunjucks extends nunjucks.Environment {
|
||||
constructor() {
|
||||
super(new Loader(), { autoescape: true, trimBlocks: true });
|
||||
this.addFilter('await', async (promise, callback) => {
|
||||
try {
|
||||
const result = await promise;
|
||||
callback(null, result);
|
||||
} catch (error) {
|
||||
callback(error);
|
||||
}
|
||||
}, true);
|
||||
this.addFilter('json', (self) => (self ? JSON.stringify(self, replacer) : ''));
|
||||
this.addFilter('parseYaml', (self) => yaml.load(self));
|
||||
this.addFilter('dumpYaml', (self) => yaml.dump(self));
|
||||
@@ -140,6 +148,7 @@ env.addGlobal('set', (obj, key, val) => {
|
||||
return '';
|
||||
});
|
||||
env.addGlobal('findSubModule', (prefix) => Object.keys(global.Hydro.ui.template).filter((n) => n.startsWith(prefix)));
|
||||
env.addGlobal('templateExists', (name) => !!global.Hydro.ui.template[name]);
|
||||
|
||||
async function render(name, state) {
|
||||
// eslint-disable-next-line no-return-await
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.32.14",
|
||||
"version": "4.33.0",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
@@ -4,103 +4,18 @@
|
||||
{% import "components/problem.html" as problem with context %}
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="large-9 columns">
|
||||
{% if domain['bulletin'] %}
|
||||
<div class="section">
|
||||
<div class="section__body typo">
|
||||
{{ domain['bulletin']|markdown|safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for node in contents %}
|
||||
{% if node[0] == 'contest' %}
|
||||
{% set tdocs = node[1] %}
|
||||
{% set tsdict = node[2] %}
|
||||
{% include "partials/homepage/contest.html" %}
|
||||
{% elif node[0] == 'homework' %}
|
||||
{% set htdocs = node[1] %}
|
||||
{% set htsdict = node[2] %}
|
||||
{% include "partials/homepage/homework.html" %}
|
||||
{% elif node[0] == 'training' %}
|
||||
{% set tdocs = node[1] %}
|
||||
{% set tsdict = node[2] %}
|
||||
{% include "partials/homepage/training.html" %}
|
||||
{% elif node[0] == 'ranking' %}
|
||||
{% set uids = node[1] %}
|
||||
{% include "partials/homepage/ranking.html" %}
|
||||
{% elif node[0] == 'discussion' %}
|
||||
{% set ddocs = node[1] %}
|
||||
{% set vndict = node[2] %}
|
||||
{% if ddocs.length %}
|
||||
<div class="section page--discussion_main">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title">{{ _('Discussion') }}</h1>
|
||||
</div>
|
||||
{% include "partials/discussion_list.html" %}
|
||||
</div>
|
||||
{% for column in contents %}
|
||||
<div class="large-{{ column.width }} columns">
|
||||
{% for s in column.sections %}
|
||||
{% if templateExists("partials/homepage/" + s[0] + ".html") %}
|
||||
{% set payload = s[1] %}
|
||||
{% include "partials/homepage/" + s[0] + ".html" %}
|
||||
{% else %}
|
||||
{% set payload = _("Template {0} not found.").format(s[0]) %}
|
||||
{% include "partials/homepage/error.html" %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="large-3 columns">
|
||||
<div class="section side nojs--hide">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title">{{ _('Hitokoto') }}</h1>
|
||||
</div>
|
||||
<div class="section__body typo" name="hitokoto"></div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if pdocs.length %}
|
||||
<div class="section side nojs--hide">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title">{{ _('Starred Problems') }}</h1>
|
||||
</div>
|
||||
<div class="section__body typo no-media col--problem-name">
|
||||
{%- for pdoc in pdocs -%}
|
||||
<form class="form--inline" action="{{ url('problem_main') }}" method="post">
|
||||
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
|
||||
<input type="hidden" name="operation" value="unstar">
|
||||
<button class="star activated" type="submit">
|
||||
<span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="{{ _('Star') }}"></span></span>
|
||||
<span class="starred--show"><span class="icon icon-star" data-tooltip="{{ _('Unstar') }}"></span></span>
|
||||
</button>
|
||||
</form>
|
||||
{{ problem.render_problem_title(pdoc, show_tags=false, show_invisible_flag=false) }}<br/>
|
||||
{%- endfor -%}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if handler.user.hasPerm(perm.PERM_VIEW_DISCUSSION) %}
|
||||
{% include 'partials/discussion_nodes_widget.html' %}
|
||||
{% endif %}
|
||||
<div class="section side">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title">{{ _('Recommended') }}</h1>
|
||||
</div>
|
||||
<div class="section__body"><ul class="group-list">
|
||||
<li class="group-list__item">
|
||||
<h2 class="section__title">{{ _('Chinese') }}</h2>
|
||||
<ol class="chip-list">
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.cometoj.com/" target="_blank">CometOJ</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://loj.ac/" target="_blank">LibreOJ</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.luogu.com.cn/" target="_blank">洛谷</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://uoj.ac/" target="_blank">UOJ</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://vijos.org/" target="_blank">Vijos</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://zoj.pintia.cn/" target="_blank">ZOJ</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li class="group-list__item">
|
||||
<h2 class="section__title">{{ _('English') }}</h2>
|
||||
<ol class="chip-list">
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://atcoder.jp/" target="_blank">AtCoder</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.codechef.com/" target="_blank">CodeChef</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://codeforces.com/" target="_blank">Codeforces</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.spoj.com/" target="_blank">SPOJ</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.topcoder.com/" target="_blank">TopCoder</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://onlinejudge.org/" target="_blank">OnlineJudge</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,7 @@
|
||||
{% if domain.bulletin %}
|
||||
<div class="section">
|
||||
<div class="section__body typo">
|
||||
{{ domain.bulletin|markdown|safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -1,3 +1,5 @@
|
||||
{% set tdocs = payload[0] %}
|
||||
{% set tsdict = payload[1] %}
|
||||
{% if tdocs.length %}
|
||||
<div class="section page--contest_main">
|
||||
<div class="section__header">
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{% set ddocs = payload[0] %}
|
||||
{% set vndict = payload[1] %}
|
||||
{% if ddocs.length %}
|
||||
<div class="section page--discussion_main">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title">{{ _('Discussion') }}</h1>
|
||||
</div>
|
||||
{% include "partials/discussion_list.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -0,0 +1,4 @@
|
||||
{% if handler.user.hasPerm(perm.PERM_VIEW_DISCUSSION) %}
|
||||
{% set vnodes = payload %}
|
||||
{% include 'partials/discussion_nodes_widget.html' %}
|
||||
{% endif %}
|
||||
@@ -0,0 +1,5 @@
|
||||
<div class="section">
|
||||
<div class="section__body typo">
|
||||
{{ payload }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
<div class="section side nojs--hide">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title">{{ _('Hitokoto') }}</h1>
|
||||
</div>
|
||||
<div class="section__body typo" name="hitokoto"></div>
|
||||
</div>
|
||||
@@ -1,3 +1,5 @@
|
||||
{% set htdocs = payload[0] %}
|
||||
{% set htsdict = payload[1] %}
|
||||
{% if htdocs.length %}
|
||||
<div class="section page--homework_main">
|
||||
<div class="section__header">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% if uids.length %}
|
||||
{% if payload.length %}
|
||||
<div class="section">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title">{{ _('Ranking') }}</h1>
|
||||
@@ -21,7 +21,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{%- for uid in uids -%}
|
||||
{%- for uid in payload -%}
|
||||
{% set udoc = udict[uid] %}
|
||||
<tr>
|
||||
<td class="col--rank">{{ loop.index }}</td>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{% set pdocs = payload[0] %}
|
||||
{% set psdict = payload[1] %}
|
||||
{% if pdocs.length %}
|
||||
<div class="section side nojs--hide">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title">{{ _('Starred Problems') }}</h1>
|
||||
</div>
|
||||
<div class="section__body typo no-media col--problem-name">
|
||||
{%- for pdoc in pdocs -%}
|
||||
<form class="form--inline" action="{{ url('problem_main') }}" method="post">
|
||||
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
|
||||
<input type="hidden" name="operation" value="unstar">
|
||||
<button class="star activated" type="submit">
|
||||
<span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="{{ _('Star') }}"></span></span>
|
||||
<span class="starred--show"><span class="icon icon-star" data-tooltip="{{ _('Unstar') }}"></span></span>
|
||||
</button>
|
||||
</form>
|
||||
{{ problem.render_problem_title(pdoc, show_tags=false, show_invisible_flag=false) }}<br/>
|
||||
{%- endfor -%}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -0,0 +1,29 @@
|
||||
<div class="section side">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title">{{ _('Recommended') }}</h1>
|
||||
</div>
|
||||
<div class="section__body"><ul class="group-list">
|
||||
<li class="group-list__item">
|
||||
<h2 class="section__title">{{ _('Chinese') }}</h2>
|
||||
<ol class="chip-list">
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.cometoj.com/" target="_blank">CometOJ</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://loj.ac/" target="_blank">LibreOJ</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.luogu.com.cn/" target="_blank">洛谷</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://uoj.ac/" target="_blank">UOJ</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://vijos.org/" target="_blank">Vijos</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://zoj.pintia.cn/" target="_blank">ZOJ</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li class="group-list__item">
|
||||
<h2 class="section__title">{{ _('English') }}</h2>
|
||||
<ol class="chip-list">
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://atcoder.jp/" target="_blank">AtCoder</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.codechef.com/" target="_blank">CodeChef</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://codeforces.com/" target="_blank">Codeforces</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.spoj.com/" target="_blank">SPOJ</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://www.topcoder.com/" target="_blank">TopCoder</a></li>
|
||||
<li class="chip-list__item"><a class="typo-a" href="https://onlinejudge.org/" target="_blank">OnlineJudge</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
@@ -1,3 +1,5 @@
|
||||
{% set tdocs = payload[0] %}
|
||||
{% set tsdict = payload[1] %}
|
||||
{% if tdocs.length %}
|
||||
<div class="section page--training_main">
|
||||
<div class="section__header">
|
||||
|
||||
Reference in new issue
Block a user