gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf83571c3f83571c3tracker#18 (mission 067): daily sync by change lists — TMDB /tv|movie/changes (since the stored day, paged) + TVmaze /updates/shows → only our changed titles (followed: full step, unfollowed: light step — changed seasons, no TVmaze), full walk on first run / gap > 14 days / failed list; show record refreshed (title, tmdbSummary, tagline, status, genres …; renamed titles re-indexed); summary = the creator's own text (page: summary > tmdbSummary > tvmazeSummary), one-time clear of copied summaries (9,647 on the live copy); gate 261, tests/realdata-018*.mjs, README + STATUSmref83571c3/components/show.hl

30.5 KB

  1. // components/show.hl — `/shows/:slug` (tracker.worldapi.org#4): a show's own page. Creator's words:
  2. // "the poster on the left, right of it the title of the show, the genre pills, below the plot summary,
  3. // below that the artists just as normal links, separated with comma color red, genres are blue" (the
  4. // header) — "then all seasons in reverse order, latest on top, below them collapsable their episodes,
  5. // episodes first the round check icon, if the episode was watched by the user looking its solid, if
  6. // not its regular, then the episode number, then the title. the last season is not collapsed. click on
  7. // the check adds a watch. the season also has a check, if the season is checked or unchecked all its
  8. // episodes get checked or unchecked. artists link to /person/<artist-slug> the genre to /genre/<genre-slug>."
  9. //
  10. // THE ROWS ARE ONE FLAT LIST, not a nested for-loop over seasons > episodes: the vendored build may
  11. // still lack the fix for hybriel#86 (a nested for over a reassigned outer list keeps stale inner
  12. // cells) — a single-level `for (row of rows)` with a `kind` field, reassigned whole on every click,
  13. // is the same proven-safe shape components/main.hl's own header and ident's inbox.hl already use.
  14. // `rows` is rebuilt from scratch (seasons/episodes refetched by id, watch rows refetched) on every
  15. // toggle — cheap: a show has at most a few dozen episodes per season.
  16. //
  17. // Mission 047 (the creator, 2026-10-01): a caret at the season header's right edge (down = open, right = collapsed); episode
  18. // rows not indented; on a phone the title first, then the poster at full width, then genres/plot/cast; a Follow toggle
  19. // next to the title. SIGNED OUT the checks and Follow are visible too: a click opens the "sign in" modal (modal.hl, copied
  20. // from components.hybriel) and writes nothing.
  21. //
  22. // tracker.worldapi.org#17 (mission 057): the caret points DOWN while a season is closed and UP while it is open. Opening a
  23. // season shows SKELETON rows at once (min(episodes, 8), a CSS shimmer, styles.hl) and then its episodes from the face
  24. // `showSeasonEpisodes`, which takes NO session: a face with `session` makes hl:web re-mount the whole page on the server and
  25. // ship every session-derived member back as a `sync` (WebFramework.hl `inbound`) — that, not the episodes, was most of the
  26. // old 250–450 ms (real data). The watched state comes from `watchedEpisodes` (this show's watched episodes per season, rendered
  27. // with the page and re-synced after every watch face). Closing is client-only (no request). An ADULT show (only its
  28. // followers see it) keeps the session face `showRows`: the public face refuses adult seasons.
  29. //
  30. // tracker.worldapi.org#12: link icons under the title — the show on TMDB, IMDb, TheTVDB, TVmaze (a movie: TMDB + IMDb),
  31. // only for the ids it has (shows.hl externalLinksOf), each in a new tab.
  32. //
  33. // tracker.worldapi.org#26: an INCOMPLETE title (one a person page added from a filmography — details.hl `needsDetails`) shows
  34. // what it has plus skeletons (poster, cast line, season rows for a series) and completes itself WITHOUT a reload: the
  35. // invisible `showProbe` (endless short CSS animation — hl:web has no mount hook, the person page's trick) calls the face
  36. // `showComplete` until it is done — one step per call (details.hl completeStep: TMDB details + ids + cast; a series' seasons/
  37. // episodes in parts; poster, TVmaze) — and the last answer's parts replace the skeletons. No session (no page re-mount); adult
  38. // refused.
  39. //
  40. // tracker.worldapi.org#28: the WHOLE cast and the key crew (details.hl stores them: a series' cast of every season, main cast
  41. // first by episode count, then "Guest stars"; crew = Created by / Directed by / Written by / Screenplay / Story / Music). The
  42. // cast shows its first `castShown` (20) and a "Show all (N)" toggle, each crew job its first `crewShown` (6) and one "Show all
  43. // crew (N)" toggle — CLIENT-SIDE (the rows are all rendered, CSS hides the rest; `castClass`/`crewClass`, no request). Names
  44. // link to /person/<slug>; the character in brackets after the name (CSS `attr(data-role)` — one element per name: the SSR's
  45. // line breaks inside a wrapper element put a space before the comma).
  46. parent './main.hl'
  47. import Modal from './modal.hl'
  48. import { appTitle } from '../project.hl'
  49. import { userIdOfSession, loginHref } from '../users.hl'
  50. import { isFollowing, setFollowed } from '../follows.hl'
  51. import { showBySlug, showById, genreById, personById, seasonsOfShow, episodesOfSeason, seasonById, posterName, externalLinksOf, summaryOf } from '../shows.hl'
  52. import { watchesOfUser, isWatched, watchedSet, setWatched, setSeasonWatched, watchClassOf } from '../watches.hl'
  53. import { needsDetails, completeStep, completeLine, persistDetails } from '../details.hl'
  54. // ---- pure helpers ----------------------------------------------------------------------------
  55. // `static`, like calendar.hl's `soonOf` — a PLAIN instance member function that calls an
  56. // hl:mpackdb-backed import (seasonsOfShow, episodesOfSeason, watchesOfUser, …) comes back null
  57. // when called from an `on server` face (confirmed by running the gate: "'buildRows' is not
  58. // callable — it holds null" at the face's call site, even though the SAME call works fine as a
  59. // member's own initializer at the top of this file). `static` is the proven-safe shape (calendar's
  60. // `soonOf`, called from `calLoad`/`calSettingsLoad`, an mpackdb-backed helper exactly like this one).
  61. static initialCollapsed = (seasons) => {
  62. let m = {}
  63. let i = 0
  64. while (i < seasons.length) {
  65. if (i > 0) { m[seasons[i].id] = true }
  66. i = i + 1
  67. }
  68. return m
  69. }
  70. static genreRowsOf = (show) => {
  71. let out = []
  72. for (gid of show.genres) {
  73. let g = genreById(gid)
  74. if (g != null) { out.push({ id = g.id name = g.name href = '/genre/' + g.urlSegment }) }
  75. }
  76. return out
  77. }
  78. // tracker#28: how many names show before "Show all" (cast; per crew job)
  79. static castShown = 20
  80. static crewShown = 6
  81. static listOf = (v) => { return v == null ? [] : v }
  82. // the cast as flat rows (no nested for, see THE ROWS above): `isPerson` rows { name, href, roleText (' (Character)' or ''),
  83. // itemClass } and before the first guest one `isLabel` row "Guest stars". itemClass: `more` = hidden until "Show all", `end` =
  84. // no comma after it (the last of a group), `cut` = the last one shown while collapsed (no comma then)
  85. static castRowsOf = (show) => {
  86. let people = []
  87. for (c of listOf(show.cast)) {
  88. let p = c != null ? personById(c.person) : null
  89. if (p != null) { people.push({ name = c.actor != null ? c.actor : p.name href = '/person/' + p.urlSegment role = c.character != null ? c.character : '' guest = c.guest == true }) }
  90. }
  91. let out = []
  92. let k = 0
  93. let guests = false
  94. while (k < people.length) {
  95. let c = people[k]
  96. if (c.guest && !guests && k > 0) {
  97. guests = true
  98. out.push({ isLabel = true isPerson = false text = 'Guest stars' name = '' href = '' roleText = '' itemClass = k >= castShown ? 'more' : '' })
  99. }
  100. let last = k == people.length - 1 || (people[k + 1].guest && !c.guest)
  101. let cls = (k >= castShown ? ' more' : '') + (last ? ' end' : '') + (k == castShown - 1 ? ' cut' : '')
  102. out.push({ isLabel = false isPerson = true text = '' name = c.name href = c.href roleText = c.role != '' ? ' (' + c.role + ')' : '' itemClass = 'artist-link' + cls })
  103. k = k + 1
  104. }
  105. return out
  106. }
  107. static castCountOf = (show) => {
  108. let n = 0
  109. for (c of listOf(show.cast)) { if (c != null && personById(c.person) != null) { n = n + 1 } }
  110. return n
  111. }
  112. static crewLabels = { creator = 'Created by' director = 'Directed by' writer = 'Written by' screenplay = 'Screenplay' story = 'Story' composer = 'Music' }
  113. // the crew as flat rows: per job (in stored order) an `isLabel` row, then its people (itemClass as for the cast, `more` after
  114. // the first crewShown of a job)
  115. static crewRowsOf = (show) => {
  116. let people = []
  117. for (c of listOf(show.crew)) {
  118. let p = c != null ? personById(c.person) : null
  119. if (p != null && crewLabels[c.job] != null) { people.push({ name = c.name != null ? c.name : p.name href = '/person/' + p.urlSegment job = c.job }) }
  120. }
  121. let out = []
  122. let k = 0
  123. let inJob = 0
  124. while (k < people.length) {
  125. let c = people[k]
  126. if (k == 0 || people[k - 1].job != c.job) {
  127. inJob = 0
  128. out.push({ isLabel = true isPerson = false text = crewLabels[c.job] name = '' href = '' itemClass = '' })
  129. }
  130. let last = k == people.length - 1 || people[k + 1].job != c.job
  131. out.push({ isLabel = false isPerson = true text = '' name = c.name href = c.href itemClass = 'crew-link' + (inJob >= crewShown ? ' more' : '') + (last ? ' end' : '') + (inJob == crewShown - 1 ? ' cut' : '') })
  132. inJob = inJob + 1
  133. k = k + 1
  134. }
  135. return out
  136. }
  137. // how many crew names are hidden while collapsed (0 = no toggle) and how many there are
  138. static crewHiddenOf = (rows) => {
  139. let n = 0
  140. for (r of rows) { if (r.isPerson && r.itemClass.includes(' more')) { n = n + 1 } }
  141. return n
  142. }
  143. static crewCountOf = (rows) => {
  144. let n = 0
  145. for (r of rows) { if (r.isPerson) { n = n + 1 } }
  146. return n
  147. }
  148. // a View attribute must be a literal, a member or a field path — never an inline expression — so
  149. // every ternary (watched -> icon class, collapsed -> row class) is resolved HERE, once, into a
  150. // plain field the View just reads (row.watchClass, row.rowClass); `watchClassOf` itself lives in
  151. // watches.hl (shared with /unwatched and /schedule, "reuse, don't copy")
  152. static buildRows = (show, uid, collapsed) => {
  153. let watched = watchedSet(uid != null ? watchesOfUser(uid) : [])
  154. let out = []
  155. for (s of seasonsOfShow(show)) {
  156. let isCollapsed = collapsed[s.id] == true
  157. let label = s.title != null && s.title != '' ? s.title : 'Season ' + s.seasonNumber
  158. let seasonWatched = watched['season:' + s.id] == true
  159. out.push({ kind = 'season' isSeason = true isEpisode = false isSkeleton = false id = s.id skeletonCount = s.episodes.length < 8 ? s.episodes.length : 8 label = label episodeCountText = s.episodes.length == 1 ? '1 episode' : s.episodes.length + ' episodes' watched = seasonWatched watchClass = watchClassOf(seasonWatched) collapsed = isCollapsed rowClass = isCollapsed ? 'collapsed' : 'expanded' })
  160. if (!isCollapsed) {
  161. for (e of episodesOfSeason(s)) {
  162. let epWatched = watched['episode:' + e.id] == true
  163. out.push({ kind = 'episode' isSeason = false isEpisode = true isSkeleton = false id = e.id seasonId = s.id episodeNumber = e.episodeNumber title = e.title != null ? e.title : '' watched = epWatched watchClass = watchClassOf(epWatched) })
  164. }
  165. }
  166. }
  167. return out
  168. }
  169. // what the client marks the rows of a season it opens with (tracker#17) — only this show's, never the user's whole watch
  170. // list (every member is shipped to the browser). Per season with a watched episode: `{ all, except }` — `all` = most of
  171. // it is watched, then `except` holds the UNwatched ids, else the watched ones (a fully watched 142-episode season is
  172. // `{ all = true except = {} }`, not 142 ids). No entry = nothing watched.
  173. static watchedEpisodesOf = (show, uid) => {
  174. let m = {}
  175. if (uid == null) { return m }
  176. let watched = watchedSet(watchesOfUser(uid))
  177. for (s of seasonsOfShow(show)) {
  178. let yes = {}
  179. let no = {}
  180. let n = 0
  181. for (eid of s.episodes) {
  182. if (watched['episode:' + eid] == true) { yes[eid] = true n = n + 1 } else { no[eid] = true }
  183. }
  184. if (n > 0) { m[s.id] = n * 2 > s.episodes.length ? { all = true except = no } : { all = false except = yes } }
  185. }
  186. return m
  187. }
  188. // is this episode watched, by that per-season shape (client-side, pure)
  189. static watchedIn = (entry, episodeId) => {
  190. if (entry == null) { return false }
  191. let listed = entry.except[episodeId] == true
  192. return entry.all ? !listed : listed
  193. }
  194. // ---- the rows as the CLIENT changes them (tracker#17) — pure: no import is reached, so they run in the browser ----------
  195. // (`watchClassOf` is an import of the mpackdb-backed watches.hl, so `filledRows` writes its two classes itself)
  196. static seasonRowAs = (row, isCollapsed) => {
  197. return { kind = 'season' isSeason = true isEpisode = false isSkeleton = false id = row.id skeletonCount = row.skeletonCount label = row.label episodeCountText = row.episodeCountText watched = row.watched watchClass = row.watchClass collapsed = isCollapsed rowClass = isCollapsed ? 'collapsed' : 'expanded' }
  198. }
  199. // the season opened: its caret up at once, `skeletonCount` placeholder rows under it
  200. static openingRows = (rows, seasonId) => {
  201. let out = []
  202. for (row of rows) {
  203. if (row.isSeason && row.id == seasonId) {
  204. out.push(seasonRowAs(row, false))
  205. let i = 0
  206. while (i < row.skeletonCount) {
  207. out.push({ kind = 'skeleton' isSeason = false isEpisode = false isSkeleton = true id = seasonId + '-skeleton-' + i seasonId = seasonId })
  208. i = i + 1
  209. }
  210. } else { out.push(row) }
  211. }
  212. return out
  213. }
  214. // the season closed: its episode (and skeleton) rows gone, caret down
  215. static closedRows = (rows, seasonId) => {
  216. let out = []
  217. for (row of rows) {
  218. if (row.isSeason && row.id == seasonId) { out.push(seasonRowAs(row, true)) }
  219. else if (!row.isSeason && row.seasonId == seasonId) { }
  220. else { out.push(row) }
  221. }
  222. return out
  223. }
  224. // the episodes arrived: they replace the season's skeleton rows. No skeleton of it left (closed meanwhile, or a watch face
  225. // already rebuilt every row) → the rows stay as they are (no double rows)
  226. static filledRows = (rows, seasonId, episodes, watched) => {
  227. let out = []
  228. let done = false
  229. for (row of rows) {
  230. if (row.isSkeleton && row.seasonId == seasonId) {
  231. if (!done) {
  232. for (e of episodes) {
  233. let w = watchedIn(watched[seasonId], e.id)
  234. out.push({ kind = 'episode' isSeason = false isEpisode = true isSkeleton = false id = e.id seasonId = seasonId episodeNumber = e.episodeNumber title = e.title watched = w watchClass = w ? 'checkicon solid' : 'checkicon regular' })
  235. }
  236. done = true
  237. }
  238. } else { out.push(row) }
  239. }
  240. return out
  241. }
  242. // a LOCAL static like buildRows (an imported mpackdb helper called straight from a member's initializer came back false
  243. // after a client-side navigation to the page — the gate's follow check)
  244. static followingOf = (show, uid) => { return uid != null && isFollowing(uid, show.id) }
  245. // mission 056: an ADULT title's page (TMDB's flag `adult == true`, mission 054) is "Not found" for everyone who does not
  246. // follow it (signed out too); a follower sees it as before. Unknown (`null`) is not hidden here — only in the lists.
  247. // With hybriel ≥ 73267707 (#121/#122) `showRow`/`found` are server sites re-derived after every session face with the page's
  248. // slug, so an Unfollow on the page hides it at once (the gate proves it; the old build left the page up until a reload).
  249. // Mission 054's try (`found = … && !adultHiddenFor(showRow, me)`, `collapsed`/`rows` from `found`) broke the checks.
  250. static adultHiddenFor = (show, uid) => { return show.adult == true && !followingOf(show, uid) }
  251. // the page's show — null when there is none OR it is hidden for this user: every member is shipped to the browser, so the
  252. // row of a hidden title must never be one
  253. static visibleShow = (slug, uid) => {
  254. let s = showBySlug(slug)
  255. return s != null && adultHiddenFor(s, uid) ? null : s
  256. }
  257. // the initial open/closed seasons from the SLUG alone (not from `showRow`, which reads the session — see `collapsed`)
  258. static initialCollapsedOf = (slug) => {
  259. let s = showBySlug(slug)
  260. return s != null ? initialCollapsed(seasonsOfShow(s)) : {}
  261. }
  262. // tracker#26: the page loads this title's full details on open
  263. static completingOf = (show) => { return needsDetails(show) }
  264. // the face's work: ONE step of completing the title (details.hl completeStep — a series takes a few; a second viewer drives the
  265. // same job or finds it complete); when done, every part of the page that changes — the rows without anyone's watch state (a
  266. // title that was incomplete had no episodes to watch)
  267. static completedPageOf = (slug) => {
  268. let show = showBySlug(slug)
  269. if (show == null || show.adult == true) { return { error = 'no such show' } }
  270. if (needsDetails(show)) {
  271. let r = completeStep(show.id)
  272. if (r.retry || r.adult == true) { return { error = r.error != '' ? r.error : 'no such show' } }
  273. if (!r.done) { return { done = false steps = r.sum.steps } }
  274. if (!r.skipped) {
  275. persistDetails()
  276. console.log('details on open: ' + completeLine(show.title, r.sum))
  277. }
  278. show = showById(show.id)
  279. }
  280. let cl = initialCollapsed(seasonsOfShow(show))
  281. let pn = posterName(show)
  282. let crew = crewRowsOf(show)
  283. return { done = true title = show.title summary = summaryOf(show) poster = pn genreRows = genreRowsOf(show) castRows = castRowsOf(show)
  284. castCount = castCountOf(show) castMore = castCountOf(show) > castShown crewRows = crew crewCount = crewCountOf(crew) crewMore = crewHiddenOf(crew) > 0
  285. linkRows = externalLinksOf(show) collapsed = cl rows = buildRows(show, null, cl) }
  286. }
  287. // ---- reactive members -----------------------------------------------------------------------
  288. slug = null
  289. session = null
  290. userId = userIdOfSession(session)
  291. signedIn = userId != null
  292. // SESSION SYNC (mission 047; since hybriel #121/#122, mission 056): a face taking `session` answers with a `sync` of every
  293. // member derived from session that reaches an import (here `showRow`, `found`, `following`, `rows`, …), re-derived on the
  294. // server with the page's route params but the MOUNT's other state — so client state (`collapsed`) must never derive from
  295. // them. `me` stays the plain copy mission 047 introduced.
  296. me = userId
  297. showRow = visibleShow(slug, me)
  298. found = showRow != null
  299. notFound = showRow == null
  300. // the Follow toggle: "Follow" = the inverted button (accent border), "Following" = the filled one
  301. following = found ? followingOf(showRow, me) : false
  302. followClass = following ? 'follow' : 'follow inverted'
  303. followText = following ? 'Following' : 'Follow'
  304. signInHref = loginHref
  305. title = found ? showRow.title : ''
  306. // tracker#18: the creator's own text, else TMDB's, else TVmaze's
  307. summary = found ? summaryOf(showRow) : ''
  308. poster = found ? posterName(showRow) : null
  309. hasPoster = poster != null
  310. posterUrl = hasPoster ? '/posters/' + poster : ''
  311. genreRows = found ? genreRowsOf(showRow) : []
  312. hasGenres = genreRows.length > 0
  313. castRows = found ? castRowsOf(showRow) : []
  314. hasCast = castRows.length > 0
  315. // tracker#28: "Show all (N)" — the toggles' state is CLIENT state: literals, never derived from `showRow` (session sync)
  316. castCount = found ? castCountOf(showRow) : 0
  317. castMore = castCount > castShown
  318. castAllText = 'Show all (' + castCount + ')'
  319. castClass = 'collapsed'
  320. crewRows = found ? crewRowsOf(showRow) : []
  321. hasCrew = crewRows.length > 0
  322. crewCount = crewCountOf(crewRows)
  323. crewMore = crewHiddenOf(crewRows) > 0
  324. crewAllText = 'Show all crew (' + crewCount + ')'
  325. crewClass = 'collapsed'
  326. linkRows = found ? externalLinksOf(showRow) : []
  327. hasLinks = linkRows.length > 0
  328. // NOT from `showRow`/`found`: they read the session (via `me`), so a member derived from them is re-derived on the server
  329. // after every session face with the MOUNT's state — `collapsed` (client state) would snap back to the initial seasons (mission
  330. // 056: the 2nd episode click in a re-opened season did nothing). The season ids of a hidden page are no secret.
  331. collapsed = initialCollapsedOf(slug)
  332. rows = found ? buildRows(showRow, me, collapsed) : []
  333. hasRows = rows.length > 0
  334. watchedEpisodes = found ? watchedEpisodesOf(showRow, me) : {}
  335. // an adult page (followers only) opens its seasons through the session face `showRows`
  336. adultShow = found && showRow.adult == true
  337. // tracker#26: incomplete → skeletons + the probe until `showComplete` answered
  338. completing = found ? completingOf(showRow) : false
  339. completeBusy = false
  340. isSeries = found && showRow.type != 'movie'
  341. skeletonSeasons = ['1', '2', '3']
  342. __title = found ? title + ' — ' + appTitle : appTitle
  343. View {
  344. showPage {
  345. if (notFound) {
  346. article { class = "main"
  347. h1 { "Not found" }
  348. p { "This show doesn't exist." }
  349. }
  350. }
  351. if (found) {
  352. showHeader {
  353. showPoster {
  354. if (hasPoster) { img { src = posterUrl alt = title } }
  355. if (completing) { skeletonPoster { "aria-hidden" = "true" } }
  356. }
  357. showMeta {
  358. showTitle {
  359. h1 { title }
  360. button { id = "follow" type = "button" class = followClass followText on click(e) { emit toggleFollow(e) } }
  361. }
  362. if (hasLinks) {
  363. showLinks {
  364. for (l of linkRows) { a { class = "extlink" href = l.href target = "_blank" rel = "noopener" title = l.title "aria-label" = l.title "data-site" = l.site l.label } }
  365. }
  366. }
  367. if (hasGenres) {
  368. showGenres {
  369. for (g of genreRows) { a { class = "genre-pill" href = g.href g.name } }
  370. }
  371. }
  372. showSummary { summary }
  373. if (hasCrew) {
  374. showCrew { class = crewClass
  375. for (r of crewRows) {
  376. if (r.isLabel) { crewLabel { r.text } }
  377. if (r.isPerson) { a { class = r.itemClass href = r.href r.name } }
  378. }
  379. if (crewMore) {
  380. button { id = "crewtoggle" type = "button" class = "quiet showall"
  381. whenCollapsed { crewAllText }
  382. whenAll { "Show less" }
  383. on click(e) { emit toggleCrewAll(e) }
  384. }
  385. }
  386. }
  387. }
  388. if (hasCast) {
  389. showCast { class = castClass
  390. castHeading { "Cast" }
  391. for (c of castRows) {
  392. if (c.isLabel) { castLabel { class = c.itemClass c.text } }
  393. if (c.isPerson) { a { class = c.itemClass href = c.href "data-role" = c.roleText c.name } }
  394. }
  395. if (castMore) {
  396. button { id = "casttoggle" type = "button" class = "quiet showall"
  397. whenCollapsed { castAllText }
  398. whenAll { "Show less" }
  399. on click(e) { emit toggleCastAll(e) }
  400. }
  401. }
  402. }
  403. }
  404. if (completing) { skeletonCast { "aria-hidden" = "true" } }
  405. }
  406. }
  407. if (completing) {
  408. showLoading { id = "showloading" "aria-busy" = "true"
  409. if (isSeries) {
  410. for (k of skeletonSeasons) {
  411. skeletonRow { "aria-hidden" = "true"
  412. skeletonCheck { }
  413. skeletonTitle { }
  414. }
  415. }
  416. }
  417. showProbe { "aria-hidden" = "true" on animationiteration(e) { emit completeTick(e) } }
  418. }
  419. }
  420. if (hasRows) {
  421. showSeasons {
  422. for (row of rows) {
  423. if (row.isSeason) {
  424. seasonRow { class = row.rowClass
  425. button { type = "button" class = row.watchClass value = row.id "aria-label" = "mark season watched"
  426. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  427. circle { cx = "12" cy = "12" r = "10" }
  428. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  429. }
  430. on click(e) { emit toggleSeason(row.id) }
  431. }
  432. button { type = "button" class = "season-toggle" value = row.id
  433. seasonLabel { row.label }
  434. seasonCount { row.episodeCountText }
  435. seasonCaret { "aria-hidden" = "true"
  436. svg { viewBox = "0 0 24 24" width = "20" height = "20"
  437. path { d = "M6 9 L12 15 L18 9" }
  438. }
  439. }
  440. on click(e) { emit toggleCollapse(row.id) }
  441. }
  442. }
  443. }
  444. if (row.isEpisode) {
  445. episodeRow {
  446. button { type = "button" class = row.watchClass value = row.id "aria-label" = "mark episode watched"
  447. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  448. circle { cx = "12" cy = "12" r = "10" }
  449. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  450. }
  451. on click(e) { emit toggleEpisode(row.id) }
  452. }
  453. episodeNumber { row.episodeNumber }
  454. episodeTitle { row.title }
  455. }
  456. }
  457. if (row.isSkeleton) {
  458. skeletonRow { "aria-hidden" = "true"
  459. skeletonCheck { }
  460. skeletonNumber { }
  461. skeletonTitle { }
  462. }
  463. }
  464. }
  465. }
  466. }
  467. Modal { id = "signin" title = "Sign in"
  468. p { "You need to sign in to follow shows and mark episodes." }
  469. footer {
  470. button { type = "button" value = "close" "Close" }
  471. a { id = "signin-link" class = "button" href = signInHref "Sign in with ident" }
  472. }
  473. }
  474. }
  475. }
  476. }
  477. // Every rebuild of `rows` happens SERVER-SIDE, never by calling `buildRows` from a client handler:
  478. // a member function whose body reaches an hl:mpackdb-backed import (seasonsOfShow, episodesOfSeason,
  479. // watchesOfUser, …) compiles to nothing on the client (no case ever assigns it — a genuine Hybriel
  480. // gap, filed under `issues`) even though the client bundle still calls it, so `this.buildRows(...)`
  481. // throws "not a function" in the browser. The client here only ever ASSIGNS the `rows` the server
  482. // already built (`rows = r.rows`) — never calls a tainted local helper itself. `slug` goes along so
  483. // the face can refetch the show without depending on implicit access to a sibling member.
  484. //
  485. // tracker#17: opening shows the skeleton rows BEFORE the request; the answer replaces them unless the season was closed
  486. // meanwhile (then nothing). An error closes the season again. Closing never asks the server.
  487. on toggleCollapse(seasonId) {
  488. let m = collapsed
  489. if (collapsed[seasonId] != true) {
  490. m[seasonId] = true
  491. collapsed = m
  492. rows = closedRows(rows, seasonId)
  493. return null
  494. }
  495. m[seasonId] = false
  496. collapsed = m
  497. rows = openingRows(rows, seasonId)
  498. if (adultShow) {
  499. let a = emit server showRows(slug, collapsed)
  500. if (collapsed[seasonId] == true) { return null }
  501. if (a == null || a.error != null) { m[seasonId] = true collapsed = m rows = closedRows(rows, seasonId) return null }
  502. rows = a.rows
  503. return null
  504. }
  505. let r = emit server showSeasonEpisodes('' + seasonId)
  506. if (collapsed[seasonId] == true) { return null }
  507. if (r == null || r.error != null) { m[seasonId] = true collapsed = m rows = closedRows(rows, seasonId) return null }
  508. rows = filledRows(rows, seasonId, r.episodes, watchedEpisodes)
  509. }
  510. // tracker#26: the probe's tick — `showComplete` step by step until `done` (once per page: `completeBusy`; other requests are
  511. // served between two calls); the last answer replaces the skeletons. A lost answer (null) lets the next tick go on where the
  512. // server is; an error (TMDB down, adult) ends the loading and keeps what the page has.
  513. on completeTick(e) {
  514. if (completeBusy || !completing) { return null }
  515. completeBusy = true
  516. let s = slug
  517. let r = emit server showComplete(s)
  518. while (r != null && r.error == null && r.done != true && slug == s) { r = emit server showComplete(s) }
  519. completeBusy = false
  520. if (r == null || slug != s) { return null }
  521. if (r.error != null) { completing = false return null }
  522. title = r.title
  523. summary = r.summary
  524. poster = r.poster
  525. genreRows = r.genreRows
  526. castRows = r.castRows
  527. castCount = r.castCount
  528. castMore = r.castMore
  529. castAllText = 'Show all (' + r.castCount + ')'
  530. crewRows = r.crewRows
  531. crewCount = r.crewCount
  532. crewMore = r.crewMore
  533. crewAllText = 'Show all crew (' + r.crewCount + ')'
  534. linkRows = r.linkRows
  535. collapsed = r.collapsed
  536. rows = r.rows
  537. completing = false
  538. }
  539. // tracker#28: the cast / crew "Show all" toggles — client-only, no request (CSS shows the hidden names)
  540. on toggleCastAll(e) {
  541. castClass = castClass == 'all' ? 'collapsed' : 'all'
  542. }
  543. on toggleCrewAll(e) {
  544. crewClass = crewClass == 'all' ? 'collapsed' : 'all'
  545. }
  546. // signed out: the modal, nothing is sent
  547. on toggleEpisode(episodeId) {
  548. if (!signedIn) { document.getElementById('signin').showModal() return null }
  549. let r = emit server showToggleEpisode(slug, '' + episodeId, collapsed)
  550. if (r == null || r.error != null) { return null }
  551. rows = r.rows
  552. }
  553. on toggleSeason(seasonId) {
  554. if (!signedIn) { document.getElementById('signin').showModal() return null }
  555. let r = emit server showToggleSeason(slug, '' + seasonId, collapsed)
  556. if (r == null || r.error != null) { return null }
  557. rows = r.rows
  558. }
  559. on toggleFollow(e) {
  560. if (!signedIn) { document.getElementById('signin').showModal() return null }
  561. let r = emit server showToggleFollow(slug)
  562. if (r == null || r.error != null) { return null }
  563. following = r.following
  564. followClass = r.following ? 'follow' : 'follow inverted'
  565. followText = r.following ? 'Following' : 'Follow'
  566. }
  567. // ---- the faces (the trailing `session` is always the server's: hybriel#16) ----
  568. // tracker#26: complete an incomplete title and answer the page's parts — public data, NO session (no page re-mount)
  569. on server showComplete(slug) {
  570. return completedPageOf(slug != null ? '' + slug : '')
  571. }
  572. // every row for these open/closed seasons — only an ADULT show's page still uses it (its followers; tracker#17)
  573. on server showRows(slug, collapsed, session) {
  574. let show = showBySlug(slug)
  575. let uid = userIdOfSession(session)
  576. if (show == null || adultHiddenFor(show, uid)) { return { error = 'no such show' } }
  577. return { ok = true rows = buildRows(show, uid, collapsed) }
  578. }
  579. // tracker#17: one season's episodes, in order — public data, so NO `session` (no page re-mount, no sync: the fast path).
  580. // Refuses a season of an adult title (those pages use showRows above).
  581. on server showSeasonEpisodes(seasonId) {
  582. if (seasonId == null || hlTypeName(seasonId) != 'String') { return { error = 'no such season' } }
  583. let season = seasonById(seasonId)
  584. if (season == null) { return { error = 'no such season' } }
  585. let show = showById(season.show)
  586. if (show == null || show.adult == true) { return { error = 'no such season' } }
  587. let out = []
  588. for (e of episodesOfSeason(season)) { out.push({ id = e.id episodeNumber = e.episodeNumber title = e.title != null ? e.title : '' }) }
  589. return { ok = true episodes = out }
  590. }
  591. on server showToggleEpisode(slug, episodeId, collapsed, session) {
  592. let show = showBySlug(slug)
  593. if (show == null) { return { error = 'no such show' } }
  594. let uid = userIdOfSession(session)
  595. if (uid == null) { return { error = 'you are not signed in' } }
  596. if (adultHiddenFor(show, uid)) { return { error = 'no such show' } }
  597. let rows = watchesOfUser(uid)
  598. let watched = isWatched(rows, 'episode', episodeId) == false
  599. let ok = setWatched(uid, 'episode', episodeId, rows, watched)
  600. if (!ok) { return { error = 'could not save the watch' } }
  601. return { ok = true rows = buildRows(show, uid, collapsed) }
  602. }
  603. on server showToggleSeason(slug, seasonId, collapsed, session) {
  604. let show = showBySlug(slug)
  605. if (show == null) { return { error = 'no such show' } }
  606. let uid = userIdOfSession(session)
  607. if (uid == null) { return { error = 'you are not signed in' } }
  608. if (adultHiddenFor(show, uid)) { return { error = 'no such show' } }
  609. let season = seasonById(seasonId)
  610. if (season == null) { return { error = 'no such season' } }
  611. let rows = watchesOfUser(uid)
  612. let watched = isWatched(rows, 'season', seasonId) == false
  613. let ok = setSeasonWatched(uid, seasonId, season.episodes, rows, watched)
  614. if (!ok) { return { error = 'could not save the watch' } }
  615. return { ok = true rows = buildRows(show, uid, collapsed) }
  616. }
  617. on server showToggleFollow(slug, session) {
  618. let show = showBySlug(slug)
  619. if (show == null) { return { error = 'no such show' } }
  620. let uid = userIdOfSession(session)
  621. if (uid == null) { return { error = 'you are not signed in' } }
  622. let follow = isFollowing(uid, show.id) == false
  623. if (!setFollowed(uid, show.id, follow)) { return { error = 'could not save the follow' } }
  624. return { ok = true following = follow }
  625. }

