gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commita8923d93a8923d93log: RV44 startedmrea8923d93/components/person.hl

6.6 KB

  1. // components/person.hl — `/person/<slug>` (tracker.worldapi.org#16): a person's page — name, photo, born/died, bio, then
  2. // the filmography (poster, title, year, role; series and movies, newest first, each → its page: /series/, /shows/ or /movies/<slug>).
  3. // The show page's cast and the search's people link here. tracker.worldapi.org#20: the heading is "Person | <name>" (the type word
  4. // in the person colour, styles.hl `type-*`), each row's kind word in its type's colour.
  5. //
  6. // FIRST VISIT of a person we don't have complete yet (people.hl `needsFill`): the page shows what we have plus "Loading
  7. // filmography…" and fills in WITHOUT a reload — the face `personFill` does ONE step per call (1st: TMDB person + credits,
  8. // then 40 titles per call, the last marks the person complete) and the handler calls it until it says `done`; between two
  9. // calls hl:web serves every other request. hl:web gives a page no "mounted" hook, so the first call comes from a tick like
  10. // the shell's offline probe (components/main.hl): the invisible `personProbe` runs an endless short CSS animation
  11. // (styles.hl) and its `animationiteration` starts the fill (once — `busy`). A failed fill shows why; the next visit tries again.
  12. //
  13. // mission 060 (tracker.worldapi.org#27): the person's short id (shortids.hl) under the photo (no photo: under the facts).
  14. //
  15. // HYBRIEL TRAPS: no session here at all (the fill needs no sign-in — one TMDB request per person, ever), so hybriel#121/#122
  16. // can't bite; every list is replaced whole. Helpers are LOCAL statics (an imported mpackdb helper straight in a member's
  17. // initializer came back wrong after a client-side navigation — components/show.hl `followingOf`).
  18. parent './main.hl'
  19. import { appTitle } from '../project.hl'
  20. import { personBySlug, personInfoOf, filmographyOf, needsFill, personFillStep } from '../lib/people.hl'
  21. import { warmReady, warmText } from '../lib/warm.hl'
  22. import { textArg } from '../lib/util.hl'
  23. // everything the page shows for one slug
  24. static pageOf = (&slug) => {
  25. let p = personBySlug(&slug)
  26. if (p == null) { return { found = false name = '' photoUrl = '' born = '' died = '' bio = '' rows = [] loading = false shortId = '' } }
  27. info = personInfoOf(&p)
  28. return { found = true name = info.name photoUrl = info.photoUrl born = info.born died = info.died bio = info.bio
  29. rows = filmographyOf(&p) loading = needsFill(&p) shortId = p.shortId != null ? '' + p.shortId : '' }
  30. }
  31. // one fill step for the person of this slug; the last answers the whole page again
  32. static fillOf = (&slug) => {
  33. let p = personBySlug(&slug)
  34. if (p == null) { return { error = 'no such person' } }
  35. r = personFillStep(&p.id)
  36. if (r.error != null) { return { error = r.error } }
  37. if (r.done != true) { return { done = false pos = r.pos total = r.total } }
  38. out = pageOf(&slug)
  39. out.done = true
  40. out.added = r.added
  41. return out
  42. }
  43. // ---- reactive members -----------------------------------------------------------------------
  44. slug = null
  45. start = pageOf(&slug)
  46. found = start.found
  47. notFound = !start.found
  48. name = start.name
  49. photoUrl = start.photoUrl
  50. hasPhoto = photoUrl != ''
  51. // mission 060 (tracker.worldapi.org#27): the short id under the photo — no photo: under the name and facts
  52. shortId = start.shortId
  53. hasShortId = shortId != ''
  54. shortIdInMeta = hasShortId && !hasPhoto
  55. born = start.born
  56. hasBorn = born != ''
  57. died = start.died
  58. hasDied = died != ''
  59. bio = start.bio
  60. hasBio = bio != ''
  61. bioClass = 'short'
  62. rows = start.rows
  63. hasRows = rows.length > 0
  64. loading = start.loading
  65. loadText = 'Loading filmography…'
  66. busy = false
  67. fillError = ''
  68. hasFillError = fillError != ''
  69. noRows = found && !loading && rows.length == 0 && fillError == ''
  70. __title = found ? name + ' — ' + appTitle : appTitle
  71. // mission T17 (boot time): the server listens while bootscan.hl still builds the lists / slug maps / search index (lib/warm.hl); until the 'all'
  72. // stage is there this page says so instead of showing half a map
  73. warming = !warmReady('all')
  74. warmNote = warming ? warmText() : ''
  75. View {
  76. personPage { "data-loading" = loading
  77. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  78. if (notFound) {
  79. article { class = "main"
  80. h1 { "Not found" }
  81. p { "This person doesn't exist." }
  82. }
  83. }
  84. if (found) {
  85. personHeader {
  86. if (hasPhoto) {
  87. personPhoto {
  88. img { src = photoUrl alt = name }
  89. if (hasShortId) { shortIdLabel { id = "shortid" title = "Short id" shortId } }
  90. }
  91. }
  92. personMeta {
  93. h1 { class = "typed" typeWord { class = "type-word type-person" "Person" } typeSep { "|" } typeName { name } }
  94. if (hasBorn) { personFact { class = "born" born } }
  95. if (hasDied) { personFact { class = "died" died } }
  96. if (shortIdInMeta) { shortIdLabel { id = "shortid" title = "Short id" shortId } }
  97. }
  98. }
  99. // a SHORT bio: four lines (styles.hl), a click shows all of it
  100. if (hasBio) { personBio { class = bioClass title = "Show all" bio on click(e) { emit toggleBio(e) } } }
  101. h2 { class = "film-heading" "Filmography" }
  102. if (loading) {
  103. personLoading { id = "personloading" loadText
  104. personProbe { "aria-hidden" = "true" on animationiteration(e) { emit fillTick(e) } }
  105. }
  106. }
  107. if (hasFillError) { p { id = "fillerror" class = "message" fillError } }
  108. if (noRows) { p { id = "nofilms" class = "muted" "No shows or movies known." } }
  109. if (hasRows) {
  110. filmRows {
  111. for (row of rows) {
  112. a { class = "film-row" href = row.href
  113. img { class = "film-poster" src = row.posterUrl alt = "" loading = "lazy" }
  114. filmText {
  115. filmTitle { row.title }
  116. filmMeta {
  117. filmYear { row.year }
  118. filmType { class = row.typeClass row.typeLabel }
  119. }
  120. filmRole { row.role }
  121. }
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. // the probe's tick: the fill, step by step, until done (once per page — `busy`); a lost answer (null) just waits for the
  130. // next tick and goes on where the server is
  131. on fillTick(e) {
  132. if (busy || !loading) { return null }
  133. busy = true
  134. s = slug
  135. let r = emit server personFill(s)
  136. while (r != null && r.error == null && r.done != true && slug == s) {
  137. loadText = 'Loading filmography… ' + r.pos + ' of ' + r.total + ' titles'
  138. r = emit server personFill(s)
  139. }
  140. busy = false
  141. if (r == null || slug != s) { return null }
  142. if (r.error != null) {
  143. loading = false
  144. fillError = 'Could not load the filmography: ' + r.error
  145. return null
  146. }
  147. photoUrl = r.photoUrl
  148. born = r.born
  149. died = r.died
  150. bio = r.bio
  151. rows = r.rows
  152. loading = false
  153. }
  154. on toggleBio(e) {
  155. bioClass = bioClass == 'short' ? 'full' : 'short'
  156. }
  157. // ---- the face (a unique name: hl:web dispatches faces by name across all files) ----
  158. on server personFill(slug) {
  159. return fillOf(textArg(&slug))
  160. }

Branches

Latest commits

  • a8923d93log: RV44 startedmre
  • cf28cf77mission RV44mre
  • 585782dfLog: tracker#60 Chrome look, STATUS rewrittenmre
  • 147d0172conductor: caramboleyo is the user, not owner/creatorApollo
  • 21dd0cfblog: #60 live measurement, reviewmre
  • 7793cf94HM62b report: person indexes with fixed mpackdbmre
  • 09d66ed5status: #60 livemre
  • 4171672flog: #60 livemre
  • f52862a2log: HM62b startedmre
  • 88fde2c4mission HM62bmre
  • a722e526log: #62 blocked by hybriel#317mre
  • 074a7418log: #62 assigned to Tracker; pending rulemre
  • 06f6ae8fHM62 report: mpackdb index gapmre
  • 86fe5430log: HM62 startedmre
  • 755307bbmission HM62mre
  • 4b2f2995HM61 report: tracker#61 packed people ordermre
  • 48faa84flog: #60 deploy startedmre
  • 90734c6cMerge branch 'hm60-shortids'mre
  • e0db0d1bHM60 report: tracker#60 packed short-ID ownersmre
  • 3c79b576Pack short-ID ownership into byte buffersmre