converge/pkg/server/templates/basepage.templ
Erik Brakkee 7e60e23df1 A lot of work in getting cut and paste from the UI to
work properly.

Wrote two web components. One for cut and paste in general, and another for code samples.
2024-08-05 22:51:49 +02:00

96 lines
3.1 KiB
Plaintext

package templates
func active(actual int, active int) string {
res := "nav-item nav-link"
if actual == active {
return res + " active"
}
return res
}
templ BasePage(tab int) {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../static/css/bootstrap.min.css"
crossorigin="anonymous">
<link rel="stylesheet" href="../static/icons/font/bootstrap-icons.css">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="../static/js/htmx.1.9.12.js"></script>
<script src="../static/js/htmx.ws.1.9.12.js"></script>
<script type="module" src="../static/js/custom.js"></script>
<title>Converge</title>
</head>
<body>
<!-- script>
htmx.logAll();
</script -->
<script>
function getTimezone() {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
}
if (!window.originalWebSocket) {
console.log("timezone override for websockets")
window.originalWebSocket = htmx.createWebSocket
htmx.createWebSocket = function(url) {
url = new URL(url, window.location.href).href
url = url.replace(/^http/, 'ws');
let modifiedUrl = url + "?timezone=" + getTimezone()
return window.originalWebSocket(modifiedUrl)
}
}
document.body.addEventListener(
"htmx:configRequest",
function(evt) {
console.log("Adding timezone to htmx request headers and making URL absolute");
evt.detail.headers["X-Timezone"] = getTimezone();
}
);
</script>
<script src="../static/js/bootstrap.bundle.min.js"
crossorigin="anonymous"></script>
<div class="container-fluid" hx-boost="true">
<div class="row">
<div class="col">
<nav class="navbar navbar-expand-sm navbar-light bg-light">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarNavAltMarkup"
aria-controls="navbarNav" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="nav nav-pills">
<a class={active(1,tab)} href="index.html">overview</a>
<a class={active(2,tab)} href="usage.html">usage</a>
<a class={active(3,tab)} href="downloads.html">downloads</a>
<a class={active(4,tab)} href="sessions.html">sessions</a>
</div>
</div>
</nav>
</div>
</div>
<div class="row">
<div class="col">
{ children... }
</div>
</div>
</div>
</body>
</html>
}