gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit3e07b1cf3e07b1cfVendor complete Hybriel day39 plugin sources and librariesmre3e07b1cf/project.hl

5.9 KB

  1. // project.hl — notes.worldapi.org: THE MAP. Config, routes and WHO HEARS WHAT. Hybriel on hl:web.
  2. // Notes with an ident login (ticket notes#1): a sidebar of the user's notes (subject = first line, last edited
  3. // first) and the selected note on the right, edited with the Hybriel MdEditor block (components/md-editor/, copied verbatim from
  4. // components.hybriel, tools/sync-components.sh). Saved on the server in storage/mpackdb/; kept offline in the browser by hl:web (tickets
  5. // notes#2, notes#4: `offline` below — no JavaScript of our own).
  6. //
  7. // WHERE WHAT IS (README "Files"):
  8. // notes, their sync rules, every write to notes.db lib/notes.hl (+ lib/notes-helpers.hl)
  9. // users, the ident exchange, both logins' user step lib/users.hl
  10. // /login/callback, /api/me, /api/notes lib/api.hl (+ lib/api-helpers.hl, lib/jsoncheck.hl)
  11. // env, table folder, lists, id checks lib/util.hl
  12. // the page shell, login/logout faces components/main.hl
  13. // the notes page (list, editor, offline + sync faces) components/notes.hl
  14. // /login/failed, all CSS components/loginfailed.hl, styles.hl
  15. // the ident selector bridge (ident's custom event) login.js
  16. import WebFramework from 'hl:web'
  17. import { env } from 'hl:proc'
  18. import Styles from './components/styles.hl'
  19. import { tagOf, userIdOfSession, publicUrl } from './lib/users.hl'
  20. import { loginCallback, apiMe, apiNotes } from './lib/api.hl'
  21. import { dark, darker } from './shared/tokens.hl'
  22. import Notes from './components/notes.hl'
  23. import LoginFailed from './components/loginfailed.hl'
  24. static siteName = "notes"
  25. appTitle = siteName
  26. // ---- THE INSTALLABLE APP (mission 046), as calendar.worldapi.org / tracker do it: hl:web's own web app manifest
  27. // (/__hl/manifest.webmanifest, linked from every head with the apple-touch-icon and theme-color) from these settings.
  28. // Icons in icons/ (icon.svg is the source, the PNGs are rendered from it with rsvg-convert, README "PWA"). The theme
  29. // colour is the header's background (darker), the splash background the page's (dark) — both off the tokens.
  30. // OFFLINE (notes#4): `offline = [Notes]` below makes hl:web register its generated service worker (/__hl/sw.js), keep
  31. // the page's state per user in the browser and queue the saves made without a network.
  32. appThemeColor = darker.value
  33. appBackgroundColor = dark.value
  34. appIcons = [
  35. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }
  36. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }
  37. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }
  38. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }
  39. ]
  40. appTouchIcon = '/icons/apple-touch-icon.png'
  41. appFavicon = '/icons/favicon.svg'
  42. styles = Styles
  43. routes = [
  44. { pattern = "/favicon.ico" file = "./icons/favicon.ico" headers = { 'Cache-Control' = 'no-cache' } }
  45. // the installable app (mission 046): the icons (the manifest is hl:web's own, from appIcons)
  46. { pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' } }
  47. { pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' } }
  48. { pattern = "/icons/apple-touch-icon.png" file = "./icons/apple-touch-icon.png" headers = { 'Cache-Control' = 'no-cache' } }
  49. { pattern = "/icons/favicon.svg" file = "./icons/favicon.svg" headers = { 'Cache-Control' = 'no-cache' } }
  50. // the login button's return writes the session: the request and the store go BY REFERENCE (lib/api.hl)
  51. { pattern = "/login/callback" function = (route, req) => { return loginCallback(route, &req, &server.sessions) } }
  52. { pattern = "/login/failed" component = LoginFailed }
  53. { pattern = "/login.js" file = "./login.js" headers = { 'Cache-Control' = 'no-cache' } }
  54. // the JSON API (ticket notes#2, lib/api.hl) — the page itself syncs through its faces (components/notes.hl)
  55. { pattern = "/api/me" function = apiMe }
  56. { pattern = "/api/notes" function = apiNotes }
  57. { pattern = "/" component = Notes }
  58. { pattern = "/note/:id" component = Notes }
  59. ]
  60. // OFFLINE (notes#4, hl:web COMPONENTS §10): the notes page is kept — the service worker, its state per user, the queue
  61. offline = [Notes]
  62. // WHO GETS THE PUSH: the login state reaches the tabs of one session; a user's notes reach every tab of that user.
  63. // `notesSignedIn` / `notesSignedOut` go to the tabs of ONE session: the one whose login carries that random tag.
  64. // `notesChanged(user, list)` goes to every tab signed in as `user` (components/notes.hl, after each save or delete).
  65. audience = {
  66. notesChanged = (user, list, session) => { return user != null && userIdOfSession(session) == user }
  67. notesSignedIn = (tag, session) => { return tag != null && tagOf(session) == tag }
  68. notesSignedOut = (tag, session) => { return tag != null && tagOf(session) == tag }
  69. }
  70. sessionDir = env('NOTES_SESSIONS') != null ? env('NOTES_SESSIONS') : null
  71. port = env('NOTES_PORT') != null ? toNumber(env('NOTES_PORT')) : 8710
  72. // HL_HOST = the interface hl:web binds: 127.0.0.1 on Byrodin behind nginx; unset = 0.0.0.0 (dev on Loreana).
  73. // NOTES_WATCH=0 = no dev watcher. The session cookie is `notessid` (hybriel #10). A note taker is not logged
  74. // out after 15 minutes of thinking: the session idles out after the 14 days of sessionMaxAge.
  75. watching = env('NOTES_WATCH') != '0'
  76. sessionCookie = 'notessid'
  77. sessionIdle = 1209600
  78. // SECURITY (mission SN): the session cookie is `Secure` when the public address is https (the proxy speaks http to us, so the app says
  79. // so); no face of ours takes a file (the editor runs with files = "off"), so /__hl/upload — open to anyone, held in memory — refuses
  80. // every file with a size (uploadMax = 0)
  81. sessionSecure = publicUrl.startsWith('https://')
  82. uploadMax = 0
  83. server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie, sessionSecure = sessionSecure, uploadMax = uploadMax, sessionMaxAge = 3122064000)
  84. on Error(e) { console.log('error absorbed: ' + e.message) }

Branches

Latest commits

  • 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
  • 4dc98282notes#15: a deleted note made in this tab leaves the list at once (the delete now removes this tab's edit under every key the row has: local id, server id); gate: browser.mjs notes#15 section, red on the old codemre
  • e4e7402fnotes#11: plain declarations instead of let for variables never reassigned (components/notes.hl 3, lib/jsoncheck.hl 5, lib/util.hl 2, tools/migrate-short-ids.hl 8)mre
  • 27b6a09enotes#8: Style blocks in the nested form (note-list, note-editor, .ask with their children nested, :empty as a nested pseudo-class); the same CSS rules, the pages look the samemre
  • 71a9538bnotes: B27W report, log linemre
  • 78ba0073notes: an ident access key (Authorization: Bearer idt_…) reads and writes its identity's notes through /api/me and /api/notes; gate tests/ident-access-notes.mjs (ident#27)mre
  • 3de46dacnotes: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 73+5 failing → 78 passedmre
  • 5909d458notes: MdEditor from components 59704ce (text on the clipboard always pastes, a file manager copy still attaches; pipe rows without a delimiter row; tickets#49, notes#5)mre
  • 98bd6a98N5b: pipe rows without a delimiter row are a table (MdEditor ad4e929, plain copy); gate tests/dashboard-table.mjs; reportmre
  • dbf93319N5 report: components gate rerun 613 passed, 0 failedmre
  • 3a8bc0d2N5: empty Table-button table is written as a real pipe table (MdEditor 4bd1112, plain copy); gate tests/table-button.mjs; reportmre
  • c16bd443N5: step 1 report (tables pass locally; his DASHBOARD note has no delimiter row)mre
  • 6091320anotes: MdEditor 7437e32 (surface drawn at once when the page is claimed); gate measures claim-to-text on 5 note loads at 1280 and 390mre
  • 0aa9277enotes: move each component's styles into its own Style block (shell and header selector in main.hl, list, editor frame and delete question in notes.hl); styles.hl keeps the theme inherit, the accent and the message colour; .gitignore ignores a bin symlink too; tests/shots.mjs for the pixel comparemre
  • 9ba01de3notes: write the standby service out in full so the boot gate can read the main servicemre
  • 98cab40anotes: standby service on its port plus 10 and a deploy that hands over through it without a gapmre