core: customizable discussion nodes (#213)

This commit is contained in:
undefined committed 2021-09-19 21:30:11 +08:00
1 parent e5a9d6cb0a
commit 95df2cfaf2
4 files changed
+47 -44

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.36.7", "version": "2.36.8",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+5 -3
View File
@@ -1,3 +1,4 @@
import { load } from 'js-yaml';
import { Dictionary } from 'lodash'; import { Dictionary } from 'lodash';
import moment from 'moment-timezone'; import moment from 'moment-timezone';
import { import {
@@ -8,7 +9,7 @@ import type { DomainDoc } from '../interface';
import avatar from '../lib/avatar'; import avatar from '../lib/avatar';
import paginate from '../lib/paginate'; import paginate from '../lib/paginate';
import { import {
DEFAULT_NODES, PERM, PERMS_BY_FAMILY, PRIV, PERM, PERMS_BY_FAMILY, PRIV,
} from '../model/builtin'; } from '../model/builtin';
import * as discussion from '../model/discussion'; import * as discussion from '../model/discussion';
import domain from '../model/domain'; import domain from '../model/domain';
@@ -72,8 +73,9 @@ class DomainDashboardHandler extends ManageHandler {
} }
async postInitDiscussionNode({ domainId }) { async postInitDiscussionNode({ domainId }) {
for (const category of Object.keys(DEFAULT_NODES)) { const nodes = load(system.get('discussion.nodes'));
for (const item of DEFAULT_NODES[category]) { for (const category of Object.keys(nodes)) {
for (const item of nodes[category]) {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
const curr = await discussion.getNode(domainId, item.name); const curr = await discussion.getNode(domainId, item.name);
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
+40 -40
View File
@@ -276,55 +276,55 @@ export const DEFAULT_NODES = {
], ],
Hydro: [ Hydro: [
{ pic: 'hydro', name: 'Hydro' }, { pic: 'hydro', name: 'Hydro' },
{ pic: null, name: '团队' }, { name: '团队' },
{ pic: null, name: '月赛' }, { name: '月赛' },
{ pic: 'advice', name: '建议' }, { pic: 'advice', name: '建议' },
], ],
数据结构: [ 数据结构: [
{ pic: null, name: '散列表' }, { name: '散列表' },
{ pic: null, name: '搜索树' }, { name: '搜索树' },
{ pic: null, name: '栈和队列' }, { name: '栈和队列' },
{ pic: null, name: '图' }, { name: '图' },
{ pic: null, name: '堆' }, { name: '堆' },
], ],
算法: [ 算法: [
{ pic: null, name: '数论' }, { name: '数论' },
{ pic: null, name: '几何' }, { name: '几何' },
{ pic: null, name: '图论' }, { name: '图论' },
{ pic: null, name: '网络流' }, { name: '网络流' },
{ pic: null, name: '动态规划' }, { name: '动态规划' },
{ pic: null, name: '背包' }, { name: '背包' },
{ pic: null, name: '排序' }, { name: '排序' },
{ pic: null, name: '搜索' }, { name: '搜索' },
{ pic: null, name: '并查集' }, { name: '并查集' },
{ pic: null, name: '贪心' }, { name: '贪心' },
{ pic: null, name: '博弈论' }, { name: '博弈论' },
], ],
在线题库: [ 在线题库: [
{ pic: null, name: 'CodeForces' }, { name: 'CodeForces' },
{ pic: null, name: 'TopCoder' }, { name: 'TopCoder' },
{ pic: null, name: 'POJ' }, { name: 'POJ' },
{ pic: null, name: 'BZOJ' }, { name: 'BZOJ' },
{ pic: null, name: 'USACO' }, { name: 'USACO' },
{ pic: null, name: 'RQNOJ' }, { name: 'RQNOJ' },
{ pic: null, name: 'UOJ' }, { name: 'UOJ' },
{ pic: null, name: 'LOJ' }, { name: 'LOJ' },
{ pic: null, name: '洛谷' }, { name: '洛谷' },
], ],
泛: [ 泛: [
{ pic: null, name: '数学' }, { name: '数学' },
{ pic: null, name: '编程' }, { name: '编程' },
{ pic: null, name: '数据库' }, { name: '数据库' },
{ pic: null, name: 'C' }, { name: 'C' },
{ pic: null, name: 'C++' }, { name: 'C++' },
{ pic: null, name: 'Pascal' }, { name: 'Pascal' },
{ pic: null, name: 'Java' }, { name: 'Java' },
{ pic: null, name: 'PHP' }, { name: 'PHP' },
{ pic: null, name: 'Python' }, { name: 'Python' },
{ pic: null, name: 'Julia' }, { name: 'Julia' },
{ pic: null, name: '游戏' }, { name: '游戏' },
{ pic: null, name: '保送' }, { name: '保送' },
{ pic: null, name: 'ACM' }, { name: 'ACM' },
], ],
}; };
+1
View File
@@ -192,6 +192,7 @@ SystemSetting(
Setting('setting_limits', 'limit.submission', 30, 'number', 'limit.submission', 'Max submission count per minute'), Setting('setting_limits', 'limit.submission', 30, 'number', 'limit.submission', 'Max submission count per minute'),
Setting('setting_limits', 'limit.pretest', 60, 'number', 'limit.pretest', 'Max pretest count per minute'), Setting('setting_limits', 'limit.pretest', 60, 'number', 'limit.pretest', 'Max pretest count per minute'),
Setting('setting_basic', 'default.priv', builtin.PRIV.PRIV_DEFAULT, 'number', 'default.priv', 'Default Privilege', FLAG_PRO), Setting('setting_basic', 'default.priv', builtin.PRIV.PRIV_DEFAULT, 'number', 'default.priv', 'Default Privilege', FLAG_PRO),
Setting('setting_basic', 'discussion.nodes', builtin.DEFAULT_NODES, 'yaml', 'discussion.nodes', 'Discussion Nodes'),
Setting('setting_basic', 'problem.categories', builtin.CATEGORIES, 'yaml', 'problem.categories', 'Problem Categories'), Setting('setting_basic', 'problem.categories', builtin.CATEGORIES, 'yaml', 'problem.categories', 'Problem Categories'),
Setting('setting_basic', 'pagination.problem', 100, 'number', 'pagination.problem', 'Problems per page'), Setting('setting_basic', 'pagination.problem', 100, 'number', 'pagination.problem', 'Problems per page'),
Setting('setting_basic', 'pagination.contest', 20, 'number', 'pagination.contest', 'Contests per page'), Setting('setting_basic', 'pagination.contest', 20, 'number', 'pagination.contest', 'Contests per page'),