diff --git a/README.md b/README.md index 634684677..161fbebe7 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ Hydro 用户群:1085853538

更新日志(点击展开)

-## Hydro 4.17.0 / UI 4.55.0 +## Hydro 4.17.1 / UI 4.55.1 - core: 限制显示名长度 - core: 支持调整代码长度限制 diff --git a/framework/framework/package.json b/framework/framework/package.json index 8071672eb..9848d03d5 100644 --- a/framework/framework/package.json +++ b/framework/framework/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/framework", - "version": "0.1.0", + "version": "0.1.1", "main": "index.ts", "license": "MIT", "peerDependencies": { diff --git a/packages/elastic/index.ts b/packages/elastic/index.ts index 60d51d6ec..5f9db740d 100644 --- a/packages/elastic/index.ts +++ b/packages/elastic/index.ts @@ -11,7 +11,11 @@ const processDocument = (doc: Partial) => { doc.content &&= doc.content.replace(/[[\]【】()()]/g, ' '); doc.title &&= doc.title.replace(/[[\]【】()()]/g, ' ') .replace(/([a-zA-Z]{2,})(\d+)/, '$1$2 $1 $2'); - doc.pid &&= doc.pid.replace(/([a-zA-Z]{2,})(\d+)/, '$1$2 $1 $2'); + if (doc.pid?.includes('-')) { + const ns = doc.pid.split('-')[0]; + doc.tag.push(ns); + } + doc.pid &&= doc.pid.replace(/([a-zA-Z]{2,})(\d+)/, '$1$2 $1 $2').replace(/-/g, ' '); return _.omit(doc, indexOmit); }; diff --git a/packages/elastic/package.json b/packages/elastic/package.json index fe71a0a18..154ba1888 100644 --- a/packages/elastic/package.json +++ b/packages/elastic/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/elastic-search", - "version": "1.1.7", + "version": "1.1.8", "main": "index.ts", "repository": "https://github.com/hydro-dev/Hydro", "author": "undefined ", diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 90b40baa0..ae596ef9e 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "4.17.0", + "version": "4.17.1", "bin": "bin/hydrooj.js", "main": "src/plugin-api", "module": "src/plugin-api", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 481209cb3..b9a22fee8 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -109,7 +109,7 @@ export class ProblemMainHandler extends Handler { const psdict = {}; const search = global.Hydro.lib.problemSearch || defaultSearch; const parsed = parser.parse(q, { - keywords: ['category', 'difficulty'], + keywords: ['category', 'difficulty', 'namespace'], offsets: false, alwaysArray: true, tokenize: true, @@ -120,6 +120,12 @@ export class ProblemMainHandler extends Handler { query.difficulty = { $in: parsed.difficulty.map(Number) }; } if (category.length) query.$and = category.map((tag) => ({ tag })); + if (parsed.namespace?.length) { + const mappedPrefix = this.domain.namespaces?.[parsed.namespace[0]]; + query.$and ||= []; + if (mappedPrefix) query.$and.push({ sort: new RegExp(`^${mappedPrefix}-`) }); + else query.$and.push({ tag: parsed.namespace[0] }); + } if (text) category.push(text); if (category.length) this.UiContext.extraTitleContent = category.join(','); let total = 0; diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index 235e4cd18..b0dcf4ff3 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.55.0", + "version": "4.55.1", "author": "undefined ", "license": "AGPL-3.0", "main": "index.ts", diff --git a/packages/ui-default/templates/partials/problem_list.html b/packages/ui-default/templates/partials/problem_list.html index 89d5e3059..c1c8b6edf 100644 --- a/packages/ui-default/templates/partials/problem_list.html +++ b/packages/ui-default/templates/partials/problem_list.html @@ -54,7 +54,7 @@ {% endif %} {% endif %} - + {{ problem.render_problem_title(pdoc) }} {{ pdoc.nAccept }} / {{ pdoc.nSubmit }} diff --git a/packages/vjudge/package.json b/packages/vjudge/package.json index 9fe913607..e707f85b1 100644 --- a/packages/vjudge/package.json +++ b/packages/vjudge/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/vjudge", - "version": "1.9.12", + "version": "1.9.13", "description": "Submit problems to remote oj", "main": "./src/index.ts", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/vjudge/src/providers/hustoj.ts b/packages/vjudge/src/providers/hustoj.ts index 563fc4487..6bf4a3e12 100644 --- a/packages/vjudge/src/providers/hustoj.ts +++ b/packages/vjudge/src/providers/hustoj.ts @@ -233,195 +233,6 @@ export class HUSTOJ extends BasicFetcher implements IBasicProvider { } } -export class YBT extends HUSTOJ { - updateConfig() { - // this.LANGUAGES = { - // cc: 1, - // c: 2, - // java: 3, - // pas: 4, - // py: 5, - // py3: 5, - // }; - this.config.login.extra = { login: '登录' }; - this.config.submit = { - endpoint: '/action.php', - idField: 'problem_id', - langField: 'language', - codeField: 'source', - extra: { submit: '提交', user_id: this.account.handle }, - tooFrequent: '提交频繁啦!', - }; - this.config.ceInfo = { - endpoint: '/show_ce_info.php?runid={rid}', - matcher: /(.*?)<\/td>/gmi, - }; - this.config.server = 'http://ybt.ssoier.cn:8088/'; - } - - async waitForSubmission(rid, next, end) { - const url = `/statusx1.php?runidx=${rid}`; - let res = await this.get(url); - let staText = res.text.split(':'); - while (isProcessing(staText[4])) { - next({ status: STATUS.STATUS_JUDGING, progress: 0 }); - await sleep(1000); - res = await this.get(url); - staText = res.text.split(':'); - } - if (VERDICT[staText[4]] === STATUS.STATUS_COMPILE_ERROR) { - const ceInfoUrl = this.config.ceInfo.endpoint.replace('{rid}', rid); - let compilerText = 'Cannot get compiler text'; - if (this.config.ceInfo.matcher) { - const resp = await this.get(ceInfoUrl); - const match = this.config.ceInfo.matcher.exec(resp.text); - if (match) compilerText = decodeURIComponent(match[1]).replace(/\n/g, '').replace(//g, '\n').replace(/\n\n/g, '\n'); - } else if (this.config.ceInfo.selector) { - const { document } = await this.html(ceInfoUrl); - const match = document.querySelector(this.config.ceInfo.selector)?.innerHTML; - if (match) compilerText = decodeURIComponent(match).replace(/\n/g, '').replace(//g, '\n').replace(/\n\n/g, '\n'); - } - end({ - status: STATUS.STATUS_COMPILE_ERROR, - score: 0, - time: 0, - memory: 0, - compilerText, - }); - return; - } - const staText4 = staText[4].split('|'); - const staText5 = staText[5].split(','); - let totalTime = 0; - let totalMem = 0; - let totalScore = 0; - let totalStatus = STATUS.STATUS_WRONG_ANSWER; - for (const i in staText5) { - if (staText5[i]) { - let score; - const staText5i = staText5[i].split('|'); - if (VERDICT[staText5i[0]] === STATUS.STATUS_ACCEPTED) { - score = 100; - totalScore += score; - } else score = 0; - const staText5i1 = staText5i[1].split('_'); - totalMem += +staText5i1[0]; - totalTime += +staText5i1[1]; - next({ - status: STATUS.STATUS_JUDGING, - case: { - status: VERDICT[staText5i[0]], - score, - time: +staText5i1[1], - memory: +staText5i1[0], - }, - progress: 99, - }); - } - } - if (VERDICT[staText4[0]] === STATUS.STATUS_ACCEPTED) { - totalScore = 100; - totalStatus = STATUS.STATUS_ACCEPTED; - } else if (totalScore >= 100) { - totalScore = 0; - } - end({ - status: totalStatus, - score: totalScore, - time: totalTime, - memory: totalMem, - }); - } -} - -// 已弃用。请直接从 https://hydro.ac/ybtbas.zip 下载题库文件并按照压缩包内说明导入系统。 -export class YBTBAS extends YBT { - static langs = { - ybtbas: { - display: 'YBTBAS', - hidden: true, - remote: 'ybtbas', - }, - 'ybtbas.7': { - display: 'G++14', - monaco: 'cpp', - highlight: 'cpp', - }, - 'ybtbas.1': { - display: 'G++', - monaco: 'cpp', - highlight: 'cpp', - }, - 'ybtbas.2': { - display: 'GCC', - monaco: 'cpp', - highlight: 'cpp', - }, - 'ybtbas.3': { - display: 'Java', - monaco: 'java', - highlight: 'java', - }, - 'ybtbas.4': { - display: 'Pascal', - monaco: 'pas', - highlight: 'pascal', - }, - 'ybtbas.5': { - display: 'Python', - monaco: 'python', - highlight: 'python', - }, - }; - - updateConfig() { - this.config.login.check = '退出登录'; - this.config.login.extra = async () => { - const captcha = await this.get('/login_xx.php').responseType('arraybuffer'); - if (captcha.headers['set-cookie']) this.setCookie(captcha.headers['set-cookie']); - if (!global.parseCaptcha) await sleep(30000); - if (!global.parseCaptcha) return { login: '登录' }; - return { - login: '登录', - auth: await global.parseCaptcha(captcha.body).toLowerCase(), - }; - }; - this.config.submit = { - endpoint: '/action.php', - idField: 'problem_id', - langField: 'language', - codeField: 'source', - extra: { submit: '提交', user_id: this.account.handle }, - tooFrequent: '提交频繁啦!', - rid: /runidx=([0-9]+)/mi, - noRefetch: true, - }; - this.config.ceInfo = { - endpoint: '/show_ce_info.php?runid={rid}', - selector: 'table[width="900px"]>tbody>tr>td>div>center>table>tbody>tr>td', - }; - this.config.server = 'http://bas.ssoier.cn:8086/'; - sleep(30000).then(() => { - // Prevent cookie expiration - if (!global.parseCaptcha) setInterval(() => this.get('/'), 60000); - }); - } -} - -export class BZOJ extends HUSTOJ { - updateConfig() { - this.config.login = { - endpoint: '/login.php', - usernameField: 'user_id', - passwordField: 'password', - extra: { submit: 'Submit' }, - }; - this.config.submit.tooFrequent = 'You should not submit more than twice in 10 seconds.....'; - this.config.submit.rid = /Submit_Time<\/td><\/tr>\n([0-9]+)/igm; - this.config.ceInfo.matcher = /
([\s\S]*?)<\/pre>/im;
-    }
-}
-
 export class XJOI extends HUSTOJ {
     updateConfig() {
         // this.LANGUAGES = { cc: 'g++', c: 'gcc', pas: 'fpc' };
diff --git a/packages/vjudge/src/providers/index.ts b/packages/vjudge/src/providers/index.ts
index b35b14bfe..53046ed1b 100644
--- a/packages/vjudge/src/providers/index.ts
+++ b/packages/vjudge/src/providers/index.ts
@@ -2,11 +2,8 @@ import codeforces from './codeforces';
 import csgoj from './csgoj';
 import hduoj from './hduoj';
 import {
-    BZOJ as bzoj,
     HUSTOJ as hustoj,
     XJOI as xjoi,
-    YBT as ybt,
-    YBTBAS as ybtbas,
 } from './hustoj';
 import poj from './poj';
 import spoj from './spoj';
@@ -20,10 +17,7 @@ const vjudge: Record = {
     spoj,
     uoj,
     hustoj,
-    bzoj,
     xjoi,
-    ybt,
-    ybtbas,
     hduoj,
     yacs,
 };