Files
tytd2025/Tesses.YouTubeDownloader.Server/src/components/shell.tcross
Mike Nolan c82957cc61
Some checks failed
Build and Deploy on Tag / 🔨 Build for everything else (push) Failing after 11s
Build and Deploy on Tag / 🔨 Build for PowerPC (push) Failing after 20s
Make it a little faster, queue is in sqlite now, fix db bug and more
2026-06-25 15:35:39 -05:00

146 lines
4.5 KiB
Plaintext

func Components.Shell(title, html, page, $mypage)
{
if(TypeOf(mypage) != "Path")
mypage = /;
var index = (/).MakeRelative(mypage).ToString();
if(index == "") index = "./";
const service_worker_script_path = (/"service_worker.js").MakeRelative(mypage).ToString();
const service_worker_script = $"<script>
if(\"serviceWorker\" in navigator) {123.ToChar()}
navigator.serviceWorker.register({Json.Encode(service_worker_script_path)})
.then(()=>console.log('Service worker registered'))
.catch(()=>console.log('service work not registered'));
{125.ToChar()}
</script>";
var pages = [
{
text="Home",
icon="home",
href=index,
classStr="",
badge = ""
},
{
text="Queue",
icon="downloading",
href=(/"queue").MakeRelative(mypage).ToString(),,
classStr="",
badge=<b hx-trigger="every 1000ms" hx-target="this" hx-push-url="false" hx-indicator="none" hx-get="./queue-size" hx-swap="outerHTML">
?
</b>
},
{
text = "Downloads",
icon = "download",
href=(/"downloads").MakeRelative(mypage).ToString(),
classStr="",
badge=""
},
{
text = "Plugins",
icon = "extension",
href= (/"plugins").MakeRelative(mypage).ToString(),
classStr="",
badge=""
},
{
text = "Settings",
icon = "settings",
href= (/"settings").MakeRelative(mypage).ToString(),
classStr="",
badge=""
},
{
text = "Api",
icon = "api",
href = (/"api").MakeRelative(mypage).ToString(),
classStr="",
badge=""
}
];
pages[page].classStr = " primary-container";
return <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TYTD - {title}</title>
<link rel="stylesheet" href={(/"beer.min.css").MakeRelative(mypage).ToString()}>
<link rel="stylesheet" href={(/"theme.css").MakeRelative(mypage).ToString()}>
<link rel="manifest" href={(/"site.webmanifest").MakeRelative(mypage).ToString()}>
<script src={(/"htmx.min.js").MakeRelative(mypage).ToString()} defer></script>
<script src={(/"offline.js").MakeRelative(mypage).ToString()} defer></script>
<script type="module" src={(/"beer.min.js").MakeRelative(mypage).ToString()} defer></script>
</head>
<body hx-indicator="#loading-indicator">
<dialog class="left" id="leftpane">
<header>
<nav>
<img class="circle large" src="/tytd-128.png">
<h6 class="max">TYTD2025</h6>
<button hx-on:click="ui('#leftpane')" class="transparent circle large">
<i>close</i>
</button>
</nav>
</header>
<div class="space"></div>
<ul class="list">
<each(var page : pages)>
<li class={$"wave round{page.classStr}"} hx-target="body" hx-push-url="true" hx-get={page.href}>
<i>{page.icon}</i>
<span class="max">{page.text}</span>
<raw(page.badge)>
</li>
</each>
</ul>
</dialog>
<header class="fixed primary-container">
<nav>
<button hx-on:click="ui('#leftpane')" class="circle transparent">
<i>menu</i>
</button>
<h6 class="max">TYTD2025</h6>
</nav>
</header>
/*<nav class="bottom">
<each(var page : pages)>
<a hx-get={page.href} hx-target="body" hx-push-url="true" class={page.classStr}>
<i>{page.icon}</i>
<if(page.text == "Home")>
<true>
<span hx-trigger="every 1000ms" hx-target="this" hx-push-url="false" hx-indicator="none" hx-get="./queue-size" hx-swap="outerHTML" class="badge">
?
</span>
</true>
</if>
<div>{page.text}</div>
</a>
</each>
</nav>*/
<main class="responsive">
<raw(html)>
</main>
<div class="htmx-indicator shape loading-indicator extra" id="loading-indicator">
<img class="responsive" src="./tytd.svg">
</div>
<raw(service_worker_script)>
</body>
</html>;
}