ips/pkg6depotd/templates/base.html
Till Wegmueller 4591767a0a
fix: Embed static assets in binary and fix font loading
Static files (CSS, JS) were served via ServeDir using CARGO_MANIFEST_DIR
which only exists on the build machine, not on deployed servers. This
caused: white unstyled page, always-visible loading indicators, and
broken manifest loading.

- Embed style.css and htmx.min.js into the binary via include_str!
- Serve them from dedicated handlers with proper content-type and caching
- Move Google Fonts from CSS @import to <link> tags with preconnect
  for non-blocking font loading
- Remove ServeDir dependency from routes
2026-03-15 22:49:33 +01:00

64 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Package Repository{% endblock %}</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Source+Sans+3:wght@300;400;500;600;700&display=swap">
<link rel="stylesheet" href="/ui/static/css/style.css">
<script src="/ui/static/js/htmx.min.js"></script>
</head>
<body>
<nav class="depot-nav">
<div class="nav-inner">
<a href="/ui/" class="brand">pkg depot</a>
<div class="nav-links">
<a href="/ui/"{% block nav_publishers %}{% endblock %}>Publishers</a>
<a href="/ui/search"{% block nav_search %}{% endblock %}>Search</a>
</div>
</div>
</nav>
<main class="container">
{% block content %}{% endblock %}
</main>
<div id="p5i-cart" class="p5i-cart" style="display:none">
<span class="cart-count" id="p5i-count">0</span>
<span class="cart-label">selected</span>
<a href="#" class="cart-action" id="p5i-download" onclick="downloadP5i(); return false;">Download P5I</a>
</div>
<script>
const p5iSelection = new Set();
function toggleP5i(checkbox, publisher, fmri) {
const key = publisher + '|' + fmri;
if (checkbox.checked) {
p5iSelection.add(key);
} else {
p5iSelection.delete(key);
}
const cart = document.getElementById('p5i-cart');
const count = document.getElementById('p5i-count');
count.textContent = p5iSelection.size;
cart.style.display = p5iSelection.size > 0 ? 'flex' : 'none';
}
function downloadP5i() {
const byPub = {};
for (const key of p5iSelection) {
const [pub_, fmri] = key.split('|', 2);
if (!byPub[pub_]) byPub[pub_] = [];
byPub[pub_].push(fmri);
}
const publishers = Object.keys(byPub);
if (publishers.length === 0) return;
const pub_ = publishers[0];
const params = new URLSearchParams();
params.set('publisher', pub_);
for (const fmri of byPub[pub_]) {
params.append('pkg', fmri);
}
window.location.href = '/ui/p5i?' + params.toString();
}
</script>
</body>
</html>