Caspar Template
This commit is contained in:
@@ -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, {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user