mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-26 14:21:13 +00:00
formatting
This commit is contained in:
parent
dba041fb90
commit
b568756b83
7 changed files with 20 additions and 12 deletions
|
@ -2,13 +2,13 @@ import type { Response } from "express";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
export default async ({ res }: { res: Response }) => {
|
export default async ({ res }: { res: Response }) => {
|
||||||
res.setHeader("Content-Type", "application/javascript");
|
res
|
||||||
|
.setHeader("Content-Type", "application/javascript")
|
||||||
res.sendFile(
|
.sendFile(
|
||||||
path.resolve(
|
path.resolve(
|
||||||
`./dist/service-worker${
|
`./dist/service-worker${
|
||||||
process.env.NODE_ENV === "development" ? "-development" : ""
|
process.env.NODE_ENV === "development" ? "-development" : ""
|
||||||
}.js`
|
}.js`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,5 @@ import type { Response } from "express";
|
||||||
import { buildThemeList } from "../utils/build-themes-list";
|
import { buildThemeList } from "../utils/build-themes-list";
|
||||||
|
|
||||||
export default async ({ res }: { res: Response }) => {
|
export default async ({ res }: { res: Response }) => {
|
||||||
res.type("json");
|
res.type("json").send(JSON.stringify(await buildThemeList()));
|
||||||
res.send(JSON.stringify(await buildThemeList()));
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,5 +5,6 @@ export default function ({ res, next }: { res: Response; next: NextFunction }) {
|
||||||
"Content-Security-Policy",
|
"Content-Security-Policy",
|
||||||
`default-src 'self'; manifest-src *; connect-src *; img-src * data:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; form-action 'self'; base-uri 'self'; frame-src *; media-src *`
|
`default-src 'self'; manifest-src *; connect-src *; img-src * data:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; form-action 'self'; base-uri 'self'; frame-src *; media-src *`
|
||||||
);
|
);
|
||||||
|
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,9 @@ import { readdir } from "fs/promises";
|
||||||
const extraThemesFolder =
|
const extraThemesFolder =
|
||||||
process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes";
|
process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes";
|
||||||
|
|
||||||
|
const themes = ["darkly", "darkly-red", "litely", "litely-red"];
|
||||||
|
|
||||||
export async function buildThemeList(): Promise<string[]> {
|
export async function buildThemeList(): Promise<string[]> {
|
||||||
const themes = ["darkly", "darkly-red", "litely", "litely-red"];
|
|
||||||
if (existsSync(extraThemesFolder)) {
|
if (existsSync(extraThemesFolder)) {
|
||||||
const dirThemes = await readdir(extraThemesFolder);
|
const dirThemes = await readdir(extraThemesFolder);
|
||||||
const cssThemes = dirThemes
|
const cssThemes = dirThemes
|
||||||
|
|
|
@ -14,6 +14,7 @@ export async function createSsrHtml(
|
||||||
isoData: IsoDataOptionalSite
|
isoData: IsoDataOptionalSite
|
||||||
) {
|
) {
|
||||||
const site = isoData.site_res;
|
const site = isoData.site_res;
|
||||||
|
|
||||||
const appleTouchIcon = site?.site_view.site.icon
|
const appleTouchIcon = site?.site_view.site.icon
|
||||||
? `data:image/png;base64,${sharp(
|
? `data:image/png;base64,${sharp(
|
||||||
await fetchIconPng(site.site_view.site.icon)
|
await fetchIconPng(site.site_view.site.icon)
|
||||||
|
|
|
@ -11,6 +11,7 @@ export function getErrorPageData(error: Error, site?: GetSiteResponse) {
|
||||||
const adminMatrixIds = site?.admins
|
const adminMatrixIds = site?.admins
|
||||||
.map(({ person: { matrix_user_id } }) => matrix_user_id)
|
.map(({ person: { matrix_user_id } }) => matrix_user_id)
|
||||||
.filter(id => id) as string[] | undefined;
|
.filter(id => id) as string[] | undefined;
|
||||||
|
|
||||||
if (adminMatrixIds && adminMatrixIds.length > 0) {
|
if (adminMatrixIds && adminMatrixIds.length > 0) {
|
||||||
errorPageData.adminMatrixIds = adminMatrixIds;
|
errorPageData.adminMatrixIds = adminMatrixIds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,19 @@ export function setForwardedHeaders(headers: IncomingHttpHeaders): {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
} {
|
} {
|
||||||
const out: { [key: string]: string } = {};
|
const out: { [key: string]: string } = {};
|
||||||
|
|
||||||
if (headers.host) {
|
if (headers.host) {
|
||||||
out.host = headers.host;
|
out.host = headers.host;
|
||||||
}
|
}
|
||||||
|
|
||||||
const realIp = headers["x-real-ip"];
|
const realIp = headers["x-real-ip"];
|
||||||
|
|
||||||
if (realIp) {
|
if (realIp) {
|
||||||
out["x-real-ip"] = realIp as string;
|
out["x-real-ip"] = realIp as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const forwardedFor = headers["x-forwarded-for"];
|
const forwardedFor = headers["x-forwarded-for"];
|
||||||
|
|
||||||
if (forwardedFor) {
|
if (forwardedFor) {
|
||||||
out["x-forwarded-for"] = forwardedFor as string;
|
out["x-forwarded-for"] = forwardedFor as string;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue