2021-02-22 02:39:04 +00:00
|
|
|
import express from "express";
|
2023-05-12 01:07:59 +00:00
|
|
|
import { existsSync } from "fs";
|
|
|
|
import { readdir, readFile } from "fs/promises";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { IncomingHttpHeaders } from "http";
|
|
|
|
import { Helmet } from "inferno-helmet";
|
|
|
|
import { matchPath, StaticRouter } from "inferno-router";
|
2021-02-22 02:39:04 +00:00
|
|
|
import { renderToString } from "inferno-server";
|
2021-07-17 20:42:55 +00:00
|
|
|
import IsomorphicCookie from "isomorphic-cookie";
|
2023-06-14 12:20:40 +00:00
|
|
|
import { GetSite, GetSiteResponse, LemmyHttp } from "lemmy-js-client";
|
2021-02-22 02:39:04 +00:00
|
|
|
import path from "path";
|
2021-07-17 20:42:55 +00:00
|
|
|
import process from "process";
|
|
|
|
import serialize from "serialize-javascript";
|
2023-05-12 01:07:59 +00:00
|
|
|
import sharp from "sharp";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { App } from "../shared/components/app/app";
|
2023-06-14 12:20:40 +00:00
|
|
|
import { getHttpBaseExternal, getHttpBaseInternal } from "../shared/env";
|
2021-02-12 17:54:35 +00:00
|
|
|
import {
|
|
|
|
ILemmyConfig,
|
|
|
|
InitialFetchRequest,
|
2023-05-14 23:49:55 +00:00
|
|
|
IsoDataOptionalSite,
|
2021-02-22 02:39:04 +00:00
|
|
|
} from "../shared/interfaces";
|
|
|
|
import { routes } from "../shared/routes";
|
2023-06-14 12:20:40 +00:00
|
|
|
import { RequestState, wrapClient } from "../shared/services/HttpService";
|
2023-05-14 15:08:06 +00:00
|
|
|
import {
|
|
|
|
ErrorPageData,
|
|
|
|
favIconPngUrl,
|
|
|
|
favIconUrl,
|
|
|
|
initializeSite,
|
|
|
|
isAuthPath,
|
|
|
|
} from "../shared/utils";
|
2023-05-14 20:25:03 +00:00
|
|
|
|
2020-08-23 04:04:58 +00:00
|
|
|
const server = express();
|
2021-03-30 01:46:42 +00:00
|
|
|
const [hostname, port] = process.env["LEMMY_UI_HOST"]
|
|
|
|
? process.env["LEMMY_UI_HOST"].split(":")
|
2021-03-30 01:17:19 +00:00
|
|
|
: ["0.0.0.0", "1234"];
|
2022-03-02 15:35:59 +00:00
|
|
|
const extraThemesFolder =
|
|
|
|
process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes";
|
2020-08-23 04:04:58 +00:00
|
|
|
|
2022-08-16 20:39:09 +00:00
|
|
|
if (!process.env["LEMMY_UI_DISABLE_CSP"] && !process.env["LEMMY_UI_DEBUG"]) {
|
2022-06-01 16:43:54 +00:00
|
|
|
server.use(function (_req, res, next) {
|
|
|
|
res.setHeader(
|
|
|
|
"Content-Security-Policy",
|
2023-06-06 12:45:17 +00:00
|
|
|
`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 *`
|
2022-06-01 16:43:54 +00:00
|
|
|
);
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
}
|
2022-05-25 03:33:11 +00:00
|
|
|
const customHtmlHeader = process.env["LEMMY_UI_CUSTOM_HTML_HEADER"] || "";
|
|
|
|
|
2020-08-23 04:04:58 +00:00
|
|
|
server.use(express.json());
|
|
|
|
server.use(express.urlencoded({ extended: false }));
|
2021-02-22 02:39:04 +00:00
|
|
|
server.use("/static", express.static(path.resolve("./dist")));
|
2020-08-23 04:04:58 +00:00
|
|
|
|
2021-09-06 14:25:48 +00:00
|
|
|
const robotstxt = `User-Agent: *
|
2021-09-05 22:34:40 +00:00
|
|
|
Disallow: /login
|
|
|
|
Disallow: /settings
|
|
|
|
Disallow: /create_community
|
|
|
|
Disallow: /create_post
|
2021-09-06 14:25:48 +00:00
|
|
|
Disallow: /create_private_message
|
2021-09-05 22:34:40 +00:00
|
|
|
Disallow: /inbox
|
2021-09-06 14:25:48 +00:00
|
|
|
Disallow: /setup
|
|
|
|
Disallow: /admin
|
|
|
|
Disallow: /password_change
|
2021-09-05 22:34:40 +00:00
|
|
|
Disallow: /search/
|
|
|
|
`;
|
2021-09-06 14:25:48 +00:00
|
|
|
|
2023-05-12 01:07:59 +00:00
|
|
|
server.get("/service-worker.js", async (_req, res) => {
|
|
|
|
res.setHeader("Content-Type", "application/javascript");
|
2023-06-14 12:20:40 +00:00
|
|
|
res.sendFile(
|
|
|
|
path.resolve(
|
|
|
|
`./dist/service-worker${
|
|
|
|
process.env.NODE_ENV === "development" ? "-development" : ""
|
|
|
|
}.js`
|
|
|
|
)
|
|
|
|
);
|
2023-05-12 01:07:59 +00:00
|
|
|
});
|
|
|
|
|
2021-09-06 14:25:48 +00:00
|
|
|
server.get("/robots.txt", async (_req, res) => {
|
|
|
|
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
|
|
res.send(robotstxt);
|
2021-09-05 22:34:40 +00:00
|
|
|
});
|
2020-08-23 04:04:58 +00:00
|
|
|
|
2022-03-02 15:35:59 +00:00
|
|
|
server.get("/css/themes/:name", async (req, res) => {
|
|
|
|
res.contentType("text/css");
|
|
|
|
const theme = req.params.name;
|
2022-03-03 17:55:26 +00:00
|
|
|
if (!theme.endsWith(".css")) {
|
2023-05-14 23:49:55 +00:00
|
|
|
res.statusCode = 400;
|
2022-03-02 15:35:59 +00:00
|
|
|
res.send("Theme must be a css file");
|
|
|
|
}
|
|
|
|
|
|
|
|
const customTheme = path.resolve(`./${extraThemesFolder}/${theme}`);
|
2023-05-12 01:07:59 +00:00
|
|
|
if (existsSync(customTheme)) {
|
2022-03-02 15:35:59 +00:00
|
|
|
res.sendFile(customTheme);
|
|
|
|
} else {
|
|
|
|
const internalTheme = path.resolve(`./dist/assets/css/themes/${theme}`);
|
2023-02-03 02:14:59 +00:00
|
|
|
|
|
|
|
// If the theme doesn't exist, just send litely
|
2023-05-12 01:07:59 +00:00
|
|
|
if (existsSync(internalTheme)) {
|
2023-02-03 02:14:59 +00:00
|
|
|
res.sendFile(internalTheme);
|
|
|
|
} else {
|
|
|
|
res.sendFile(path.resolve("./dist/assets/css/themes/litely.css"));
|
|
|
|
}
|
2022-03-02 15:35:59 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-05-12 01:07:59 +00:00
|
|
|
async function buildThemeList(): Promise<string[]> {
|
|
|
|
const themes = ["darkly", "darkly-red", "litely", "litely-red"];
|
|
|
|
if (existsSync(extraThemesFolder)) {
|
|
|
|
const dirThemes = await readdir(extraThemesFolder);
|
|
|
|
const cssThemes = dirThemes
|
2022-03-03 17:55:26 +00:00
|
|
|
.filter(d => d.endsWith(".css"))
|
|
|
|
.map(d => d.replace(".css", ""));
|
|
|
|
themes.push(...cssThemes);
|
2022-03-02 15:35:59 +00:00
|
|
|
}
|
|
|
|
return themes;
|
|
|
|
}
|
|
|
|
|
|
|
|
server.get("/css/themelist", async (_req, res) => {
|
|
|
|
res.type("json");
|
2023-05-12 01:07:59 +00:00
|
|
|
res.send(JSON.stringify(await buildThemeList()));
|
2022-03-02 15:35:59 +00:00
|
|
|
});
|
|
|
|
|
2021-09-06 14:25:48 +00:00
|
|
|
// server.use(cookieParser());
|
2021-02-22 02:39:04 +00:00
|
|
|
server.get("/*", async (req, res) => {
|
2021-11-17 21:23:46 +00:00
|
|
|
try {
|
2023-01-04 16:56:24 +00:00
|
|
|
const activeRoute = routes.find(route => matchPath(req.path, route));
|
|
|
|
let auth: string | undefined = IsomorphicCookie.load("jwt", req);
|
2021-11-17 21:23:46 +00:00
|
|
|
|
2023-04-15 14:47:10 +00:00
|
|
|
const getSiteForm: GetSite = { auth };
|
2021-11-17 21:23:46 +00:00
|
|
|
|
2023-04-15 14:47:10 +00:00
|
|
|
const headers = setForwardedHeaders(req.headers);
|
2023-06-14 12:20:40 +00:00
|
|
|
const client = wrapClient(new LemmyHttp(getHttpBaseInternal(), headers));
|
2021-11-17 21:23:46 +00:00
|
|
|
|
2023-05-14 15:08:06 +00:00
|
|
|
const { path, url, query } = req;
|
|
|
|
|
2021-11-17 21:23:46 +00:00
|
|
|
// Get site data first
|
|
|
|
// This bypasses errors, so that the client can hit the error on its own,
|
|
|
|
// in order to remove the jwt on the browser. Necessary for wrong jwts
|
2023-05-14 23:49:55 +00:00
|
|
|
let site: GetSiteResponse | undefined = undefined;
|
2023-06-14 12:20:40 +00:00
|
|
|
const routeData: RequestState<any>[] = [];
|
|
|
|
let errorPageData: ErrorPageData | undefined = undefined;
|
|
|
|
let try_site = await client.getSite(getSiteForm);
|
|
|
|
if (try_site.state === "failed" && try_site.msg == "not_logged_in") {
|
|
|
|
console.error(
|
|
|
|
"Incorrect JWT token, skipping auth so frontend can remove jwt cookie"
|
|
|
|
);
|
|
|
|
getSiteForm.auth = undefined;
|
|
|
|
auth = undefined;
|
|
|
|
try_site = await client.getSite(getSiteForm);
|
|
|
|
}
|
2023-05-14 15:08:06 +00:00
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
if (!auth && isAuthPath(path)) {
|
|
|
|
return res.redirect("/login");
|
|
|
|
}
|
2023-05-14 18:59:42 +00:00
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
if (try_site.state === "success") {
|
|
|
|
site = try_site.data;
|
2023-05-14 23:49:55 +00:00
|
|
|
initializeSite(site);
|
2021-11-17 21:23:46 +00:00
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
if (path != "/setup" && !site.site_view.local_site.site_setup) {
|
|
|
|
return res.redirect("/setup");
|
|
|
|
}
|
|
|
|
|
2023-05-14 23:49:55 +00:00
|
|
|
if (site) {
|
|
|
|
const initialFetchReq: InitialFetchRequest = {
|
|
|
|
client,
|
|
|
|
auth,
|
|
|
|
path,
|
|
|
|
query,
|
|
|
|
site,
|
|
|
|
};
|
2023-04-15 14:47:10 +00:00
|
|
|
|
2023-05-14 23:49:55 +00:00
|
|
|
if (activeRoute?.fetchInitialData) {
|
2023-06-14 12:20:40 +00:00
|
|
|
routeData.push(
|
|
|
|
...(await Promise.all([
|
|
|
|
...activeRoute.fetchInitialData(initialFetchReq),
|
|
|
|
]))
|
|
|
|
);
|
2023-05-14 23:49:55 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-14 12:20:40 +00:00
|
|
|
} else if (try_site.state === "failed") {
|
|
|
|
errorPageData = getErrorPageData(new Error(try_site.msg), site);
|
2021-11-17 21:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Redirect to the 404 if there's an API error
|
2023-06-14 12:20:40 +00:00
|
|
|
if (routeData[0] && routeData[0].state === "failed") {
|
|
|
|
const error = routeData[0].msg;
|
2023-04-15 14:47:10 +00:00
|
|
|
console.error(error);
|
|
|
|
if (error === "instance_is_private") {
|
2021-12-30 15:26:45 +00:00
|
|
|
return res.redirect(`/signup`);
|
|
|
|
} else {
|
2023-06-14 12:20:40 +00:00
|
|
|
errorPageData = getErrorPageData(new Error(error), site);
|
2021-12-30 15:26:45 +00:00
|
|
|
}
|
2021-11-17 21:23:46 +00:00
|
|
|
}
|
|
|
|
|
2023-05-14 23:49:55 +00:00
|
|
|
const isoData: IsoDataOptionalSite = {
|
2023-05-14 15:08:06 +00:00
|
|
|
path,
|
2021-11-17 21:23:46 +00:00
|
|
|
site_res: site,
|
2023-05-16 01:02:34 +00:00
|
|
|
routeData,
|
2023-05-17 00:34:15 +00:00
|
|
|
errorPageData,
|
2021-11-17 21:23:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = (
|
2023-05-14 15:08:06 +00:00
|
|
|
<StaticRouter location={url} context={isoData}>
|
2022-06-21 21:42:29 +00:00
|
|
|
<App />
|
2021-11-17 21:23:46 +00:00
|
|
|
</StaticRouter>
|
|
|
|
);
|
|
|
|
|
|
|
|
const root = renderToString(wrapper);
|
2023-05-14 23:49:55 +00:00
|
|
|
|
|
|
|
res.send(await createSsrHtml(root, isoData));
|
2021-11-17 21:23:46 +00:00
|
|
|
} catch (err) {
|
2023-05-14 23:49:55 +00:00
|
|
|
// If an error is caught here, the error page couldn't even be rendered
|
2021-12-02 16:46:32 +00:00
|
|
|
console.error(err);
|
2023-05-14 15:08:06 +00:00
|
|
|
res.statusCode = 500;
|
2023-05-15 03:45:21 +00:00
|
|
|
return res.send(
|
|
|
|
process.env.NODE_ENV === "development" ? err.message : "Server error"
|
|
|
|
);
|
2021-11-17 21:23:46 +00:00
|
|
|
}
|
2020-08-23 04:04:58 +00:00
|
|
|
});
|
2020-11-12 21:56:46 +00:00
|
|
|
|
2021-03-29 15:35:32 +00:00
|
|
|
server.listen(Number(port), hostname, () => {
|
|
|
|
console.log(`http://${hostname}:${port}`);
|
2020-08-23 04:04:58 +00:00
|
|
|
});
|
|
|
|
|
2021-07-16 18:29:22 +00:00
|
|
|
function setForwardedHeaders(headers: IncomingHttpHeaders): {
|
|
|
|
[key: string]: string;
|
|
|
|
} {
|
2023-06-05 21:31:12 +00:00
|
|
|
const out: { [key: string]: string } = {};
|
2023-01-04 16:56:24 +00:00
|
|
|
if (headers.host) {
|
|
|
|
out.host = headers.host;
|
2020-11-12 21:56:46 +00:00
|
|
|
}
|
2023-06-05 21:31:12 +00:00
|
|
|
const realIp = headers["x-real-ip"];
|
2023-01-04 16:56:24 +00:00
|
|
|
if (realIp) {
|
|
|
|
out["x-real-ip"] = realIp as string;
|
|
|
|
}
|
2023-06-05 21:31:12 +00:00
|
|
|
const forwardedFor = headers["x-forwarded-for"];
|
2023-01-04 16:56:24 +00:00
|
|
|
if (forwardedFor) {
|
|
|
|
out["x-forwarded-for"] = forwardedFor as string;
|
2020-11-12 21:56:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
2020-08-23 04:04:58 +00:00
|
|
|
}
|
2020-09-10 16:39:01 +00:00
|
|
|
|
2021-02-22 02:39:04 +00:00
|
|
|
process.on("SIGINT", () => {
|
|
|
|
console.info("Interrupted");
|
2020-09-10 16:39:01 +00:00
|
|
|
process.exit(0);
|
|
|
|
});
|
2022-03-24 20:34:04 +00:00
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
const iconSizes = [72, 96, 144, 192, 512];
|
2023-05-12 01:07:59 +00:00
|
|
|
const defaultLogoPathDirectory = path.join(
|
|
|
|
process.cwd(),
|
|
|
|
"dist",
|
|
|
|
"assets",
|
|
|
|
"icons"
|
|
|
|
);
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
export async function generateManifestBase64({
|
|
|
|
my_user,
|
|
|
|
site_view: {
|
|
|
|
site,
|
|
|
|
local_site: { community_creation_admin_only },
|
|
|
|
},
|
|
|
|
}: GetSiteResponse) {
|
|
|
|
const url = getHttpBaseExternal();
|
|
|
|
|
2023-05-12 01:07:59 +00:00
|
|
|
const icon = site.icon ? await fetchIconPng(site.icon) : null;
|
|
|
|
|
|
|
|
const manifest = {
|
|
|
|
name: site.name,
|
|
|
|
description: site.description ?? "A link aggregator for the fediverse",
|
|
|
|
start_url: url,
|
|
|
|
scope: url,
|
|
|
|
display: "standalone",
|
|
|
|
id: "/",
|
|
|
|
background_color: "#222222",
|
|
|
|
theme_color: "#222222",
|
|
|
|
icons: await Promise.all(
|
|
|
|
iconSizes.map(async size => {
|
|
|
|
let src = await readFile(
|
|
|
|
path.join(defaultLogoPathDirectory, `icon-${size}x${size}.png`)
|
|
|
|
).then(buf => buf.toString("base64"));
|
|
|
|
|
|
|
|
if (icon) {
|
|
|
|
src = await sharp(icon)
|
|
|
|
.resize(size, size)
|
|
|
|
.png()
|
|
|
|
.toBuffer()
|
|
|
|
.then(buf => buf.toString("base64"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
sizes: `${size}x${size}`,
|
|
|
|
type: "image/png",
|
|
|
|
src: `data:image/png;base64,${src}`,
|
|
|
|
purpose: "any maskable",
|
|
|
|
};
|
|
|
|
})
|
|
|
|
),
|
2023-06-14 12:20:40 +00:00
|
|
|
shortcuts: [
|
|
|
|
{
|
|
|
|
name: "Search",
|
|
|
|
short_name: "Search",
|
|
|
|
description: "Perform a search.",
|
|
|
|
url: "/search",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Communities",
|
|
|
|
url: "/communities",
|
|
|
|
short_name: "Communities",
|
|
|
|
description: "Browse communities",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
.concat(
|
|
|
|
my_user
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
name: "Create Post",
|
|
|
|
url: "/create_post",
|
|
|
|
short_name: "Create Post",
|
|
|
|
description: "Create a post.",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []
|
|
|
|
)
|
|
|
|
.concat(
|
|
|
|
my_user?.local_user_view.person.admin || !community_creation_admin_only
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
name: "Create Community",
|
|
|
|
url: "/create_community",
|
|
|
|
short_name: "Create Community",
|
|
|
|
description: "Create a community",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []
|
|
|
|
),
|
|
|
|
related_applications: [
|
|
|
|
{
|
|
|
|
platform: "f-droid",
|
|
|
|
url: "https://f-droid.org/packages/com.jerboa/",
|
|
|
|
id: "com.jerboa",
|
|
|
|
},
|
|
|
|
],
|
2023-05-12 01:07:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Buffer.from(JSON.stringify(manifest)).toString("base64");
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchIconPng(iconUrl: string) {
|
2023-06-14 12:20:40 +00:00
|
|
|
return await fetch(iconUrl)
|
2023-05-12 01:07:59 +00:00
|
|
|
.then(res => res.blob())
|
|
|
|
.then(blob => blob.arrayBuffer());
|
|
|
|
}
|
2023-05-14 23:49:55 +00:00
|
|
|
|
2023-05-22 12:38:05 +00:00
|
|
|
function getErrorPageData(error: Error, site?: GetSiteResponse) {
|
2023-05-17 00:34:15 +00:00
|
|
|
const errorPageData: ErrorPageData = {};
|
2023-05-14 23:49:55 +00:00
|
|
|
|
2023-05-22 12:38:05 +00:00
|
|
|
if (site) {
|
|
|
|
errorPageData.error = error.message;
|
2023-05-14 23:49:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const adminMatrixIds = site?.admins
|
|
|
|
.map(({ person: { matrix_user_id } }) => matrix_user_id)
|
|
|
|
.filter(id => id) as string[] | undefined;
|
|
|
|
if (adminMatrixIds && adminMatrixIds.length > 0) {
|
|
|
|
errorPageData.adminMatrixIds = adminMatrixIds;
|
|
|
|
}
|
|
|
|
|
2023-05-17 00:34:15 +00:00
|
|
|
return errorPageData;
|
2023-05-14 23:49:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function createSsrHtml(root: string, isoData: IsoDataOptionalSite) {
|
|
|
|
const site = isoData.site_res;
|
|
|
|
const appleTouchIcon = site?.site_view.site.icon
|
|
|
|
? `data:image/png;base64,${sharp(
|
|
|
|
await fetchIconPng(site.site_view.site.icon)
|
|
|
|
)
|
|
|
|
.resize(180, 180)
|
|
|
|
.extend({
|
|
|
|
bottom: 20,
|
|
|
|
top: 20,
|
|
|
|
left: 20,
|
|
|
|
right: 20,
|
|
|
|
background: "#222222",
|
|
|
|
})
|
|
|
|
.png()
|
|
|
|
.toBuffer()
|
|
|
|
.then(buf => buf.toString("base64"))}`
|
|
|
|
: favIconPngUrl;
|
|
|
|
|
2023-06-13 10:34:21 +00:00
|
|
|
const erudaStr =
|
|
|
|
process.env["LEMMY_UI_DEBUG"] === "true"
|
|
|
|
? renderToString(
|
|
|
|
<>
|
|
|
|
<script src="//cdn.jsdelivr.net/npm/eruda"></script>
|
|
|
|
<script>eruda.init();</script>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
: "";
|
2023-05-14 23:49:55 +00:00
|
|
|
|
|
|
|
const helmet = Helmet.renderStatic();
|
|
|
|
|
|
|
|
const config: ILemmyConfig = { wsHost: process.env.LEMMY_UI_LEMMY_WS_HOST };
|
|
|
|
|
|
|
|
return `
|
|
|
|
<!DOCTYPE html>
|
2023-06-11 15:21:41 +00:00
|
|
|
<html ${helmet.htmlAttributes.toString()}>
|
2023-05-14 23:49:55 +00:00
|
|
|
<head>
|
2023-06-12 20:17:57 +00:00
|
|
|
<script>window.isoData = ${serialize(isoData)}</script>
|
2023-05-14 23:49:55 +00:00
|
|
|
<script>window.lemmyConfig = ${serialize(config)}</script>
|
|
|
|
|
|
|
|
<!-- A remote debugging utility for mobile -->
|
|
|
|
${erudaStr}
|
|
|
|
|
|
|
|
<!-- Custom injected script -->
|
|
|
|
${customHtmlHeader}
|
|
|
|
|
|
|
|
${helmet.title.toString()}
|
|
|
|
${helmet.meta.toString()}
|
|
|
|
|
|
|
|
<!-- Required meta tags -->
|
|
|
|
<meta name="Description" content="Lemmy">
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
|
|
<link
|
|
|
|
id="favicon"
|
|
|
|
rel="shortcut icon"
|
|
|
|
type="image/x-icon"
|
|
|
|
href=${site?.site_view.site.icon ?? favIconUrl}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<!-- Web app manifest -->
|
|
|
|
${
|
|
|
|
site &&
|
|
|
|
`<link
|
|
|
|
rel="manifest"
|
2023-06-14 12:20:40 +00:00
|
|
|
href=${`data:application/manifest+json;base64,${await generateManifestBase64(
|
|
|
|
site
|
|
|
|
)}`}
|
2023-05-14 23:49:55 +00:00
|
|
|
/>`
|
|
|
|
}
|
|
|
|
<link rel="apple-touch-icon" href=${appleTouchIcon} />
|
|
|
|
<link rel="apple-touch-startup-image" href=${appleTouchIcon} />
|
|
|
|
|
|
|
|
<!-- Styles -->
|
|
|
|
<link rel="stylesheet" type="text/css" href="/static/styles/styles.css" />
|
|
|
|
|
|
|
|
<!-- Current theme and more -->
|
|
|
|
${helmet.link.toString()}
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body ${helmet.bodyAttributes.toString()}>
|
|
|
|
<noscript>
|
|
|
|
<div class="alert alert-danger rounded-0" role="alert">
|
|
|
|
<b>Javascript is disabled. Actions will not work.</b>
|
|
|
|
</div>
|
|
|
|
</noscript>
|
|
|
|
|
|
|
|
<div id='root'>${root}</div>
|
|
|
|
<script defer src='/static/js/client.js'></script>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
`;
|
|
|
|
}
|