gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitfff2f537fff2f537Merge branch 'calendar31-lib' into mainAtlasfff2f537/project.hl

5.0 KB

  1. // project.hl — calendar.worldapi.org: THE MAP. Config, routes and WHO HEARS WHAT. Hybriel on hl:web.
  2. // The month view at `/` (ticket #1); login with ident and the user's private events (ticket #2).
  3. //
  4. // WHERE WHAT IS (README "Files"):
  5. // events, every write to events.db, the faces' answers lib/events.hl (+ lib/events-helpers.hl)
  6. // the default reminders (settings.db) lib/settings.hl
  7. // users, the ident exchange, both logins' user step lib/users.hl
  8. // /login/callback lib/api.hl (+ lib/api-helpers.hl)
  9. // env, table folder, lists, id checks lib/util.hl
  10. // the page shell, login/logout faces components/main.hl
  11. // `/` and the event faces, /login/failed, all CSS components/calendar.hl, loginfailed.hl, styles.hl
  12. // Web Push: subscriptions + the clock that sends lib/push.hl (faces calPushSave / calPushOff in calendar.hl)
  13. // the month view UI components/month-view/
  14. // dates, names, reminders, clock lib/{dates,names,reminders,clock}.hl
  15. import WebFramework from 'hl:web'
  16. import { env } from 'hl:proc'
  17. import Styles from './components/styles.hl'
  18. import { dark, darker } from './shared/tokens.hl'
  19. import { tagOf } from './lib/users.hl'
  20. import { loginCallback, health } from './lib/api.hl'
  21. import Calendar from './components/calendar.hl'
  22. import LoginFailed from './components/loginfailed.hl'
  23. import Push from './lib/push.hl'
  24. import { envOr } from './lib/util.hl'
  25. import { publicUrl } from './lib/users.hl'
  26. static siteName = "Calendar"
  27. appTitle = siteName
  28. appThemeColor = darker.value
  29. appBackgroundColor = dark.value
  30. appIcons = [
  31. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }
  32. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }
  33. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }
  34. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }
  35. ]
  36. offline = [ Calendar ]
  37. styles = Styles
  38. routes = [
  39. { pattern = "/favicon.ico" direct = "" }
  40. // the login button's return writes the session: the request and the store go BY REFERENCE (lib/api.hl)
  41. { pattern = "/login/callback" function = (Hybrid route, Hybrid req) => { return loginCallback(route, &req, &server.sessions) } }
  42. { pattern = "/health" function = (Hybrid route, Hybrid req) => { return health() } }
  43. { pattern = "/login/failed" component = LoginFailed }
  44. { pattern = "/login.js" file = "./login.js" headers = { 'Cache-Control' = 'no-cache' 'X-Content-Type-Options' = 'nosniff' } }
  45. // the installable app (ticket #3): the icons (manifest and service worker are hl:web's own, from appIcons / offline)
  46. { pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' 'X-Content-Type-Options' = 'nosniff' } }
  47. { pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' 'X-Content-Type-Options' = 'nosniff' } }
  48. { pattern = "/" component = Calendar }
  49. ]
  50. // WHO GETS THE PUSH: the login state reaches the tabs of one session.
  51. // `calendarSignedIn` / `calendarSignedOut` go to the tabs of ONE session: the one whose login carries that random tag.
  52. audience = {
  53. calendarSignedIn = (tag, session) => { return tag != null && tagOf(session) == tag }
  54. calendarSignedOut = (tag, session) => { return tag != null && tagOf(session) == tag }
  55. }
  56. sessionDir = env('CALENDAR_SESSIONS') != null ? env('CALENDAR_SESSIONS') : null
  57. port = env('CALENDAR_PORT') != null ? toNumber(env('CALENDAR_PORT')) : 8380
  58. // HL_HOST = the interface hl:web binds: 127.0.0.1 on Byrodin behind nginx; unset = 0.0.0.0 (dev on Loreana).
  59. // CALENDAR_WATCH=0 = no dev watcher.
  60. watching = env('CALENDAR_WATCH') != '0'
  61. // The session idles out after the 14 days of sessionMaxAge, not after 15 minutes.
  62. sessionCookie = 'calendarsid'
  63. sessionIdle = 1209600
  64. // WEB PUSH (calendar#9): the VAPID key pair and contact, all three or none (tools/vapid-keys.hl makes the pair; README "Web Push").
  65. // Unset = no push: the page still shows reminders while it is open.
  66. pushPublic = envOr('CALENDAR_PUSH_PUBLIC', '')
  67. pushPrivate = envOr('CALENDAR_PUSH_PRIVATE', '')
  68. pushContact = envOr('CALENDAR_PUSH_SUBJECT', '')
  69. pushOn = pushPublic != '' && pushPrivate != '' && pushContact != ''
  70. // the sender's clock lives on an INSTANCE of lib/push.hl
  71. push = new Push()
  72. // SECURITY (mission SC): the session cookie is `Secure` when the public address is https (nginx speaks http to us, so the app says so);
  73. // no face of ours takes a file, so /__hl/upload (open to anyone, held in memory) refuses every file with a size (uploadMax = 0)
  74. sessionSecure = publicUrl.startsWith('https://')
  75. uploadMax = 0
  76. server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie, sessionSecure = sessionSecure, uploadMax = uploadMax, pushKey = pushOn ? pushPublic : null, pushPrivateKey = pushOn ? pushPrivate : null, pushSubject = pushOn ? pushContact : null, sessionMaxAge = 3122064000)
  77. on Error(e) { console.log('error absorbed: ' + e.message) }

Branches

Latest commits

  • fff2f537Merge branch 'calendar31-lib' into mainAtlas
  • 07cde3dc|||PR keep worker records out of the repo; README vendor is day72Atlas
  • a753b0ab|||PR move shared calendar logic to libAtlas
  • b32a921dMerge branch 'vendor-day72' into mainAtlas
  • 60a0dd19|||PR Hybriel day72 (00c9dbb8) instead of the withdrawn day73Atlas
  • 53f5464dMerge branch 'calendar26-day73' into mainAtlas
  • 338499ec|||PR Keep reminder settings open during editing and rejected savesAtlas
  • ad9e8d59|||PR Use framework page and popover state, Hybriel day73Atlas
  • cab224a1Re-vendor calendar to verified Hybriel day73Atlas
  • f9b8f918Merge branch 'calendar-vendor-day61' into mainAtlas
  • 66341793|||PR Vendor Hybriel day61Atlas
  • 36fc596bMerge branch 'vendor-day59' into mainAtlas
  • b37cc1da|||PR Vendor Hybriel day59Atlas
  • 05665102Merge branch 'vendor-day56' into mainAtlas
  • 687296fb|||PR Vendor Hybriel day56Atlas
  • a6166d4eMerge branch 'hl-standard-3' into mainAtlas
  • 6d0eb3b0|||PR Calendar day add buttons only when signed in (Kunibert minor)Atlas
  • add4b499|||PR Make calendar day actions keyboard accessibleAtlas
  • 79e49b4dMerge branch 'hl-standard' into mainAtlas
  • e9fec7bb|||PR HL-STANDARD clean-up: typed parameters, plain locals, by-reference cacheAtlas