gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit641f3b54641f3b54Tracker: Apollo answermre641f3b54/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

  • 641f3b54Tracker: Apollo answermre
  • 8b3cbddaTracker: status, TR7 fix livemre
  • ec30162aTracker: TR7 fix livemre
  • 54cbec80compose: ignore SIGPIPE (TR7 crash loop, exit 141)mre
  • 3e164b63Tracker: status after CL1mre
  • 9d686bb3Tracker: CL1 reviewedmre
  • b8bba562CL1: crash loop report (SIGPIPE confirmed, trap wrapper option)mre
  • 298785f2Tracker: CL1 startedmre
  • 36b22710Tracker: port slot, CL1 briefmre
  • a401190fTracker: GO for the crash loopmre
  • e195d372Tracker: token pathsmre
  • 7f541d11Tracker conductor: CONDUCTOR.md, short STATUS.md, old status + decisions archive to archive/2026-10-31mre
  • 8dd423f7README: login.js stays by caramboleyo's explicit rulemre
  • d8df1493tracker: standby service on port 45018 and a gap-free hand-over in deploy.sh step 4mre
  • 36dd1686ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • ff9b838etracker: the Ended status pill uses the same red as layouts (pill danger); gate updatedmre
  • 40d9719eTP2: LOG line and report for the tracker pillsmre
  • ab3f2ba5tracker: status, genres, TMDB/IMDb/TVDB/TVmaze links and list kinds use the theme's pill; dense season list with the season check centred on its title line; gates for bothmre
  • 521061d6tracker header on phones: signed in, the brand fits whole at 360 and 390 px (tighter gaps and side paddings, slightly smaller brand, narrow screens and signed in only); mobile gate checks itmre
  • 18114a53tracker: franchises gate waits for the signed-out selector instead of the removed Log in buttonmre