gitoria

components

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1b7413be1b7413beIgnore detached media events and space demo option outputsmre1b7413be/components/comments/demo.hl

3.9 KB

  1. // demo.hl — `/comments`: the comments block on a page with the mock thread of lib/comments.hl. WHAT IS STORED IS THE APP'S DECISION:
  2. // the block tells this page (post, edit, delete, like) through the four functions it is handed; the page makes a new list and hands it
  3. // back. "You are" switches the current user, so Edit / Delete show only on that user's comments; "nobody" reads only.
  4. // ATTACHMENTS (attach = "true", mission 009): files dropped, chosen or pasted into the form go with the post — the page's face stores
  5. // them (one day, lib/uploads.hl) and the new comment shows them: pictures as thumbnails, other files as rows. Up to 2 MB per file.
  6. parent '../main.hl'
  7. import Comments from './comments.hl'
  8. import { demoComments, withNew, withEdit, without, withLike, attachedOf } from '../../lib/comments.hl'
  9. import { storeMdFiles } from '../../lib/uploads.hl'
  10. __title = 'Comments · Hybriel components'
  11. Hybrid thread = demoComments
  12. String me = 'alice'
  13. // who is chosen: its button is filled and pressed, the others quiet (a View attribute cannot hold an expression, so each is a member)
  14. String aliceClass = ''
  15. String bobClass = 'quiet'
  16. String nobodyClass = 'quiet'
  17. String alicePressed = 'true'
  18. String bobPressed = 'false'
  19. String nobodyPressed = 'false'
  20. String meText = 'now alice'
  21. String told = 'nothing yet'
  22. Number seq = 0
  23. posted = (text, files) => {
  24. let stored = []
  25. if (files.length > 0) {
  26. stored = emit server demoAttach(files)
  27. if (stored == null) {
  28. told = 'post refused'
  29. return false
  30. }
  31. }
  32. seq = seq + 1
  33. thread = withNew(thread, me, text, seq, stored)
  34. told = files.length > 0 ? 'post with ' + files.length + ' files' : 'post'
  35. }
  36. edited = (id, text) => {
  37. thread = withEdit(thread, id, text)
  38. told = 'edit ' + id
  39. }
  40. deleted = (id) => {
  41. thread = without(thread, id)
  42. told = 'delete ' + id
  43. }
  44. // what a push from elsewhere does in an app (another user edits): the page gets a new list, nobody pressed anything in this block
  45. on demoElsewhere(e) { thread = withEdit(thread, 'c2', 'Changed **elsewhere**: bob edited it in another tab.') }
  46. liked = (id) => {
  47. thread = withLike(thread, id)
  48. told = 'like ' + id
  49. }
  50. View {
  51. commentsDemo {
  52. h1 { "Comments" }
  53. p { class = "muted" "A thread: avatar, name, time, “edited” with the earlier versions, the text as Markdown, a like, and Edit / Delete on your own comments. Type a new one below in the Markdown editor." }
  54. p { class = "comments-who" role = "group" 'aria-label' = "Act as" "You are:"
  55. button { type = "button" id = "as-alice" class = aliceClass 'aria-pressed' = alicePressed "alice" on click(e) { emit demoAs('alice') } }
  56. button { type = "button" id = "as-bob" class = bobClass 'aria-pressed' = bobPressed "bob" on click(e) { emit demoAs('bob') } }
  57. button { type = "button" id = "as-nobody" class = nobodyClass 'aria-pressed' = nobodyPressed "nobody" on click(e) { emit demoAs('') } }
  58. output { id = "comments-me" class = "muted" meText }
  59. }
  60. p { button { type = "button" id = "elsewhere" "bob edits his comment elsewhere (a push)" on click(e) { emit demoElsewhere(e) } } }
  61. Comments { comments = thread user = me onPost = posted onEdit = edited onDelete = deleted onLike = liked signInText = "Choose a user above to comment." attach = "true" maxFileSize = 2097152 }
  62. p { class = "muted" "The page was told: " output { id = "comments-told" told } }
  63. p { a { id = "readme" href = "/comments/README.md" "README (how to use it)" } }
  64. }
  65. }
  66. on demoAs(who) {
  67. me = who
  68. aliceClass = who == 'alice' ? '' : 'quiet'
  69. bobClass = who == 'bob' ? '' : 'quiet'
  70. nobodyClass = who == '' ? '' : 'quiet'
  71. alicePressed = who == 'alice' ? 'true' : 'false'
  72. bobPressed = who == 'bob' ? 'true' : 'false'
  73. nobodyPressed = who == '' ? 'true' : 'false'
  74. meText = 'now ' + (who == '' ? 'nobody' : who)
  75. }
  76. // the files of a new comment: stored for a day, what the block shows of each back (the demo's decision: lib/uploads.hl)
  77. on server demoAttach(files) { return attachedOf(files, storeMdFiles(files)) }

Branches

Latest commits

  • 1b7413beIgnore detached media events and space demo option outputsmre
  • ca3b4959Re-vendor complete Hybriel plugins and runtime to day44mre
  • df9e7df9Last-item checks run in the browser gate (components#26 fixed on day41); media-player loop is a plain Booleanmre
  • 895a5afcRe-vendor complete Hybriel plugins and runtime to day41mre
  • 16006bb3Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
  • 88397fc3Re-vendor complete Hybriel plugins and runtime to day39mre
  • 9b872cedRecord IC28 deployment and live icon verificationmre
  • 46fefaa7Count the icons entry in the offline home-page checkmre
  • c7e14cabRecord IC28 rerun and unchanged-main baseline comparisonmre
  • 5e090ffdRecord IC28 review evidence and gate resultsmre
  • adfe2c4dAdd shuffle, repeat and repeatOne shared iconsmre
  • c96709c8media-player: skip = false and repeat = 'one' options (jukebox#19)mre
  • bd4aa808Record VL24 deployment and live verificationmre
  • e5b98ecfRun virtual-list gate before deploymentmre
  • 2e9b4a8evirtual-list: into main, with centerId and scrollTop/onScroll (jukebox#20)mre
  • 69954249Align all plugin sources with Hybriel day38bmre
  • f740f666Re-vendor components to Hybriel set day38bmre
  • 8176eb14Record CS23b deployment and live verificationmre
  • 84e3ddaaRemove blank line before pagination Style closing bracemre
  • a92298ddRecord exact CSS and same-date proof after specificity reviewmre