components
All repositories: gitoria
3.9 KB
// 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:// 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// back. "You are" switches the current user, so Edit / Delete show only on that user's comments; "nobody" reads only.// ATTACHMENTS (attach = "true", mission 009): files dropped, chosen or pasted into the form go with the post — the page's face stores// 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.parent '../main.hl'import Comments from './comments.hl'import { demoComments, withNew, withEdit, without, withLike, attachedOf } from '../../lib/comments.hl'import { storeMdFiles } from '../../lib/uploads.hl'__title = 'Comments · Hybriel components'Hybrid thread = demoCommentsString me = 'alice'// who is chosen: its button is filled and pressed, the others quiet (a View attribute cannot hold an expression, so each is a member)String aliceClass = ''String bobClass = 'quiet'String nobodyClass = 'quiet'String alicePressed = 'true'String bobPressed = 'false'String nobodyPressed = 'false'String meText = 'now alice'String told = 'nothing yet'Number seq = 0posted = (text, files) => {let stored = []if (files.length > 0) {stored = emit server demoAttach(files)if (stored == null) {told = 'post refused'return false}}seq = seq + 1thread = withNew(thread, me, text, seq, stored)told = files.length > 0 ? 'post with ' + files.length + ' files' : 'post'}edited = (id, text) => {thread = withEdit(thread, id, text)told = 'edit ' + id}deleted = (id) => {thread = without(thread, id)told = 'delete ' + id}// what a push from elsewhere does in an app (another user edits): the page gets a new list, nobody pressed anything in this blockon demoElsewhere(e) { thread = withEdit(thread, 'c2', 'Changed **elsewhere**: bob edited it in another tab.') }liked = (id) => {thread = withLike(thread, id)told = 'like ' + id}View {commentsDemo {h1 { "Comments" }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." }p { class = "comments-who" role = "group" 'aria-label' = "Act as" "You are:"button { type = "button" id = "as-alice" class = aliceClass 'aria-pressed' = alicePressed "alice" on click(e) { emit demoAs('alice') } }button { type = "button" id = "as-bob" class = bobClass 'aria-pressed' = bobPressed "bob" on click(e) { emit demoAs('bob') } }button { type = "button" id = "as-nobody" class = nobodyClass 'aria-pressed' = nobodyPressed "nobody" on click(e) { emit demoAs('') } }output { id = "comments-me" class = "muted" meText }}p { button { type = "button" id = "elsewhere" "bob edits his comment elsewhere (a push)" on click(e) { emit demoElsewhere(e) } } }Comments { comments = thread user = me onPost = posted onEdit = edited onDelete = deleted onLike = liked signInText = "Choose a user above to comment." attach = "true" maxFileSize = 2097152 }p { class = "muted" "The page was told: " output { id = "comments-told" told } }p { a { id = "readme" href = "/comments/README.md" "README (how to use it)" } }}}on demoAs(who) {me = whoaliceClass = who == 'alice' ? '' : 'quiet'bobClass = who == 'bob' ? '' : 'quiet'nobodyClass = who == '' ? '' : 'quiet'alicePressed = who == 'alice' ? 'true' : 'false'bobPressed = who == 'bob' ? 'true' : 'false'nobodyPressed = who == '' ? 'true' : 'false'meText = 'now ' + (who == '' ? 'nobody' : who)}// the files of a new comment: stored for a day, what the block shows of each back (the demo's decision: lib/uploads.hl)on server demoAttach(files) { return attachedOf(files, storeMdFiles(files)) }
Branches
Latest commits
- 67e043c8plugins/web/README.md from hybriel cb9e480dmre
- 519b56e9styles.hl: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
- 29f63d01md-editor: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
- 869f49c7files-upload: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
- f60dab20month-view: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
- 5b3c349aRe-vendor to Hybriel set day35 (cb9e480d): plugins core and web sources, README vendoring notemre
- 3449b117components: a startup error prints its message before exit 1 (hybriel#247)mre
- 59704ce1Merge branch 'n5b-pipes'mre
- 23b9164aMdEditor: a clipboard whose text is only the names or file:// paths of its files (a file manager copy) is about the files, as before; any other text wins (tickets#49); gate casesmre
- b0f1ec28MdEditor: a clipboard with text always pastes the text, also when a picture is on it too (a spreadsheet or office app), files on or off; a picture alone still goes to the files; real Ctrl+V gate tests/md-paste-files.mjs (tickets#49)mre
- ad4e929bMdEditor: pipe rows without a delimiter row are a table (first row = header, short rows padded, written back without an invented | --- | line) (notes#5)mre
- 4bd11128MdEditor: the Table button's empty table is written as a real pipe table (empty cells), so it survives the source switch, a save and a reload (notes#7)mre
- 7437e32bMdEditor draws its surface at once when claimed from server HTML: 1 ms mount animation, the first editor mounts all editors of the pagemre
- 5de0264cRe-vendor onto Hybriel master acaceaf3 (set-day27b): binary, lib and plugins; exit 1 on a startup fault; .gitignore binmre
- 79c77e7dMerge sb3-standby: components deploys through its standbymre
- c5442043components: no jobs switch needed in the standbymre
- 8d2fb24ccomponents: a standby container (port 45016, profile standby); deploy hands over through standby-swap.sh without a gapmre
- c2834dd3Merge mr-fixes: media player state after a queue pick, Range handling, cover-less audio, accessibility labelsmre
- 354fe3c6Media player: audio without a cover starts and shows its time (the mount tick sits on the seek bar, which every item has); the speed button names the current speed, the seek slider says its time in words; a gate page for the first render on cover-less audio and a fourth demo queue item without a covermre
- ee4aee1eMedia player: a new queue item shows its own speed, mute, play state and time and starts when asked, also for two videos in a row; the media route reads suffix ranges and ignores range lists and garbage instead of answering 500; stronger gate checks (the 10 percent drag, the played bar, the queue tap)mre