components
All repositories: gitoria
1.9 KB
// lib/uploads.hl — WHERE THE SHOWCASE KEEPS UPLOADED FILES (the site's decision, not the components'): the file upload demo// keeps each file in storage/uploads under a random name (nothing is served back); the Markdown editor demo keeps its files in// storage/md-files (served at /md-editor/files/…, see project.hl), only with a known kind of extension (nothing a browser would// run). Both keep a file for one day: every upload first stores, then removes what is older.import { writeFile, mkDir, listDir, remove } from 'hl:fs'import { randomBytes } from 'hl:crypto'import { now } from 'hl:time'static kinds = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'pdf', 'txt', 'md', 'zip']// the file upload demo: one file in, its name and size backstatic storeUpload = (file) => {mkDir('storage/uploads')writeFile('storage/uploads/' + now() + '-' + randomBytes(6) + '.bin', file.bytes)dropOld('storage/uploads')return { name = file.name size = file.size }}// the Markdown editor demo: files in, the address of each back, in orderstatic storeMdFiles = (files) => {mkDir('storage/md-files')let urls = []for (f of files) {let stored = now() + '-' + randomBytes(6) + '.' + extensionOf(f.name)writeFile('storage/md-files/' + stored, f.bytes)urls.push('/md-editor/files/' + stored)}dropOld('storage/md-files')return urls}// the stored extension: the file's own when it is a known kind, else 'bin'static extensionOf = (name) => {let dot = name.lastIndexOf('.')let ext = dot >= 0 ? name.slice(dot + 1).toLowerCase() : ''let known = falsefor (k of kinds) { if (k == ext) { known = true } }return known ? ext : 'bin'}// removes the files of a folder stored more than a day ago (the name starts with the time it was stored)static dropOld = (dir) => {for (e of listDir(dir)) {let stamp = toNumber(e.name.slice(0, e.name.indexOf('-')))if (stamp != null && stamp < now() - 86400000) { remove(e.path) }}}
Branches
- mainmain branch
Latest commits
- 172914a3components code order (mission 002) 2/4: lib/uploads.hl (demo upload storage), thin demo handlers, project.hl map; gate 220/0, same outputmre
- d29f35b1components code order (mission 002) 1/4: styles.hl -> components/styles.hl; gate 220/0, same outputmre
- 09945750components: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, http1 773de63e); gate 220/0mre
- ede4d19acomponents: Hybriel master 190aa11d (fc838894 GC correctness, #126 closure scopes, #127); gate 220/0mre
- 2bb9a935components: Hybriel master 8efba065 (re-vendor round 069: #126 memory, #48 lambda copy)mre
- e4f01768antcolony#40: mission references point to the moved missionsmre
- d32b44e2antcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
- 0fb80b57components: Hybriel master ff51cf46 (re-vendor round)mre
- 57408b6ecomponents#14: installable app (manifest, service worker, offline index), own iconmre
- 317bd09fdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- becbd59bcomponents#13: modal dialog (<dialog> based, focus wrap, backdrop/Esc/x close with reason, scroll lock, footer buttons)mre
- 367dd19adeploy.sh: never send .git or .gitignore to Byrodinmre
- 4b4dabe5State of 2026-09-27, before the move to gitoriamre