notes
All repositories: gitoria
6.1 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)// rejected drafts, every write to drafts.db lib/drafts.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, publicUrl } 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 = (Hybrid route, Hybrid 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 = (String user, Hybrid list, Hybrid session) => { return user != null && userIdOfSession(session) == user }notesSignedIn = (String tag, Hybrid session) => { return tag != null && tagOf(session) == tag }notesSignedOut = (String tag, Hybrid 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 = 1209600// SECURITY (mission SN): the session cookie is `Secure` when the public address is https (the proxy speaks http to us, so the app says// so); no face of ours takes a file (the editor runs with files = "off"), so /__hl/upload — open to anyone, held in memory — refuses// every file with a size (uploadMax = 0)sessionSecure = publicUrl.startsWith('https://')uploadMax = 0server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie, sessionSecure = sessionSecure, uploadMax = uploadMax, sessionMaxAge = 3122064000)on Error(Hybrid e) { console.log('error absorbed: ' + e.message) }
Branches
Latest commits
- 4c6e0bf6Merge branch 'notes13-day61' into mainAtlas
- eb51864f|||PR Back/Forward via navigate, server drafts, Hybriel day61Atlas
- 3537cf7eMerge branch 'vendor-day59' into mainAtlas
- c13d188b|||PR Vendor Hybriel day59Atlas
- 24c95433Merge branch 'notes17-ghost-note' into mainAtlas
- ae1075b2Preserve rejected drafts during note ID adoptionAtlas
- 383cce23|||PR Prevent saved local edits from restoring deleted notesAtlas
- 99ca1cf6Merge branch 'vendor-day56' into mainAtlas
- 649cef37|||PR Vendor Hybriel day56Atlas
- aadd0abcMerge branch 'hl-standard-2' into mainAtlas
- 52ffac9f|||PR Keyboard and reload checks for the notes gate (HL-STANDARD F21, F5)Atlas
- 617ee8c0Merge branch 'hl-standard' into mainAtlas
- 452458ee|||PR Type the function parameters of notes' own .hl files (HL-STANDARD L10)Atlas
- 23758cd6Re-vendor complete Hybriel plugins and runtime to day44mre
- 5d7cc700Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 3e07b1cfVendor complete Hybriel day39 plugin sources and librariesmre
- d7366702Check session cookie flags after login and assert anonymous GET stays cookielessmre
- 16bc8fd8Re-vendor Hybriel day38b with the mpackdb store-open race fixmre
- d860dc2dnotes#12: the markup names its own rules instead of hand-written class strings: the selected row is `aria-current="page"` (the list-first theme rule styles it, no class), the delete question is `Style.pAsk` and follows its own `open` attribute (bound to `asking`), the error line is `Style.pMessage` (body once in lib/looks.hl, rule in notes.hl, main.hl and loginfailed.hl). The CSS declarations are the same, only selectors changed (.ask -> p.ask, .ask.open -> p.ask[open], .message -> p.message); the pages look the same (AE 0 at 4 sizes). main.hl's selectorClass in/out stays (login.js reads it).mre
- 2e7f8664notes#13: the list and back links pass the note key from the loop (emit pick(e, r.key)) instead of writing data-note into the View and reading it back with getAttribute; the two window.history.replaceState calls and the identcode e.target.value read stay (hl:web has no replace-navigation, a bound hidden input is not adopted on a script's change event), see NO13 reportmre