gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd6d03fa3d6d03fa3mission: T36Bmred6d03fa3/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

  • 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
  • 7aea52batmdb fix: protect owners without slugs and record passing gatesmre
  • 9b3c2559tmdb fix: revalidate planned identities and reserve target idsmre
  • 6da612fclog: T36A tool defectmre
  • d56ee0daT36A: report unsafe TMDB apply revalidation and stop before livemre
  • 08e55255log: HM56 done, T36A startedmre
  • 91bcdf0eAvoid per-row list copies and reproduce keyed-row blockersmre
  • 5fd2ac75status: #36 GOmre
  • 0d253b45mission: T36Amre
  • 2aa22d23log: #36 GOmre
  • 833aee2flog: #50 closed, HM56 startedmre
  • ac58c1e5mission: HM56mre
  • 58979c0clog: HM54 held for decision, DP65 startedmre
  • bb2ebc67log: #64 live, #53 mergedmre