mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
Merge branch 'master' into remove-union
This commit is contained in:
17 files changed
+103
-70
No files matched your search
@@ -23,7 +23,7 @@ import serializer from './serializer';
|
|||||||
|
|
||||||
export { WebSocket, WebSocketServer } from 'ws';
|
export { WebSocket, WebSocketServer } from 'ws';
|
||||||
|
|
||||||
const kHandler = Symbol.for('hydro.handler');
|
export const kHandler = Symbol.for('hydro.handler');
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
|
||||||
export function encodeRFC5987ValueChars(str: string) {
|
export function encodeRFC5987ValueChars(str: string) {
|
||||||
@@ -111,7 +111,7 @@ export interface UserModel {
|
|||||||
|
|
||||||
export interface HandlerCommon { }
|
export interface HandlerCommon { }
|
||||||
export class HandlerCommon {
|
export class HandlerCommon {
|
||||||
static [kHandler] = true;
|
static [kHandler]: string | boolean = true;
|
||||||
session: Record<string, any>;
|
session: Record<string, any>;
|
||||||
args: Record<string, any>;
|
args: Record<string, any>;
|
||||||
request: HydroRequest;
|
request: HydroRequest;
|
||||||
@@ -313,7 +313,7 @@ function executeMiddlewareStack(context: any, middlewares: { name: string, func:
|
|||||||
return dispatch(0);
|
return dispatch(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface WebServiceConfig {
|
export interface WebServiceConfig {
|
||||||
keys: string[];
|
keys: string[];
|
||||||
proxy: boolean;
|
proxy: boolean;
|
||||||
cors?: string;
|
cors?: string;
|
||||||
@@ -459,6 +459,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
|||||||
const h = new HandlerClass(ctx, this.ctx);
|
const h = new HandlerClass(ctx, this.ctx);
|
||||||
ctx.handler = h;
|
ctx.handler = h;
|
||||||
const method = ctx.method.toLowerCase();
|
const method = ctx.method.toLowerCase();
|
||||||
|
const name = (typeof HandlerClass[kHandler] === 'string' ? HandlerClass[kHandler] : HandlerClass.name).replace(/Handler$/, '');
|
||||||
try {
|
try {
|
||||||
const operation = (method === 'post' && ctx.request.body?.operation)
|
const operation = (method === 'post' && ctx.request.body?.operation)
|
||||||
? `_${ctx.request.body.operation}`.replace(/_([a-z])/gm, (s) => s[1].toUpperCase())
|
? `_${ctx.request.body.operation}`.replace(/_([a-z])/gm, (s) => s[1].toUpperCase())
|
||||||
@@ -479,7 +480,6 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
|||||||
throw new MethodNotAllowedError(method);
|
throw new MethodNotAllowedError(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = HandlerClass.name.replace(/Handler$/, '');
|
|
||||||
const steps = [
|
const steps = [
|
||||||
'log/__init', 'init', 'handler/init',
|
'log/__init', 'init', 'handler/init',
|
||||||
`handler/before-prepare/${name}#${method}`, `handler/before-prepare/${name}`, 'handler/before-prepare',
|
`handler/before-prepare/${name}#${method}`, `handler/before-prepare/${name}`, 'handler/before-prepare',
|
||||||
@@ -516,7 +516,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
try {
|
||||||
await this.ctx.serial(`handler/error/${HandlerClass.name.replace(/Handler$/, '')}`, h, e);
|
await this.ctx.serial(`handler/error/${name}`, h, e);
|
||||||
await this.ctx.serial('handler/error', h, e);
|
await this.ctx.serial('handler/error', h, e);
|
||||||
await h.onerror(e);
|
await h.onerror(e);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -596,7 +596,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
|||||||
|
|
||||||
private register(type: 'route' | 'conn', routeName: string, path: string, HandlerClass: any, ...permPrivChecker) {
|
private register(type: 'route' | 'conn', routeName: string, path: string, HandlerClass: any, ...permPrivChecker) {
|
||||||
if (!HandlerClass?.[kHandler] || !isClass(HandlerClass)) throw new Error('Invalid registration.');
|
if (!HandlerClass?.[kHandler] || !isClass(HandlerClass)) throw new Error('Invalid registration.');
|
||||||
const name = HandlerClass.name;
|
const name = typeof HandlerClass[kHandler] === 'string' ? HandlerClass[kHandler] : HandlerClass.name;
|
||||||
if (this.registrationCount[name] && this.registry[name] !== HandlerClass) {
|
if (this.registrationCount[name] && this.registry[name] !== HandlerClass) {
|
||||||
logger.warn('Route with name %s already exists.', name);
|
logger.warn('Route with name %s already exists.', name);
|
||||||
}
|
}
|
||||||
@@ -697,7 +697,7 @@ declare module 'cordis' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apply(ctx: Context, config) {
|
export async function apply(ctx: Context, config: WebServiceConfig) {
|
||||||
ctx.provide('server', undefined, true);
|
ctx.provide('server', undefined, true);
|
||||||
ctx.server = new WebService(ctx, config);
|
ctx.server = new WebService(ctx, config);
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ class FpsProblemImportHandler extends Handler {
|
|||||||
if (!result?.fps) throw new BadRequestError('Selected file is not a valid FPS problemset.');
|
if (!result?.fps) throw new BadRequestError('Selected file is not a valid FPS problemset.');
|
||||||
for (const p of result.fps.item) {
|
for (const p of result.fps.item) {
|
||||||
const markdown = [p.description?.[0], p.input?.[0], p.output?.[0], p.hint?.[0]].some((i) => i?.includes('[md]'));
|
const markdown = [p.description?.[0], p.input?.[0], p.output?.[0], p.hint?.[0]].some((i) => i?.includes('[md]'));
|
||||||
const content = buildContent({
|
let content = buildContent({
|
||||||
description: p.description?.[0],
|
description: p.description?.[0],
|
||||||
input: p.input?.[0],
|
input: p.input?.[0],
|
||||||
output: p.output?.[0],
|
output: p.output?.[0],
|
||||||
@@ -62,6 +62,14 @@ class FpsProblemImportHandler extends Handler {
|
|||||||
addTestdata(p.test_input[2 * i + 1], `${i + 1}`, 'out');
|
addTestdata(p.test_input[2 * i + 1], `${i + 1}`, 'out');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (p.img?.length) {
|
||||||
|
for (const img of p.img) {
|
||||||
|
const filename = String.random(8) + img.src[0].split('/').pop().split('.').pop();
|
||||||
|
tasks.push(ProblemModel.addAdditionalFile(domainId, pid, filename, Buffer.from(img.base64[0], 'base64')));
|
||||||
|
content = content.replace(img.src[0], `file://${filename}`);
|
||||||
|
}
|
||||||
|
await ProblemModel.edit(domainId, pid, { content });
|
||||||
|
}
|
||||||
await Promise.all(tasks);
|
await Promise.all(tasks);
|
||||||
if (p.solution) {
|
if (p.solution) {
|
||||||
let s = '';
|
let s = '';
|
||||||
|
|||||||
@@ -44,7 +44,12 @@ function judgeCase(c: NormalizedCase) {
|
|||||||
user_stderr: fileIds.stderr ? { fileId: fileIds.stderr } : { content: '' },
|
user_stderr: fileIds.stderr ? { fileId: fileIds.stderr } : { content: '' },
|
||||||
score: c.score,
|
score: c.score,
|
||||||
detail,
|
detail,
|
||||||
env: { ...ctx.env, HYDRO_TESTCASE: c.id.toString() },
|
env: {
|
||||||
|
...ctx.env,
|
||||||
|
HYDRO_TESTCASE: c.id.toString(),
|
||||||
|
HYDRO_TIME_USAGE: time.toString(),
|
||||||
|
HYDRO_MEMORY_USAGE: Math.floor(memory / 1024).toString(),
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} else if (status === STATUS.STATUS_RUNTIME_ERROR && code && detail) {
|
} else if (status === STATUS.STATUS_RUNTIME_ERROR && code && detail) {
|
||||||
|
|||||||
@@ -121,14 +121,12 @@ export class HomeHandler extends Handler {
|
|||||||
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)) return [[], {}];
|
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)) return [[], {}];
|
||||||
const psdocs = await ProblemModel.getMultiStatus(domainId, { uid: this.user._id, star: true })
|
const psdocs = await ProblemModel.getMultiStatus(domainId, { uid: this.user._id, star: true })
|
||||||
.sort('_id', 1).limit(limit).toArray();
|
.sort('_id', 1).limit(limit).toArray();
|
||||||
const psdict = {};
|
|
||||||
for (const psdoc of psdocs) psdict[psdoc.docId] = psdoc;
|
|
||||||
const pdict = await ProblemModel.getList(
|
const pdict = await ProblemModel.getList(
|
||||||
domainId, psdocs.map((pdoc) => pdoc.docId),
|
domainId, psdocs.map((pdoc) => pdoc.docId),
|
||||||
this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id, false,
|
this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id, false,
|
||||||
);
|
);
|
||||||
const pdocs = Object.keys(pdict).filter((i) => +i).map((i) => pdict[i]);
|
const pdocs = Object.keys(pdict).filter((i) => +i).map((i) => pdict[i]);
|
||||||
return [pdocs, psdict];
|
return [pdocs];
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRecentProblems(domainId: string, limit = 10) {
|
async getRecentProblems(domainId: string, limit = 10) {
|
||||||
|
|||||||
@@ -186,18 +186,6 @@ export class ProblemMainHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@param('pid', Types.UnsignedInt)
|
|
||||||
async postStar(domainId: string, pid: number) {
|
|
||||||
await problem.setStar(domainId, pid, this.user._id, true);
|
|
||||||
this.back({ star: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
@param('pid', Types.UnsignedInt)
|
|
||||||
async postUnstar(domainId: string, pid: number) {
|
|
||||||
await problem.setStar(domainId, pid, this.user._id, false);
|
|
||||||
this.back({ star: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
@param('pids', Types.NumericArray)
|
@param('pids', Types.NumericArray)
|
||||||
@param('target', Types.String)
|
@param('target', Types.String)
|
||||||
async postCopy(domainId: string, pids: number[], target: string) {
|
async postCopy(domainId: string, pids: number[], target: string) {
|
||||||
@@ -438,6 +426,12 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
|
|||||||
await problem.del(this.pdoc.domainId, this.pdoc.docId);
|
await problem.del(this.pdoc.domainId, this.pdoc.docId);
|
||||||
this.response.redirect = this.url('problem_main');
|
this.response.redirect = this.url('problem_main');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@param('star', Types.Boolean)
|
||||||
|
async postStar(domainId: string, star: boolean) {
|
||||||
|
await problem.setStar(domainId, this.pdoc.docId, this.user._id, star);
|
||||||
|
this.back({ star });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ProblemSubmitHandler extends ProblemDetailHandler {
|
export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ declare module '../context' {
|
|||||||
i18n: I18nService;
|
i18n: I18nService;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
declare module '../service/bus' {
|
||||||
|
interface EventMap {
|
||||||
|
'app/i18n/update': (lang: string) => void;
|
||||||
|
}
|
||||||
|
}
|
||||||
declare global {
|
declare global {
|
||||||
interface String {
|
interface String {
|
||||||
translate: (...languages: string[]) => string;
|
translate: (...languages: string[]) => string;
|
||||||
@@ -22,6 +27,7 @@ class I18nService extends Service {
|
|||||||
this.ctx.effect(() => {
|
this.ctx.effect(() => {
|
||||||
translations[lang] ||= [];
|
translations[lang] ||= [];
|
||||||
translations[lang].unshift(content);
|
translations[lang].unshift(content);
|
||||||
|
this.ctx.emit('app/i18n/update', lang);
|
||||||
return () => {
|
return () => {
|
||||||
translations[lang] = translations[lang].filter((i) => i !== content);
|
translations[lang] = translations[lang].filter((i) => i !== content);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -124,12 +124,12 @@ class MongoService {
|
|||||||
return [pageDocs, numPages, count];
|
return [pageDocs, numPages, count];
|
||||||
}
|
}
|
||||||
|
|
||||||
async ranked<T extends Record<string, any>>(cursor: FindCursor<T>, equ: (a: T, b: T) => boolean): Promise<[number, T][]> {
|
async ranked<T extends Record<string, any>>(cursor: T[] | FindCursor<T>, equ: (a: T, b: T) => boolean): Promise<[number, T][]> {
|
||||||
let last = null;
|
let last = null;
|
||||||
let r = 0;
|
let r = 0;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const results = [];
|
const results = [];
|
||||||
const docs = await cursor.toArray();
|
const docs = cursor instanceof Array ? cursor : await cursor.toArray();
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
if ((doc as any).unrank) {
|
if ((doc as any).unrank) {
|
||||||
results.push([0, doc]);
|
results.push([0, doc]);
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
/* eslint-disable github/array-foreach */
|
/* eslint-disable github/array-foreach */
|
||||||
import {
|
import {
|
||||||
$, addPage, AutoloadPage, request,
|
$, addPage, AutoloadPage, i18n, Notification, request,
|
||||||
} from '@hydrooj/ui-default';
|
} from '@hydrooj/ui-default';
|
||||||
|
|
||||||
/* global DocsAPI */
|
/* global DocsAPI */
|
||||||
|
|
||||||
let loaded = false;
|
let loaded = false;
|
||||||
async function load() {
|
function load(): Promise<boolean> {
|
||||||
if (loaded) return Promise.resolve();
|
if (loaded) return Promise.resolve(true);
|
||||||
|
if (!UiContext.onlyofficeApi) {
|
||||||
|
console.error('Onlyoffice api not set');
|
||||||
|
Notification.error(i18n('onlyoffice.not_configured'));
|
||||||
|
return Promise.resolve(false);
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const scriptElement = document.createElement('script');
|
const scriptElement = document.createElement('script');
|
||||||
scriptElement.src = UiContext.onlyofficeApi;
|
scriptElement.src = UiContext.onlyofficeApi;
|
||||||
scriptElement.async = true;
|
scriptElement.async = true;
|
||||||
document.head.appendChild(scriptElement);
|
document.head.appendChild(scriptElement);
|
||||||
scriptElement.onload = resolve;
|
scriptElement.onload = () => resolve(true);
|
||||||
scriptElement.onerror = reject;
|
scriptElement.onerror = reject;
|
||||||
loaded = true;
|
loaded = true;
|
||||||
});
|
});
|
||||||
@@ -40,9 +44,16 @@ const getEles = (types: string[]) => types.flatMap((type) => $(`div[data-${type}
|
|||||||
|
|
||||||
addPage(new AutoloadPage('onlyoffice', async () => {
|
addPage(new AutoloadPage('onlyoffice', async () => {
|
||||||
const all = getEles(['doc', 'docx', 'cell', 'xls', 'xlsx', 'slide', 'ppt', 'pptx', 'pdf']);
|
const all = getEles(['doc', 'docx', 'cell', 'xls', 'xlsx', 'slide', 'ppt', 'pptx', 'pdf']);
|
||||||
if (all.length) await load();
|
if (!all.length) return;
|
||||||
|
try {
|
||||||
|
const result = await load();
|
||||||
|
if (!result) return;
|
||||||
getEles(['doc', 'docx']).forEach(loader('word'));
|
getEles(['doc', 'docx']).forEach(loader('word'));
|
||||||
getEles(['cell', 'xls', 'xlsx']).forEach(loader('cell'));
|
getEles(['cell', 'xls', 'xlsx']).forEach(loader('cell'));
|
||||||
getEles(['slide', 'ppt', 'pptx']).forEach(loader('slide'));
|
getEles(['slide', 'ppt', 'pptx']).forEach(loader('slide'));
|
||||||
getEles(['pdf']).forEach(loader('pdf'));
|
getEles(['pdf']).forEach(loader('pdf'));
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`Failed to initialize onlyoffice: ${e.message}`);
|
||||||
|
Notification.error(i18n('onlyoffice.inialize_fail', e.message));
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
@@ -84,6 +84,18 @@ export function apply(ctx: Context) {
|
|||||||
enumerable: false,
|
enumerable: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ctx.inject(['i18n'], (c) => {
|
||||||
|
c.i18n.load('en', {
|
||||||
|
'onlyoffice.not_configured': 'Onlyoffice API not configured.',
|
||||||
|
'onlyoffice.initialize_fail': 'Failed to initialize onlyoffice: {0}',
|
||||||
|
});
|
||||||
|
c.i18n.load('zh', {
|
||||||
|
'onlyoffice.not_configured': 'Onlyoffice 未配置。自行安装 onlyoffice 软件或是使用外部提供的 API。',
|
||||||
|
'onlyoffice.initialize_fail': '初始化 onlyoffice 失败: {0}',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
ctx.Route('onlyoffice-jwt', '/onlyoffice-jwt', OnlyofficeJWTHandler);
|
ctx.Route('onlyoffice-jwt', '/onlyoffice-jwt', OnlyofficeJWTHandler);
|
||||||
if (SystemModel.get('onlyoffice.pdf')) {
|
if (SystemModel.get('onlyoffice.pdf')) {
|
||||||
ctx.provideModule('richmedia', 'pdf', {
|
ctx.provideModule('richmedia', 'pdf', {
|
||||||
|
|||||||
@@ -145,5 +145,6 @@ export async function apply(ctx: Context) {
|
|||||||
ctx.on('system/setting', () => triggerHotUpdate());
|
ctx.on('system/setting', () => triggerHotUpdate());
|
||||||
ctx.on('app/watch/change', triggerHotUpdate);
|
ctx.on('app/watch/change', triggerHotUpdate);
|
||||||
ctx.on('app/watch/unlink', triggerHotUpdate);
|
ctx.on('app/watch/unlink', triggerHotUpdate);
|
||||||
|
ctx.on('app/i18n/update', debouncedBuildUI);
|
||||||
debouncedBuildUI();
|
debouncedBuildUI();
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import { AutoloadPage } from 'vj/misc/Page';
|
import { AutoloadPage } from 'vj/misc/Page';
|
||||||
import { request } from 'vj/utils';
|
import { request, tpl } from 'vj/utils';
|
||||||
|
|
||||||
function setStarButtonState($starButton: JQuery<any>, star: boolean) {
|
function setStarButtonState($starButton: JQuery<any>, star: boolean) {
|
||||||
if (star) {
|
if (star) {
|
||||||
@@ -11,6 +11,29 @@ function setStarButtonState($starButton: JQuery<any>, star: boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const starPage = new AutoloadPage('starPage', () => {
|
const starPage = new AutoloadPage('starPage', () => {
|
||||||
|
function render(container) {
|
||||||
|
const eles = $(container).find('[data-star]');
|
||||||
|
for (const el of eles) {
|
||||||
|
if ($(el).find('.star-form')) continue;
|
||||||
|
const pid = $(el).closest('[data-pid]').data('pid');
|
||||||
|
const star = $(el).data('star') === 'true' ? 1 : 0;
|
||||||
|
if (!pid) continue;
|
||||||
|
$(tpl`<form class="form--inline" action="/d/${UiContext.domain._id}/p/${pid}" method="post">
|
||||||
|
<input type="hidden" name="operation" value="star">
|
||||||
|
<input type="hidden" name="star" value="${star ? 'false' : 'true'}">
|
||||||
|
<button class="star${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>`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render(document);
|
||||||
|
$(document).on('vjContentNew', (ev) => {
|
||||||
|
render(ev.target);
|
||||||
|
});
|
||||||
|
|
||||||
$(document).on('click', '.star', (ev) => {
|
$(document).on('click', '.star', (ev) => {
|
||||||
const $button = $(ev.currentTarget);
|
const $button = $(ev.currentTarget);
|
||||||
const currentState = $button.hasClass('activated');
|
const currentState = $button.hasClass('activated');
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import { i18n, request, tpl } from 'vj/utils';
|
|||||||
|
|
||||||
const page = new NamedPage([
|
const page = new NamedPage([
|
||||||
'problem_create', 'problem_edit', 'problem_solution', 'problem_submit',
|
'problem_create', 'problem_edit', 'problem_solution', 'problem_submit',
|
||||||
'problem_files', 'problem_detail', 'discussion_node', 'discussion_detail',
|
'problem_config', 'problem_statistics', 'problem_files', 'problem_detail',
|
||||||
|
'discussion_node', 'discussion_detail',
|
||||||
], () => {
|
], () => {
|
||||||
$(document).on('click', '[name="problem-sidebar__show-category"]', (ev) => {
|
$(document).on('click', '[name="problem-sidebar__show-category"]', (ev) => {
|
||||||
$(ev.currentTarget).hide();
|
$(ev.currentTarget).hide();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
{% import "components/contest.html" as contest with context %}
|
{% import "components/contest.html" as contest with context %}
|
||||||
{% import "components/problem.html" as problem with context %}
|
{% import "components/problem.html" as problem with context %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{{ set(UiContext, 'tdoc', tdoc) }}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="medium-9 columns">
|
<div class="medium-9 columns">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{% set pdocs = payload[0] %}
|
{% set pdocs = payload[0] %}
|
||||||
{% set psdict = payload[1] %}
|
|
||||||
{% if pdocs.length %}
|
{% if pdocs.length %}
|
||||||
<div class="section side nojs--hide">
|
<div class="section side nojs--hide">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
@@ -7,15 +6,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="section__body typo no-media col--problem-name">
|
<div class="section__body typo no-media col--problem-name">
|
||||||
{%- for pdoc in pdocs -%}
|
{%- for pdoc in pdocs -%}
|
||||||
<form class="form--inline" action="{{ url('problem_main') }}" method="post">
|
<p data-pid="{{ pdoc.docId }}" data-star="true">
|
||||||
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
|
{{ problem.render_problem_title(pdoc, show_tags=false, show_invisible_flag=false) }}
|
||||||
<input type="hidden" name="operation" value="unstar">
|
</p>
|
||||||
<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 -%}
|
{%- endfor -%}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -54,17 +54,7 @@
|
|||||||
<td class="col--status record-status--border edit-mode-hide"></td>
|
<td class="col--status record-status--border edit-mode-hide"></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="col--name col--problem-name">
|
<td class="col--name col--problem-name" {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %} data-star="{{ psdoc.star }}"{% endif %}>
|
||||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
|
||||||
<form class="form--inline" action="{{ url('problem_main', domainId = pdoc.domainId) }}" method="post">
|
|
||||||
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
|
|
||||||
<input type="hidden" name="operation" value="{{ "star" if not psdoc.star else "unstar" }}">
|
|
||||||
<button class="star{% if psdoc.star %} activated{% endif %}" 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>
|
|
||||||
{% endif %}
|
|
||||||
{{ problem.render_problem_title(pdoc) }}
|
{{ problem.render_problem_title(pdoc) }}
|
||||||
</td>
|
</td>
|
||||||
<td class="col--ac-tried">{{ pdoc.nAccept }} / {{ pdoc.nSubmit }}</td>
|
<td class="col--ac-tried">{{ pdoc.nAccept }} / {{ pdoc.nSubmit }}</td>
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
{% set pdoc=pdict[pid] %}
|
{% set pdoc=pdict[pid] %}
|
||||||
{% set psdoc=psdict[pid] %}
|
{% set psdoc=psdict[pid] %}
|
||||||
{% set self_psdoc=selfPsdict[pid] %}
|
{% set self_psdoc=selfPsdict[pid] %}
|
||||||
<tr>
|
<tr data-pid="{{ pid }}">
|
||||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
||||||
{% if psdoc['rid'] %}
|
{% if psdoc['rid'] %}
|
||||||
{{ record.render_status_td(psdoc, rid_key='rid', short=should_compare) }}
|
{{ record.render_status_td(psdoc, rid_key='rid', short=should_compare) }}
|
||||||
@@ -118,17 +118,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="col--name col--problem-name">
|
<td class="col--name col--problem-name"{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %} data-star="{{ psdoc.star }}"{% endif %}>
|
||||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
|
||||||
<form class="form--inline" action="{{ url('problem_main') }}" method="post">
|
|
||||||
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
|
|
||||||
<input type="hidden" name="operation" value="{% if not psdoc['star'] %}star{% else %}unstar{% endif %}">
|
|
||||||
<button class="star{% if psdoc['star'] %} activated{% endif %}" 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>
|
|
||||||
{% endif %}
|
|
||||||
{{ problem.render_problem_title(
|
{{ problem.render_problem_title(
|
||||||
pdoc,
|
pdoc,
|
||||||
invalid=not tsdoc['enroll'] or nsdict[node['_id']]['isInvalid'],
|
invalid=not tsdoc['enroll'] or nsdict[node['_id']]['isInvalid'],
|
||||||
|
|||||||
@@ -36,9 +36,9 @@
|
|||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) and not tdoc %}
|
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) and not tdoc %}
|
||||||
<form class="form--inline" action="{{ url('problem_main') }}" method="post">
|
<form class="form--inline" action="" method="post">
|
||||||
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
|
<input type="hidden" name="star" value="{{ 'true' if not psdoc.star else 'false' }}">
|
||||||
<input type="hidden" name="operation" value="{{ "star" if not psdoc.star else "unstar" }}">
|
<input type="hidden" name="operation" value="star">
|
||||||
<button class="star{% if psdoc.star %} activated{% endif %}" type="submit">
|
<button class="star{% if psdoc.star %} activated{% endif %}" type="submit">
|
||||||
<span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="{{ _('Star') }}"></span></span>
|
<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>
|
<span class="starred--show"><span class="icon icon-star" data-tooltip="{{ _('Unstar') }}"></span></span>
|
||||||
|
|||||||
Reference in new issue
Block a user