gitoria

components

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit0dce28990dce2899reports/K1-bubble.mdmre0dce2899/lib/comments.hl

3.1 KB

  1. // lib/comments.hl — THE COMMENTS DEMO'S MOCK DATA (the site's, not the component's): a short thread with an edited comment and likes,
  2. // and what the demo page does when the block tells it something — a new list each time (the block shows the list it is given).
  3. // The demo keeps the list in the page (every visitor plays with an own copy); only the files attached to a new comment are stored,
  4. // for one day (lib/uploads.hl storeMdFiles, served at /md-editor/files/… with nosniff + sandbox).
  5. static NL = "
  6. "
  7. static demoUsers = ['alice', 'bob']
  8. static demoComments = [
  9. { id = 'c1' author = 'alice' when = 'Oct 17, 09:12' text = 'The block takes **Markdown**: *emphasis*, `code`, links like [the README](/comments/README.md) and lists:' + NL + NL + '- one' + NL + '- two' likes = 2 liked = false history = [] }
  10. { id = 'c2' author = 'bob' when = 'Oct 17, 10:40' text = 'Edited twice — the earlier versions fold out under **edited**.' likes = 1 liked = true history = [ { when = 'Oct 17, 10:31' text = 'First try.' } { when = 'Oct 17, 10:35' text = 'First try, fixed.' } ]
  11. files = [ { name = 'icon-512.png' url = '/icons/icon-512.png' image = true size = 3354 } { name = 'README.md' url = '/comments/README.md' image = false size = 5395 } ] }
  12. { id = 'c3' author = 'alice' when = 'Oct 18, 14:05' text = 'A long word wraps on a phone: Donaudampfschifffahrtsgesellschaftskapitänswitwenrentenversicherung.' likes = 0 liked = false history = []
  13. files = [ { name = 'members-only-report-with-a-long-name-2026-10-20.pdf' image = false size = 48213 } ] }
  14. ]
  15. // a new comment by `who` at the end, with its attached files ([{ name, url, image, size }], [] = none)
  16. static withNew = (list, who, text, seq, files) => {
  17. out = []
  18. for (c of list) { out.push(c) }
  19. out.push({ id = 'n' + seq author = who when = 'just now' text = text likes = 0 liked = false history = [] files = files })
  20. return out
  21. }
  22. // the files of a new comment, stored (one day): what the block shows of each — a picture is an image/* file
  23. static attachedOf = (files, urls) => {
  24. out = []
  25. let i = 0
  26. for (f of files) {
  27. out.push({ name = f.name url = urls[i] image = ('' + f.type).startsWith('image/') size = f.size })
  28. i = i + 1
  29. }
  30. return out
  31. }
  32. // the comment `id` with a new text; its old text goes to the end of its history
  33. static withEdit = (list, id, text) => {
  34. out = []
  35. for (c of list) {
  36. if (c.id == id) {
  37. let past = []
  38. for (h of c.history) { past.push(h) }
  39. past.push({ when = c.when text = c.text })
  40. out.push({ id = c.id author = c.author when = 'just now' text = text likes = c.likes liked = c.liked history = past files = c.files })
  41. } else { out.push(c) }
  42. }
  43. return out
  44. }
  45. static without = (list, id) => {
  46. out = []
  47. for (c of list) { if (c.id != id) { out.push(c) } }
  48. return out
  49. }
  50. // the user's like on `id` switched: on adds one, off takes one away
  51. static withLike = (list, id) => {
  52. out = []
  53. for (c of list) {
  54. if (c.id == id) { out.push({ id = c.id author = c.author when = c.when text = c.text likes = c.liked ? c.likes - 1 : c.likes + 1 liked = !c.liked history = c.history files = c.files }) }
  55. else { out.push(c) }
  56. }
  57. return out
  58. }

Branches

Latest commits

  • 0dce2899reports/K1-bubble.mdmre
  • 6b0936a0comments: 'edited' foldable also drops the theme's border, margin and radius (display: contents alone left them computed)mre
  • 8d79ff79comments bubble hugs its content: a readonly md-editor surface gets no inline min-height (it beat the stylesheet's min-height 0); 'edited' is a quiet label beside the time, versions unframed; gate checksmre
  • ef253fecreports/F4-icons.mdmre
  • ba96735ficons: README, md-editor README note, gate checks for the single focus ring and toolbar iconsmre
  • 96c97691icons: shared Icon component; md-editor toolbar and files-upload remove use it; no inner focus ring in md-editormre
  • 0d6863d6reports/F3-mdvalue.mdmre
  • d58ed98bMdEditor: an older text of the editor handed back is not an outside change (kept surface, written back); gate for itmre
  • c2d0de59MdEditor: show a value that changes from outside (data-value observer), demo button and gatemre
  • c4272fa3re-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
  • 2e22618etests: cdp-blank/md-bg/md-keys-run Chrome range and base port from env (MDK_CHROME, MDK_PORT), defaults unchangedmre
  • a5d2384bre-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
  • 52902d23docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 022b943fdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • d17f8543mission 012: re-vendor Hybriel master f9614007 (plugins), fixes comments push redraw; gate 480/0mre
  • 5f95de05mission 012: re-vendor Hybriel ce6f2e0a (plugins), report: gate 478/2 on comments push redrawmre
  • 3794c591mission 011: report, LOG, STATUS, md-keys-run widths, cdp-blank helpermre
  • 77a93c16mission 011: gate hook for md-keys (480/0), flatten() runs one at a time (removeChild race), surface also built on first focus / pointer-down (background tab), md-bg test, README keysmre
  • 3c906718mission 011: md-editor key tests (real keys) and fixes: nested p/ul flatten, bare br, link change, Ctrl+E, code block exit (WIP)mre
  • 1442e583mission 010: report, LOG, STATUSmre