fix(api): 🐛 Fix incorrect function order causing Lysand branding not to be applied in glitch-soc

This commit is contained in:
Jesse Wierzbinski 2024-04-15 21:54:39 -10:00
parent 852a393c78
commit 6a419a2015
No known key found for this signature in database

View file

@ -192,6 +192,32 @@ const indexTransforms = async (
user: UserWithRelations | null, user: UserWithRelations | null,
) => { ) => {
let newFileContents = fileContents; let newFileContents = fileContents;
for (const server of config.frontend.glitch.server) {
newFileContents = newFileContents.replaceAll(
`${new URL(server).origin}/`,
"/",
);
newFileContents = newFileContents.replaceAll(
new URL(server).host,
new URL(config.http.base_url).host,
);
}
newFileContents = newFileContents.replaceAll(
"Glitch-soc is free open source software forked from Mastodon.",
"Lysand is free and open-source software using the Glitch-Soc frontend.",
);
newFileContents = newFileContents.replaceAll("Mastodon", "Lysand");
newFileContents = newFileContents.replaceAll(
"Lysand is free, open-source software, and a trademark of Mastodon gGmbH.",
"This is not a Mastodon instance.",
);
newFileContents = newFileContents.replaceAll(
"joinmastodon.org",
"lysand.org",
);
// Find script id="initial-state" and replace its contents with custom json // Find script id="initial-state" and replace its contents with custom json
const rewriter = new HTMLRewriter() const rewriter = new HTMLRewriter()
.on("script#initial-state", { .on("script#initial-state", {
@ -276,31 +302,6 @@ const indexTransforms = async (
}) })
.transform(new Response(newFileContents)); .transform(new Response(newFileContents));
for (const server of config.frontend.glitch.server) {
newFileContents = newFileContents.replaceAll(
`${new URL(server).origin}/`,
"/",
);
newFileContents = newFileContents.replaceAll(
new URL(server).host,
new URL(config.http.base_url).host,
);
}
newFileContents = newFileContents.replaceAll(
"Glitch-soc is free open source software forked from Mastodon.",
"Lysand is free and open-source software using the Glitch-Soc frontend.",
);
newFileContents = newFileContents.replaceAll("Mastodon", "Lysand");
newFileContents = newFileContents.replaceAll(
"Lysand is free, open-source software, and a trademark of Mastodon gGmbH.",
"This is not a Mastodon instance.",
);
newFileContents = newFileContents.replaceAll(
"joinmastodon.org",
"lysand.org",
);
return rewriter.text(); return rewriter.text();
}; };