mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
remove html2md
This commit is contained in:
1 parent
9e225f5daa
commit
f723e2815f
11 files changed
+60
-109
No files matched your search
+1
-1
@@ -11,7 +11,7 @@
|
||||
"pub": "node build/publish",
|
||||
"jest": "node build/jest",
|
||||
"start": "node --async-stack-traces --trace-deprecation --enable-source-maps build/start",
|
||||
"clean": "zsh -c \"rm -r tsconfig.build.tsbuildinfo ./packages/*/tsconfig.tsbuildinfo ./packages/*/dist ./coverage\""
|
||||
"clean": "zsh -c \"rm -r tsconfig.build.tsbuildinfo ./packages/*/tsconfig.tsbuildinfo ./packages/*/dist ./.coverage\""
|
||||
},
|
||||
"version": "1.0.0",
|
||||
"license": "AGPL-3.0-only",
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'hydrooj';
|
||||
import TurndownService from 'turndown';
|
||||
|
||||
declare module 'hydrooj' {
|
||||
interface Lib {
|
||||
convertHTML: (str: string) => string,
|
||||
}
|
||||
}
|
||||
|
||||
const turndownService = new TurndownService({
|
||||
headingStyle: 'atx',
|
||||
codeBlockStyle: 'fenced',
|
||||
bulletListMarker: '-',
|
||||
});
|
||||
|
||||
export function convertHTML(html: string) {
|
||||
return turndownService.turndown(html);
|
||||
}
|
||||
|
||||
global.Hydro.lib.convertHTML = convertHTML;
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"name": "@hydrooj/html2md",
|
||||
"version": "1.0.2",
|
||||
"description": "turn html into markdown",
|
||||
"main": "lib.js",
|
||||
"typings": "lib.d.ts",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
"author": "undefined <masnn0@outlook.com>",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"turndown": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/turndown": "^5.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hydrooj": "^2.12.22"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"lint": "eslint . --ext ts --fix"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import 'hydrooj';
|
||||
import { convertHTML } from '@hydrooj/html2md/lib';
|
||||
|
||||
describe('html2md', () => {
|
||||
test('convertHTML', () => {
|
||||
expect(convertHTML('<h1>Test</h1><p>test</p>')).toStrictEqual('# Test\n\ntest');
|
||||
});
|
||||
});
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2019",
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "node",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"composite": true,
|
||||
"strictBindCallApply": true,
|
||||
"experimentalDecorators": true,
|
||||
"outDir": ".",
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": [
|
||||
"*.ts"
|
||||
],
|
||||
"exclude": []
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.13.9",
|
||||
"version": "2.13.10",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -43,7 +43,7 @@ const checks: Dictionary<CheckItem> = {
|
||||
},
|
||||
};
|
||||
|
||||
export async function start(ctx, log, warn, error, cb: (id: string) => any) {
|
||||
export async function start(ctx, log, warn, error, cb: (id: string) => void) {
|
||||
const id = String.random(6);
|
||||
cb(id);
|
||||
for (const name in checks) {
|
||||
|
||||
@@ -5,6 +5,10 @@ import { Dictionary, NumericDictionary } from 'lodash';
|
||||
|
||||
export type NumberKeys<O> = {
|
||||
[K in keyof O]: number extends O[K] ? K : never
|
||||
}[keyof O];
|
||||
|
||||
export type ArrayKeys<O, P = any> = {
|
||||
[K in keyof O]: P[] extends O[K] ? K : never
|
||||
}[keyof O]
|
||||
|
||||
export interface System {
|
||||
@@ -157,7 +161,7 @@ export type ProblemConfig = LocalProblemConfig | RemoteProblemConfig;
|
||||
export interface Pdoc {
|
||||
_id: ObjectID,
|
||||
domainId: string,
|
||||
docType: number,
|
||||
docType: 10,
|
||||
docId: number,
|
||||
pid: string,
|
||||
owner: number,
|
||||
@@ -181,14 +185,21 @@ export interface Pdoc {
|
||||
|
||||
export type Pdict = NumericDictionary<Pdoc>;
|
||||
|
||||
export interface ProblemStatusDoc {
|
||||
export interface StatusDoc {
|
||||
_id: ObjectID,
|
||||
docId: number,
|
||||
docId: any,
|
||||
docType: number,
|
||||
domainId: string,
|
||||
uid: number,
|
||||
}
|
||||
|
||||
export interface ProblemStatusDoc extends StatusDoc {
|
||||
docId: number,
|
||||
docType: 10,
|
||||
rid?: ObjectID,
|
||||
status?: number,
|
||||
nSubmit?: number,
|
||||
nAccept?: number,
|
||||
star?: boolean,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { Collection } from 'mongodb';
|
||||
import * as db from '../service/db';
|
||||
import * as bus from '../service/bus';
|
||||
import { Bdoc } from '../interface';
|
||||
|
||||
const coll: Collection<Bdoc> = db.collection('blacklist');
|
||||
const coll = db.collection('blacklist');
|
||||
|
||||
export async function add(ip: string) {
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import assert from 'assert';
|
||||
import { ObjectID, Cursor, FilterQuery } from 'mongodb';
|
||||
import {
|
||||
ObjectID, Cursor, FilterQuery, UpdateQuery,
|
||||
} from 'mongodb';
|
||||
import * as db from '../service/db';
|
||||
import * as bus from '../service/bus';
|
||||
import {
|
||||
Pdoc, Ddoc, Ufdoc, Drdoc, Tdoc, TrainingDoc, NumberKeys,
|
||||
Pdoc, Ddoc, Ufdoc, Drdoc, Tdoc, TrainingDoc, NumberKeys, ArrayKeys, ProblemStatusDoc,
|
||||
} from '../interface';
|
||||
|
||||
type DocID = ObjectID | string | number;
|
||||
@@ -35,6 +37,11 @@ export interface DocType {
|
||||
[TYPE_HOMEWORK]: Tdoc,
|
||||
}
|
||||
|
||||
export interface DocStatusType {
|
||||
[TYPE_PROBLEM]: ProblemStatusDoc,
|
||||
[key: number]: any
|
||||
}
|
||||
|
||||
export async function add<T extends DocID, K extends keyof DocType>(
|
||||
domainId: string, content: string, owner: number,
|
||||
docType: K, docId: DocType[K]['docId'],
|
||||
@@ -104,8 +111,8 @@ export function deleteMulti<K extends keyof DocType>(
|
||||
return coll.deleteMany({ ...query, domainId, docType });
|
||||
}
|
||||
|
||||
export function deleteMultiStatus<K extends keyof DocType>(
|
||||
domainId: string, docType: K, query?: FilterQuery<DocType[K]>,
|
||||
export function deleteMultiStatus<K extends keyof DocStatusType>(
|
||||
domainId: string, docType: K, query?: FilterQuery<DocStatusType[K]>,
|
||||
) {
|
||||
return collStatus.deleteMany({ ...query, domainId, docType });
|
||||
}
|
||||
@@ -128,8 +135,6 @@ export async function inc<K extends keyof DocType>(
|
||||
return res.value;
|
||||
}
|
||||
|
||||
type Q = NumberKeys<DocType[10]>
|
||||
|
||||
export async function incAndSet<K extends keyof DocType>(
|
||||
domainId: string, docType: K, docId: DocType[K]['docId'],
|
||||
key: NumberKeys<DocType[K]>, value: number, args: Partial<DocType[K]>,
|
||||
@@ -169,7 +174,7 @@ export async function push<K extends keyof DocType, T extends keyof DocType[K]>(
|
||||
|
||||
export async function pull<K extends keyof DocType>(
|
||||
domainId: string, docType: K, docId: DocType[K]['docId'],
|
||||
setKey: string, contents: string[],
|
||||
setKey: ArrayKeys<DocType[K]>, contents: string[],
|
||||
): Promise<DocType[K]> {
|
||||
const res = await coll.findOneAndUpdate(
|
||||
{ domainId, docType, docId },
|
||||
@@ -179,10 +184,10 @@ export async function pull<K extends keyof DocType>(
|
||||
return res.value;
|
||||
}
|
||||
|
||||
export async function deleteSub(
|
||||
domainId: string, docType: number, docId: DocID,
|
||||
key: string, subId: ObjectID,
|
||||
) {
|
||||
export async function deleteSub<K extends keyof DocType>(
|
||||
domainId: string, docType: K, docId: DocType[K]['docId'],
|
||||
key: ArrayKeys<DocType[K]>, subId: ObjectID,
|
||||
): Promise<DocType[K]> {
|
||||
const res = await coll.findOneAndUpdate(
|
||||
{ domainId, docType, docId },
|
||||
{ $pull: { [key]: { _id: subId } } },
|
||||
@@ -191,10 +196,10 @@ export async function deleteSub(
|
||||
return res.value;
|
||||
}
|
||||
|
||||
export async function getSub(
|
||||
domainId: string, docType: number, docId: DocID,
|
||||
key: string, subId: ObjectID,
|
||||
) {
|
||||
export async function getSub<T extends keyof DocType, K extends ArrayKeys<DocType[T]>>(
|
||||
domainId: string, docType: T, docId: DocType[T]['docId'],
|
||||
key: K, subId: ObjectID,
|
||||
): Promise<[DocType[T], DocType[T][K]][0]> {
|
||||
const doc = await coll.findOne({
|
||||
domainId,
|
||||
docType,
|
||||
@@ -208,10 +213,10 @@ export async function getSub(
|
||||
return [doc, null];
|
||||
}
|
||||
|
||||
export async function setSub(
|
||||
domainId: string, docType: number, docId: DocID,
|
||||
key: string, subId: ObjectID, args: any,
|
||||
) {
|
||||
export async function setSub<T extends keyof DocType, K extends ArrayKeys<DocType[T]>>(
|
||||
domainId: string, docType: T, docId: DocType[T]['docId'],
|
||||
key: K, subId: ObjectID, args: UpdateQuery<DocType[T][K][0]>['$set'],
|
||||
): Promise<DocType[T]> {
|
||||
const $set = {};
|
||||
for (const k in args) {
|
||||
$set[`${key}.$.${k}`] = args[k];
|
||||
@@ -229,9 +234,9 @@ export async function setSub(
|
||||
return res.value;
|
||||
}
|
||||
|
||||
export async function addToSet(
|
||||
domainId: string, docType: number, docId: DocID,
|
||||
setKey: string, content: string,
|
||||
export async function addToSet<T extends keyof DocType, K extends ArrayKeys<DocType[T], string>>(
|
||||
domainId: string, docType: T, docId: DocType[T]['docId'],
|
||||
setKey: K, content: string,
|
||||
) {
|
||||
const res = await coll.findOneAndUpdate(
|
||||
{ domainId, docType, docId },
|
||||
@@ -241,23 +246,29 @@ export async function addToSet(
|
||||
return res.value;
|
||||
}
|
||||
|
||||
export function getStatus(domainId: string, docType: number, docId: DocID, uid: number) {
|
||||
export function getStatus<K extends keyof DocStatusType>(
|
||||
domainId: string, docType: K, docId: DocStatusType[K]['docId'], uid: number,
|
||||
): Promise<DocStatusType[K]> {
|
||||
return collStatus.findOne({
|
||||
domainId, docType, docId, uid,
|
||||
});
|
||||
}
|
||||
|
||||
export function getMultiStatus(domainId: string, docType: number, args: any) {
|
||||
export function getMultiStatus<K extends keyof DocStatusType>(
|
||||
domainId: string, docType: K, args: FilterQuery<DocStatusType[K]>,
|
||||
): Cursor<DocStatusType[K]> {
|
||||
return collStatus.find({ ...args, docType, domainId });
|
||||
}
|
||||
|
||||
export function getMultiStatusWithoutDomain(docType: number, args: any) {
|
||||
export function getMultiStatusWithoutDomain<K extends keyof DocStatusType>(
|
||||
docType: K, args: FilterQuery<DocStatusType[K]>,
|
||||
): Cursor<DocStatusType[K]> {
|
||||
return collStatus.find({ ...args, docType });
|
||||
}
|
||||
|
||||
export async function setStatus(
|
||||
domainId: string, docType: number, docId: DocID, uid: number, args: any,
|
||||
) {
|
||||
export async function setStatus<K extends keyof DocStatusType>(
|
||||
domainId: string, docType: K, docId: DocStatusType[K]['docId'], uid: number, args: UpdateQuery<DocStatusType[K]>['$set'],
|
||||
): Promise<DocStatusType[K]> {
|
||||
const res = await collStatus.findOneAndUpdate(
|
||||
{
|
||||
domainId, docType, docId, uid,
|
||||
@@ -268,7 +279,9 @@ export async function setStatus(
|
||||
return res.value;
|
||||
}
|
||||
|
||||
export function setMultiStatus(domainId: string, docType: number, query: any, args: any) {
|
||||
export function setMultiStatus<K extends keyof DocStatusType>(
|
||||
domainId: string, docType: K, query: FilterQuery<DocStatusType[K]>, args: UpdateQuery<DocStatusType[K]>['$set'],
|
||||
) {
|
||||
return collStatus.updateMany(
|
||||
{ domainId, docType, ...query },
|
||||
{ $set: args },
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
{ "path": "packages/hydrooj" },
|
||||
{ "path": "packages/hydrojudge" },
|
||||
{ "path": "packages/geoip" },
|
||||
{ "path": "packages/html2md" },
|
||||
{ "path": "packages/better-search" },
|
||||
{ "path": "packages/fps-importer" },
|
||||
{ "path": "packages/login-with-github" },
|
||||
|
||||
Reference in new issue
Block a user