gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit73fa20dd73fa20ddMerge hm49b-styles: tracker#49 rest of the component stylesmre73fa20dd/components/show.hl

50.1 KB

  1. // components/show.hl — a title's own page (tracker.worldapi.org#4): since tracker#21 (mission 068) `/series/:slug`, `/movies/:slug`
  2. // and `/shows/:slug` (the last through project.hl showsRoute: a show is rendered there, a series or movie answers 301 to its
  3. // own address). tracker#20: the heading is "<Type> | <title>" — Series / Show / Movie in the type's colour (styles.hl
  4. // `type-*`), the title white. Creator's words:
  5. // "the poster on the left, right of it the title of the show, the genre pills, below the plot summary,
  6. // below that the artists just as normal links, separated with comma color red, genres are blue" (the
  7. // header) — "then all seasons in reverse order, latest on top, below them collapsable their episodes,
  8. // episodes first the round check icon, if the episode was watched by the user looking its solid, if
  9. // not its regular, then the episode number, then the title. the last season is not collapsed. click on
  10. // the check adds a watch. the season also has a check, if the season is checked or unchecked all its
  11. // episodes get checked or unchecked. artists link to /person/<artist-slug> the genre to /genre/<genre-slug>."
  12. //
  13. // THE ROWS ARE ONE FLAT LIST, not a nested for-loop over seasons > episodes: the vendored build may
  14. // still lack the fix for hybriel#86 (a nested for over a reassigned outer list keeps stale inner
  15. // cells) — a single-level `for (row of rows)` with a `kind` field, reassigned whole on every click,
  16. // is the same proven-safe shape components/main.hl's own header and ident's inbox.hl already use.
  17. // `rows` is rebuilt from scratch (seasons/episodes refetched by id, watch rows refetched) on every
  18. // toggle — cheap: a show has at most a few dozen episodes per season.
  19. //
  20. // Mission 047 (the creator, 2026-10-01): a caret at the season header's right edge (down = open, right = collapsed); episode
  21. // rows not indented; on a phone the title first, then the poster at full width, then genres/plot/cast; a Follow toggle
  22. // next to the title (tracker#34, mission 030: under the poster, as wide as the poster; next to the title the status pill, #35). SIGNED OUT the checks and Follow are visible too: a click opens the "sign in" modal (modal.hl, copied
  23. // from components.hybriel) and writes nothing.
  24. //
  25. // tracker.worldapi.org#17 (mission 057): the caret points DOWN while a season is closed and UP while it is open. Opening a
  26. // season shows SKELETON rows at once (min(episodes, 8), a CSS shimmer, styles.hl) and then its episodes from the face
  27. // `showSeasonEpisodes`, which takes NO session: a face with `session` makes hl:web re-mount the whole page on the server and
  28. // ship every session-derived member back as a `sync` (WebFramework.hl `inbound`) — that, not the episodes, was most of the
  29. // old 250–450 ms (real data). The watched state comes from `watchedEpisodes` (this show's watched episodes per season, rendered
  30. // with the page and re-synced after every watch face). Closing is client-only (no request). An ADULT show (only its
  31. // followers see it) keeps the session face `showRows`: the public face refuses adult seasons.
  32. //
  33. // tracker.worldapi.org#12: link icons under the title — the show on TMDB, IMDb, TheTVDB, TVmaze (a movie: TMDB + IMDb),
  34. // only for the ids it has (shows.hl externalLinksOf), each in a new tab.
  35. //
  36. // mission 058: #22 every episode row shows its air date (`release`, 'YYYY-MM-DD' like /my/unwatched; none → empty). #23 a
  37. // season's check is DERIVED: solid exactly when every one of its episodes is watched (a season without episodes: its own
  38. // season watch) — unchecking one episode turns the season off with the face's answer, checking it again turns it on; the
  39. // season click watches all when not all are watched, else unwatches all. #24 a MOVIE's page has its own watched check
  40. // (watch `targetType = 'movie'`, target = the title's id; face `showToggleMovie`), signed out → the sign-in modal.
  41. //
  42. // tracker.worldapi.org#26: an INCOMPLETE title (one a person page added from a filmography — details.hl `needsDetails`) shows
  43. // what it has plus skeletons (poster, cast line, season rows for a series) and completes itself WITHOUT a reload: the
  44. // invisible `showProbe` (endless short CSS animation — hl:web has no mount hook, the person page's trick) calls the face
  45. // `showComplete` until it is done — one step per call (details.hl completeStep: TMDB details + ids + cast; a series' seasons/
  46. // episodes in parts; poster, TVmaze) — and the last answer's parts replace the skeletons. No session (no page re-mount); adult
  47. // refused.
  48. //
  49. // tracker.worldapi.org#28: the WHOLE cast and the key crew (details.hl stores them: a series' cast of every season, main cast
  50. // first by episode count, then "Guest stars"; crew = Created by / Directed by / Written by / Screenplay / Story / Music). The
  51. // cast shows its first `castShown` (20) and a "Show all (N)" toggle, each crew job its first `crewShown` (6) and one "Show all
  52. // crew (N)" toggle — CLIENT-SIDE (the rows are all rendered, CSS hides the rest; `castClass`/`crewClass`, no request). Names
  53. // link to /person/<slug>; the character in brackets after the name (CSS `attr(data-role)` — one element per name: the SSR's
  54. // line breaks inside a wrapper element put a space before the comma).
  55. parent './main.hl'
  56. import Modal from './modal.hl'
  57. import FranchiseWidget from './franchisewidget.hl'
  58. import { appTitle } from '../project.hl'
  59. import { userIdOfSession, loginHref } from '../lib/users.hl'
  60. import { isFollowing, toggleFollowed } from '../lib/follows.hl'
  61. import { showBySlug, showById, genreById, personLinkOf, seasonsOfShow, episodesOfSeason, seasonById, episodeById, posterName, externalLinksOf, summaryOf, titleKind, statusOf, titlePath } from '../lib/shows.hl'
  62. import { watchesOfUser, watchedSetOf, isWatched, watchedSet, watchClassOf, seasonAllWatched, toggleWatched, toggleSeasonWatched } from '../lib/watches.hl'
  63. import { needsDetails, completeStep, completeLine, persistDetails } from '../lib/details.hl'
  64. import { widgetsOf } from '../lib/franchises.hl'
  65. import { listOr, textArg } from '../lib/util.hl'
  66. import { dateText } from '../lib/people.hl'
  67. import { warmReady, warmText } from '../lib/warm.hl'
  68. // ---- pure helpers ----------------------------------------------------------------------------
  69. // `static`, like calendar.hl's `soonOf` — a PLAIN instance member function that calls an
  70. // hl:mpackdb-backed import (seasonsOfShow, episodesOfSeason, watchesOfUser, …) comes back null
  71. // when called from an `on server` face (confirmed by running the gate: "'buildRows' is not
  72. // callable — it holds null" at the face's call site, even though the SAME call works fine as a
  73. // member's own initializer at the top of this file). `static` is the proven-safe shape (calendar's
  74. // `soonOf`, called from `calLoad`/`calSettingsLoad`, an mpackdb-backed helper exactly like this one).
  75. static initialCollapsed = (&seasons) => {
  76. m = {}
  77. let i = 0
  78. while (i < seasons.length) {
  79. // mobile audit MK: a season of more than 150 episodes starts closed too (a soap whose 1,175 episodes are ONE season made a 69,000 px page
  80. // of 1,200 tap targets); a tap on its header opens it
  81. if (i > 0 || seasons[i].episodes.length > 150) { m[seasons[i].id] = true }
  82. i = i + 1
  83. }
  84. return m
  85. }
  86. static genreRowsOf = (&show) => {
  87. out = []
  88. for (gid of show.genres) {
  89. let g = genreById(&gid)
  90. if (g != null) { out.push({ id = g.id name = g.name href = '/genres/' + g.urlSegment }) }
  91. }
  92. return out
  93. }
  94. // tracker#28: how many names show before "Show all" (cast; per crew job)
  95. static castShown = 20
  96. static crewShown = 6
  97. // the cast as flat rows (no nested for, see THE ROWS above; tracker#42: people by shows.hl personLinkOf, not whole records): `isPerson` rows { name, href, roleText (' (Character)' or ''),
  98. // itemClass } and before the first guest one `isLabel` row "Guest stars". itemClass: `more` = hidden until "Show all", `end` =
  99. // no comma after it (the last of a group), `cut` = the last one shown while collapsed (no comma then)
  100. static castRowsOf = (show) => {
  101. people = []
  102. for (c of listOr(&show.cast)) {
  103. let p = c != null && c.person != null ? personLinkOf(&c.person) : null
  104. // mission 062: a guest without a person record — the link creates it on the first open (project.hl guestRoute)
  105. 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 }) }
  106. else if (c != null && c.person == null && c.tmdbId != null && c.actor != null) { people.push({ name = c.actor href = '/person/tmdb/' + c.tmdbId + '?show=' + show.id role = c.character != null ? c.character : '' guest = true }) }
  107. }
  108. out = []
  109. let k = 0
  110. let guests = false
  111. while (k < people.length) {
  112. let c = people[k]
  113. if (c.guest && !guests && k > 0) {
  114. guests = true
  115. out.push({ isLabel = true isPerson = false text = 'Guest stars' name = '' href = '' roleText = '' itemClass = k >= castShown ? 'more' : '' })
  116. }
  117. let last = k == people.length - 1 || (people[k + 1].guest && !c.guest)
  118. let cls = (k >= castShown ? ' more' : '') + (last ? ' end' : '') + (k == castShown - 1 ? ' cut' : '')
  119. out.push({ isLabel = false isPerson = true text = '' name = c.name href = c.href roleText = c.role != '' ? ' (' + c.role + ')' : '' itemClass = 'artist-link' + cls })
  120. k = k + 1
  121. }
  122. return out
  123. }
  124. static castCountOf = (&rows) => {
  125. let n = 0
  126. for (r of rows) { if (r.isPerson) { n = n + 1 } }
  127. return n
  128. }
  129. static crewLabels = { creator = 'Created by' director = 'Directed by' writer = 'Written by' screenplay = 'Screenplay' story = 'Story' composer = 'Music' }
  130. // the crew as flat rows: per job (in stored order) an `isLabel` row, then its people (itemClass as for the cast, `more` after
  131. // the first crewShown of a job)
  132. static crewRowsOf = (&show) => {
  133. people = []
  134. for (c of listOr(&show.crew)) {
  135. let p = c != null ? personLinkOf(&c.person) : null
  136. if (p != null && crewLabels[c.job] != null) { people.push({ name = c.name != null ? c.name : p.name href = '/person/' + p.urlSegment job = c.job }) }
  137. }
  138. out = []
  139. let k = 0
  140. let inJob = 0
  141. while (k < people.length) {
  142. let c = people[k]
  143. if (k == 0 || people[k - 1].job != c.job) {
  144. inJob = 0
  145. out.push({ isLabel = true isPerson = false text = crewLabels[c.job] name = '' href = '' itemClass = '' })
  146. }
  147. let last = k == people.length - 1 || people[k + 1].job != c.job
  148. 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' : '') })
  149. inJob = inJob + 1
  150. k = k + 1
  151. }
  152. return out
  153. }
  154. // how many crew names are hidden while collapsed (0 = no toggle) and how many there are
  155. static crewHiddenOf = (&rows) => {
  156. let n = 0
  157. for (r of rows) { if (r.isPerson && r.itemClass.includes(' more')) { n = n + 1 } }
  158. return n
  159. }
  160. static crewCountOf = (&rows) => {
  161. let n = 0
  162. for (r of rows) { if (r.isPerson) { n = n + 1 } }
  163. return n
  164. }
  165. // a View attribute must be a literal, a member or a field path — never an inline expression — so
  166. // every ternary (watched -> icon class, collapsed -> row class) is resolved HERE, once, into a
  167. // plain field the View just reads (row.watchClass, row.rowClass); `watchClassOf` itself lives in
  168. // watches.hl (shared with /unwatched and /schedule, "reuse, don't copy")
  169. // #22: an episode's air date as the lists show it ('YYYY-MM-DD'), '' when it has none
  170. static airDateOf = (&e) => { return e.release != null && hlTypeName(e.release) == 'String' ? e.release : '' }
  171. static buildRows = (&show, &uid, collapsed) => {
  172. // GC1: the user's kept watched set (watches.hl watchedSetOf, rebuilt after their next write), not a new one built from a by-value copy of
  173. // every watch row (12,866 rows on the creator's data) on every page and every check click
  174. watched = uid != null ? watchedSetOf(&uid) : {}
  175. out = []
  176. for (s of seasonsOfShow(&show)) {
  177. let isCollapsed = collapsed[s.id] == true
  178. let label = s.title != null && s.title != '' ? s.title : 'Season ' + s.seasonNumber
  179. let seasonWatched = seasonAllWatched(&s, &watched)
  180. 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' })
  181. if (!isCollapsed) {
  182. for (e of episodesOfSeason(&s)) {
  183. let epWatched = watched['episode:' + e.id] == true
  184. 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 : '' airDate = airDateOf(&e) watched = epWatched watchClass = watchClassOf(&epWatched) })
  185. }
  186. }
  187. }
  188. return out
  189. }
  190. // what the client marks the rows of a season it opens with (tracker#17) — only this show's, never the user's whole watch
  191. // list (every member is shipped to the browser). Per season with a watched episode: `{ all, except }` — `all` = most of
  192. // it is watched, then `except` holds the UNwatched ids, else the watched ones (a fully watched 142-episode season is
  193. // `{ all = true except = {} }`, not 142 ids). No entry = nothing watched.
  194. static watchedEpisodesOf = (&show, &uid) => {
  195. m = {}
  196. if (uid == null) { return m }
  197. watched = watchedSetOf(&uid)
  198. for (s of seasonsOfShow(&show)) {
  199. let yes = {}
  200. let no = {}
  201. let n = 0
  202. for (eid of s.episodes) {
  203. if (watched['episode:' + eid] == true) { yes[eid] = true n = n + 1 } else { no[eid] = true }
  204. }
  205. if (n > 0) { m[s.id] = n * 2 > s.episodes.length ? { all = true except = no } : { all = false except = yes } }
  206. }
  207. return m
  208. }
  209. // is this episode watched, by that per-season shape (client-side, pure)
  210. static watchedIn = (&entry, &episodeId) => {
  211. if (entry == null) { return false }
  212. listed = entry.except[episodeId] == true
  213. return entry.all ? !listed : listed
  214. }
  215. // ---- the rows as the CLIENT changes them (tracker#17) — pure: no import is reached, so they run in the browser ----------
  216. // (`watchClassOf` is an import of the mpackdb-backed watches.hl, so `filledRows` writes its two classes itself)
  217. static seasonRowAs = (&row, &isCollapsed) => {
  218. 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' }
  219. }
  220. // the season opened: its caret up at once, `skeletonCount` placeholder rows under it
  221. static openingRows = (&rows, seasonId) => {
  222. out = []
  223. for (row of rows) {
  224. if (row.isSeason && row.id == seasonId) {
  225. out.push(seasonRowAs(&row, false))
  226. let i = 0
  227. while (i < row.skeletonCount) {
  228. out.push({ kind = 'skeleton' isSeason = false isEpisode = false isSkeleton = true id = seasonId + '-skeleton-' + i seasonId = seasonId })
  229. i = i + 1
  230. }
  231. } else { out.push(row) }
  232. }
  233. return out
  234. }
  235. // the season closed: its episode (and skeleton) rows gone, caret down
  236. static closedRows = (&rows, &seasonId) => {
  237. out = []
  238. for (row of rows) {
  239. if (row.isSeason && row.id == seasonId) { out.push(seasonRowAs(&row, true)) }
  240. else if (!row.isSeason && row.seasonId == seasonId) { }
  241. else { out.push(row) }
  242. }
  243. return out
  244. }
  245. // the episodes arrived: they replace the season's skeleton rows. No skeleton of it left (closed meanwhile, or a watch face
  246. // already rebuilt every row) → the rows stay as they are (no double rows)
  247. static filledRows = (&rows, seasonId, &episodes, watched) => {
  248. out = []
  249. let done = false
  250. for (row of rows) {
  251. if (row.isSkeleton && row.seasonId == seasonId) {
  252. if (!done) {
  253. for (e of episodes) {
  254. let w = watchedIn(&watched[seasonId], &e.id)
  255. out.push({ kind = 'episode' isSeason = false isEpisode = true isSkeleton = false id = e.id seasonId = seasonId episodeNumber = e.episodeNumber title = e.title airDate = e.airDate watched = w watchClass = w ? 'checkicon solid' : 'checkicon regular' })
  256. }
  257. done = true
  258. }
  259. } else { out.push(row) }
  260. }
  261. return out
  262. }
  263. // a LOCAL static like buildRows (an imported mpackdb helper called straight from a member's initializer came back false
  264. // after a client-side navigation to the page — the gate's follow check)
  265. static followingOf = (&show, &uid) => { return uid != null && isFollowing(&uid, &show.id) }
  266. // #24: has this user watched this movie (a watch `movie:<title id>`)?
  267. static movieWatchedOf = (&show, &uid) => {
  268. if (uid == null) { return false }
  269. rows = watchesOfUser(&uid)
  270. return isWatched(&rows, 'movie', &show.id)
  271. }
  272. // mission 056: an ADULT title's page (TMDB's flag `adult == true`, mission 054) is "Not found" for everyone who does not
  273. // follow it (signed out too); a follower sees it as before. Unknown (`null`) is not hidden here — only in the lists.
  274. // With hybriel ≥ 73267707 (#121/#122) `showRow`/`found` are server sites re-derived after every session face with the page's
  275. // 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).
  276. // Mission 054's try (`found = … && !adultHiddenFor(showRow, me)`, `collapsed`/`rows` from `found`) broke the checks.
  277. static adultHiddenFor = (&show, &uid) => { return show.adult == true && !followingOf(&show, &uid) }
  278. // 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
  279. // row of a hidden title must never be one
  280. static visibleShow = (&slug, &uid) => {
  281. s = showBySlug(&slug)
  282. return s != null && adultHiddenFor(&s, &uid) ? null : s
  283. }
  284. // tracker.worldapi.org#19 (mission 066): the franchise widget(s), one per timeline the title is in (components/franchisewidget.hl)
  285. static franchiseWidgetsOf = (&show) => { return widgetsOf(&show.id) }
  286. // tracker#33 (mission 032): a movie's release date and runtime under its title — "17 September 2026 · 7 min", "… · 2 h 15 min";
  287. // what is missing is left out ('' = no line)
  288. static runtimeText = (&m) => {
  289. if (m == null || hlTypeName(m) != 'Number' || m <= 0) { return '' }
  290. mins = m % 60
  291. hours = (m - mins) / 60
  292. if (hours == 0) { return mins + ' min' }
  293. return mins == 0 ? hours + ' h' : hours + ' h ' + mins + ' min'
  294. }
  295. static movieFactsOf = (&s) => {
  296. if (s.type != 'movie') { return '' }
  297. parts = []
  298. d = dateText(&s.release)
  299. if (d != null) { parts.push(d) }
  300. r = runtimeText(&s.runtime)
  301. if (r != '') { parts.push(r) }
  302. return parts.join(' · ')
  303. }
  304. // mission 062: what the page shows of the title, as a SMALL object — `showRow` reads the session, so hl:web ships it with the page
  305. // AND re-sends it after every watch/follow click (SESSION SYNC below): the whole record was ~1 MB on The Simpsons (300 cast + crew
  306. // entries). null = not found / hidden.
  307. static pageShowOf = (&slug, &uid) => {
  308. s = visibleShow(&slug, &uid)
  309. if (s == null) { return null }
  310. movie = s.type == 'movie'
  311. st = statusOf(&s)
  312. return { id = s.id title = s.title summary = summaryOf(&s) type = s.type adult = s.adult == true shortId = s.shortId != null ? '' + s.shortId : '' statusText = st.text statusTone = st.tone
  313. poster = posterName(&s) genreRows = genreRowsOf(&s) linkRows = externalLinksOf(&s) completing = completingOf(&s) following = followingOf(&s, &uid)
  314. movieWatched = movie ? movieWatchedOf(&s, &uid) : false facts = movieFactsOf(&s) }
  315. }
  316. // the seasons/episodes rows and the per-season watch state by the slug (the record itself stays on the server)
  317. static rowsOfSlug = (&slug, &uid, &collapsed) => {
  318. s = showBySlug(&slug)
  319. return s != null ? buildRows(&s, &uid, collapsed) : []
  320. }
  321. static watchedEpisodesOfSlug = (&slug, &uid) => {
  322. s = showBySlug(&slug)
  323. return s != null ? watchedEpisodesOf(&s, &uid) : {}
  324. }
  325. // the initial open/closed seasons and the title's kind (tracker#20/#21: the heading's type word) from the SLUG alone (not from
  326. // `showRow`, which reads the session — see `collapsed`) — one slug lookup for both
  327. static slugInfoOf = (&slug) => {
  328. s = showBySlug(&slug)
  329. return s != null ? { collapsed = initialCollapsed(seasonsOfShow(&s)) kind = titleKind(&s) canonical = titlePath(&s) } : { collapsed = {} kind = 'series' canonical = '' }
  330. }
  331. // mission 062: the cast and crew rows by the SLUG alone (not from `showRow`, which reads the session — see `castRows`). An
  332. // ADULT title (its page only for its followers) shows none: every member is shipped to the browser, and adult titles never get
  333. // credits anyway (details.hl skips them; at most a migrated cast)
  334. static publicShowOf = (&slug) => {
  335. s = showBySlug(&slug)
  336. return s != null && s.adult != true ? s : null
  337. }
  338. static castOfSlug = (&slug) => {
  339. s = publicShowOf(&slug)
  340. return s != null ? castRowsOf(s) : []
  341. }
  342. static crewOfSlug = (&slug) => {
  343. s = publicShowOf(&slug)
  344. return s != null ? crewRowsOf(&s) : []
  345. }
  346. // tracker#26: the page loads this title's full details on open
  347. static completingOf = (&show) => { return needsDetails(&show) }
  348. // the face's work: ONE step of completing the title (details.hl completeStep — a series takes a few; a second viewer drives the
  349. // same job or finds it complete); when done, every part of the page that changes — the rows without anyone's watch state (a
  350. // title that was incomplete had no episodes to watch)
  351. static completedPageOf = (&slug) => {
  352. let show = showBySlug(&slug)
  353. if (show == null || show.adult == true) { return { error = 'no such show' } }
  354. if (needsDetails(&show)) {
  355. let r = completeStep(&show.id)
  356. if (r.retry || r.adult == true) { return { error = r.error != '' ? r.error : 'no such show' } }
  357. if (!r.done) { return { done = false steps = r.sum.steps } }
  358. if (!r.skipped) {
  359. persistDetails()
  360. console.log('details on open: ' + completeLine(&show.title, &r.sum))
  361. }
  362. show = showById(&show.id)
  363. }
  364. cl = initialCollapsed(seasonsOfShow(&show))
  365. pn = posterName(&show)
  366. crew = crewRowsOf(&show)
  367. cast = castRowsOf(show)
  368. return { done = true title = show.title summary = summaryOf(&show) poster = pn genreRows = genreRowsOf(&show) castRows = cast
  369. castCount = castCountOf(&cast) castMore = castCountOf(&cast) > castShown crewRows = crew crewCount = crewCountOf(&crew) crewMore = crewHiddenOf(&crew) > 0
  370. linkRows = externalLinksOf(&show) collapsed = cl rows = buildRows(&show, null, cl) }
  371. }
  372. // ---- reactive members -----------------------------------------------------------------------
  373. slug = null
  374. session = null
  375. userId = userIdOfSession(&session)
  376. signedIn = userId != null
  377. // SESSION SYNC (mission 047; since hybriel #121/#122, mission 056): a face taking `session` answers with a `sync` of every
  378. // member derived from session that reaches an import (here `showRow`, `found`, `following`, `rows`, …), re-derived on the
  379. // server with the page's route params but the MOUNT's other state — so client state (`collapsed`) must never derive from
  380. // them. `me` stays the plain copy mission 047 introduced.
  381. me = userId
  382. showRow = pageShowOf(&slug, &me)
  383. found = showRow != null
  384. notFound = showRow == null
  385. // the Follow toggle: "Follow" = the inverted button (accent text on a surface, no border since tracker#32), "Following" = the
  386. // filled one (the theme's `primary`)
  387. following = found ? showRow.following : false
  388. followClass = following ? 'follow primary' : 'follow inverted'
  389. followText = following ? 'Following' : 'Follow'
  390. signInHref = loginHref
  391. // #24: a movie's watched check (same icon/classes as the episodes); the classes written out, not `watchClassOf` (an import of
  392. // the mpackdb-backed watches.hl cannot run in the browser when the member is re-derived there)
  393. isMovie = found && showRow.type == 'movie'
  394. movieWatched = isMovie ? showRow.movieWatched : false
  395. movieWatchClass = movieWatched ? 'checkicon solid' : 'checkicon regular'
  396. movieWatchText = movieWatched ? 'Watched' : 'Not watched'
  397. signInText = isMovie ? 'You need to sign in to follow movies and mark them watched.' : 'You need to sign in to follow shows and mark episodes.'
  398. title = found ? showRow.title : ''
  399. // tracker#35: the status pill next to a series' title — TVmaze's status, else TMDB's (shows.hl statusOf); none on a movie
  400. statusText = found ? showRow.statusText : ''
  401. hasStatus = statusText != ''
  402. // tracker#33: a movie's release date + runtime (movieFactsOf)
  403. factsText = found ? showRow.facts : ''
  404. hasFacts = factsText != ''
  405. statusClass = found ? 'pill ' + (showRow.statusTone == 'running' ? 'success' : (showRow.statusTone == 'pending' ? 'warning' : ((showRow.statusTone == 'canceled' || showRow.statusTone == 'ended') ? 'danger' : 'quiet'))) : 'pill quiet'
  406. // tracker#20: "Series | Reacher" — the kind from the slug (pure strings here: they are re-derived in the browser too)
  407. slugInfo = slugInfoOf(&slug)
  408. pageKind = slugInfo.kind
  409. typeText = pageKind == 'movie' ? 'Movie' : (pageKind == 'show' ? 'Show' : 'Series')
  410. typeClass = 'type-word type-' + pageKind
  411. // tracker#18: the creator's own text, else TMDB's, else TVmaze's (pageShowOf → shows.hl summaryOf)
  412. summary = found && showRow.summary != null ? showRow.summary : ''
  413. poster = found ? showRow.poster : null
  414. hasPoster = poster != null
  415. posterUrl = hasPoster ? '/posters/' + poster : ''
  416. // mission 060 (tracker.worldapi.org#27): the short id under the poster (none yet while the backfill has not reached it)
  417. shortId = found ? showRow.shortId : ''
  418. hasShortId = shortId != ''
  419. genreRows = found ? showRow.genreRows : []
  420. hasGenres = genreRows.length > 0
  421. // mission 062: cast + crew from the SLUG (`castOfSlug`, `crewOfSlug`), never from `showRow` — a member derived from the session is
  422. // re-derived and re-SENT after every watch/follow click (SESSION SYNC above): The Simpsons' 300 names took 0.7 s per click
  423. castRows = castOfSlug(&slug)
  424. hasCast = castRows.length > 0
  425. // tracker#28: "Show all (N)" — the toggles' state is CLIENT state: literals, never derived from `showRow` (session sync)
  426. castCount = castCountOf(&castRows)
  427. castMore = castCount > castShown
  428. castAllText = 'Show all (' + castCount + ')'
  429. castClass = 'collapsed'
  430. crewRows = crewOfSlug(&slug)
  431. hasCrew = crewRows.length > 0
  432. crewCount = crewCountOf(&crewRows)
  433. crewMore = crewHiddenOf(&crewRows) > 0
  434. crewAllText = 'Show all crew (' + crewCount + ')'
  435. crewClass = 'collapsed'
  436. linkRows = found ? showRow.linkRows : []
  437. franchiseWidgets = found ? franchiseWidgetsOf(&showRow) : []
  438. hasLinks = linkRows.length > 0
  439. // NOT from `showRow`/`found`: they read the session (via `me`), so a member derived from them is re-derived on the server
  440. // after every session face with the MOUNT's state — `collapsed` (client state) would snap back to the initial seasons (mission
  441. // 056: the 2nd episode click in a re-opened season did nothing). The season ids of a hidden page are no secret.
  442. collapsed = slugInfo.collapsed
  443. // mission 062: has this page opened/closed a season (client state) — then a watch face sends its own rows (toggleEpisode)
  444. collapsedChanged = false
  445. rows = found ? rowsOfSlug(&slug, &me, &collapsed) : []
  446. hasRows = rows.length > 0
  447. watchedEpisodes = found ? watchedEpisodesOfSlug(&slug, &me) : {}
  448. // an adult page (followers only) opens its seasons through the session face `showRows`
  449. adultShow = found && showRow.adult == true
  450. // tracker#26: incomplete → skeletons + the probe until `showComplete` answered
  451. completing = found ? showRow.completing : false
  452. // tracker#33: a title TMDB has no poster for (The Remaining) shows the placeholder in the poster's place — the column was empty
  453. // but for the short id, the page looked unfinished; while an incomplete title loads, the skeleton instead
  454. posterLoading = completing && !hasPoster
  455. noPoster = !hasPoster && !completing
  456. completeBusy = false
  457. isSeries = found && showRow.type != 'movie'
  458. skeletonSeasons = ['1', '2', '3']
  459. __title = found ? title + ' — ' + appTitle : appTitle
  460. // tracker#41 (mission 037b): the title's own address (og:url in the served head) — under a moved slug (a merged duplicate's, a
  461. // former one: lib/shows.hl showBySlug finds the keeper) this page IS the keeper's, and the head names the keeper's address; hl:web
  462. // has no page-level <link rel="canonical">. From the slug alone (slugInfo), not from the session.
  463. canonicalPath = slugInfo.canonical
  464. __meta = canonicalPath != '' ? [{ property = 'og:url' content = canonicalPath }] : []
  465. // mission T17 (boot time): the server listens while bootscan.hl still builds the lists / slug maps / search index (lib/warm.hl); until the 'titles'
  466. // stage is there this page says so instead of showing half a map
  467. warming = !warmReady('titles')
  468. warmNote = warming ? warmText() : ''
  469. // Component styles use the shared theme variables.
  470. Style {
  471. showPage {
  472. display = 'block'
  473. }
  474. showHeader {
  475. display = 'flex'
  476. flexDirection = 'column'
  477. gap = '.6rem'
  478. marginBottom = '1.2rem'
  479. @media {
  480. minWidth = '40rem'
  481. flexDirection = 'row'
  482. alignItems = 'flex-start'
  483. gap = '1rem'
  484. marginBottom = '1.5rem'
  485. }
  486. }
  487. showPoster {
  488. display = 'block'
  489. width = '100%'
  490. img {
  491. display = 'block'
  492. width = '100%'
  493. height = 'auto'
  494. borderRadius = 'var(--radius-large)'
  495. aspectRatio = '2 / 3'
  496. objectFit = 'cover'
  497. background = 'var(--color-surface)'
  498. }
  499. @media {
  500. minWidth = '40rem'
  501. flex = 'none'
  502. width = '10rem'
  503. }
  504. }
  505. showMeta {
  506. display = 'contents'
  507. overflowWrap = 'anywhere'
  508. @media {
  509. minWidth = '40rem'
  510. display = 'block'
  511. flex = '1'
  512. 'min-width' = '0'
  513. }
  514. }
  515. showTitle {
  516. order = '-1'
  517. display = 'flex'
  518. flexWrap = 'wrap'
  519. alignItems = 'center'
  520. gap = '.4rem .6rem'
  521. h1 {
  522. flex = '0 1 auto'
  523. minWidth = '0'
  524. margin = '0'
  525. }
  526. '.pill' {
  527. flex = 'none'
  528. }
  529. @media {
  530. minWidth = '40rem'
  531. marginBottom = '1rem'
  532. }
  533. }
  534. 'button.follow' {
  535. display = 'block'
  536. width = '100%'
  537. marginTop = '.5rem'
  538. padding = '.4rem .8rem'
  539. fontSize = '.95rem'
  540. }
  541. showFacts {
  542. flexBasis = '100%'
  543. fontSize = '.95rem'
  544. color = 'var(--color-text-muted)'
  545. }
  546. showLinks {
  547. order = '-1'
  548. display = 'flex'
  549. flexWrap = 'wrap'
  550. gap = '.4rem'
  551. }
  552. movieWatch {
  553. order = '-1'
  554. display = 'flex'
  555. alignItems = 'center'
  556. gap = '.4rem'
  557. @media {
  558. minWidth = '40rem'
  559. margin = '-.4rem 0 .8rem'
  560. }
  561. }
  562. movieWatchLabel {
  563. fontSize = '.95rem'
  564. color = 'var(--color-text)'
  565. }
  566. showGenres {
  567. display = 'flex'
  568. flexWrap = 'wrap'
  569. gap = '.4rem'
  570. margin = '.5rem 0'
  571. }
  572. showSummary {
  573. display = 'block'
  574. margin = '.5rem 0'
  575. fontSize = '.95rem'
  576. color = 'var(--color-text)'
  577. @media {
  578. minWidth = '40rem'
  579. fontSize = '1rem'
  580. }
  581. }
  582. showCrew {
  583. display = 'block'
  584. margin = '.5rem 0'
  585. crewLabel {
  586. firstChild {
  587. marginTop = '0'
  588. }
  589. }
  590. }
  591. showCast {
  592. display = 'block'
  593. margin = '.5rem 0'
  594. }
  595. castHeading {
  596. display = 'block'
  597. fontSize = '.75rem'
  598. letterSpacing = '.04em'
  599. textTransform = 'uppercase'
  600. color = 'var(--color-text-muted)'
  601. }
  602. crewLabel {
  603. display = 'block'
  604. marginTop = '.35rem'
  605. fontSize = '.75rem'
  606. letterSpacing = '.04em'
  607. textTransform = 'uppercase'
  608. color = 'var(--color-text-muted)'
  609. }
  610. castLabel {
  611. display = 'block'
  612. margin = '.4rem 0 .1rem'
  613. fontSize = '.75rem'
  614. letterSpacing = '.04em'
  615. textTransform = 'uppercase'
  616. color = 'var(--color-text-muted)'
  617. }
  618. '.artist-link' {
  619. color = 'var(--color-type5)'
  620. }
  621. '.crew-link' {
  622. color = 'var(--color-type5)'
  623. }
  624. 'a.artist-link::after' {
  625. content = "attr(data-role) ', '"
  626. color = 'var(--color-text-muted)'
  627. }
  628. 'a.crew-link::after' {
  629. content = "', '"
  630. color = 'var(--color-text-muted)'
  631. }
  632. 'a.artist-link.end::after' {
  633. content = 'attr(data-role)'
  634. }
  635. 'show-cast.collapsed' {
  636. 'a.artist-link.cut::after' {
  637. content = 'attr(data-role)'
  638. }
  639. '.more' {
  640. display = 'none'
  641. }
  642. whenAll {
  643. display = 'none'
  644. }
  645. }
  646. 'a.crew-link.end::after' {
  647. content = 'none'
  648. }
  649. 'show-crew.collapsed' {
  650. 'a.crew-link.cut::after' {
  651. content = 'none'
  652. }
  653. '.more' {
  654. display = 'none'
  655. }
  656. whenAll {
  657. display = 'none'
  658. }
  659. }
  660. 'button.showall' {
  661. display = 'block'
  662. margin = '.3rem 0 0'
  663. padding = '.15rem 0'
  664. fontSize = '.85rem'
  665. color = 'var(--color-accent)'
  666. background = 'transparent'
  667. hover {
  668. background = 'transparent'
  669. textDecoration = 'underline'
  670. }
  671. }
  672. 'show-cast.all' {
  673. whenCollapsed {
  674. display = 'none'
  675. }
  676. }
  677. 'show-crew.all' {
  678. whenCollapsed {
  679. display = 'none'
  680. }
  681. }
  682. showSeasons {
  683. display = 'block'
  684. }
  685. seasonRow {
  686. display = 'flex'
  687. alignItems = 'center'
  688. gap = '.6rem'
  689. padding = '.5rem 0'
  690. borderTop = '1px solid ' + 'var(--color-border)' // functional: the season foldable's line
  691. 'button.checkicon' {
  692. margin = '-.3125rem 0'
  693. }
  694. }
  695. 'button.season-toggle' {
  696. flex = '1'
  697. minWidth = '0'
  698. display = 'flex'
  699. alignItems = 'center'
  700. gap = '.6rem'
  701. justifyContent = 'flex-start'
  702. padding = '0'
  703. color = 'var(--color-text)'
  704. background = 'transparent'
  705. border = '0'
  706. fontWeight = '600'
  707. cursor = 'pointer'
  708. textAlign = 'left'
  709. margin = '-.3125rem 0'
  710. }
  711. seasonCount {
  712. fontWeight = '400'
  713. fontSize = '.85rem'
  714. color = 'var(--color-text-muted)'
  715. }
  716. seasonCaret {
  717. flex = 'none'
  718. alignSelf = 'center'
  719. display = 'grid'
  720. marginLeft = 'auto'
  721. color = 'var(--color-text-muted)'
  722. transition = 'transform .15s'
  723. svg {
  724. display = 'block'
  725. fill = 'none'
  726. stroke = 'currentColor'
  727. strokeWidth = '2'
  728. strokeLinecap = 'round'
  729. strokeLinejoin = 'round'
  730. }
  731. }
  732. 'season-row.expanded' {
  733. seasonCaret {
  734. transform = 'rotate(180deg)'
  735. }
  736. }
  737. episodeRow {
  738. display = 'flex'
  739. alignItems = 'center'
  740. gap = '.6rem'
  741. minHeight = '2.125rem'
  742. padding = '0'
  743. 'button.checkicon' {
  744. margin = '-.3125rem 0'
  745. }
  746. }
  747. episodeNumber {
  748. flex = 'none'
  749. width = '1.6rem'
  750. color = 'var(--color-text-muted)'
  751. fontVariantNumeric = 'tabular-nums'
  752. }
  753. episodeTitle {
  754. flex = '1'
  755. minWidth = '0'
  756. overflowWrap = 'anywhere'
  757. }
  758. episodeDate {
  759. flex = 'none'
  760. fontSize = '.85rem'
  761. color = 'var(--color-text-muted)'
  762. fontVariantNumeric = 'tabular-nums'
  763. }
  764. skeletonRow {
  765. display = 'flex'
  766. alignItems = 'center'
  767. gap = '.6rem'
  768. minHeight = '2.125rem'
  769. padding = '0'
  770. }
  771. skeletonCheck {
  772. display = 'block'
  773. borderRadius = 'var(--radius-small)'
  774. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  775. backgroundSize = '400% 100%'
  776. animation = 'tracker-shimmer 1.4s linear infinite'
  777. flex = 'none'
  778. width = '1.375rem'
  779. height = '1.375rem'
  780. borderRadius = '50%'
  781. margin = '0 .6875rem'
  782. }
  783. skeletonNumber {
  784. display = 'block'
  785. borderRadius = 'var(--radius-small)'
  786. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  787. backgroundSize = '400% 100%'
  788. animation = 'tracker-shimmer 1.4s linear infinite'
  789. flex = 'none'
  790. width = '1.6rem'
  791. height = '1rem'
  792. }
  793. skeletonTitle {
  794. display = 'block'
  795. borderRadius = 'var(--radius-small)'
  796. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  797. backgroundSize = '400% 100%'
  798. animation = 'tracker-shimmer 1.4s linear infinite'
  799. flex = '1'
  800. maxWidth = '60%'
  801. height = '1rem'
  802. }
  803. 'skeleton-row:nth-of-type(even)' {
  804. skeletonTitle {
  805. maxWidth = '42%'
  806. }
  807. }
  808. skeletonPoster {
  809. display = 'block'
  810. borderRadius = 'var(--radius-large)'
  811. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  812. backgroundSize = '400% 100%'
  813. animation = 'tracker-shimmer 1.4s linear infinite'
  814. width = '100%'
  815. aspectRatio = '2 / 3'
  816. }
  817. skeletonCast {
  818. display = 'block'
  819. borderRadius = 'var(--radius-large)'
  820. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  821. backgroundSize = '400% 100%'
  822. animation = 'tracker-shimmer 1.4s linear infinite'
  823. width = '70%'
  824. height = '1rem'
  825. margin = '.5rem 0'
  826. }
  827. showLoading {
  828. display = 'block'
  829. marginTop = '1rem'
  830. }
  831. showProbe {
  832. position = 'fixed'
  833. left = '0'
  834. top = '0'
  835. width = '1px'
  836. height = '1px'
  837. opacity = '0'
  838. pointerEvents = 'none'
  839. animation = 'tracker-person-tick .1s linear infinite'
  840. }
  841. '@keyframes tracker-shimmer' {
  842. 'from' {
  843. backgroundPosition = '100% 0'
  844. }
  845. to {
  846. backgroundPosition = '0% 0'
  847. }
  848. }
  849. }
  850. View {
  851. showPage {
  852. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  853. if (notFound) {
  854. article { class = "main"
  855. h1 { "Not found" }
  856. p { "This show doesn't exist." }
  857. }
  858. }
  859. if (found) {
  860. showHeader {
  861. showPoster {
  862. if (hasPoster) { img { src = posterUrl alt = title } }
  863. if (noPoster) { img { class = "no-poster" src = "/posters/none" alt = "no poster" } }
  864. if (posterLoading) { skeletonPoster { "aria-hidden" = "true" } }
  865. // tracker#34: Follow directly under the poster, as wide as the poster (creator: "the follow button should go below
  866. // the picture … and expand to the size o the poster")
  867. button { id = "follow" type = "button" class = followClass followText on click(e) { emit toggleFollow(e) } }
  868. if (hasShortId) { shortIdLabel { id = "shortid" title = "Short id" shortId } }
  869. }
  870. showMeta {
  871. showTitle {
  872. h1 { class = "typed" typeWord { class = typeClass typeText } typeSep { "|" } typeName { title } }
  873. if (hasStatus) { span { class = statusClass statusText } }
  874. if (hasFacts) { showFacts { id = "moviefacts" factsText } }
  875. }
  876. if (isMovie) {
  877. movieWatch {
  878. button { id = "moviewatch" type = "button" class = movieWatchClass "aria-label" = "mark movie watched"
  879. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  880. circle { cx = "12" cy = "12" r = "10" }
  881. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  882. }
  883. on click(e) { emit toggleMovie(e) }
  884. }
  885. movieWatchLabel { movieWatchText }
  886. }
  887. }
  888. if (hasLinks) {
  889. showLinks {
  890. for (l of linkRows) { a { class = "pill quiet extlink" href = l.href target = "_blank" rel = "noopener" title = l.title "aria-label" = l.title "data-site" = l.site l.label } }
  891. }
  892. }
  893. // mission 025: the franchise widget right under the title/poster block — on a phone (showMeta dissolves, see styles.hl)
  894. // after the poster and before the genres, plot and cast; from 40rem in the right column under the title
  895. FranchiseWidget { widgets = franchiseWidgets }
  896. if (hasGenres) {
  897. showGenres {
  898. for (g of genreRows) { a { class = "pill type-4 genre-pill" href = g.href g.name } }
  899. }
  900. }
  901. showSummary { summary }
  902. if (hasCrew) {
  903. showCrew { class = crewClass
  904. for (r of crewRows) {
  905. if (r.isLabel) { crewLabel { r.text } }
  906. if (r.isPerson) { a { class = r.itemClass href = r.href r.name } }
  907. }
  908. if (crewMore) {
  909. button { id = "crewtoggle" type = "button" class = "quiet showall"
  910. whenCollapsed { crewAllText }
  911. whenAll { "Show less" }
  912. on click(e) { emit toggleCrewAll(e) }
  913. }
  914. }
  915. }
  916. }
  917. if (hasCast) {
  918. showCast { class = castClass
  919. castHeading { "Cast" }
  920. for (c of castRows) {
  921. if (c.isLabel) { castLabel { class = c.itemClass c.text } }
  922. if (c.isPerson) { a { class = c.itemClass href = c.href "data-role" = c.roleText c.name } }
  923. }
  924. if (castMore) {
  925. button { id = "casttoggle" type = "button" class = "quiet showall"
  926. whenCollapsed { castAllText }
  927. whenAll { "Show less" }
  928. on click(e) { emit toggleCastAll(e) }
  929. }
  930. }
  931. }
  932. }
  933. if (completing) { skeletonCast { "aria-hidden" = "true" } }
  934. }
  935. }
  936. if (completing) {
  937. showLoading { id = "showloading" "aria-busy" = "true"
  938. if (isSeries) {
  939. for (k of skeletonSeasons) {
  940. skeletonRow { "aria-hidden" = "true"
  941. skeletonCheck { }
  942. skeletonTitle { }
  943. }
  944. }
  945. }
  946. showProbe { "aria-hidden" = "true" on animationiteration(e) { emit completeTick(e) } }
  947. }
  948. }
  949. if (hasRows) {
  950. showSeasons {
  951. for (row of rows) {
  952. if (row.isSeason) {
  953. seasonRow { class = row.rowClass
  954. button { type = "button" class = row.watchClass value = row.id "aria-label" = "mark season watched"
  955. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  956. circle { cx = "12" cy = "12" r = "10" }
  957. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  958. }
  959. on click(e) { emit toggleSeason(row.id) }
  960. }
  961. button { type = "button" class = "season-toggle" value = row.id
  962. seasonLabel { row.label }
  963. seasonCount { row.episodeCountText }
  964. seasonCaret { "aria-hidden" = "true"
  965. svg { viewBox = "0 0 24 24" width = "20" height = "20"
  966. path { d = "M6 9 L12 15 L18 9" }
  967. }
  968. }
  969. on click(e) { emit toggleCollapse(row.id) }
  970. }
  971. }
  972. }
  973. if (row.isEpisode) {
  974. episodeRow {
  975. button { type = "button" class = row.watchClass value = row.id "aria-label" = "mark episode watched"
  976. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  977. circle { cx = "12" cy = "12" r = "10" }
  978. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  979. }
  980. on click(e) { emit toggleEpisode(row.id) }
  981. }
  982. episodeNumber { row.episodeNumber }
  983. episodeTitle { row.title }
  984. episodeDate { row.airDate }
  985. }
  986. }
  987. if (row.isSkeleton) {
  988. skeletonRow { "aria-hidden" = "true"
  989. skeletonCheck { }
  990. skeletonNumber { }
  991. skeletonTitle { }
  992. }
  993. }
  994. }
  995. }
  996. }
  997. Modal { id = "signin" title = "Sign in"
  998. p { signInText }
  999. footer {
  1000. button { type = "button" value = "close" "Close" }
  1001. a { id = "signin-link" class = "button primary" href = signInHref "Sign in with ident" }
  1002. }
  1003. }
  1004. }
  1005. }
  1006. }
  1007. // Every rebuild of `rows` happens SERVER-SIDE, never by calling `buildRows` from a client handler:
  1008. // a member function whose body reaches an hl:mpackdb-backed import (seasonsOfShow, episodesOfSeason,
  1009. // watchesOfUser, …) compiles to nothing on the client (no case ever assigns it — a genuine Hybriel
  1010. // gap, filed under `issues`) even though the client bundle still calls it, so `this.buildRows(...)`
  1011. // throws "not a function" in the browser. The client here only ever ASSIGNS the `rows` the server
  1012. // already built (`rows = r.rows`) — never calls a tainted local helper itself. `slug` goes along so
  1013. // the face can refetch the show without depending on implicit access to a sibling member.
  1014. //
  1015. // tracker#17: opening shows the skeleton rows BEFORE the request; the answer replaces them unless the season was closed
  1016. // meanwhile (then nothing). An error closes the season again. Closing never asks the server.
  1017. on toggleCollapse(seasonId) {
  1018. collapsedChanged = true
  1019. m = collapsed
  1020. if (collapsed[seasonId] != true) {
  1021. m[seasonId] = true
  1022. collapsed = m
  1023. rows = closedRows(&rows, &seasonId)
  1024. return null
  1025. }
  1026. m[seasonId] = false
  1027. collapsed = m
  1028. rows = openingRows(&rows, seasonId)
  1029. if (adultShow) {
  1030. let a = emit server showRows(slug, collapsed)
  1031. if (collapsed[seasonId] == true) { return null }
  1032. if (a == null || a.error != null) { m[seasonId] = true collapsed = m rows = closedRows(&rows, &seasonId) return null }
  1033. rows = a.rows
  1034. return null
  1035. }
  1036. let r = emit server showSeasonEpisodes('' + seasonId)
  1037. if (collapsed[seasonId] == true) { return null }
  1038. if (r == null || r.error != null) { m[seasonId] = true collapsed = m rows = closedRows(&rows, &seasonId) return null }
  1039. rows = filledRows(&rows, seasonId, &r.episodes, watchedEpisodes)
  1040. }
  1041. // tracker#26: the probe's tick — `showComplete` step by step until `done` (once per page: `completeBusy`; other requests are
  1042. // served between two calls); the last answer replaces the skeletons. A lost answer (null) lets the next tick go on where the
  1043. // server is; an error (TMDB down, adult) ends the loading and keeps what the page has.
  1044. on completeTick(e) {
  1045. if (completeBusy || !completing) { return null }
  1046. completeBusy = true
  1047. s = slug
  1048. let r = emit server showComplete(s)
  1049. while (r != null && r.error == null && r.done != true && slug == s) { r = emit server showComplete(s) }
  1050. completeBusy = false
  1051. if (r == null || slug != s) { return null }
  1052. if (r.error != null) { completing = false return null }
  1053. title = r.title
  1054. summary = r.summary
  1055. poster = r.poster
  1056. genreRows = r.genreRows
  1057. castRows = r.castRows
  1058. castCount = r.castCount
  1059. castMore = r.castMore
  1060. castAllText = 'Show all (' + r.castCount + ')'
  1061. crewRows = r.crewRows
  1062. crewCount = r.crewCount
  1063. crewMore = r.crewMore
  1064. crewAllText = 'Show all crew (' + r.crewCount + ')'
  1065. linkRows = r.linkRows
  1066. collapsed = r.collapsed
  1067. collapsedChanged = true
  1068. rows = r.rows
  1069. completing = false
  1070. }
  1071. // tracker#28: the cast / crew "Show all" toggles — client-only, no request (CSS shows the hidden names)
  1072. on toggleCastAll(e) {
  1073. castClass = castClass == 'all' ? 'collapsed' : 'all'
  1074. }
  1075. on toggleCrewAll(e) {
  1076. crewClass = crewClass == 'all' ? 'collapsed' : 'all'
  1077. }
  1078. // signed out: the modal, nothing is sent
  1079. // mission 062: the new `rows` come with the SAME ack as the session sync (SESSION SYNC above: `rows` derives from the session) —
  1080. // but that sync is built with the MOUNT's open seasons. So the face sends its own rows only once this page opened/closed a season
  1081. // (`collapsedChanged`, or a completed title); else they came twice (a second buildRows + 14 kB on The Simpsons: ~40 ms per click)
  1082. on toggleEpisode(episodeId) {
  1083. if (!signedIn) { document.getElementById('signin').showModal() return null }
  1084. let r = emit server showToggleEpisode(slug, '' + episodeId, collapsed, collapsedChanged)
  1085. if (r == null || r.error != null) { return null }
  1086. if (r.rows != null) { rows = r.rows }
  1087. }
  1088. on toggleSeason(seasonId) {
  1089. if (!signedIn) { document.getElementById('signin').showModal() return null }
  1090. let r = emit server showToggleSeason(slug, '' + seasonId, collapsed, collapsedChanged)
  1091. if (r == null || r.error != null) { return null }
  1092. if (r.rows != null) { rows = r.rows }
  1093. }
  1094. // #24: the movie's own check — signed out the modal, nothing sent
  1095. on toggleMovie(e) {
  1096. if (!signedIn) { document.getElementById('signin').showModal() return null }
  1097. let r = emit server showToggleMovie(slug)
  1098. if (r == null || r.error != null) { return null }
  1099. movieWatched = r.watched
  1100. movieWatchClass = r.watched ? 'checkicon solid' : 'checkicon regular'
  1101. movieWatchText = r.watched ? 'Watched' : 'Not watched'
  1102. }
  1103. on toggleFollow(e) {
  1104. if (!signedIn) { document.getElementById('signin').showModal() return null }
  1105. let r = emit server showToggleFollow(slug)
  1106. if (r == null || r.error != null) { return null }
  1107. following = r.following
  1108. followClass = r.following ? 'follow primary' : 'follow inverted'
  1109. followText = r.following ? 'Following' : 'Follow'
  1110. }
  1111. // ---- the faces (the trailing `session` is always the server's: hybriel#16) ----
  1112. // tracker#26: complete an incomplete title and answer the page's parts — public data, NO session (no page re-mount)
  1113. on server showComplete(slug) {
  1114. return completedPageOf(textArg(&slug))
  1115. }
  1116. // every row for these open/closed seasons — only an ADULT show's page still uses it (its followers; tracker#17)
  1117. on server showRows(slug, collapsed, session) {
  1118. show = showBySlug(&slug)
  1119. uid = userIdOfSession(&session)
  1120. if (show == null || adultHiddenFor(&show, &uid)) { return { error = 'no such show' } }
  1121. return { ok = true rows = buildRows(&show, &uid, collapsed) }
  1122. }
  1123. // tracker#17: one season's episodes, in order — public data, so NO `session` (no page re-mount, no sync: the fast path).
  1124. // Refuses a season of an adult title (those pages use showRows above).
  1125. on server showSeasonEpisodes(seasonId) {
  1126. if (seasonId == null || hlTypeName(seasonId) != 'String') { return { error = 'no such season' } }
  1127. season = seasonById(&seasonId)
  1128. if (season == null) { return { error = 'no such season' } }
  1129. show = showById(&season.show)
  1130. if (show == null || show.adult == true) { return { error = 'no such season' } }
  1131. out = []
  1132. for (e of episodesOfSeason(&season)) { out.push({ id = e.id episodeNumber = e.episodeNumber title = e.title != null ? e.title : '' airDate = airDateOf(&e) }) }
  1133. return { ok = true episodes = out }
  1134. }
  1135. on server showToggleEpisode(slug, episodeId, collapsed, withRows, session) {
  1136. show = showBySlug(&slug)
  1137. if (show == null) { return { error = 'no such show' } }
  1138. uid = userIdOfSession(&session)
  1139. if (uid == null) { return { error = 'you are not signed in' } }
  1140. if (adultHiddenFor(&show, &uid)) { return { error = 'no such show' } }
  1141. // mission SK: only an episode OF THIS SHOW — the id is the peer's (any text became a watch row before)
  1142. ep = episodeId != null && hlTypeName(episodeId) == 'String' ? episodeById(&episodeId) : null
  1143. if (ep == null || ep.show != show.id) { return { error = 'no such episode' } }
  1144. if (toggleWatched(&uid, 'episode', &episodeId) == null) { return { error = 'could not save the watch' } }
  1145. return withRows == true ? { ok = true rows = buildRows(&show, &uid, collapsed) } : { ok = true }
  1146. }
  1147. on server showToggleSeason(slug, seasonId, collapsed, withRows, session) {
  1148. show = showBySlug(&slug)
  1149. if (show == null) { return { error = 'no such show' } }
  1150. uid = userIdOfSession(&session)
  1151. if (uid == null) { return { error = 'you are not signed in' } }
  1152. if (adultHiddenFor(&show, &uid)) { return { error = 'no such show' } }
  1153. season = seasonId != null && hlTypeName(seasonId) == 'String' ? seasonById(&seasonId) : null
  1154. if (season == null || season.show != show.id) { return { error = 'no such season' } }
  1155. // #23: not all episodes watched → watch them all; all watched → unwatch them all (lib/watches.hl)
  1156. if (toggleSeasonWatched(&uid, &season) == null) { return { error = 'could not save the watch' } }
  1157. return withRows == true ? { ok = true rows = buildRows(&show, &uid, collapsed) } : { ok = true }
  1158. }
  1159. // #24: a movie's watched check (only a movie: a series is watched by its episodes)
  1160. on server showToggleMovie(slug, session) {
  1161. show = showBySlug(&slug)
  1162. if (show == null || show.type != 'movie') { return { error = 'no such movie' } }
  1163. uid = userIdOfSession(&session)
  1164. if (uid == null) { return { error = 'you are not signed in' } }
  1165. if (adultHiddenFor(&show, &uid)) { return { error = 'no such movie' } }
  1166. watched = toggleWatched(&uid, 'movie', &show.id)
  1167. if (watched == null) { return { error = 'could not save the watch' } }
  1168. return { ok = true watched = watched }
  1169. }
  1170. on server showToggleFollow(slug, session) {
  1171. show = showBySlug(&slug)
  1172. if (show == null) { return { error = 'no such show' } }
  1173. uid = userIdOfSession(&session)
  1174. if (uid == null) { return { error = 'you are not signed in' } }
  1175. // mission SK: an adult title is its followers' only — nobody else may start following it (that opened its page to anyone who
  1176. // guessed the slug); a follower may still stop
  1177. if (adultHiddenFor(&show, &uid)) { return { error = 'no such show' } }
  1178. follow = toggleFollowed(&uid, &show.id)
  1179. if (follow == null) { return { error = 'could not save the follow' } }
  1180. return { ok = true following = follow }
  1181. }

