Caspar Template
All checks were successful
Build & Push Docker (latest) / verify (push) Successful in 9m29s
Build & Push Docker (latest) / build (push) Successful in 8s

This commit is contained in:
Aiden Wilson
2026-05-29 22:51:32 +10:00
parent a88306aec7
commit bba1ab5cee
6 changed files with 375 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
import { fetchOembed } from "./oembed.js";
import { loadProviders } from "./providers.js";
import { errorPage, graphicPage, homePage } from "./templates.js";
import { casparTemplatePage, errorPage, graphicPage, homePage } from "./templates.js";
const __dirname = fileURLToPath(new URL(".", import.meta.url));
const rootDir = join(__dirname, "..");
@@ -52,7 +52,11 @@ function getNumber(searchParams, key, defaultValue, min, max) {
}
async function serveStatic(requestUrl, response) {
const path = requestUrl.pathname === "/styles.css" ? "styles.css" : "";
const staticPaths = new Map([
["/styles.css", "styles.css"],
["/caspar.js", "caspar.js"],
]);
const path = staticPaths.get(requestUrl.pathname) || "";
if (!path) {
return false;
@@ -117,6 +121,11 @@ async function handleRequest(request, response) {
return;
}
if (requestUrl.pathname === "/caspar") {
send(response, 200, casparTemplatePage());
return;
}
if (requestUrl.pathname === "/providers") {
const providers = await loadProviders();
sendJson(response, 200, {

View File

@@ -330,6 +330,17 @@ export function homePage({ providersCount = 0 } = {}) {
</html>`;
}
export function casparTemplatePage() {
return `${commonHead({ title: "oEmbed CasparCG Template", htmlClass: "graphic-document transparent" })}
<body class="graphic transparent is-loading" style="--stage-width:1920px; --stage-height:1080px; --scale:1; --chroma:#00ff00;">
<main class="stage fit-contain">
<section class="embed provider-empty" data-source="" style="--embed-width:500px"></section>
</main>
<script src="/caspar.js"></script>
</body>
</html>`;
}
export function graphicPage({
targetUrl,
embed,