television

a simple LAN/WLAN desktop public broadcasting service
git clone http://git.permacomputing.net/repos/television.git # read-only access
Log | Files | Refs | README

commit 167303da0312fe15d871755f6ad03bc96d002af9
parent 044ac729602f5399e85d0aeafd3f28b36d08f3c7
Author: ugrnm <ultrageranium@bleu255.com>
Date:   Wed,  9 Oct 2024 23:54:32 +0200

super stealth mode

Diffstat:
M.gitignore | 2+-
MREADME | 11++++++-----
Mwww/index.html | 15+--------------
Dwww/style.css | 29-----------------------------
Dwww/tv.js | 54------------------------------------------------------
Rwww/bg.png -> www/tv/bg.png | 0
Awww/tv/index.html | 14++++++++++++++
Rwww/nosignal.jpg -> www/tv/nosignal.jpg | 0
Awww/tv/style.css | 29+++++++++++++++++++++++++++++
Awww/tv/tv.js | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 105 insertions(+), 103 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,3 @@ go.sum -www/tv.jpg +www/tv/tv.jpg television diff --git a/README b/README @@ -95,7 +95,7 @@ examples What does this do? It just werks. Just run it like this from the git folder (after building it), -and ask everyone to join http://your.local.ip.address:8888 +and ask everyone to join http://your.local.ip.address:8888/tv --- @@ -104,12 +104,13 @@ and ask everyone to join http://your.local.ip.address:8888 What does this do? -port 666 Somehow you insisted to serve the result on - http://your.local.ip.address:666. + http://your.local.ip.address:666/tv --- television \ - -snap "scrot /tmp/www/tv.tmp.jpg && mv /tmp/www/tv.tmp.jpg /tmp/www/tv.jpg" \ + -snap "scrot /tmp/www/tv/tv.tmp.jpg \ + && mv /tmp/www/tv/tv.tmp.jpg /tmp/www/tv/tv.jpg" \ -www /tmp/www \ -idle @@ -131,8 +132,8 @@ What does this do? ./television \ -snap "import \ - -colors 2 -dither FloydSteinberg -window root www/tv.tmp.jpg \ - && mv www/tv.tmp.jpg www/tv.jpg" + -colors 2 -dither FloydSteinberg -window root www/tv/tv.tmp.jpg \ + && mv www/tv/tv.tmp.jpg www/tv/tv.jpg" What does this do? diff --git a/www/index.html b/www/index.html @@ -1,14 +1 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="UTF-8"> - <title>television</title> - <link rel="stylesheet" href="/style.css"> - <script src="/tv.js"></script> - </head> - <body> - <img id="nosignal" src="/nosignal.jpg" alt="no signal"> - <img id="television" src="/tv.jpg" alt="television"> - </body> -</html> - +o/ diff --git a/www/style.css b/www/style.css @@ -1,29 +0,0 @@ -* { - margin: 0; - padding 0; -} - -html { - background-color: #000; - background-image: url("/bg.png"); - background-position: center; - z-index: 0; -} - -img { - margin: auto; - position: absolute; - top: 0; left: 0; bottom: 0; right: 0; - max-width: 100%; - max-height: 100%; -} - -img#nosignal { - z-index: 5; - visibility: hidden; -} - -img#television { - z-index: 10; -} - diff --git a/www/tv.js b/www/tv.js @@ -1,54 +0,0 @@ -(function () { - // Fetch a new tv.jpg every second - a non-obvious HOWTO - // - // In theory, fetch() combined with a "no-store" cache directive should be - // enough to 1. force re-download the image and 2. bypass the cache entirely. - // However in practice, even though FF and chromium are properly - // re-downloading the new file without using their cache, they will *not* - // refresh the view. To force redraw the image we need to rewrite the img src - // with a classic cache busting garbage URL trick. If we do, then FF and - // chromium *do* display the new image, but then it means we have downloaded - // the file twice! This is obviously super wasteful. A workaround to limit - // the damages, is to use a different method for fetching. By default it uses - // GET, but if we use HEAD instead, it won't download the file, it will just - // get the headers, thus validating the response, and as follow-up function - // we can use our traditional cache busting src rewrite. It's still two http - // requests, but only one file download. - // - // Could it be done differently? - // - setInterval(function(){ - tv = "/tv.jpg"; - fetch(tv, { cache: "no-store", method: "HEAD" }) - .then((response) => { - document.getElementById("nosignal").style.visibility = "hidden"; - document.getElementById("television").style.visibility = "visible"; - document.getElementById("television").src=tv + "#" + Date.now(); - }) - .catch((error) => { - document.getElementById("television").style.visibility = "hidden"; - document.getElementById("nosignal").style.visibility = "visible"; - }); - }, 1000); - - // Press 'f' to enter fullscreen - // Press 'f' again to exit fullscreen - // - function toggleFullScreen() { - if (!document.fullscreenElement) { - document.documentElement.requestFullscreen(); - } else if (document.exitFullscreen) { - document.exitFullscreen(); - } - } - - document.addEventListener( - "keydown", - (e) => { - if (e.key === "f") { - toggleFullScreen(); - } - }, - false, - ); -})(); diff --git a/www/bg.png b/www/tv/bg.png Binary files differ. diff --git a/www/tv/index.html b/www/tv/index.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="UTF-8"> + <title>television</title> + <link rel="stylesheet" href="/tv/style.css"> + <script src="/tv/tv.js"></script> + </head> + <body> + <img id="nosignal" src="/tv/nosignal.jpg" alt="no signal"> + <img id="television" src="/tv/tv.jpg" alt="television"> + </body> +</html> + diff --git a/www/nosignal.jpg b/www/tv/nosignal.jpg Binary files differ. diff --git a/www/tv/style.css b/www/tv/style.css @@ -0,0 +1,29 @@ +* { + margin: 0; + padding 0; +} + +html { + background-color: #000; + background-image: url("/tv/bg.png"); + background-position: center; + z-index: 0; +} + +img { + margin: auto; + position: absolute; + top: 0; left: 0; bottom: 0; right: 0; + max-width: 100%; + max-height: 100%; +} + +img#nosignal { + z-index: 5; + visibility: hidden; +} + +img#television { + z-index: 10; +} + diff --git a/www/tv/tv.js b/www/tv/tv.js @@ -0,0 +1,54 @@ +(function () { + // Fetch a new tv.jpg every second - a non-obvious HOWTO + // + // In theory, fetch() combined with a "no-store" cache directive should be + // enough to 1. force re-download the image and 2. bypass the cache entirely. + // However in practice, even though FF and chromium are properly + // re-downloading the new file without using their cache, they will *not* + // refresh the view. To force redraw the image we need to rewrite the img src + // with a classic cache busting garbage URL trick. If we do, then FF and + // chromium *do* display the new image, but then it means we have downloaded + // the file twice! This is obviously super wasteful. A workaround to limit + // the damages, is to use a different method for fetching. By default it uses + // GET, but if we use HEAD instead, it won't download the file, it will just + // get the headers, thus validating the response, and as follow-up function + // we can use our traditional cache busting src rewrite. It's still two http + // requests, but only one file download. + // + // Could it be done differently? + // + setInterval(function(){ + tv = "/tv/tv.jpg"; + fetch(tv, { cache: "no-store", method: "HEAD" }) + .then((response) => { + document.getElementById("nosignal").style.visibility = "hidden"; + document.getElementById("television").style.visibility = "visible"; + document.getElementById("television").src=tv + "#" + Date.now(); + }) + .catch((error) => { + document.getElementById("television").style.visibility = "hidden"; + document.getElementById("nosignal").style.visibility = "visible"; + }); + }, 1000); + + // Press 'f' to enter fullscreen + // Press 'f' again to exit fullscreen + // + function toggleFullScreen() { + if (!document.fullscreenElement) { + document.documentElement.requestFullscreen(); + } else if (document.exitFullscreen) { + document.exitFullscreen(); + } + } + + document.addEventListener( + "keydown", + (e) => { + if (e.key === "f") { + toggleFullScreen(); + } + }, + false, + ); +})();