notes
All repositories: gitoria
5.5 KB
// project.hl — notes.worldapi.org: THE MAP. Config, routes and WHO HEARS WHAT. Hybriel on hl:web.// Notes with an ident login (ticket notes#1): a sidebar of the user's notes (subject = first line, last edited// first) and the selected note on the right, edited with the Hybriel MdEditor block (components/md-editor/, copied verbatim from// components.hybriel, tools/sync-components.sh). Saved on the server in storage/mpackdb/; kept offline in the browser by hl:web (tickets// notes#2, notes#4: `offline` below — no JavaScript of our own).//// WHERE WHAT IS (README "Files"):// notes, their sync rules, every write to notes.db lib/notes.hl (+ lib/notes-helpers.hl)// users, the ident exchange, both logins' user step lib/users.hl// /login/callback, /api/me, /api/notes lib/api.hl (+ lib/api-helpers.hl, lib/jsoncheck.hl)// env, table folder, lists, id checks lib/util.hl// the page shell, login/logout faces components/main.hl// the notes page (list, editor, offline + sync faces) components/notes.hl// /login/failed, all CSS components/loginfailed.hl, styles.hl// the ident selector bridge (ident's custom event) login.jsimport WebFramework from 'hl:web'import { env } from 'hl:proc'import Styles from './components/styles.hl'import { tagOf, userIdOfSession } from './lib/users.hl'import { loginCallback, apiMe, apiNotes } from './lib/api.hl'import { dark, darker } from './shared/tokens.hl'import Notes from './components/notes.hl'import LoginFailed from './components/loginfailed.hl'static siteName = "notes"appTitle = siteName// ---- THE INSTALLABLE APP (mission 046), as calendar.worldapi.org / tracker do it: hl:web's own web app manifest// (/__hl/manifest.webmanifest, linked from every head with the apple-touch-icon and theme-color) from these settings.// Icons in icons/ (icon.svg is the source, the PNGs are rendered from it with rsvg-convert, README "PWA"). The theme// colour is the header's background (darker), the splash background the page's (dark) — both off the tokens.// OFFLINE (notes#4): `offline = [Notes]` below makes hl:web register its generated service worker (/__hl/sw.js), keep// the page's state per user in the browser and queue the saves made without a network.appThemeColor = darker.valueappBackgroundColor = dark.valueappIcons = [{ src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }{ src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }{ src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }{ src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }]appTouchIcon = '/icons/apple-touch-icon.png'appFavicon = '/icons/favicon.svg'styles = Stylesroutes = [{ pattern = "/favicon.ico" file = "./icons/favicon.ico" headers = { 'Cache-Control' = 'no-cache' } }// the installable app (mission 046): the icons (the manifest is hl:web's own, from appIcons){ pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/icons/apple-touch-icon.png" file = "./icons/apple-touch-icon.png" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/icons/favicon.svg" file = "./icons/favicon.svg" headers = { 'Cache-Control' = 'no-cache' } }// the login button's return writes the session: the request and the store go BY REFERENCE (lib/api.hl){ pattern = "/login/callback" function = (route, req) => { return loginCallback(route, &req, &server.sessions) } }{ pattern = "/login/failed" component = LoginFailed }{ pattern = "/login.js" file = "./login.js" headers = { 'Cache-Control' = 'no-cache' } }// the JSON API (ticket notes#2, lib/api.hl) — the page itself syncs through its faces (components/notes.hl){ pattern = "/api/me" function = apiMe }{ pattern = "/api/notes" function = apiNotes }{ pattern = "/" component = Notes }{ pattern = "/note/:id" component = Notes }]// OFFLINE (notes#4, hl:web COMPONENTS §10): the notes page is kept — the service worker, its state per user, the queueoffline = [Notes]// WHO GETS THE PUSH: the login state reaches the tabs of one session; a user's notes reach every tab of that user.// `notesSignedIn` / `notesSignedOut` go to the tabs of ONE session: the one whose login carries that random tag.// `notesChanged(user, list)` goes to every tab signed in as `user` (components/notes.hl, after each save or delete).audience = {notesChanged = (user, list, session) => { return user != null && userIdOfSession(session) == user }notesSignedIn = (tag, session) => { return tag != null && tagOf(session) == tag }notesSignedOut = (tag, session) => { return tag != null && tagOf(session) == tag }}sessionDir = env('NOTES_SESSIONS') != null ? env('NOTES_SESSIONS') : nullport = env('NOTES_PORT') != null ? toNumber(env('NOTES_PORT')) : 8710// HL_HOST = the interface hl:web binds: 127.0.0.1 on Byrodin behind nginx; unset = 0.0.0.0 (dev on Loreana).// NOTES_WATCH=0 = no dev watcher. The session cookie is `notessid` (hybriel #10). A note taker is not logged// out after 15 minutes of thinking: the session idles out after the 14 days of sessionMaxAge.watching = env('NOTES_WATCH') != '0'sessionCookie = 'notessid'sessionIdle = 1209600server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie)on Error(e) { console.log('error absorbed: ' + e.message) }
Branches
Latest commits
- ba1e73f8notes: a sent edit is done once the server's version is not older, so a second writer's text shows in the first tab; gate: two writers both waysmre
- c69ef9ebsync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
- 2eb783f5sync components 9a: shared Icon (icons/icons.hl), md-editor toolbar icons + single focus ring (components f4-icons ba96735)mre
- 4dd46dadsync-components: copy icons/icons.hl + README (F4); testsmre
- c92e4a0ftests/e2e-outside.mjs: real-Chrome E2E, a note pushed from another device while open, then typingmre
- 0516b4ccmd-editor.hl: verbatim copy of components f3-mdvalue (an older text handed back is kept)mre
- 38cc11ecmd-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
- 3e7e79f5reports/H1-hydrate.mdmre
- d98775e8tests/browser.mjs: wait for hydration before the clicks after a goto('/') (tables new note, phone sidebar)mre
- 1f3198b6tests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
- 39cf9fdfre-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
- db07aa84tests: short-id-switch ports from env (NOTES_SWITCH_IDENT_PORT/_PORT), defaults unchangedmre
- ef9f9feere-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
- 5485467cdocker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- 86ea4a85deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- edeab20fnotes mission 015: mission, report, LOG, STATUSmre
- 542a0383notes mission 015: e2e-chrome E2E_HOST (own cookie jar in the shared Chrome)mre
- 8b30f510notes mission 015: main-menu from layouts 0bcc629, current = true kept (route marks only /), server-HTML marker checksmre
- 84b574c4notes mission 015: re-vendor plugins from hybriel f9614007 (incl. web, #117)mre
- 447da53dnotes mission 014: report — remaining gates and lisbeth E2E proofmre