Author SHA1 Message Date
Romulus21andClaude Opus 5.5 0c9b9c5823 Fait clignoter le favicon en rouge pendant un enregistrement
Favicon par défaut (static/favicon.svg) ; tant que /api/timer renvoie
une entrée en cours, il alterne chaque seconde entre un point rouge plein
et pâle, sur toutes les pages. État relu au chargement, après chaque
requête htmx, au retour sur l'onglet et toutes les 20 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:54:34 +01:00
Romulus21andClaude Opus 5.5 aa4f5aeb0a Versionne les URL de app.css et app.js
Un hash du contenu est ajouté en ?v= : après un déploiement, le
navigateur recharge le CSS/JS au lieu de garder l'ancien en cache
(max-age=3600).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:39:05 +01:00
Romulus21andClaude Opus 5.5 b4702fdf71 Merge branch 'feat/clients-pictos'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:36:44 +01:00
4 changed files with 64 additions and 8 deletions

No files matched your search

+19 -6
View File
@@ -44,18 +44,31 @@ pub fn app(pool: SqlitePool) -> Router {
) )
}), }),
) )
.route("/static/app.js", get(|| asset("text/javascript", APP_JS)))
.route("/static/app.css", get(|| asset("text/css", APP_CSS)))
.route( .route(
"/static/app.js", "/static/favicon.svg",
get(|| asset("text/javascript", include_str!("../../static/app.js"))), get(|| asset("image/svg+xml", include_str!("../../static/favicon.svg"))),
)
.route(
"/static/app.css",
get(|| asset("text/css", include_str!("../../static/app.css"))),
) )
.layer(TraceLayer::new_for_http()) .layer(TraceLayer::new_for_http())
.with_state(pool) .with_state(pool)
} }
const APP_CSS: &str = include_str!("../../static/app.css");
const APP_JS: &str = include_str!("../../static/app.js");
/// Hash of app.css + app.js, appended as `?v=` to their URLs so a deploy
/// bypasses the browser cache.
pub fn asset_version() -> &'static str {
static VERSION: std::sync::LazyLock<String> = std::sync::LazyLock::new(|| {
use std::hash::{Hash, Hasher};
let mut h = std::collections::hash_map::DefaultHasher::new();
(APP_CSS, APP_JS).hash(&mut h);
format!("{:x}", h.finish())
});
&VERSION
}
// En livereload, le CSS/JS doit être relu à chaque rechargement. // En livereload, le CSS/JS doit être relu à chaque rechargement.
const CACHE_CONTROL: &str = if cfg!(feature = "livereload") { const CACHE_CONTROL: &str = if cfg!(feature = "livereload") {
"no-cache" "no-cache"
+41
View File
@@ -61,3 +61,44 @@ function removeRow(button) {
for (const input of row.querySelectorAll("input")) input._flatpickr?.destroy(); for (const input of row.querySelectorAll("input")) input._flatpickr?.destroy();
row.remove(); row.remove();
} }
// Favicon : point rouge clignotant tant qu'un enregistrement est en cours,
// sur toutes les pages (état lu sur /api/timer).
const favicon = document.getElementById("favicon");
const IDLE_ICON = favicon.href;
const recIcon = (opacity) =>
"data:image/svg+xml," +
encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="13" fill="#e5322d" fill-opacity="${opacity}"/></svg>`,
);
const REC_ON = recIcon(1);
const REC_OFF = recIcon(0.2);
let recording = false;
let blinkOn = false;
function setRecording(value) {
if (value === recording) return;
recording = value;
blinkOn = true;
favicon.href = recording ? REC_ON : IDLE_ICON;
}
setInterval(() => {
if (!recording) return;
blinkOn = !blinkOn;
favicon.href = blinkOn ? REC_ON : REC_OFF;
}, 1000);
async function refreshRecording() {
try {
const res = await fetch("/api/timer", { headers: { accept: "application/json" } });
if (res.ok) setRecording((await res.json()) !== null);
} catch {
// Serveur injoignable : on garde l'état connu.
}
}
refreshRecording();
setInterval(refreshRecording, 20000);
document.addEventListener("visibilitychange", () => {
if (!document.hidden) refreshRecording();
});
document.body.addEventListener("htmx:afterRequest", refreshRecording);
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="12" fill="none" stroke="#2f6f5e" stroke-width="4"/><path d="M16 9v7l4 3" fill="none" stroke="#2f6f5e" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>

After

Width:  |  Height:  |  Size: 261 B

+3 -2
View File
@@ -4,12 +4,13 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Tempus{% endblock %} · Tempus</title> <title>{% block title %}Tempus{% endblock %} · Tempus</title>
<link rel="icon" id="favicon" type="image/svg+xml" href="/static/favicon.svg">
<link rel="stylesheet" href="/static/flatpickr/flatpickr.min.css"> <link rel="stylesheet" href="/static/flatpickr/flatpickr.min.css">
<link rel="stylesheet" href="/static/app.css"> <link rel="stylesheet" href="/static/app.css?v={{ crate::routes::asset_version() }}">
<script src="/static/htmx.min.js" defer></script> <script src="/static/htmx.min.js" defer></script>
<script src="/static/flatpickr/flatpickr.min.js" defer></script> <script src="/static/flatpickr/flatpickr.min.js" defer></script>
<script src="/static/flatpickr/fr.min.js" defer></script> <script src="/static/flatpickr/fr.min.js" defer></script>
<script src="/static/app.js" defer></script> <script src="/static/app.js?v={{ crate::routes::asset_version() }}" defer></script>
</head> </head>
<body> <body>
<header class="topbar"> <header class="topbar">