tracker
All repositories: gitoria
2.5 KB
// lib/images.hl — THE IMAGE FILES the pages show (mission 028: out of project.hl, whose routes /posters/:name and// /profiles/:name call `imageResponse`):// /posters/<name> a title's poster (tracker.worldapi.org#4) from storage/mpackdb/posters/ — the file name is the title's// oldId + its extension (shows.hl posterName), downloaded by the sync (tmdb.hl syncPoster)// /profiles/<name> a person's photo (tracker.worldapi.org#16) from storage/mpackdb/profiles/ — downloaded on the first visit// of the person page (people.hl syncProfile)// Both fall back to a placeholder svg when the file isn't there yet (the mongo export never included the poster bytes): "no poster",// a person's "no photo" (tracker#37: /people's tiles).import { Response } from 'hl:http1'import { readBytes, exists } from 'hl:fs'import { imageHeaders } from './security.hl'static placeholderPoster = './assets/poster-placeholder.svg'static placeholderPhoto = './assets/photo-placeholder.svg'static posterNameChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_'// a plain file name: letters, digits, '.', '-', '_', at most 100 (also the genre redirect's check, project.hl genreMoved)static isSafePosterName = (&name) => {if (name == null || hlTypeName(name) != 'String' || name == '' || name.length > 100) { return false }let i = 0while (i < name.length) {if (!posterNameChars.includes(name[i])) { return false }i = i + 1}return true}static endsWithStr = (&s, suffix) => { return s.length >= suffix.length && s.slice(s.length - suffix.length) == suffix }static mimeOfPoster = (&name) => {if (endsWithStr(name, '.png')) { return 'image/png' }if (endsWithStr(name, '.webp')) { return 'image/webp' }if (endsWithStr(name, '.svg')) { return 'image/svg+xml' }return 'image/jpeg'}// the answer for `<dir>/<name>`: the file (a day in the browser's cache), else the placeholder (an hour); a name that is no// plain file name → 400 "bad <what> name"static imageResponse = (&dir, &name, &what) => {if (!isSafePosterName(name)) { return new Response('bad ' + what + ' name', { status = 400 headers = { 'Content-Type' = 'text/plain; charset=utf-8' 'X-Content-Type-Options' = 'nosniff' } }) }path = dir + '/' + nameif (exists(path)) { return new Response(readBytes(path), { headers = imageHeaders(mimeOfPoster(name), 'public, max-age=86400') }) }return new Response(readBytes(what == 'photo' ? placeholderPhoto : placeholderPoster), { headers = imageHeaders('image/svg+xml', 'public, max-age=3600') })}
Branches
Latest commits
- 9d686bb3Tracker: CL1 reviewedmre
- b8bba562CL1: crash loop report (SIGPIPE confirmed, trap wrapper option)mre
- 298785f2Tracker: CL1 startedmre
- 36b22710Tracker: port slot, CL1 briefmre
- a401190fTracker: GO for the crash loopmre
- e195d372Tracker: token pathsmre
- 7f541d11Tracker conductor: CONDUCTOR.md, short STATUS.md, old status + decisions archive to archive/2026-10-31mre
- 8dd423f7README: login.js stays by caramboleyo's explicit rulemre
- d8df1493tracker: standby service on port 45018 and a gap-free hand-over in deploy.sh step 4mre
- 36dd1686ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- ff9b838etracker: the Ended status pill uses the same red as layouts (pill danger); gate updatedmre
- 40d9719eTP2: LOG line and report for the tracker pillsmre
- ab3f2ba5tracker: status, genres, TMDB/IMDb/TVDB/TVmaze links and list kinds use the theme's pill; dense season list with the season check centred on its title line; gates for bothmre
- 521061d6tracker header on phones: signed in, the brand fits whole at 360 and 390 px (tighter gaps and side paddings, slightly smaller brand, narrow screens and signed in only); mobile gate checks itmre
- 18114a53tracker: franchises gate waits for the signed-out selector instead of the removed Log in buttonmre
- 08561d73ident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
- 59ef1e4atests/browser: repair 'done' check counts the 404 titles the first run already finished (race: failed=1 when Bulk Film 79 ran before the restart)mre
- 5925fc4dreports/MK-mobile.md: rebase update, gate countsmre
- 6adbc7f0extlink badges: background-clip after the background shorthand (it reset the clip: the pills were 44 px tall); gates check the lookmre
- 8d3b0f20widget: the franchise link's 44 px tap area no longer overlaps the Prequel/Sequel rowmre