gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitc1c4178cc1c4178cMerge branch 'rv39'mrec1c4178c/components/franchise.hl

5.1 KB

  1. // components/franchise.hl — `/franchises/:slug` (a franchise's index: its timelines, each a list of its titles) AND
  2. // `/timelines/:tslug` (one timeline, its franchise above it) — tracker.worldapi.org#19, mission 066. Each timeline has its own
  3. // sort toggle: "Timeline" (the in-world order, as edited) | "Release" (a movie by its release, a series by the release date of
  4. // its LAST episode — franchises.hl releaseKeyOf). A row: small poster, title (year), Movie/Series and the date the release
  5. // sort uses.
  6. //
  7. // ONE FLAT LIST of rows (a `head` row per timeline, then its `item` rows), not a nested for over timelines > titles: the same
  8. // proven shape as the show page's seasons (hybriel#86). Both orders of every timeline come with the page (`blocks`); a toggle
  9. // only rebuilds `rows` in the browser (`flatRows` is pure) — no request.
  10. parent './main.hl'
  11. import { appTitle } from '../project.hl'
  12. import { franchisePage, timelinePage, isEditorSession } from '../lib/franchises.hl'
  13. import { pillClassOfWord } from '../lib/shows.hl'
  14. // static + LOCAL: an mpackdb-backed helper must be `static` (hybriel#115/#116, mission 047)
  15. static pageOf = (slug, &tslug) => {
  16. let p = tslug != null ? timelinePage(tslug) : franchisePage(slug)
  17. return p != null ? p : { kind = 'none' name = '' slug = '' summary = '' franchiseName = '' franchiseHref = '' blocks = [] editHref = '' }
  18. }
  19. static editorOf = (&session) => { return isEditorSession(&session) }
  20. // pure (runs in the browser on a toggle): the rows of every timeline in its chosen order. `named`: a head shows the timeline's
  21. // name (the franchise index); a timeline's own page has it in its h1 already (mission 025: the name was there twice)
  22. static flatRows = (&blocks, &modes, &named) => {
  23. out = []
  24. for (b of blocks) {
  25. let byRelease = modes[b.id] == 'release'
  26. out.push({ kind = 'head' isHead = true isItem = false key = b.id id = b.id name = b.name hasName = named href = b.href countText = b.countText
  27. timelineClass = byRelease ? 'sortbtn' : 'sortbtn on' releaseClass = byRelease ? 'sortbtn on' : 'sortbtn' })
  28. let list = byRelease ? b.byRelease : b.items
  29. for (it of list) {
  30. out.push({ kind = 'item' isHead = false isItem = true key = b.id + ':' + it.id id = it.id timeline = b.id pos = it.pos title = it.title href = it.href
  31. posterUrl = it.posterUrl typeLabel = it.kind typeClass = pillClassOfWord(&it.kind) dateLabel = it.dateLabel })
  32. }
  33. }
  34. return out
  35. }
  36. slug = null
  37. tslug = null
  38. session = null
  39. canEdit = editorOf(&session)
  40. data = pageOf(&slug, &tslug)
  41. found = data.kind != 'none'
  42. notFound = data.kind == 'none'
  43. isTimeline = data.kind == 'timeline'
  44. name = data.name
  45. summary = data.summary
  46. hasSummary = summary != ''
  47. hasFranchise = data.franchiseName != ''
  48. franchiseName = data.franchiseName
  49. franchiseHref = data.franchiseHref
  50. editHref = data.editHref
  51. showEdit = canEdit && isTimeline
  52. // tracker#20 (merge, mission 070): "Franchise | Star Trek", "Timeline | …" — the type word in its colour (styles.hl type-*)
  53. typeText = isTimeline ? 'Timeline' : 'Franchise'
  54. typeClass = isTimeline ? 'type-word type-timeline' : 'type-word type-franchise'
  55. blocks = data.blocks
  56. hasBlocks = blocks.length > 0
  57. noBlocks = found && blocks.length == 0
  58. modes = {}
  59. namedHeads = !isTimeline
  60. rows = flatRows(&blocks, &modes, &namedHeads)
  61. __title = found ? name + ' — ' + appTitle : appTitle
  62. View {
  63. franchisePage { "data-kind" = data.kind
  64. if (notFound) {
  65. h1 { "Not found" }
  66. p { "This franchise or timeline doesn't exist." }
  67. }
  68. if (found) {
  69. if (hasFranchise) { a { id = "franchise-up" class = "franchise-up" href = franchiseHref franchiseName } }
  70. franchisesHead {
  71. h1 { class = "typed" typeWord { class = typeClass typeText } typeSep { "|" } typeName { name } }
  72. if (showEdit) { a { id = "timeline-edit" class = "button" href = editHref "Edit" } }
  73. }
  74. if (hasSummary) { p { class = "franchise-summary" summary } }
  75. if (noBlocks) { p { class = "muted" "No timelines yet." } }
  76. if (hasBlocks) {
  77. timelineBlocks {
  78. for (row of rows) {
  79. if (row.isHead) {
  80. timelineHead { "data-timeline" = row.id
  81. timelineTitle {
  82. if (row.hasName) { a { class = "timeline-name" href = row.href row.name } }
  83. timelineCount { row.countText }
  84. }
  85. sortToggle { "aria-label" = "Sort"
  86. button { type = "button" class = row.timelineClass value = "timeline" "Timeline" on click(e) { emit sortTimeline(row.id, 'timeline') } }
  87. button { type = "button" class = row.releaseClass value = "release" "Release" on click(e) { emit sortTimeline(row.id, 'release') } }
  88. }
  89. }
  90. }
  91. if (row.isItem) {
  92. a { class = "timeline-item" href = row.href "data-timeline" = row.timeline
  93. img { class = "film-poster" src = row.posterUrl alt = "" loading = "lazy" }
  94. filmText {
  95. filmTitle { row.title }
  96. filmMeta {
  97. span { class = row.typeClass row.typeLabel }
  98. span { class = "timeline-date" row.dateLabel }
  99. }
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. on sortTimeline(timelineId, mode) {
  110. m = modes
  111. m[timelineId] = mode
  112. modes = m
  113. rows = flatRows(&blocks, &modes, &namedHeads)
  114. }

Branches

Latest commits

  • c1c4178cMerge branch 'rv39'mre
  • a016e9abReapply "Merge branch 'rv39'"mre
  • f29e2502log: RV39 gate fixmre
  • d9fce111browser gate #26: exact frame count incl. SL1 people step (hybriel#308)mre
  • ad529ac1log: m572 verdictmre
  • 1b37d404RV39 on hold: hybriel#308mre
  • f9127c68Revert "Merge branch 'rv39'"mre
  • cd39f3d3log: hybriel#308mre
  • 51341d6elog: RV39 deploy startedmre
  • c9e29e06Merge branch 'rv39'mre
  • 0f8d1fdclog: RV39 report, browser 387/2mre
  • 50249b0bRV39: reportmre
  • 10ed9581compose: HL_GC_STATS=1mre
  • 955da19bRV39: re-vendor Hybriel set day39 (source 51e921d7, bin 6b481aa7)mre
  • 64b8d1dclog: RV39 startedmre
  • 1f2df72amission RV39mre
  • 6c1936f9log+status: GC planmre
  • 2846a840log: m569 result, GC hypothesismre
  • b24cd2d5log: Anton on hl:fetch, mission 569mre
  • 7d42cac1log+status: SL1 measured, fetch stalls remainmre