stream: make the web player installable as a PWA
Wire up a web manifest, service worker and icon routes so the player can be installed on mobile. The static manifest stays generic; the page regenerates it at runtime from STATION_NAME so an instance keeps its name. The service worker only caches the app shell, never the live stream or the playback APIs. Icons (192/512, maskable and apple-touch) are rasterized from the favicon. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
976f009297
commit
c73b71d32f
10 changed files with 239 additions and 0 deletions
|
|
@ -224,6 +224,15 @@ output.harbor(
|
|||
home_html = file.contents("/etc/liquidsoap/index.html")
|
||||
favicon_svg = file.contents("/etc/liquidsoap/favicon.svg")
|
||||
|
||||
# Ressources de la webapp installable (PWA) : manifeste, service worker et jeu
|
||||
# d'icônes. Chargées une fois au démarrage puis servies telles quelles.
|
||||
manifest_json = file.contents("/etc/liquidsoap/manifest.webmanifest")
|
||||
sw_js = file.contents("/etc/liquidsoap/sw.js")
|
||||
icon_192 = file.contents("/etc/liquidsoap/icon-192.png")
|
||||
icon_512 = file.contents("/etc/liquidsoap/icon-512.png")
|
||||
icon_maskable_512 = file.contents("/etc/liquidsoap/icon-maskable-512.png")
|
||||
apple_touch_icon = file.contents("/etc/liquidsoap/apple-touch-icon.png")
|
||||
|
||||
harbor.http.register(
|
||||
port=8000, method="GET", "/",
|
||||
fun(_, resp) -> begin
|
||||
|
|
@ -240,6 +249,58 @@ harbor.http.register(
|
|||
end
|
||||
)
|
||||
|
||||
harbor.http.register(
|
||||
port=8000, method="GET", "/manifest.webmanifest",
|
||||
fun(_, resp) -> begin
|
||||
resp.content_type("application/manifest+json; charset=utf-8")
|
||||
resp.data(manifest_json)
|
||||
end
|
||||
)
|
||||
|
||||
# Le service worker doit être servi depuis la racine pour couvrir tout le site
|
||||
# (portée par défaut = son emplacement). Pas de cache HTTP agressif : le
|
||||
# navigateur revérifie régulièrement le script.
|
||||
harbor.http.register(
|
||||
port=8000, method="GET", "/sw.js",
|
||||
fun(_, resp) -> begin
|
||||
resp.content_type("text/javascript; charset=utf-8")
|
||||
resp.header("Cache-Control", "no-cache")
|
||||
resp.data(sw_js)
|
||||
end
|
||||
)
|
||||
|
||||
harbor.http.register(
|
||||
port=8000, method="GET", "/icon-192.png",
|
||||
fun(_, resp) -> begin
|
||||
resp.content_type("image/png")
|
||||
resp.data(icon_192)
|
||||
end
|
||||
)
|
||||
|
||||
harbor.http.register(
|
||||
port=8000, method="GET", "/icon-512.png",
|
||||
fun(_, resp) -> begin
|
||||
resp.content_type("image/png")
|
||||
resp.data(icon_512)
|
||||
end
|
||||
)
|
||||
|
||||
harbor.http.register(
|
||||
port=8000, method="GET", "/icon-maskable-512.png",
|
||||
fun(_, resp) -> begin
|
||||
resp.content_type("image/png")
|
||||
resp.data(icon_maskable_512)
|
||||
end
|
||||
)
|
||||
|
||||
harbor.http.register(
|
||||
port=8000, method="GET", "/apple-touch-icon.png",
|
||||
fun(_, resp) -> begin
|
||||
resp.content_type("image/png")
|
||||
resp.data(apple_touch_icon)
|
||||
end
|
||||
)
|
||||
|
||||
harbor.http.register(
|
||||
port=8000, method="GET", "/nowplaying",
|
||||
fun(_, resp) -> begin
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue