mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: 支持在题目中通过 file://name 索引至附加文件
This commit is contained in:
1 parent
99efc98d2d
commit
252a251ce4
7 files changed
+14
-34
No files matched your search
@@ -24,7 +24,6 @@ home_account: Account Settings
|
||||
home_domain_account: Profile @ Domain
|
||||
home_domain_create: Create Domain
|
||||
home_domain: My Domains
|
||||
home_file: My Files
|
||||
home_messages: Messages
|
||||
home_preference: Preference
|
||||
home_security: Security
|
||||
|
||||
@@ -325,7 +325,6 @@ home_account: 계정
|
||||
home_domain_account: 그룹 계정
|
||||
home_domain_create: 그룹 생성
|
||||
home_domain: 그룹
|
||||
home_file: 파일
|
||||
home_messages: 메시지
|
||||
home_preference: 설정
|
||||
home_security: 보안
|
||||
|
||||
@@ -328,7 +328,6 @@ home_account: 账户设置
|
||||
home_domain_account: 当前域的设置
|
||||
home_domain_create: 创建域
|
||||
home_domain: 我的域
|
||||
home_file: 我的文件
|
||||
home_messages: 站内消息
|
||||
home_preference: 偏好设置
|
||||
home_security: 安全设置
|
||||
@@ -530,6 +529,7 @@ Problem Tags Visibility: 题目标签可见性
|
||||
problem_create: 创建题目
|
||||
problem_detail: 题目详情
|
||||
problem_edit: 编辑题目
|
||||
problem_files: 题目文件
|
||||
problem_import: 导入题目
|
||||
problem_main: 题库
|
||||
problem_settings: 题目设置
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.15.11",
|
||||
"version": "2.15.12",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
@@ -24,7 +24,7 @@
|
||||
"koa-static-cache": "^5.1.3",
|
||||
"lodash": "^4.17.20",
|
||||
"lru-cache": "^6.0.0",
|
||||
"minio": "7.0.18",
|
||||
"minio": "7.0.17",
|
||||
"moment-timezone": "^0.5.32",
|
||||
"mongodb": "^3.6.3",
|
||||
"nodemailer": "^6.4.17",
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as bus from '../service/bus';
|
||||
import {
|
||||
Route, Connection, Handler, ConnectionHandler, param, Types,
|
||||
} from '../service/server';
|
||||
import storage from '../service/storage';
|
||||
import * as misc from '../lib/misc';
|
||||
import { md5 } from '../lib/crypto';
|
||||
import * as mail from '../lib/mail';
|
||||
@@ -210,7 +209,7 @@ class HomeSettingsHandler extends Handler {
|
||||
this.response.body.settings = setting.ACCOUNT_SETTINGS;
|
||||
} else if (category === 'domain') {
|
||||
this.response.body.settings = setting.DOMAIN_USER_SETTINGS;
|
||||
} else throw new NotFoundError();
|
||||
} else throw new NotFoundError(category);
|
||||
}
|
||||
|
||||
async post(args: any) {
|
||||
@@ -378,28 +377,6 @@ class HomeMessagesConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
class HomeFileHandler extends Handler {
|
||||
async get() {
|
||||
const path = [
|
||||
['Hydro', 'homepage'],
|
||||
['domain_file', null],
|
||||
];
|
||||
const ufdocs = await storage.list(`user/${this.user._id}/`);
|
||||
this.response.template = 'home_file.html';
|
||||
this.response.body = { ufdocs, path };
|
||||
}
|
||||
|
||||
@param('ufid', Types.String)
|
||||
async postDelete(domainId: string, target: string) {
|
||||
if (!target.startsWith(`user/${this.user._id}`)) this.checkPriv(PRIV.PRIV_DELETE_FILE);
|
||||
else this.checkPriv(PRIV.PRIV_DELETE_FILE_SELF);
|
||||
const { size } = await storage.getMeta(target);
|
||||
await storage.del(target);
|
||||
await user.inc(this.user._id, 'usage', -size);
|
||||
this.back();
|
||||
}
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
Route('homepage', '/', HomeHandler);
|
||||
Route('home_security', '/home/security', HomeSecurityHandler, PRIV.PRIV_USER_PROFILE);
|
||||
@@ -408,7 +385,6 @@ async function apply() {
|
||||
Route('home_domain', '/home/domain', HomeDomainHandler, PRIV.PRIV_USER_PROFILE);
|
||||
Route('home_domain_create', '/home/domain/create', HomeDomainCreateHandler, PRIV.PRIV_CREATE_DOMAIN);
|
||||
Route('home_messages', '/home/messages', HomeMessagesHandler, PRIV.PRIV_USER_PROFILE);
|
||||
Route('home_file', '/home/file', HomeFileHandler, PRIV.PRIV_USER_PROFILE);
|
||||
Connection('home_messages_conn', '/home/messages-conn', HomeMessagesConnectionHandler, PRIV.PRIV_USER_PROFILE);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import { NotFoundError } from '../error';
|
||||
import { Route, Handler } from '../service/server';
|
||||
|
||||
class NotFoundHandler extends Handler {
|
||||
async prepare() {
|
||||
throw new NotFoundError();
|
||||
prepare() {
|
||||
throw new NotFoundError(this.request.path);
|
||||
}
|
||||
|
||||
all() { }
|
||||
|
||||
@@ -190,7 +190,13 @@ export class ProblemDetailHandler extends ProblemHandler {
|
||||
};
|
||||
}
|
||||
|
||||
async get(...args: any[]) { } // eslint-disable-line
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async get(..._args: any[]) {
|
||||
// Navigate to current additional file download
|
||||
// e.g.  will navigate to 
|
||||
this.response.body.pdoc.content = this.response.body.pdoc.content
|
||||
.replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`);
|
||||
}
|
||||
|
||||
@param('pid', Types.UnsignedInt)
|
||||
async postRejudge(domainId: string, pid: number) {
|
||||
@@ -207,7 +213,7 @@ export class ProblemDetailHandler extends ProblemHandler {
|
||||
export class ProblemExportHandler extends ProblemDetailHandler {
|
||||
async get() {
|
||||
const hasPerm = (this.user._id === this.pdoc.owner && this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA_SELF))
|
||||
|| this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA_SELF);
|
||||
|| this.user.hasPerm(PERM.PERM_READ_PROBLEM_DATA);
|
||||
const pdoc = pick(this.pdoc, ['pid', 'acMsg', 'content', 'config', 'title', 'html', 'tag', 'category']);
|
||||
const zip = new AdmZip();
|
||||
if (hasPerm) {
|
||||
|
||||
Reference in new issue
Block a user