gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit4399bc2f4399bc2fReference remaining component-owned root Style rulesmre4399bc2f/components/person.hl

8.5 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. // Component styles use the shared theme variables.
  76. Style {
  77. personMeta {
  78. display = 'block'
  79. minWidth = '0'
  80. overflowWrap = 'anywhere'
  81. shortIdLabel {
  82. textAlign = 'left'
  83. }
  84. }
  85. personPage {
  86. display = 'block'
  87. }
  88. personHeader {
  89. display = 'flex'
  90. alignItems = 'flex-start'
  91. gap = '.8rem'
  92. marginBottom = '1rem'
  93. @media {
  94. minWidth = '40rem'
  95. gap = '1rem'
  96. }
  97. }
  98. personPhoto {
  99. flex = 'none'
  100. display = 'block'
  101. width = '6rem'
  102. img {
  103. display = 'block'
  104. width = '100%'
  105. height = 'auto'
  106. aspectRatio = '2 / 3'
  107. objectFit = 'cover'
  108. borderRadius = 'var(--radius-large)'
  109. background = 'var(--color-surface)'
  110. }
  111. @media {
  112. minWidth = '40rem'
  113. width = '10rem'
  114. }
  115. }
  116. personFact {
  117. display = 'block'
  118. fontSize = '.95rem'
  119. color = 'var(--color-text-muted)'
  120. }
  121. personBio {
  122. display = 'block'
  123. margin = '0 0 1rem'
  124. fontSize = '.95rem'
  125. whiteSpace = 'pre-line'
  126. cursor = 'pointer'
  127. }
  128. 'person-bio.short' {
  129. display = '-webkit-box'
  130. overflow = 'hidden'
  131. '-webkit-line-clamp' = '4'
  132. '-webkit-box-orient' = 'vertical'
  133. }
  134. personLoading {
  135. display = 'block'
  136. padding = '.6rem 0'
  137. color = 'var(--color-text-muted)'
  138. animation = 'tracker-person-pulse 1.2s ease-in-out infinite alternate'
  139. }
  140. personProbe {
  141. position = 'fixed'
  142. left = '0'
  143. top = '0'
  144. width = '1px'
  145. height = '1px'
  146. opacity = '0'
  147. pointerEvents = 'none'
  148. animation = 'tracker-person-tick .1s linear infinite'
  149. }
  150. '@keyframes tracker-person-pulse' {
  151. 'from' {
  152. opacity = '1'
  153. }
  154. to {
  155. opacity = '.45'
  156. }
  157. }
  158. filmRows {
  159. display = 'block'
  160. }
  161. aFilmRow {
  162. display = 'flex'
  163. alignItems = 'center'
  164. gap = '.8rem'
  165. padding = '.45rem 0'
  166. color = 'var(--color-text)'
  167. hover {
  168. textDecoration = 'none'
  169. filmTitle {
  170. color = 'var(--color-accent)'
  171. }
  172. }
  173. }
  174. filmRole {
  175. fontSize = '.85rem'
  176. color = 'var(--color-type5)'
  177. overflowWrap = 'anywhere'
  178. empty {
  179. display = 'none'
  180. }
  181. }
  182. filmYear {
  183. empty {
  184. display = 'none'
  185. }
  186. }
  187. }
  188. View {
  189. personPage { "data-loading" = loading
  190. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  191. if (notFound) {
  192. article { class = "main"
  193. h1 { "Not found" }
  194. p { "This person doesn't exist." }
  195. }
  196. }
  197. if (found) {
  198. personHeader {
  199. if (hasPhoto) {
  200. personPhoto {
  201. img { src = photoUrl alt = name }
  202. if (hasShortId) { shortIdLabel { id = "shortid" title = "Short id" shortId } }
  203. }
  204. }
  205. personMeta {
  206. h1 { class = "typed" typeWord { class = "type-word type-person" "Person" } typeSep { "|" } typeName { name } }
  207. if (hasBorn) { personFact { class = "born" born } }
  208. if (hasDied) { personFact { class = "died" died } }
  209. if (shortIdInMeta) { shortIdLabel { id = "shortid" title = "Short id" shortId } }
  210. }
  211. }
  212. // a SHORT bio: four lines (styles.hl), a click shows all of it
  213. if (hasBio) { personBio { class = bioClass title = "Show all" bio on click(e) { emit toggleBio(e) } } }
  214. h2 { class = "film-heading" "Filmography" }
  215. if (loading) {
  216. personLoading { id = "personloading" loadText
  217. personProbe { "aria-hidden" = "true" on animationiteration(e) { emit fillTick(e) } }
  218. }
  219. }
  220. if (hasFillError) { p { id = "fillerror" class = "message" fillError } }
  221. if (noRows) { p { id = "nofilms" class = "muted" "No shows or movies known." } }
  222. if (hasRows) {
  223. filmRows {
  224. for (row of rows) {
  225. a { Style.aFilmRow href = row.href
  226. img { class = "film-poster" src = row.posterUrl alt = "" loading = "lazy" }
  227. filmText {
  228. filmTitle { row.title }
  229. filmMeta {
  230. filmYear { row.year }
  231. filmType { class = row.typeClass row.typeLabel }
  232. }
  233. filmRole { row.role }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. }
  242. // the probe's tick: the fill, step by step, until done (once per page — `busy`); a lost answer (null) just waits for the
  243. // next tick and goes on where the server is
  244. on fillTick(e) {
  245. if (busy || !loading) { return null }
  246. busy = true
  247. s = slug
  248. let r = emit server personFill(s)
  249. while (r != null && r.error == null && r.done != true && slug == s) {
  250. loadText = 'Loading filmography… ' + r.pos + ' of ' + r.total + ' titles'
  251. r = emit server personFill(s)
  252. }
  253. busy = false
  254. if (r == null || slug != s) { return null }
  255. if (r.error != null) {
  256. loading = false
  257. fillError = 'Could not load the filmography: ' + r.error
  258. return null
  259. }
  260. photoUrl = r.photoUrl
  261. born = r.born
  262. died = r.died
  263. bio = r.bio
  264. rows = r.rows
  265. loading = false
  266. }
  267. on toggleBio(e) {
  268. bioClass = bioClass == 'short' ? 'full' : 'short'
  269. }
  270. // ---- the face (a unique name: hl:web dispatches faces by name across all files) ----
  271. on server personFill(slug) {
  272. return fillOf(textArg(&slug))
  273. }

Branches

Latest commits

  • 4399bc2fReference remaining component-owned root Style rulesmre
  • aed12917Reference owned Style rules in genres and searchmre
  • 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