tracker
All repositories: gitoria
15.1 KB
// project.hl — tracker.worldapi.org: THE MAP (mission 028, docs: README "Files"). Config, the routes and how the parts are wired;// what each feature does is in the file named here, not in this one.//// login (ident only, the header's selector + button) lib/users.hl, components/main.hl, login.js, /login/* below// the shell: header, main menu, user menu, sidebar components/main.hl (theme/shell/*, vendored from layouts.worldapi.org)// /genres · /people (the main menu) · /settings lib/catalog.hl genreList · lib/people.hl peoplePage · components/settings.hl// titles: records, slugs, kinds, list caches lib/shows.hl a title's page: components/show.hl// public lists /movies /series /shows /genres, home lib/catalog.hl// components/{movies,allseries,allshows,genre,home,tilelist}.hl// follows · watches · /my/* lib/follows.hl · lib/watches.hl// components/{myshows,mymovies,unwatched,schedule}.hl// search, web search, import lib/search.hl (+ search-helpers.hl) components/search.hl// people, a person's page and filmography fill lib/people.hl components/person.hl// cast + crew, the credits job lib/credits.hl (+ credits-helpers.hl)// a title completed from TMDB (details repair) lib/details.hl// TMDB / TVmaze requests, posters lib/tmdb.hl// the sync of one title · which titles a day lib/sync.hl (+ sync-helpers.hl) · lib/dailysync.hl// adult flag + kind backfills lib/backfill.hl// short ids (/<shortId>) lib/shortids.hl// the boot scans: ONE streamed pass per table lib/bootscan.hl// franchises + timelines · TMDB collection seed lib/franchises.hl · lib/collections.hl// the curated franchises (data/franchises.json, #40) lib/franchiseseed.hl// components/franchise*.hl, timelineedit.hl// duplicate titles merged lib/merge.hl// the background jobs and their clocks lib/jobs.hl (one instance, made below after the server)// poster + photo files lib/images.hl// HTTP redirects / title page adapter lib/redirects.hl · lib/title-route.hl// shared helpers (env, paths, dates, ids, lists) lib/util.hl// styles · design tokens · the WorldAPI theme components/styles.hl · shared/tokens.hl · theme/ (never edited here)//// Config (env; no committed secret — the first deploy registers this app in ident and sets these, done by the architect, as// with ident's own .env for SMTP): TRACKER_PORT (45008), TRACKER_URL (this app's own public address, for the return URL),// IDENT_URL (https://ident.worldapi.org), TRACKER_KEY (pk_…), TRACKER_SECRET (sk_…), TRACKER_STORAGE, TRACKER_SESSIONS,// TRACKER_WATCH, TMDB_READ_TOKEN; the jobs' switches and limits: lib/jobs.hl (README "Config").import WebFramework from 'hl:web'import { env, exit } from 'hl:proc'import { now, every } from 'hl:time'import Styles from './components/styles.hl'import Home from './components/home.hl'import LoginFailed from './components/loginfailed.hl'import Show from './components/show.hl'import Unwatched from './components/unwatched.hl'import Schedule from './components/schedule.hl'import MyShows from './components/myshows.hl'import MyMovies from './components/mymovies.hl'import Movies from './components/movies.hl'import AllShows from './components/allshows.hl'import AllSeries from './components/allseries.hl'import Search from './components/search.hl'import Person from './components/person.hl'import Genre from './components/genre.hl'import Genres from './components/genres.hl'import People from './components/people.hl'import Settings from './components/settings.hl'import Franchises from './components/franchises.hl'import Franchise from './components/franchise.hl'import FranchiseEdit from './components/franchiseedit.hl'import TimelineEdit from './components/timelineedit.hl'import { dark, darker } from './shared/tokens.hl'import { loginCallback, sessionAudience } from './lib/users.hl'import { posterRoute, profileRoute } from './lib/images.hl'import { bootStep, bootBegin } from './lib/bootscan.hl'import { warmTitleCaches, warmEpisodeKeys, movedSlugCount } from './lib/shows.hl'import { allWatchedEpisodeIds } from './lib/watches.hl'import { allFollowedShowIds } from './lib/follows.hl'import { shortIdRoute } from './lib/shortids.hl'import { guestRoute } from './lib/people.hl'import { moveCopiedSummaries } from './lib/dailysync.hl'import { ensureFranchises } from './lib/franchises.hl'import Jobs from './lib/jobs.hl'import { findRoute } from './lib/search.hl'import { unwatchedMoved, scheduleMoved, genreMoved } from './lib/redirects.hl'import { showsRoute } from './lib/title-route.hl'import App from './lib/app.hl'static appTitle = App.appTitle// ---- THE INSTALLABLE APP (tracker.worldapi.org#10), the same way calendar.worldapi.org does it: hl:web's own web app// manifest (/__hl/manifest.webmanifest, linked from every head with the apple-touch-icon and theme-color) and service// worker (/__hl/sw.js) from these settings — no JavaScript of ours. Icons in icons/ (icon.svg is the source, the PNGs// are rendered from it with rsvg-convert, README "Icons"). The theme colour is the header's background (darker), the// splash background the page's (dark) — both off the tokens, not written out again.appThemeColor = darker.valueappBackgroundColor = dark.valueappIcons = [{ src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }{ src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }{ src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }{ src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }]appTouchIcon = '/icons/apple-touch-icon.png'appFavicon = '/icons/favicon.svg'// OFFLINE: only the shell — the header and `/` (components/main.hl says "You are offline" while the browser has no// network). The data pages are not kept: without a network they get hl:web's "Unavailable offline" page.offline = [ Home ]styles = Stylesport = env('TRACKER_PORT') != null ? toNumber(env('TRACKER_PORT')) : 45008watching = env('TRACKER_WATCH') != '0'// read by hl:web's own manifest config (WebFramework.hl `cfg.sessionDir`), not the constructor call belowsessionDir = env('TRACKER_SESSIONS') != null ? env('TRACKER_SESSIONS') : nullroutes = [{ pattern = "/favicon.ico" file = "./icons/favicon.ico" headers = { 'Cache-Control' = 'no-cache' } }// the installable app (tracker.worldapi.org#10): the icons (manifest and service worker are hl:web's own, from appIcons / offline){ pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/icons/apple-touch-icon.png" file = "./icons/apple-touch-icon.png" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/icons/favicon.svg" file = "./icons/favicon.svg" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/login/callback" function = loginCallback }{ pattern = "/login/failed" component = LoginFailed }{ pattern = "/login.js" file = "./login.js" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/posters/:name" function = posterRoute }// tracker.worldapi.org#13: every movie / every series, 24 per page — the page is a PATH segment (`/movies/page/2`), a// page component cannot read `?page=` (hybriel#11) — and the movies the user follows{ pattern = "/movies" component = Movies }{ pattern = "/movies/page/:page" component = Movies }// tracker.worldapi.org#21 (mission 068): series and shows split — /series lists the series, /shows the shows; a title's page// is /movies/<slug>, /series/<slug> or /shows/<slug> (one component; /shows/<slug> is showsRoute above){ pattern = "/movies/:slug" component = Show }{ pattern = "/series" component = AllSeries }{ pattern = "/series/page/:page" component = AllSeries }{ pattern = "/series/:slug" component = Show }{ pattern = "/shows" component = AllShows }{ pattern = "/shows/page/:page" component = AllShows }{ pattern = "/shows/:slug" function = showsRoute }{ pattern = "/my/movies" component = MyMovies }{ pattern = "/my/unwatched" component = Unwatched }{ pattern = "/my/schedule" component = Schedule }// #21: /my/series and /my/shows (one component, components/myshows.hl; any other word there is its "Not found"){ pattern = "/my/:tv" component = MyShows }{ pattern = "/unwatched" function = unwatchedMoved }{ pattern = "/schedule" function = scheduleMoved }// tracker.worldapi.org#14: the search — `/search/<text>` (hl:web gives a page no query string, so not `?q=`){ pattern = "/search/:q?" component = Search }{ pattern = "/find" function = findRoute }// tracker.worldapi.org#16: a person's page (the show page's cast and the search link here) and their photo{ pattern = "/person/tmdb/:tmdb" function = guestRoute }{ pattern = "/person/:slug" component = Person }{ pattern = "/profiles/:name" function = profileRoute }// mission 058 (tracker.worldapi.org#25): a genre's movies and series, like /movies (the page in the path){ pattern = "/genres/:genre" component = Genre }{ pattern = "/genres/:genre/page/:page" component = Genre }{ pattern = "/genre/:genre" function = genreMoved }// tracker#32 (mission 031): the main menu's Genres and People, the user menu's Settings{ pattern = "/genres" component = Genres }// tracker#37 (mission 032): /people = everyone, the one updated last first, 24 per page (the page in the path, like /movies){ pattern = "/people" component = People }{ pattern = "/people/page/:page" component = People }{ pattern = "/settings" component = Settings }// tracker.worldapi.org#19 (mission 066): franchises and timelines, the creator's editor (`/franchises/edit` before the slug){ pattern = "/franchises" component = Franchises }{ pattern = "/franchises/page/:page" component = Franchises }{ pattern = "/franchises/edit" component = FranchiseEdit }{ pattern = "/franchises/:slug" component = Franchise }{ pattern = "/timelines/:tslug" component = Franchise }{ pattern = "/timelines/:slug/edit" component = TimelineEdit }{ pattern = "/" component = Home }// mission 060 (tracker.worldapi.org#27): a short id → its page (LAST: every named one-segment route above wins){ pattern = "/:sid" function = shortIdRoute }]// WHO GETS THE PUSH: the login state reaches the tabs of one session (components/main.hl trackerSignedIn/Out).audience = {trackerSignedIn = sessionAudiencetrackerSignedOut = sessionAudience}// cookies are per host, not per port: an own name keeps this app's session apart from// ident's own (and from any other worldapi app sharing a dev host), see ident README "Design// tokens" / hybriel#10 hybriel#17.sessionCookie = 'trackersid'// tracker#30 (mission 025): the slim list caches (lib/shows.hl cardOf / episodeRowsOf) of every followed title, before the first// /my/ load — not filled by that loadtitleCachesStart = now()titleCachesWarm = warmTitleCaches(allFollowedShowIds())episodeKeysWarm = warmEpisodeKeys(allWatchedEpisodeIds())console.log('list caches: ' + titleCachesWarm + ' followed titles, ' + episodeKeysWarm + ' watched episodes in ' + (now() - titleCachesStart) + ' ms')// tracker#18, ONCE (lib/dailysync.hl moveCopiedSummaries): a `summary` that is only the migrated copy of tmdbSummary is MOVED to// `migratedSummary` (mission 070: kept, not shown) — the current TMDB text shows; the creator's own texts staysummariesMoved = moveCopiedSummaries()if (summariesMoved.ran) { console.log('summaries: moved ' + summariesMoved.moved + ' copies of tmdbSummary to migratedSummary, kept ' + summariesMoved.kept + ' own texts, errors ' + summariesMoved.errors + ', ' + summariesMoved.ms + ' ms') }// mission 066: which timelines every title is in (one scan of the timelines), before the first show pagefranchisesReady = ensureFranchises()// mission 043 (tracker#45): ONE streamed pass per table builds the public lists, the slug maps, the search index, the short ids, the// cast photos and /people's order (lib/bootscan.hl). Mission T17 (boot time): the pass is resumable — it runs here for up to// TRACKER_WARM_SYNC_MS (default 1000; the gates give 600000 = a complete start, as before) and, if the tables are bigger, goes// on from a clock AFTER the server listens (a 5 GB copy: 2.3 M rows, minutes of CPU). Pages that need more than is built say "starting up"// (components/warm*.hl); the jobs start when the scan is done (lib/jobs.hl needs the complete short-id map and indexes).warmSyncMs = env('TRACKER_WARM_SYNC_MS') != null ? toNumber(env('TRACKER_WARM_SYNC_MS')) : 1000warmStepMs = env('TRACKER_WARM_STEP_MS') != null ? toNumber(env('TRACKER_WARM_STEP_MS')) : 60// (test knob: TRACKER_WARM_HOLD_MS = the clock leaves the scan alone for that long after the server listens; tests/warmstart.mjs)warmHoldMs = env('TRACKER_WARM_HOLD_MS') != null ? toNumber(env('TRACKER_WARM_HOLD_MS')) : 0bootDone = falseif (warmSyncMs > 0) { bootDone = bootStep(&warmSyncMs) } else { bootBegin() }if (bootDone) { console.log('moved slugs: ' + movedSlugCount() + ' (their pages show the keeper)') }// tracker#31 + #41 (missions 026, 037, 037b): the slug of a merged duplicate, or a keeper's former slug, has NO route of its own: hl:web// writes every route into each page's HTML (its client route table) — one per moved slug listed 56 of them, adult titles' among// them, on every page (#41). /movies/:slug and /series/:slug (component routes, which cannot redirect) find the keeper by the slug// map (lib/shows.hl showBySlug) and render its page with its canonical address in the head (components/show.hl `__meta` og:url);// /shows/<slug> (showsRoute, a function route) answers 301. No request tap: the class tap of mission 037 crashed hybriel 06617221// after ~37 answers.server = new WebFramework(routes = routes, styles = styles, port = port, sessionCookie = sessionCookie, watchMode = watching, sessionMaxAge = 3122064000)// ---- THE BACKGROUND JOBS (lib/jobs.hl): the daily TMDB sync, the backfills, the details repair, the credits job, the duplicate// merge, the short-id backfill, the collection seed, the curated franchise seed — constructing it starts their clocks and logs which ones are offjobs = nullif (bootDone) { jobs = new Jobs() }else {console.log('boot scan: listening first, the scan goes on in steps of ' + warmStepMs + ' ms')warmListenAt = now()warmClock = every(0.004)on warmClock.tick(x) {if (bootDone || now() - warmListenAt < warmHoldMs) { return null }bootDone = bootStep(&warmStepMs)if (bootDone) {warmClock.stop()console.log('moved slugs: ' + movedSlugCount() + ' (their pages show the keeper)')jobs = new Jobs()}return null}}on Error(e) {if (e.phase == 'startup') { exit(1) }console.log('error absorbed: ' + e.message)}
Branches
Latest commits
- 9ba258d3|||PR records: HM55b resultTracker
- 64f2d300Merge branch 'records-hm55b2' into mainTracker
- ae3b80dc|||PR records: HM55b briefTracker
- 7ef3cb3bMerge branch 'records-st55' into mainTracker
- fec2e080|||PR records: STATUS HM55Tracker
- 8e174918Merge branch 'records-hm55b' into mainTracker
- b1ecee57|||PR records: HM55 stateTracker
- 28eab08cMerge branch 'records-hm55' into mainTracker
- d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
- 3059f86cMerge branch 'records-design-rule' into mainTracker
- 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
- d1390692Merge branch 'records-dp75b' into mainTracker
- a4d1a7d2|||PR records: later steps checked, branch auditTracker
- e070e16fMerge branch 'records-dp75' into mainTracker
- 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
- bfc4ea4dMerge branch 'ap62' into mainTracker
- 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker
- b9c7c3c8Merge branch 'records-dp74' into mainTracker
- 85cfb4ae|||PR records: AP61 day61, DP74 liveTracker
- b1496147Merge branch 'ap61' into mainTracker