gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchnotes9-no-pollc49ce093|||PR WIP remove notes polling and use framework reachabilityAtlasnotes9-no-poll/project.hl

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

Branches

Latest commits

  • c49ce093|||PR WIP remove notes polling and use framework reachabilityAtlas
  • c028ac61Merge branch 'notes-pr7-kunibert' into mainAtlas
  • 9cc92bdfKeep conflict and history fixes while awaiting queued save supportAtlas
  • a5c27cb6Allow real edits back to earlier text and honor configured identAtlas
  • 15c46ced|||PR Preserve note edits, conflict bases and visible historyAtlas
  • 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