gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit2ae8a47b2ae8a47bMerge branch 'sk-sec'mre2ae8a47b/components/timelineedit.hl

7.0 KB

  1. // components/timelineedit.hl — `/timelines/:slug/edit` (tracker.worldapi.org#19, mission 066): the creator's editor of ONE
  2. // timeline — its franchise (a row of chips: None + every franchise; a tap attaches it), its titles in their in-world order
  3. // (↑ / ↓ move one place, ✕ removes), and "Add titles": our database as you type (search.hl's index), "Add" puts the title at
  4. // the end. Mobile first: one column, big tap targets. Only the creator (franchises.hl isEditorSession) sees the controls; every
  5. // face checks it again.
  6. //
  7. // HYBRIEL TRAPS (as components/search.hl, hybriel#121/#122): no member reads both the route param and `session` — the
  8. // timeline's data come from `slug` alone, the editor state from `session` alone; every list is replaced whole with the
  9. // face's answer, never appended to.
  10. parent './main.hl'
  11. import { appTitle } from '../project.hl'
  12. import { isEditorSession, editPageOf, addToTimeline, removeFromTimeline, moveInTimeline, setTimelineFranchise, editSearch } from '../lib/franchises.hl'
  13. import { warmReady, warmText } from '../lib/warm.hl'
  14. static editorOf = (&session) => { return isEditorSession(session) }
  15. static startOf = (&slug) => { return editPageOf(slug) }
  16. slug = null
  17. session = null
  18. isEditor = editorOf(session)
  19. notEditor = isEditor == false
  20. start = startOf(slug)
  21. found = start.found
  22. notFound = start.found == false
  23. timelineId = start.id
  24. name = start.name
  25. viewHref = start.viewHref
  26. rows = start.rows
  27. hasRows = rows.length > 0
  28. noRows = rows.length == 0
  29. countText = rows.length == 1 ? '1 title' : rows.length + ' titles'
  30. chips = start.chips
  31. results = []
  32. hasResults = results.length > 0
  33. searchNote = ''
  34. hasSearchNote = searchNote != ''
  35. message = ''
  36. hasMessage = message != ''
  37. __title = found ? 'Edit ' + name + ' — ' + appTitle : appTitle
  38. // mission T17 (boot time): the server listens while bootscan.hl still builds the lists / slug maps / search index (lib/warm.hl); until the 'all'
  39. // stage is there this page says so instead of showing half a map
  40. warming = !warmReady('all')
  41. warmNote = warming ? warmText() : ''
  42. View {
  43. timelineEditPage { "data-timeline" = timelineId
  44. if (warming) { p { id = "warming" class = "message banner" warmNote } }
  45. if (notFound) {
  46. h1 { "Not found" }
  47. p { "This timeline doesn't exist." }
  48. }
  49. if (found) {
  50. franchisesHead {
  51. h1 { class = "typed" typeWord { class = "type-word type-timeline" "Timeline" } typeSep { "|" } typeName { name } }
  52. a { id = "timeline-view" class = "button" href = viewHref "View" }
  53. }
  54. if (notEditor) { p { id = "edit-refused" class = "muted" "Only the creator can edit franchises and timelines." } }
  55. if (isEditor) {
  56. if (hasMessage) { p { id = "edit-message" class = "message" message } }
  57. editSection {
  58. h2 { class = "film-heading" "Franchise" }
  59. chipRow { id = "franchise-chips"
  60. for (c of chips) { button { type = "button" class = c.cls value = c.id c.name on click(e) { emit pickFranchise(c.id) } } }
  61. }
  62. a { class = "edit-new-franchise" href = "/franchises/edit" "New franchise …" }
  63. }
  64. editSection {
  65. h2 { class = "film-heading" "Titles in timeline order" }
  66. p { class = "muted list-count" countText }
  67. if (noRows) { p { class = "muted" "No titles yet — add some below." } }
  68. if (hasRows) {
  69. editRows { id = "edit-rows"
  70. for (row of rows) {
  71. editRow { "data-show" = row.id
  72. editPos { row.pos }
  73. img { class = "film-poster" src = row.posterUrl alt = "" }
  74. filmText {
  75. filmTitle { row.title }
  76. filmMeta { span { row.typeLabel } }
  77. }
  78. button { type = "button" class = row.upClass value = "up" title = "Move up" "aria-label" = "Move up" "↑" on click(e) { emit moveRow(row.id, -1) } }
  79. button { type = "button" class = row.downClass value = "down" title = "Move down" "aria-label" = "Move down" "↓" on click(e) { emit moveRow(row.id, 1) } }
  80. button { type = "button" class = "quiet mv rm" value = "remove" title = "Remove" "aria-label" = "Remove" "✕" on click(e) { emit removeRow(row.id) } }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. editSection {
  87. h2 { class = "film-heading" "Add titles" }
  88. input { id = "ted-search" type = "search" placeholder = "Search our movies and series" autocomplete = "off" "aria-label" = "Search titles" on input(e) { emit searchTyped(e) } }
  89. if (hasSearchNote) { p { id = "ted-note" class = "muted" searchNote } }
  90. if (hasResults) {
  91. editRows { id = "ted-results"
  92. for (r of results) {
  93. editRow { "data-show" = r.id
  94. img { class = "film-poster" src = r.posterUrl alt = "" }
  95. filmText {
  96. filmTitle { r.title }
  97. filmMeta { span { r.typeLabel } }
  98. }
  99. button { type = "button" class = "inverted add" value = r.id "Add" on click(e) { emit addRow(r.id) } }
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. on pickFranchise(franchiseId) {
  110. let r = emit server tedSetFranchise(timelineId, '' + franchiseId)
  111. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  112. message = ''
  113. chips = r.chips
  114. }
  115. on moveRow(showId, delta) {
  116. let r = emit server tedMove(timelineId, '' + showId, delta)
  117. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  118. message = ''
  119. rows = r.rows
  120. }
  121. on removeRow(showId) {
  122. let r = emit server tedRemove(timelineId, '' + showId)
  123. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  124. message = ''
  125. rows = r.rows
  126. }
  127. on addRow(showId) {
  128. let r = emit server tedAdd(timelineId, '' + showId)
  129. if (r == null || r.error != null) { message = r != null ? r.error : 'Could not save it.' return null }
  130. message = ''
  131. rows = r.rows
  132. // the added title leaves the results (it is in the timeline now)
  133. left = []
  134. for (x of results) { if (x.id != showId) { left.push(x) } }
  135. results = left
  136. }
  137. on searchTyped(e) {
  138. v = e.target.value
  139. let r = emit server tedSearch(timelineId, v)
  140. if (r == null || document.getElementById('ted-search').value != v) { return null }
  141. results = r.rows
  142. searchNote = v.trim() == '' ? '' : r.note
  143. }
  144. // ---- the faces (unique names; the trailing `session` is the server's) ----
  145. on server tedSetFranchise(timelineId, franchiseId, session) {
  146. if (!isEditorSession(session)) { return { error = 'only the creator can do that' } }
  147. return setTimelineFranchise(timelineId, franchiseId)
  148. }
  149. on server tedMove(timelineId, showId, delta, session) {
  150. if (!isEditorSession(session)) { return { error = 'only the creator can do that' } }
  151. return moveInTimeline(timelineId, showId, delta)
  152. }
  153. on server tedRemove(timelineId, showId, session) {
  154. if (!isEditorSession(session)) { return { error = 'only the creator can do that' } }
  155. return removeFromTimeline(timelineId, showId)
  156. }
  157. on server tedAdd(timelineId, showId, session) {
  158. if (!isEditorSession(session)) { return { error = 'only the creator can do that' } }
  159. return addToTimeline(timelineId, showId)
  160. }
  161. // the search is our public database (like /search) — no session
  162. on server tedSearch(timelineId, text) {
  163. return editSearch(timelineId, text)
  164. }

Branches

Latest commits

  • 2ae8a47bMerge branch 'sk-sec'mre
  • 8fee5d52sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 944ad51eSK: report reports/SK-sec.md, LOGsk
  • 415487c1SK: import budget per user + id type check, gate checkssk
  • 7b8a4f74security audit SK: nosniff + image sandbox headers, face id checks, adult follow, login budget + new session at login, guest-link budget, tests/security.mjssk
  • f0f26c5areports: T18 section (gates, boot-gate, 3x3 table, search + short-id compare)mre
  • 2a8682a1deploy.sh GATES: tests/warmstart.mjsmre
  • 3761338breports/T17-boot.md: handoff (phase table, fix, numbers so far, open proof)mre
  • 52e09eb2boot: sync window 1000 ms (the gates ask for a complete start), README boot-time sectionmre
  • c87149e8tests/warmstart.mjs: the progressive start proven over HTTP (note in the window, 503 short id, after: everything); bootBeginmre
  • 593a6350boot: resumable start-up scan, the server listens first (T17)mre
  • be4890a0reports: H2 hydration audit (no test change needed)mre
  • 1f9c8bf4re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • c1df88eddocker-compose: HL_GC_TABLE_LOAD=62 (tracker mission 048, T16 real-data numbers)mre
  • d0a82867mission 048: report, LOG (HL_GC_TABLE_LOAD=62 measured)mre
  • 2d4be66fre-vendor Hybriel 5df4eb7e (GC: HL_GC_TABLE_LOAD knob, mission 406)mre
  • 99e7c8b9tests: realdata-m035-radii, repro-t38, realdata-060-backfill ports from env (REAL_PORT, REAL_CHROME, REPRO_CHROME), defaults unchangedmre
  • 4625aa22re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • a6dfd6ecdeploy: person-lookup gate (tracker#46)mre
  • 33ad4bd5Merge commit 'f57f64f'mre