修复katex角标漂移等问题

This commit is contained in:
undefined committed 2020-06-24 11:47:43 +08:00
1 parent 1f1efe900c
commit a248425db6
17 files changed
+491 -235

No files matched your search

+1 -1
View File
@@ -279,7 +279,7 @@ class ProblemEditHandler extends ProblemManageHandler {
async post({ domainId, title, content }) {
const pid = validator.checkPid(this.request.body.pid);
const pdoc = await problem.get(domainId, this.params.pid);
const pdoc = await problem.get(domainId, this.request.params.pid);
await problem.edit(domainId, pdoc.docId, { title, content, pid });
this.response.redirect = `/p/${pid}`;
}
+3 -2
View File
@@ -5,6 +5,7 @@ const fs = require('fs');
const os = require('os');
const path = require('path');
const download = require('./download');
const { folderSize } = require('../utils');
function root(name) {
return path.resolve(process.cwd(), name);
@@ -43,12 +44,12 @@ async function getDetail() {
const info = `${os.tmpdir()}/hydro/tmp/${file}/hydro.json`;
if (fs.existsSync(info)) {
const i = JSON.parse(fs.readFileSync(info).toString());
const f = fs.statSync(info);
const size = folderSize(`${os.tmpdir()}/hydro/tmp/${file}`);
modules.push({
id: i.id,
version: i.version,
description: i.description,
size: f.size,
size,
});
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ const md = MarkdownIt();
const Prism = require('prismjs');
// For math: $a\times b\eq 10$
const katex = require('markdown-it-katex');
const katex = require('@hydrooj/markdown-it-katex');
// Specific image size: ![image](image.png =100x100)
const Imsize = require('markdown-it-imsize');
/* Footnote support.
+1 -1
View File
@@ -52,7 +52,7 @@ perm.PERM_ALL = PERM_ALL;
const Permission = (family, key, desc) => ({ family, key, desc });
const PERMS = [
Permission('perm_general', perm.PERM_MANAGE, 'Manage the system'),
Permission('perm_general', perm.PERM_MANAGE, 'Manage domain'),
Permission('perm_general', perm.PERM_MOD_BADGE, 'Show MOD badge'),
Permission('perm_problem', perm.PERM_CREATE_PROBLEM, 'Create problems'),
Permission('perm_problem', perm.PERM_EDIT_PROBLEM, 'Edit problems'),
+1
View File
@@ -133,6 +133,7 @@ class Handler {
files: ctx.request.files,
query: ctx.query,
path: ctx.path,
params: ctx.params,
referer: ctx.request.headers.referer || '/',
};
this.response = {
+32
View File
@@ -1,3 +1,5 @@
const fs = require('fs');
const path = require('path');
const superagent = require('superagent');
const proxy = require('superagent-proxy');
@@ -72,3 +74,33 @@ Set.intersection = function Intersection(setA, setB) {
}
return intersection;
};
/**
* calculate size of a file or directory synchronously
* @param {String} folderPath path of the file or folder
* @param {fsizeOptions} opts additional options
* @returns {Number}
*/
function folderSize(folderPath) {
let size = 0;
const _next = function a(p) {
if (p) {
const stats = fs.statSync(p);
if (!stats.isDirectory() || stats.isSymbolicLink()) {
if (!stats.isSymbolicLink()) size += stats.size;
} else {
size += stats.size;
const files = fs.readdirSync(p);
if (Array.isArray(files)) {
files.forEach((file) => {
_next(path.join(p, file));
});
}
}
}
};
_next(folderPath);
return size;
}
exports.folderSize = folderSize;