]> Untitled Git - lemmy-ui.git/commitdiff
Merge branch 'main' into patch-1
authorn3oney <neo@neoney.dev>
Tue, 20 Jun 2023 22:37:48 +0000 (00:37 +0200)
committern3oney <neo@neoney.dev>
Tue, 20 Jun 2023 22:40:25 +0000 (00:40 +0200)
1  2 
src/server/handlers/theme-handler.ts

index 0000000000000000000000000000000000000000,9f1046d7f5dff41c4a0305254cf5286ee34c14cb..b107d8542461732a5bf6b78ae6e57b11d0733ad3
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,32 +1,32 @@@
 -  const customTheme = path.resolve(`./${extraThemesFolder}/${theme}`);
+ import type { Request, Response } from "express";
+ import { existsSync } from "fs";
+ import path from "path";
+ const extraThemesFolder =
+   process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes";
+ export default async (req: Request, res: Response) => {
+   res.contentType("text/css");
+   const theme = req.params.name;
+   if (!theme.endsWith(".css")) {
+     res.statusCode = 400;
+     res.send("Theme must be a css file");
+   }
++  const customTheme = path.resolve(extraThemesFolder, theme);
+   if (existsSync(customTheme)) {
+     res.sendFile(customTheme);
+   } else {
+     const internalTheme = path.resolve(`./dist/assets/css/themes/${theme}`);
+     // If the theme doesn't exist, just send litely
+     if (existsSync(internalTheme)) {
+       res.sendFile(internalTheme);
+     } else {
+       res.sendFile(path.resolve("./dist/assets/css/themes/litely.css"));
+     }
+   }
+ };