gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitce6d7d32ce6d7d32Merge rv48: Hybriel day48mrece6d7d32/components/show.hl

32.7 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 '../lib/app.hl'
  59. import { userIdOfSession, loginHref } from '../lib/users.hl'
  60. import { showBySlug, showById, seasonsOfShow, posterName, externalLinksOf, summaryOf, initialCollapsed, genreRowsOf, castShown, castRowsOf, castCountOf, crewRowsOf, crewHiddenOf, crewCountOf, buildRows, openingRows, closedRows, filledRows, franchiseWidgetsOf, pageShowOf, rowsOfSlug, watchedEpisodesOfSlug, slugInfoOf, castOfSlug, crewOfSlug, showRowsOf, showSeasonEpisodesOf, showToggleEpisodeOf, showToggleSeasonOf, showToggleMovieOf, showToggleFollowOf } from '../lib/shows.hl'
  61. import { needsDetails, completeStep, completeLine, persistDetails } from '../lib/details.hl'
  62. import { textArg } from '../lib/util.hl'
  63. import { warmReady, warmText } from '../lib/warm.hl'
  64. // tracker#26: the page loads this title's full details on open
  65. // the face's work: ONE step of completing the title (details.hl completeStep — a series takes a few; a second viewer drives the
  66. // same job or finds it complete); when done, every part of the page that changes — the rows without anyone's watch state (a
  67. // title that was incomplete had no episodes to watch)
  68. static completedPageOf = (&slug) => {
  69. let show = showBySlug(&slug)
  70. if (show == null || show.adult == true) { return { error = 'no such show' } }
  71. if (needsDetails(&show)) {
  72. r = completeStep(&show.id)
  73. if (r.retry || r.adult == true) { return { error = r.error != '' ? r.error : 'no such show' } }
  74. if (!r.done) { return { done = false steps = r.sum.steps } }
  75. if (!r.skipped) {
  76. persistDetails()
  77. console.log('details on open: ' + completeLine(&show.title, &r.sum))
  78. }
  79. show = showById(&show.id)
  80. }
  81. cl = initialCollapsed(seasonsOfShow(&show))
  82. pn = posterName(&show)
  83. crew = crewRowsOf(&show)
  84. cast = castRowsOf(show)
  85. return { done = true title = show.title summary = summaryOf(&show) poster = pn genreRows = genreRowsOf(&show) castRows = cast
  86. castCount = castCountOf(&cast) castMore = castCountOf(&cast) > castShown crewRows = crew crewCount = crewCountOf(&crew) crewMore = crewHiddenOf(&crew) > 0
  87. linkRows = externalLinksOf(&show) collapsed = cl rows = buildRows(&show, null, cl) }
  88. }
  89. // ---- reactive members -----------------------------------------------------------------------
  90. slug = null
  91. session = null
  92. userId = userIdOfSession(&session)
  93. signedIn = userId != null
  94. // SESSION SYNC (mission 047; since hybriel #121/#122, mission 056): a face taking `session` answers with a `sync` of every
  95. // member derived from session that reaches an import (here `showRow`, `found`, `following`, `rows`, …), re-derived on the
  96. // server with the page's route params but the MOUNT's other state — so client state (`collapsed`) must never derive from
  97. // them. `me` stays the plain copy mission 047 introduced.
  98. me = userId
  99. showRow = pageShowOf(&slug, &me)
  100. found = showRow != null
  101. notFound = showRow == null
  102. // the Follow toggle: "Follow" = the inverted button (accent text on a surface, no border since tracker#32), "Following" = the
  103. // filled one (the theme's `primary`)
  104. following = found ? showRow.following : false
  105. followClass = following ? 'follow primary' : 'follow inverted'
  106. followText = following ? 'Following' : 'Follow'
  107. signInHref = loginHref
  108. // #24: a movie's watched check (same icon/classes as the episodes); the classes written out, not `watchClassOf` (an import of
  109. // the mpackdb-backed watches.hl cannot run in the browser when the member is re-derived there)
  110. isMovie = found && showRow.type == 'movie'
  111. movieWatched = isMovie ? showRow.movieWatched : false
  112. movieWatchClass = movieWatched ? 'checkicon solid' : 'checkicon regular'
  113. movieWatchText = movieWatched ? 'Watched' : 'Not watched'
  114. 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.'
  115. title = found ? showRow.title : ''
  116. // tracker#35: the status pill next to a series' title — TVmaze's status, else TMDB's (shows.hl statusOf); none on a movie
  117. statusText = found ? showRow.statusText : ''
  118. hasStatus = statusText != ''
  119. // tracker#33: a movie's release date + runtime (movieFactsOf)
  120. factsText = found ? showRow.facts : ''
  121. hasFacts = factsText != ''
  122. statusClass = found ? 'pill ' + (showRow.statusTone == 'running' ? 'success' : (showRow.statusTone == 'pending' ? 'warning' : ((showRow.statusTone == 'canceled' || showRow.statusTone == 'ended') ? 'danger' : 'quiet'))) : 'pill quiet'
  123. // tracker#20: "Series | Reacher" — the kind from the slug (pure strings here: they are re-derived in the browser too)
  124. slugInfo = slugInfoOf(&slug)
  125. pageKind = slugInfo.kind
  126. typeText = pageKind == 'movie' ? 'Movie' : (pageKind == 'show' ? 'Show' : 'Series')
  127. typeClass = 'type-word type-' + pageKind
  128. // tracker#18: the creator's own text, else TMDB's, else TVmaze's (pageShowOf → shows.hl summaryOf)
  129. summary = found && showRow.summary != null ? showRow.summary : ''
  130. poster = found ? showRow.poster : null
  131. hasPoster = poster != null
  132. posterUrl = hasPoster ? '/posters/' + poster : ''
  133. // mission 060 (tracker.worldapi.org#27): the short id under the poster (none yet while the backfill has not reached it)
  134. shortId = found ? showRow.shortId : ''
  135. hasShortId = shortId != ''
  136. genreRows = found ? showRow.genreRows : []
  137. hasGenres = genreRows.length > 0
  138. // mission 062: cast + crew from the SLUG (`castOfSlug`, `crewOfSlug`), never from `showRow` — a member derived from the session is
  139. // re-derived and re-SENT after every watch/follow click (SESSION SYNC above): The Simpsons' 300 names took 0.7 s per click
  140. castRows = castOfSlug(&slug)
  141. hasCast = castRows.length > 0
  142. // tracker#28: "Show all (N)" — the toggles' state is CLIENT state: literals, never derived from `showRow` (session sync)
  143. castCount = castCountOf(&castRows)
  144. castMore = castCount > castShown
  145. castAllText = 'Show all (' + castCount + ')'
  146. castClass = 'collapsed'
  147. crewRows = crewOfSlug(&slug)
  148. hasCrew = crewRows.length > 0
  149. crewCount = crewCountOf(&crewRows)
  150. crewMore = crewHiddenOf(&crewRows) > 0
  151. crewAllText = 'Show all crew (' + crewCount + ')'
  152. crewClass = 'collapsed'
  153. linkRows = found ? showRow.linkRows : []
  154. franchiseWidgets = found ? franchiseWidgetsOf(&showRow) : []
  155. hasLinks = linkRows.length > 0
  156. // NOT from `showRow`/`found`: they read the session (via `me`), so a member derived from them is re-derived on the server
  157. // after every session face with the MOUNT's state — `collapsed` (client state) would snap back to the initial seasons (mission
  158. // 056: the 2nd episode click in a re-opened season did nothing). The season ids of a hidden page are no secret.
  159. collapsed = slugInfo.collapsed
  160. // mission 062: has this page opened/closed a season (client state) — then a watch face sends its own rows (toggleEpisode)
  161. collapsedChanged = false
  162. rows = found ? rowsOfSlug(&slug, &me, &collapsed) : []
  163. hasRows = rows.length > 0
  164. watchedEpisodes = found ? watchedEpisodesOfSlug(&slug, &me) : {}
  165. // an adult page (followers only) opens its seasons through the session face `showRows`
  166. adultShow = found && showRow.adult == true
  167. // tracker#26: incomplete → skeletons + the probe until `showComplete` answered
  168. completing = found ? showRow.completing : false
  169. // tracker#33: a title TMDB has no poster for (The Remaining) shows the placeholder in the poster's place — the column was empty
  170. // but for the short id, the page looked unfinished; while an incomplete title loads, the skeleton instead
  171. posterLoading = completing && !hasPoster
  172. noPoster = !hasPoster && !completing
  173. completeBusy = false
  174. isSeries = found && showRow.type != 'movie'
  175. skeletonSeasons = ['1', '2', '3']
  176. __title = found ? title + ' — ' + appTitle : appTitle
  177. // tracker#41 (mission 037b): the title's own address (og:url in the served head) — under a moved slug (a merged duplicate's, a
  178. // 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
  179. // has no page-level <link rel="canonical">. From the slug alone (slugInfo), not from the session.
  180. canonicalPath = slugInfo.canonical
  181. __meta = canonicalPath != '' ? [{ property = 'og:url' content = canonicalPath }] : []
  182. // mission T17 (boot time): the server listens while bootscan.hl still builds the lists / slug maps / search index (lib/warm.hl); until the 'titles'
  183. // stage is there this page says so instead of showing half a map
  184. warming = !warmReady('titles')
  185. warmNote = warming ? warmText() : ''
  186. // Component styles use the shared theme variables.
  187. Style {
  188. showPage {
  189. display = 'block'
  190. }
  191. showHeader {
  192. display = 'flex'
  193. flexDirection = 'column'
  194. gap = '.6rem'
  195. marginBottom = '1.2rem'
  196. @media {
  197. minWidth = '40rem'
  198. flexDirection = 'row'
  199. alignItems = 'flex-start'
  200. gap = '1rem'
  201. marginBottom = '1.5rem'
  202. }
  203. }
  204. showPoster {
  205. display = 'block'
  206. width = '100%'
  207. img {
  208. display = 'block'
  209. width = '100%'
  210. height = 'auto'
  211. borderRadius = 'var(--radius-large)'
  212. aspectRatio = '2 / 3'
  213. objectFit = 'cover'
  214. background = 'var(--color-surface)'
  215. }
  216. @media {
  217. minWidth = '40rem'
  218. flex = 'none'
  219. width = '10rem'
  220. }
  221. }
  222. showMeta {
  223. display = 'contents'
  224. overflowWrap = 'anywhere'
  225. @media {
  226. minWidth = '40rem'
  227. display = 'block'
  228. flex = '1'
  229. 'min-width' = '0'
  230. }
  231. }
  232. showTitle {
  233. order = '-1'
  234. display = 'flex'
  235. flexWrap = 'wrap'
  236. alignItems = 'center'
  237. gap = '.4rem .6rem'
  238. h1 {
  239. flex = '0 1 auto'
  240. minWidth = '0'
  241. margin = '0'
  242. }
  243. '.pill' {
  244. flex = 'none'
  245. }
  246. @media {
  247. minWidth = '40rem'
  248. marginBottom = '1rem'
  249. }
  250. }
  251. 'button.follow' {
  252. display = 'block'
  253. width = '100%'
  254. marginTop = '.5rem'
  255. padding = '.4rem .8rem'
  256. fontSize = '.95rem'
  257. }
  258. showFacts {
  259. flexBasis = '100%'
  260. fontSize = '.95rem'
  261. color = 'var(--color-text-muted)'
  262. }
  263. showLinks {
  264. order = '-1'
  265. display = 'flex'
  266. flexWrap = 'wrap'
  267. gap = '.4rem'
  268. }
  269. movieWatch {
  270. order = '-1'
  271. display = 'flex'
  272. alignItems = 'center'
  273. gap = '.4rem'
  274. @media {
  275. minWidth = '40rem'
  276. margin = '-.4rem 0 .8rem'
  277. }
  278. }
  279. movieWatchLabel {
  280. fontSize = '.95rem'
  281. color = 'var(--color-text)'
  282. }
  283. showGenres {
  284. display = 'flex'
  285. flexWrap = 'wrap'
  286. gap = '.4rem'
  287. margin = '.5rem 0'
  288. }
  289. showSummary {
  290. display = 'block'
  291. margin = '.5rem 0'
  292. fontSize = '.95rem'
  293. color = 'var(--color-text)'
  294. @media {
  295. minWidth = '40rem'
  296. fontSize = '1rem'
  297. }
  298. }
  299. showCrew {
  300. display = 'block'
  301. margin = '.5rem 0'
  302. crewLabel {
  303. firstChild {
  304. marginTop = '0'
  305. }
  306. }
  307. }
  308. showCast {
  309. display = 'block'
  310. margin = '.5rem 0'
  311. }
  312. castHeading {
  313. display = 'block'
  314. fontSize = '.75rem'
  315. letterSpacing = '.04em'
  316. textTransform = 'uppercase'
  317. color = 'var(--color-text-muted)'
  318. }
  319. crewLabel {
  320. display = 'block'
  321. marginTop = '.35rem'
  322. fontSize = '.75rem'
  323. letterSpacing = '.04em'
  324. textTransform = 'uppercase'
  325. color = 'var(--color-text-muted)'
  326. }
  327. castLabel {
  328. display = 'block'
  329. margin = '.4rem 0 .1rem'
  330. fontSize = '.75rem'
  331. letterSpacing = '.04em'
  332. textTransform = 'uppercase'
  333. color = 'var(--color-text-muted)'
  334. }
  335. '.artist-link' {
  336. color = 'var(--color-type5)'
  337. }
  338. '.crew-link' {
  339. color = 'var(--color-type5)'
  340. }
  341. 'a.artist-link::after' {
  342. content = "attr(data-role) ', '"
  343. color = 'var(--color-text-muted)'
  344. }
  345. 'a.crew-link::after' {
  346. content = "', '"
  347. color = 'var(--color-text-muted)'
  348. }
  349. 'a.artist-link.end::after' {
  350. content = 'attr(data-role)'
  351. }
  352. 'show-cast.collapsed' {
  353. 'a.artist-link.cut::after' {
  354. content = 'attr(data-role)'
  355. }
  356. '.more' {
  357. display = 'none'
  358. }
  359. whenAll {
  360. display = 'none'
  361. }
  362. }
  363. 'a.crew-link.end::after' {
  364. content = 'none'
  365. }
  366. 'show-crew.collapsed' {
  367. 'a.crew-link.cut::after' {
  368. content = 'none'
  369. }
  370. '.more' {
  371. display = 'none'
  372. }
  373. whenAll {
  374. display = 'none'
  375. }
  376. }
  377. buttonShowall {
  378. display = 'block'
  379. margin = '.3rem 0 0'
  380. padding = '.15rem 0'
  381. fontSize = '.85rem'
  382. color = 'var(--color-accent)'
  383. background = 'transparent'
  384. hover {
  385. background = 'transparent'
  386. textDecoration = 'underline'
  387. }
  388. }
  389. 'show-cast.all' {
  390. whenCollapsed {
  391. display = 'none'
  392. }
  393. }
  394. 'show-crew.all' {
  395. whenCollapsed {
  396. display = 'none'
  397. }
  398. }
  399. showSeasons {
  400. display = 'block'
  401. }
  402. seasonRow {
  403. display = 'flex'
  404. alignItems = 'center'
  405. gap = '.6rem'
  406. padding = '.5rem 0'
  407. borderTop = '1px solid ' + 'var(--color-border)' // functional: the season foldable's line
  408. 'button.checkicon' {
  409. margin = '-.3125rem 0'
  410. }
  411. }
  412. buttonSeasonToggle {
  413. flex = '1'
  414. minWidth = '0'
  415. display = 'flex'
  416. alignItems = 'center'
  417. gap = '.6rem'
  418. justifyContent = 'flex-start'
  419. padding = '0'
  420. color = 'var(--color-text)'
  421. background = 'transparent'
  422. border = '0'
  423. fontWeight = '600'
  424. cursor = 'pointer'
  425. textAlign = 'left'
  426. margin = '-.3125rem 0'
  427. }
  428. seasonCount {
  429. fontWeight = '400'
  430. fontSize = '.85rem'
  431. color = 'var(--color-text-muted)'
  432. }
  433. seasonCaret {
  434. flex = 'none'
  435. alignSelf = 'center'
  436. display = 'grid'
  437. marginLeft = 'auto'
  438. color = 'var(--color-text-muted)'
  439. transition = 'transform .15s'
  440. svg {
  441. display = 'block'
  442. fill = 'none'
  443. stroke = 'currentColor'
  444. strokeWidth = '2'
  445. strokeLinecap = 'round'
  446. strokeLinejoin = 'round'
  447. }
  448. }
  449. 'season-row.expanded' {
  450. seasonCaret {
  451. transform = 'rotate(180deg)'
  452. }
  453. }
  454. episodeRow {
  455. display = 'flex'
  456. alignItems = 'center'
  457. gap = '.6rem'
  458. minHeight = '2.125rem'
  459. padding = '0'
  460. 'button.checkicon' {
  461. margin = '-.3125rem 0'
  462. }
  463. }
  464. episodeNumber {
  465. flex = 'none'
  466. width = '1.6rem'
  467. color = 'var(--color-text-muted)'
  468. fontVariantNumeric = 'tabular-nums'
  469. }
  470. episodeTitle {
  471. flex = '1'
  472. minWidth = '0'
  473. overflowWrap = 'anywhere'
  474. }
  475. episodeDate {
  476. flex = 'none'
  477. fontSize = '.85rem'
  478. color = 'var(--color-text-muted)'
  479. fontVariantNumeric = 'tabular-nums'
  480. }
  481. skeletonRow {
  482. display = 'flex'
  483. alignItems = 'center'
  484. gap = '.6rem'
  485. minHeight = '2.125rem'
  486. padding = '0'
  487. }
  488. skeletonCheck {
  489. display = 'block'
  490. borderRadius = 'var(--radius-small)'
  491. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  492. backgroundSize = '400% 100%'
  493. animation = 'tracker-shimmer 1.4s linear infinite'
  494. flex = 'none'
  495. width = '1.375rem'
  496. height = '1.375rem'
  497. borderRadius = '50%'
  498. margin = '0 .6875rem'
  499. }
  500. skeletonNumber {
  501. display = 'block'
  502. borderRadius = 'var(--radius-small)'
  503. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  504. backgroundSize = '400% 100%'
  505. animation = 'tracker-shimmer 1.4s linear infinite'
  506. flex = 'none'
  507. width = '1.6rem'
  508. height = '1rem'
  509. }
  510. skeletonTitle {
  511. display = 'block'
  512. borderRadius = 'var(--radius-small)'
  513. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  514. backgroundSize = '400% 100%'
  515. animation = 'tracker-shimmer 1.4s linear infinite'
  516. flex = '1'
  517. maxWidth = '60%'
  518. height = '1rem'
  519. }
  520. 'skeleton-row:nth-of-type(even)' {
  521. skeletonTitle {
  522. maxWidth = '42%'
  523. }
  524. }
  525. skeletonPoster {
  526. display = 'block'
  527. borderRadius = 'var(--radius-large)'
  528. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  529. backgroundSize = '400% 100%'
  530. animation = 'tracker-shimmer 1.4s linear infinite'
  531. width = '100%'
  532. aspectRatio = '2 / 3'
  533. }
  534. skeletonCast {
  535. display = 'block'
  536. borderRadius = 'var(--radius-large)'
  537. background = 'linear-gradient(90deg, ' + 'var(--color-surface)' + ' 35%, ' + 'var(--color-border)' + ' 50%, ' + 'var(--color-surface)' + ' 65%)'
  538. backgroundSize = '400% 100%'
  539. animation = 'tracker-shimmer 1.4s linear infinite'
  540. width = '70%'
  541. height = '1rem'
  542. margin = '.5rem 0'
  543. }
  544. showLoading {
  545. display = 'block'
  546. marginTop = '1rem'
  547. }
  548. showProbe {
  549. position = 'fixed'
  550. left = '0'
  551. top = '0'
  552. width = '1px'
  553. height = '1px'
  554. opacity = '0'
  555. pointerEvents = 'none'
  556. animation = 'tracker-person-tick .1s linear infinite'
  557. }
  558. '@keyframes tracker-shimmer' {
  559. 'from' {
  560. backgroundPosition = '100% 0'
  561. }
  562. to {
  563. backgroundPosition = '0% 0'
  564. }
  565. }
  566. }
  567. View {
  568. showPage {
  569. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  570. if (notFound) {
  571. article { class = "main"
  572. h1 { "Not found" }
  573. p { "This show doesn't exist." }
  574. }
  575. }
  576. if (found) {
  577. showHeader {
  578. showPoster {
  579. if (hasPoster) { img { src = posterUrl alt = title } }
  580. if (noPoster) { img { class = "no-poster" src = "/posters/none" alt = "no poster" } }
  581. if (posterLoading) { skeletonPoster { "aria-hidden" = "true" } }
  582. // tracker#34: Follow directly under the poster, as wide as the poster (creator: "the follow button should go below
  583. // the picture … and expand to the size o the poster")
  584. button { id = "follow" type = "button" class = followClass followText on click(e) { emit toggleFollow(e) } }
  585. if (hasShortId) { shortIdLabel { id = "shortid" title = "Short id" shortId } }
  586. }
  587. showMeta {
  588. showTitle {
  589. h1 { class = "typed" typeWord { class = typeClass typeText } typeSep { "|" } typeName { title } }
  590. if (hasStatus) { span { class = statusClass statusText } }
  591. if (hasFacts) { showFacts { id = "moviefacts" factsText } }
  592. }
  593. if (isMovie) {
  594. movieWatch {
  595. button { id = "moviewatch" type = "button" class = movieWatchClass "aria-label" = "mark movie watched"
  596. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  597. circle { cx = "12" cy = "12" r = "10" }
  598. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  599. }
  600. on click(e) { emit toggleMovie(e) }
  601. }
  602. movieWatchLabel { movieWatchText }
  603. }
  604. }
  605. if (hasLinks) {
  606. showLinks {
  607. 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 } }
  608. }
  609. }
  610. // mission 025: the franchise widget right under the title/poster block — on a phone (showMeta dissolves, see styles.hl)
  611. // after the poster and before the genres, plot and cast; from 40rem in the right column under the title
  612. FranchiseWidget { widgets = franchiseWidgets }
  613. if (hasGenres) {
  614. showGenres {
  615. for (g of genreRows) { a { class = "pill type-4 genre-pill" href = g.href g.name } }
  616. }
  617. }
  618. showSummary { summary }
  619. if (hasCrew) {
  620. showCrew { class = crewClass
  621. for (r of crewRows) {
  622. if (r.isLabel) { crewLabel { r.text } }
  623. if (r.isPerson) { a { class = r.itemClass href = r.href r.name } }
  624. }
  625. if (crewMore) {
  626. button { id = "crewtoggle" type = "button" Style.buttonShowall class = "quiet"
  627. whenCollapsed { crewAllText }
  628. whenAll { "Show less" }
  629. on click(e) { emit toggleCrewAll(e) }
  630. }
  631. }
  632. }
  633. }
  634. if (hasCast) {
  635. showCast { class = castClass
  636. castHeading { "Cast" }
  637. for (c of castRows) {
  638. if (c.isLabel) { castLabel { class = c.itemClass c.text } }
  639. if (c.isPerson) { a { class = c.itemClass href = c.href "data-role" = c.roleText c.name } }
  640. }
  641. if (castMore) {
  642. button { id = "casttoggle" type = "button" Style.buttonShowall class = "quiet"
  643. whenCollapsed { castAllText }
  644. whenAll { "Show less" }
  645. on click(e) { emit toggleCastAll(e) }
  646. }
  647. }
  648. }
  649. }
  650. if (completing) { skeletonCast { "aria-hidden" = "true" } }
  651. }
  652. }
  653. if (completing) {
  654. showLoading { id = "showloading" "aria-busy" = "true"
  655. if (isSeries) {
  656. for (k of skeletonSeasons) {
  657. skeletonRow { "aria-hidden" = "true"
  658. skeletonCheck { }
  659. skeletonTitle { }
  660. }
  661. }
  662. }
  663. showProbe { "aria-hidden" = "true" on animationiteration(e) { emit completeTick(e) } }
  664. }
  665. }
  666. if (hasRows) {
  667. showSeasons {
  668. for (row of rows) {
  669. if (row.isSeason) {
  670. seasonRow { class = row.rowClass
  671. button { type = "button" class = row.watchClass value = row.id "aria-label" = "mark season watched"
  672. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  673. circle { cx = "12" cy = "12" r = "10" }
  674. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  675. }
  676. on click(e) { emit toggleSeason(row.id) }
  677. }
  678. button { type = "button" Style.buttonSeasonToggle value = row.id
  679. seasonLabel { row.label }
  680. seasonCount { row.episodeCountText }
  681. seasonCaret { "aria-hidden" = "true"
  682. svg { viewBox = "0 0 24 24" width = "20" height = "20"
  683. path { d = "M6 9 L12 15 L18 9" }
  684. }
  685. }
  686. on click(e) { emit toggleCollapse(row.id) }
  687. }
  688. }
  689. }
  690. if (row.isEpisode) {
  691. episodeRow {
  692. button { type = "button" class = row.watchClass value = row.id "aria-label" = "mark episode watched"
  693. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  694. circle { cx = "12" cy = "12" r = "10" }
  695. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  696. }
  697. on click(e) { emit toggleEpisode(row.id) }
  698. }
  699. episodeNumber { row.episodeNumber }
  700. episodeTitle { row.title }
  701. episodeDate { row.airDate }
  702. }
  703. }
  704. if (row.isSkeleton) {
  705. skeletonRow { "aria-hidden" = "true"
  706. skeletonCheck { }
  707. skeletonNumber { }
  708. skeletonTitle { }
  709. }
  710. }
  711. }
  712. }
  713. }
  714. Modal { id = "signin" title = "Sign in"
  715. p { signInText }
  716. footer {
  717. button { type = "button" value = "close" "Close" }
  718. a { id = "signin-link" class = "button primary" href = signInHref "Sign in with ident" }
  719. }
  720. }
  721. }
  722. }
  723. }
  724. // Every rebuild of `rows` happens SERVER-SIDE, never by calling `buildRows` from a client handler:
  725. // a member function whose body reaches an hl:mpackdb-backed import (seasonsOfShow, episodesOfSeason,
  726. // watchesOfUser, …) compiles to nothing on the client (no case ever assigns it — a genuine Hybriel
  727. // gap, filed under `issues`) even though the client bundle still calls it, so `this.buildRows(...)`
  728. // throws "not a function" in the browser. The client here only ever ASSIGNS the `rows` the server
  729. // already built (`rows = r.rows`) — never calls a tainted local helper itself. `slug` goes along so
  730. // the face can refetch the show without depending on implicit access to a sibling member.
  731. //
  732. // tracker#17: opening shows the skeleton rows BEFORE the request; the answer replaces them unless the season was closed
  733. // meanwhile (then nothing). An error closes the season again. Closing never asks the server.
  734. on toggleCollapse(seasonId) {
  735. collapsedChanged = true
  736. m = collapsed
  737. if (collapsed[seasonId] != true) {
  738. m[seasonId] = true
  739. collapsed = m
  740. rows = closedRows(&rows, &seasonId)
  741. return null
  742. }
  743. m[seasonId] = false
  744. collapsed = m
  745. rows = openingRows(&rows, seasonId)
  746. if (adultShow) {
  747. a = emit server showRows(slug, collapsed)
  748. if (collapsed[seasonId] == true) { return null }
  749. if (a == null || a.error != null) { m[seasonId] = true collapsed = m rows = closedRows(&rows, &seasonId) return null }
  750. rows = a.rows
  751. return null
  752. }
  753. r = emit server showSeasonEpisodes('' + seasonId)
  754. if (collapsed[seasonId] == true) { return null }
  755. if (r == null || r.error != null) { m[seasonId] = true collapsed = m rows = closedRows(&rows, &seasonId) return null }
  756. rows = filledRows(&rows, seasonId, &r.episodes, watchedEpisodes)
  757. }
  758. // tracker#26: the probe's tick — `showComplete` step by step until `done` (once per page: `completeBusy`; other requests are
  759. // served between two calls); the last answer replaces the skeletons. A lost answer (null) lets the next tick go on where the
  760. // server is; an error (TMDB down, adult) ends the loading and keeps what the page has.
  761. on completeTick(e) {
  762. if (completeBusy || !completing) { return null }
  763. completeBusy = true
  764. s = slug
  765. let r = emit server showComplete(s)
  766. while (r != null && r.error == null && r.done != true && slug == s) { r = emit server showComplete(s) }
  767. completeBusy = false
  768. if (r == null || slug != s) { return null }
  769. if (r.error != null) { completing = false return null }
  770. title = r.title
  771. summary = r.summary
  772. poster = r.poster
  773. genreRows = r.genreRows
  774. castRows = r.castRows
  775. castCount = r.castCount
  776. castMore = r.castMore
  777. castAllText = 'Show all (' + r.castCount + ')'
  778. crewRows = r.crewRows
  779. crewCount = r.crewCount
  780. crewMore = r.crewMore
  781. crewAllText = 'Show all crew (' + r.crewCount + ')'
  782. linkRows = r.linkRows
  783. collapsed = r.collapsed
  784. collapsedChanged = true
  785. rows = r.rows
  786. completing = false
  787. }
  788. // tracker#28: the cast / crew "Show all" toggles — client-only, no request (CSS shows the hidden names)
  789. on toggleCastAll(e) {
  790. castClass = castClass == 'all' ? 'collapsed' : 'all'
  791. }
  792. on toggleCrewAll(e) {
  793. crewClass = crewClass == 'all' ? 'collapsed' : 'all'
  794. }
  795. // signed out: the modal, nothing is sent
  796. // mission 062: the new `rows` come with the SAME ack as the session sync (SESSION SYNC above: `rows` derives from the session) —
  797. // 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
  798. // (`collapsedChanged`, or a completed title); else they came twice (a second buildRows + 14 kB on The Simpsons: ~40 ms per click)
  799. on toggleEpisode(episodeId) {
  800. if (!signedIn) { document.getElementById('signin').showModal() return null }
  801. r = emit server showToggleEpisode(slug, '' + episodeId, collapsed, collapsedChanged)
  802. if (r == null || r.error != null) { return null }
  803. if (r.rows != null) { rows = r.rows }
  804. }
  805. on toggleSeason(seasonId) {
  806. if (!signedIn) { document.getElementById('signin').showModal() return null }
  807. r = emit server showToggleSeason(slug, '' + seasonId, collapsed, collapsedChanged)
  808. if (r == null || r.error != null) { return null }
  809. if (r.rows != null) { rows = r.rows }
  810. }
  811. // #24: the movie's own check — signed out the modal, nothing sent
  812. on toggleMovie(e) {
  813. if (!signedIn) { document.getElementById('signin').showModal() return null }
  814. r = emit server showToggleMovie(slug)
  815. if (r == null || r.error != null) { return null }
  816. movieWatched = r.watched
  817. movieWatchClass = r.watched ? 'checkicon solid' : 'checkicon regular'
  818. movieWatchText = r.watched ? 'Watched' : 'Not watched'
  819. }
  820. on toggleFollow(e) {
  821. if (!signedIn) { document.getElementById('signin').showModal() return null }
  822. r = emit server showToggleFollow(slug)
  823. if (r == null || r.error != null) { return null }
  824. following = r.following
  825. followClass = r.following ? 'follow primary' : 'follow inverted'
  826. followText = r.following ? 'Following' : 'Follow'
  827. }
  828. // ---- the faces (the trailing `session` is always the server's: hybriel#16) ----
  829. // tracker#26: complete an incomplete title and answer the page's parts — public data, NO session (no page re-mount)
  830. on server showComplete(slug) {
  831. return completedPageOf(textArg(&slug))
  832. }
  833. // every row for these open/closed seasons — only an ADULT show's page still uses it (its followers; tracker#17)
  834. on server showRows(slug, collapsed, session) {
  835. uid = userIdOfSession(&session)
  836. return showRowsOf(slug, collapsed, uid)
  837. }
  838. // tracker#17: one season's episodes, in order — public data, so NO `session` (no page re-mount, no sync: the fast path).
  839. // Refuses a season of an adult title (those pages use showRows above).
  840. on server showSeasonEpisodes(seasonId) {
  841. return showSeasonEpisodesOf(seasonId)
  842. }
  843. on server showToggleEpisode(slug, episodeId, collapsed, withRows, session) {
  844. uid = userIdOfSession(&session)
  845. return showToggleEpisodeOf(slug, episodeId, collapsed, withRows, uid)
  846. }
  847. on server showToggleSeason(slug, seasonId, collapsed, withRows, session) {
  848. uid = userIdOfSession(&session)
  849. return showToggleSeasonOf(slug, seasonId, collapsed, withRows, uid)
  850. }
  851. // #24: a movie's watched check (only a movie: a series is watched by its episodes)
  852. on server showToggleMovie(slug, session) {
  853. uid = userIdOfSession(&session)
  854. return showToggleMovieOf(slug, uid)
  855. }
  856. on server showToggleFollow(slug, session) {
  857. uid = userIdOfSession(&session)
  858. return showToggleFollowOf(slug, uid)
  859. }

