gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitdf7696dbdf7696dbident#34: tests: access ticks selector quoting fixmredf7696db/lib/delivery-helpers.hl

2.4 KB

  1. // lib/delivery-helpers.hl — what lib/delivery.hl looks up: the local date, the clock (with the gates' test clock),
  2. // the two mails' subject and text. No table access. Statics only.
  3. import { now } from 'hl:time'
  4. import { envString } from './util.hl'
  5. import { readFile, exists } from 'hl:fs'
  6. static NL = '
  7. '
  8. // where the mails' "open your inbox" link points (the container sets it; unset = no link)
  9. static publicUrl = envString('IDENT_PUBLIC_URL', null)
  10. // THE CLOCK OF DELIVERY. IDENT_TEST_CLOCK (THE GATES ONLY, never set in the container) names a file holding an
  11. // epoch-ms instant: delivery then takes that as "now" — the gate moves it to Vienna's, New York's, Tokyo's 17:00, a
  12. // DST day. No file / no number in it = the real clock. Only delivery reads it; everything else keeps now().
  13. static clockFile = envString('IDENT_TEST_CLOCK', null)
  14. static clockNow = () => {
  15. if (clockFile == null || !exists(clockFile)) { return now() }
  16. n = toNumber(('' + readFile(clockFile)).trim())
  17. return n == null ? now() : n
  18. }
  19. // a `local()` reading → 'YYYY-MM-DD'
  20. static pad2 = (n) => { return n < 10 ? '0' + n : '' + n }
  21. static dateOf = (l) => { return l.year + '-' + pad2(l.month) + '-' + pad2(l.day) }
  22. static plural = (n, one, many) => { return n == 1 ? '1 ' + one : n + ' ' + many }
  23. static indented = (text) => { return ' ' + text.replaceAll(NL, NL + ' ') }
  24. static entry = (r) => {
  25. head = '* ' + r.name + ' — ' + r.app + ' · ' + r.identity + (r.urgent ? ' (urgent)' : '')
  26. return head + NL + indented(r.text) + NL + (r.link != '' ? ' ' + r.link + NL : '')
  27. }
  28. static footer = () => {
  29. inbox = publicUrl != null ? 'Your inbox: ' + publicUrl + '/inbox' + NL : ''
  30. return '--' + NL + inbox + 'Which notifications are mailed is up to you: open an app in your ident inbox and switch them.' + NL
  31. }
  32. // THE DAILY MAIL: `rows` = lib/notify.hl pendingDaily, `date` = the user's local date
  33. static digestSubject = (rows, date) => { return 'ident: ' + plural(rows.length, 'notification', 'notifications') + ' (' + date + ')' }
  34. static digestText = (rows, date, zone) => {
  35. let t = 'Hi,' + NL + NL + 'your notifications for ' + date + ' (17:00, ' + zone + '):' + NL + NL
  36. for (r of rows) { t = t + entry(r) + NL }
  37. return t + footer()
  38. }
  39. // AN URGENT ONE, at once: `r` = one row as in the daily mail
  40. static urgentSubject = (r) => { return r.app + ': ' + r.name }
  41. static urgentText = (r) => { return 'Hi,' + NL + NL + 'an urgent notification:' + NL + NL + entry(r) + NL + footer() }

Branches

Latest commits

  • df7696dbident#34: tests: access ticks selector quoting fixmre
  • 7215903eident#34: access: the unstyled classes all, app, tick, apptick, plus are dropped; the gate finds the app ticks by input[name=app]mre
  • 69b0a0ceident#34: access: the pick buttons use Style.pickCard instead of class pickmre
  • dc702419Merge branch 'f9-choose' into mainIdent
  • 8caec771|||PR ident#34 restore .choose hookmre
  • 0dbff960Merge branch 'f8-shared' into mainIdent
  • d69665f6|||PR ident#34 part 3: shared look classes (wide, avatar, chip/used, conn, choose, who, inboxlink) moved to statics or droppedmre
  • 3a64dc48ident#34: chipLook: radius as the same var() string (a bare token name in a static does not compile); selector gate selectormre
  • eb039073ident#34: tests: signin and migration find the choice without the classmre
  • 4b94a594ident#34: tests: fix selector of the identity choicemre
  • bebc88e4ident#34: main.hl drops the unstyled classes inboxlink and whomre
  • b4e7ad04ident#34: the identity choice link/button has no class (rule on #chooselist a)mre
  • 3c33d6eaident#34: the connection link in inbox has no class (rule on #conns a)mre
  • dc97ec0dident#34: the Notif. chip and the Used in link share chipLook (Style.pChip) instead of the classes chip/used/notifmre
  • 378bd432ident#34: the identity picture look is a static in styles.hl (Style.pAvatar); sizes stay with each listmre
  • 1cf79e7eident#34: the wide page column is a static in styles.hl (Style.pWide), not the class "wide"mre
  • ddc7d135Merge branch 'f7-hooks' into mainIdent
  • eee0b513|||PR ident#34 part: test-hook classes replaced by name/element/attribute selectors (tests adjusted), the shared lead/message/notice looks are statics in styles.hlmre
  • ccd6d0c4ident#34: browser gate: rowButton finds the row's button by namemre
  • 24dd414eident#34: the shared lead, message and notice looks are statics in components/styles.hl, imported by the components (lib/looks.hl gone)mre