Skip to content

Commit 4fc7b81

Browse files
committed
core: buildContent: add background field
1 parent 6f1a6c8 commit 4fc7b81

4 files changed

Lines changed: 26 additions & 25 deletions

File tree

packages/hydrooj/locales/zh.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Auto format code: 自动格式化代码
9696
Auto organize input: 自动整理输入
9797
Avatar: 头像
9898
Back to contest list: 返回比赛列表
99+
Background: 背景
99100
Be Copied: 被复制
100101
Begin at: 开始于
101102
Begin Date: 开始日期

packages/hydrooj/locales/zh_TW.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ __langname: 正體中文
3030
'Discussion: Terms Of Service': '討論區服務條款'
3131
'First Blood Notice\n{0} solved problem {1} ({2})': '題目首殺提示\n{0} 解決了題目 {1} ({2})'
3232
'Format: category 1, sub category 1.1, sub category 1.2, ..., sub category 1.x, ..., category n, sub category n.1, sub category n.2, ..., sub category n.m, ...': '格式:分類1, 子分類1.1, 子分類1.2, ..., 子分類1.x, ..., 分類n, 子分類n.1, 子分類n.2, ..., 子分類n.m, ...'
33-
Join {0}: 加入 {0}
3433
'No': ''
3534
'Note: Problem title may not be hidden.': '注意:題目標題可能不會被隱藏。'
3635
'Or upload a file:': '或者上傳一個檔案:'
@@ -39,9 +38,6 @@ Join {0}: 加入 {0}
3938
'Solved {0} problems, RP: {1} (No. {2})': '解決了 {0} 道題目,RP: {1} (No. {2})'
4039
'The value `{1}` of {0} already exists.': '{0} 的值 `{1}` 已經存在。'
4140
'Yes': ''
42-
Effects only when Difficulty is not 'Use algorithm calculated'.: 僅當難度不為“使用演算法計算”時才起效。
43-
Split by ',' '.': 由","、"、"或"。"分隔。
44-
What's file?: 什麼是檔案?
4541
(All Problems): (所有題目)
4642
(None): (無)
4743
(Not changed): 未更改
@@ -96,6 +92,7 @@ Auto format code: 自動格式化程式碼
9692
Auto organize input: 自動整理輸入
9793
Avatar: 頭像
9894
Back to contest list: 返回比賽列表
95+
Background: 背景
9996
Be Copied: 被複制
10097
Begin at: 開始於
10198
Begin Date: 開始日期
@@ -321,6 +318,7 @@ Edit problems: 修改題目
321318
Edit Profile: 編輯個人資訊
322319
Edit training plans: 修改訓練計劃
323320
Edit: 編輯
321+
Effects only when Difficulty is not 'Use algorithm calculated'.: 僅當難度不為“使用演算法計算”時才起效。
324322
Email Visibility: Email 可見性
325323
Email: 電子郵件
326324
Enabled: 開啟
@@ -431,6 +429,7 @@ IO: 輸入輸出
431429
Is rated: 計入排名
432430
It works!: 它成了!
433431
Italic: 斜體
432+
Join {0}: 加入 {0}
434433
Join: 加入
435434
Judge Status: 評測狀態
436435
judge_playground: 評測遊樂場
@@ -756,6 +755,7 @@ Solutions per page: 每頁展示的題解數量
756755
Sorry: 對不起
757756
Sort by: 排序
758757
Source type: 來源型別
758+
Split by ',' '.': 由","、"、"或"。"分隔。
759759
Split View: 分屏預覽
760760
Star Topic: 收藏討論
761761
Star: 收藏
@@ -919,6 +919,7 @@ Week: 周
919919
What is domain?: 什麼是域?
920920
What is this?: 這是什麼?
921921
What's domain?: 什麼是域?
922+
What's file?: 什麼是檔案?
922923
What's script?: 什麼是指令碼?
923924
What's this?: 這是什麼?
924925
Whether to show tags in the problem list.: 是否在題目列表中顯示題目的標籤。

packages/hydrooj/src/entry/cli.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { load as loadOptions } from '../options';
99
import { MongoService } from '../service/db';
1010
import { SettingService } from '../settings';
1111
import {
12-
addon, builtinModel, model, service,
12+
addon, builtinModel, locale, model, service,
1313
} from './common';
1414

1515
const argv = cac().parse();
@@ -110,6 +110,7 @@ export async function load(ctx: Context) {
110110
require('../service/bus').apply(ctx);
111111
const pending = global.addons;
112112
const fail = [];
113+
await locale(pending, fail);
113114
await ctx.plugin(MongoService, loadOptions() || {});
114115
await ctx.plugin(SettingService);
115116
await ctx.plugin(SystemModel.Service);

packages/hydrooj/src/lib/content.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface ProblemSource {
2+
background?: string;
23
description?: string;
34
input?: string;
45
output?: string;
@@ -43,36 +44,33 @@ export function buildContent(source: ProblemSource, type: 'markdown' | 'html' =
4344
'',
4445
]).join('\n');
4546
}
46-
return type === 'html'
47-
? [
48-
...source.description ? [`<h2>${_('Description')}</h2>`, source.description] : [],
49-
...source.input ? [`<h2>${_('Input Format')}</h2>`, source.input] : [],
50-
...source.output ? [`<h2>${_('Output Format')}</h2>`, source.output] : [],
51-
...(source.samples || []).map((sample, i) => [
47+
const line = (title: string, s: string) => s ? (type === 'html' ? [`<h2>${_(title)}</h2>`, s] : [`## ${_(title)}`, '', s, '']) : [];
48+
return [
49+
line('Background', source.background),
50+
line('Problem Description', source.description),
51+
line('Input Format', source.input),
52+
line('Output Format', source.output),
53+
type === 'html'
54+
? (source.samples || []).map((sample, i) => [
5255
`<pre><code class="language-input${i + 1}">`,
5356
sample[0],
5457
`</code></pre><pre><code class="language-output${i + 1}">`,
5558
sample[1],
5659
'</code></pre>',
57-
].join('')),
58-
...source.samplesRaw ? [source.samplesRaw] : [],
59-
...source.hint ? [`<h2>${_('Hint')}</h2>`, source.hint] : [],
60-
...source.source ? [`<h2>${_('Source')}</h2>`, source.source] : [],
61-
].join('\n')
62-
: [
63-
...source.description ? [`## ${_('Description')}`, '', source.description, ''] : [],
64-
...source.input ? [`## ${_('Input Format')}`, '', source.input, ''] : [],
65-
...source.output ? [`## ${_('Output Format')}`, '', source.output, ''] : [],
66-
...(source.samples || []).flatMap((sample, i) => [
60+
].join(''))
61+
: (source.samples || []).flatMap((sample, i) => [
62+
'',
6763
`\`\`\`input${i + 1}`,
6864
sample[0],
6965
'```',
66+
'',
7067
`\`\`\`output${i + 1}`,
7168
sample[1],
7269
'```',
70+
'',
7371
]),
74-
...source.samplesRaw ? [source.samplesRaw] : [],
75-
...source.hint ? [`## ${_('Hint')}`, '', source.hint, ''] : [],
76-
...source.source ? [`## ${_('Source')}`, '', source.source, ''] : [],
77-
].join('\n');
72+
...source.samplesRaw ? [source.samplesRaw] : [],
73+
line('Hint', source.hint),
74+
line('Source', source.source),
75+
].flat().join('\n');
7876
}

0 commit comments

Comments
 (0)