Branches

Latest commits

  • 73fa20ddMerge hm49b-styles: tracker#49 rest of the component stylesmre
  • 14195720log: HM49B done, HM51 startedmre
  • 78ee6b56Move remaining component styles into Style blocksmre
  • 7f04de33log: HM49Bmre
  • 00616cf3log: #49 batch merged, DP67 startedmre
  • d7232e86Merge hm49-styles: tracker#49 first batch of component stylesmre
  • 079f376dMove seven components' styles into Style blocksmre
  • 17d66feelog: #58 mergedmre
  • 69a6640bMerge hm58-map: tracker#58 project.hl only the mapmre
  • a85f7900Move route logic out of the project mapmre
  • 13dea5belog: #56 live, HM49 and HM58 startedmre
  • a31c8f2fdocs: tracker#36 remaining listmre
  • 975d06d1log: #36 live, DP66 startedmre
  • d6d03fa3mission: T36Bmre
  • e7512d00status: #36 rolled back, retry askedmre
  • c98e2043log: T36A rollbackmre
  • ae905f15Merge t36a: tracker#36 apply rechecks, reportmre
  • 796bfaceT36A: report validated fixes, failed live SSH check and verified rollbackmre
  • 55257852log: #53 live, #56 mergedmre
  • 78b39f1bMerge hm56-rows: tracker#56 list builders insert oncemre