Branches

Latest commits

  • f83571c3tracker#18 (mission 067): daily sync by change lists — TMDB /tv|movie/changes (since the stored day, paged) + TVmaze /updates/shows → only our changed titles (followed: full step, unfollowed: light step — changed seasons, no TVmaze), full walk on first run / gap > 14 days / failed list; show record refreshed (title, tmdbSummary, tagline, status, genres …; renamed titles re-indexed); summary = the creator's own text (page: summary > tmdbSummary > tvmazeSummary), one-time clear of copied summaries (9,647 on the live copy); gate 261, tests/realdata-018*.mjs, README + STATUSmre
  • 10bb3f93tracker#28 (mission 061): full cast (all seasons, main cast by episodes, guest stars) + crew (created by, directed by, written by, screenplay, story, music) — stored by the details completion, the daily sync, the search import (one details request) and a background credits job (resumes, RSS limit); show page collapsed after 20 with client-side Show all; showBySlug via a slug map; gate 249, tests/realdata-028.mjs, README + STATUSmre
  • 25a50bc4tracker#26 (mission 059): titles from a filmography are completed — on open (skeleton, step-wise face showComplete, no reload) and by the in-app details repair (resumes, TMDB-paced, series in parts); cast from TMDB credits; gate 231, tests/realdata-026.mjs, README + STATUSmre
  • 1704ec45tracker#17 (mission 057): season caret down/up, skeleton rows while a season loads, sessionless showSeasonEpisodes face (no page re-mount), client-only close; gate 214, tests/realdata-057.mjs, README + STATUSmre
  • f2fe3e36mission 056: README + STATUS (merge, fixes, Hybriel 8590df63, real-data check), tests/realdata-056.mjs, tools/check-public-slugs.hlmre
  • f40c250emission 056: re-vendor hybriel master 8590df63 (#121, #122); an adult title's page is Not found for non-followers; gate: leave the page before stopping the servermre
  • 2b7fdd6cmission 056: signed-out header one row on phones ("Log in", nowrap), backfill skips adult titles' posters, gate checksmre
  • 2c53d5efMerge branch 't16-person' (tracker#16 person pages) into main; filmography shows only public titles (054 adult flag), gate race fix (backfill start line)mre
  • c171227emission 054: hide adult/unknown titles from the public lists and the search; in-app adult-flag backfill (TMDB details + poster per title, resumes), gate + real-data proofmre
  • 139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre
  • 93be9476tracker#16: person pages /person/<slug> with the filmography fetched from TMDB on the first visit (step by step), gatemre
  • 47a3cae6STATUS: mission 053 merge commit idsmre
  • dcc5eecaMerge branch 't14-search'mre
  • 03edc783Merge branch 't15-tvmaze'mre
  • 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
  • 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
  • b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
  • 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
  • 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre
  • cbdc4ea7tracker#12: link icons TMDB/IMDb/TVDB/TVmaze; sync fills missing ids (TVmaze lookup); movies fetched via /movie/mre