core: support extra title content

This commit is contained in:
undefined committed 2021-03-01 00:44:12 +08:00
1 parent d49f134fa3
commit 09a83c4364
4 files changed
+6 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.18.3", "version": "2.18.4",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+2
View File
@@ -130,6 +130,7 @@ export class ProblemCategoryHandler extends ProblemHandler {
this.response.body = { this.response.body = {
path, page, pcount, ppcount, pdocs, psdict, category: category.join('+'), path, page, pcount, ppcount, pdocs, psdict, category: category.join('+'),
}; };
this.extraTitleContent = category.join('+');
} }
} }
@@ -180,6 +181,7 @@ export class ProblemDetailHandler extends ProblemHandler {
[this.pdoc.title, null, true], [this.pdoc.title, null, true],
], ],
}; };
this.extraTitleContent = this.pdoc.title;
} }
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
+1
View File
@@ -192,6 +192,7 @@ class UserDetailHandler extends Handler {
this.response.body = { this.response.body = {
isSelfProfile, udoc, sdoc, rdocs, pdocs, pcount, pdict, path, isSelfProfile, udoc, sdoc, rdocs, pdocs, pcount, pdict, path,
}; };
this.extraTitleContent = udoc.uname;
} }
} }
+2
View File
@@ -251,6 +251,7 @@ export class HandlerCommon {
user: User; user: User;
session: Record<string, any>; session: Record<string, any>;
request: Record<string, any>; request: Record<string, any>;
extraTitleContent?: string;
async limitRate(op: string, periodSecs: number, maxOperations: number) { async limitRate(op: string, periodSecs: number, maxOperations: number) {
await opcount.inc(op, this.request.ip, periodSecs, maxOperations); await opcount.inc(op, this.request.ip, periodSecs, maxOperations);
@@ -262,6 +263,7 @@ export class HandlerCommon {
} }
renderTitle(str: string) { renderTitle(str: string) {
if (this.extraTitleContent) return `${this.translate(str)} - ${this.extraTitleContent} - ${system.get('server.name')}`;
return `${this.translate(str)} - ${system.get('server.name')}`; return `${this.translate(str)} - ${system.get('server.name')}`;
} }