summary refs log tree commit diff
path: root/api/src
diff options
context:
space:
mode:
authorSamuel <34555296+Flam3rboy@users.noreply.github.com>2021-11-21 21:04:22 +0100
committerGitHub <noreply@github.com>2021-11-21 21:04:22 +0100
commitaf1a23400c93653f1e111bf726248f163c44e58d (patch)
treeccfd57efae3d9dfd6e29d040e1d15078b872f9ae /api/src
parentMerge pull request #510 from Thesourtimes/master (diff)
parentAdd user.css (diff)
downloadserver-af1a23400c93653f1e111bf726248f163c44e58d.tar.xz
Merge pull request #491 from TheArcaneBrony/master
Add plugin & css support, add styling to differentiate from discord.com
Diffstat (limited to 'api/src')
-rw-r--r--api/src/middlewares/TestClient.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/api/src/middlewares/TestClient.ts b/api/src/middlewares/TestClient.ts
index b718bdab..b50f4e5c 100644
--- a/api/src/middlewares/TestClient.ts
+++ b/api/src/middlewares/TestClient.ts
@@ -23,9 +23,26 @@ export default function TestClient(app: Application) {
 	if (GATEWAY_ENDPOINT) {
 		html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: \`${GATEWAY_ENDPOINT}\`,`);
 	}
+	// inline plugins
+	var files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "preload-plugins"));
+	var plugins = "";
+	files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script>${fs.readFileSync(path.join(__dirname, "..", "..", "assets", "preload-plugins", x))}</script>\n`; });
+	html = html.replaceAll("<!-- preload plugin marker -->", plugins);
+
+	// plugins
+	files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "plugins"));
+	plugins = "";
+	files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script src='/assets/plugins/${x}'></script>\n`; });
+	html = html.replaceAll("<!-- plugin marker -->", plugins);
+	//preload plugins
+	files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "preload-plugins"));
+	plugins = "";
+	files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script>${fs.readFileSync(path.join(__dirname, "..", "..", "assets", "preload-plugins", x))}</script>\n`; });
+	html = html.replaceAll("<!-- preload plugin marker -->", plugins);
 
-	app.use("/assets", express.static(path.join(__dirname, "..", "..", "assets")));
 
+	app.use("/assets", express.static(path.join(__dirname, "..", "..", "assets")));
+	
 	app.get("/assets/:file", async (req: Request, res: Response) => {
 		delete req.headers.host;
 		var response: FetchResponse;