Branches

Latest commits

  • ce6d7d32Merge rv48: Hybriel day48mre
  • 3da2ea86RV48: report day48 cold starts, gates and cleanupmre
  • 8d9ecdfeRV48: re-vendor Hybriel set day48 (source b6a8f429, bin 660a9524)mre
  • 4a802ae7status: RV48 runningmre
  • 0a5412b6RV48 brief, day48 outmre
  • 56665efelog: CB69 mergedmre
  • 05448a98Merge cb69-imports: appTitle in a dependency-free topicmre
  • e55b379dKeep shared app title independent of the route import graphmre
  • 9a99659blog: hybriel#334, batch waits for day48mre
  • 85fa6c9blog: CB68 result, CB69 startedmre
  • 2f07c1b7log: DP68 boot gate failed, CB68mre
  • 9652782dlog: HM59 merged, DP68 startedmre
  • 29867a75Merge hm59-logic: tracker#59 page logic moved to libmre
  • f7bfe90bMove remaining page builders into their topicsmre
  • 7c3991f9log: day46 from Antonmre
  • ec54fc35Move show page logic into the shows topicmre
  • c1a8d074log: correct timesmre
  • 5827eba9log: HM57 merged, HM59 startedmre
  • d1a91be9Merge hm57-let: tracker#57 let only for reassigned namesmre
  • a404ed75Report HM57 audit, gates and integration notesmre