Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dist/
.DS_Store
.cache/
.wrangler/
service/wrangler.production.jsonc
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"type": "module",
"engines": {
"node": ">=22"
"node": ">=22.13"
},
"scripts": {
"dev": "astro dev",
Expand Down
38 changes: 38 additions & 0 deletions service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Contributions service

Receives the guided forms (ADR 0003). It checks each contribution, keeps it
for a maintainer and erases e-mails 30 days after a decision, 180 days after
they came at most. It never publishes anything, and the site works without it.

The maintainer reads, corrects and decides in the review space, behind
Cloudflare Access. The service checks the Access token again by itself, and
admits one e-mail. Sending to check opens a public issue, without the e-mail.

No personal data enters this repository. Secrets are set at deployment.

## Run it locally

```
PUBLIC_TURNSTILE_SITE_KEY=1x00000000000000000000AA npm run build
cp -R service/assets/review dist/review
npx wrangler@4 d1 migrations apply paymap-local --local -c service/wrangler.local.jsonc
npx wrangler@4 dev -c service/wrangler.local.jsonc --port 4399
```

The forms are on `localhost:4399`, the review space on
`review.localhost:4399`. The local entry, `worker.local.ts`, opens it without
Access and invents issues: never deploy it.

The key above is Turnstile's public test key. A build without a key shows the
forms but cannot send them, so a deployed build always sets it.

The service checks answers with the same rules as the forms. When a rule or a
list changes, deploy the service first, then the site.

## Before deploying

Create the Access application for `review.paymap.africa` first, then fill
`ACCESS_TEAM` (`https://<team>.cloudflareaccess.com`, no final slash) and
`ACCESS_AUD` in `wrangler.production.jsonc`, an unversioned copy of
`wrangler.jsonc` that also names the database. Always deploy with that copy. Secrets: `TURNSTILE_SECRET`, `SENDER_KEY`,
`REVIEWER` (the admitted e-mail) and `GITHUB_TOKEN` (issues of this repository).
Binary file not shown.
Binary file not shown.
Binary file not shown.
176 changes: 176 additions & 0 deletions service/assets/review/review.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
@font-face { font-family: Newsreader; font-weight: 500; src: url(newsreader-latin-500-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: Hanken; font-weight: 400; src: url(hanken-grotesk-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: Hanken; font-weight: 600; src: url(hanken-grotesk-latin-600-normal.woff2) format('woff2'); font-display: swap; }
:root { --sable: #f6f1e7; --creux: #efe8da; --surface: #fffcf6; --ink: #14110f; --ink-2: #5e574c; --lagune: #0e6b66; --lagune-50: #e2eeeb; --safran: #f2b33d; --safran-50: #f8ebc9; --safran-text: #7a4f00; --ok: #2e6b1f; --ok-deep: #235417; --ok-bg: #e3eed8; --bad: #9a2f1f; --bad-bg: #f6e1da; --shadow: 0 1px 2px rgba(20, 17, 15, .05), 0 6px 16px rgba(20, 17, 15, .07); --display: Newsreader, Georgia, serif; --ui: Hanken, system-ui, sans-serif; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--sable); color: var(--ink); font: 16px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--lagune); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
h1, h2, strong, .v, .big .in { font-family: var(--display); font-weight: 500; }
h1, h2, p, ul, ol, fieldset { margin: 0; padding: 0; border: 0; }
ul, ol { list-style: none; }
i { font-family: Arial, sans-serif; font-style: normal; }
a { color: var(--lagune); }
.ic { flex: none; width: 18px; height: 18px; }
.bar, main { width: 100%; max-width: 1312px; margin: 0 auto; padding: 0 32px; }
.bar { display: flex; align-items: center; gap: 14px; padding-top: 22px; padding-bottom: 22px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font: 500 26px/1.5 var(--display); color: var(--ink); text-decoration: none; }
.brand em { font-style: normal; color: var(--lagune); }
.mark { position: relative; width: 34px; height: 34px; border-radius: 10px; background: var(--lagune); }
.mark::after { content: ''; position: absolute; right: 6px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--safran); }
.tag { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 13px; border-radius: 999px; background: var(--safran-50); color: var(--safran-text); font-size: 13px; font-weight: 600; }
.tag .ic { width: 15px; height: 15px; }
.out { margin-left: auto; display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
main { display: flex; flex-direction: column; gap: 24px; padding-bottom: 80px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.head h1 { font-size: 56px; line-height: 1.02; letter-spacing: -.025em; }
.tabs { display: flex; gap: 4px; padding: 5px; border-radius: 999px; background: var(--creux); }
.tabs a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.tabs .on { background: var(--surface); box-shadow: var(--shadow); color: var(--ink); }
.list, .main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.item, .card .top { display: grid; align-items: center; gap: 18px; }
.item { grid-template-columns: 54px minmax(0, 1.2fr) minmax(0, 1fr) 190px 20px; padding: 16px 22px 16px 16px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.item:hover { background: #fff; }
.m { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; overflow-wrap: anywhere; }
.m strong { font-size: 24px; line-height: 1.1; }
.s { font-size: 14px; color: var(--ink-2); }
.v { font-size: 21px; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.v s, .tile s { color: var(--ink-2); }
.v b { font-weight: 500; color: var(--ok); }
.w { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 14px; color: var(--ink-2); }
.item > i { color: var(--lagune); }
.chip { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.logo-box { display: grid; place-items: center; flex: none; width: 54px; height: 54px; border-radius: 17px; overflow: hidden; background: #fff; }
.logo-box img { width: 100%; height: 100%; object-fit: contain; }
.letter { background: #fff; color: var(--lagune); font: 500 26px/1 var(--display); }
.card { display: flex; flex-direction: column; gap: 16px; padding: 20px 24px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.card .top { grid-template-columns: 54px minmax(0, 1.2fr) minmax(0, 1fr) auto; }
.foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.track { display: flex; gap: 8px; }
.track li { flex: 1; display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-radius: 14px; background: var(--creux); font-size: 14px; font-weight: 600; color: var(--ink-2); }
.track .past { background: var(--ok-bg); color: var(--ok); }
.track .on { background: var(--safran-50); color: var(--safran-text); }
.track .bad { background: var(--bad-bg); color: var(--bad); }
.open { display: inline-flex; align-items: center; gap: 7px; flex: none; min-height: 44px; font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.opens { display: flex; flex-direction: column; }
.back { display: inline-flex; align-items: center; gap: 9px; align-self: flex-start; min-height: 44px; margin-bottom: -10px; font-size: 15px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.notice { display: flex; align-items: center; gap: 12px; padding: 12px 20px; min-height: 56px; border-radius: 18px; }
.notice a { display: inline-flex; gap: 7px; align-items: center; min-height: 44px; margin-left: auto; color: inherit; font-weight: 600; white-space: nowrap; text-decoration: none; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.hero { display: flex; flex-direction: column; gap: 22px; padding: 26px; border-radius: 26px; background: var(--lagune-50); }
.hero .top { display: flex; align-items: center; gap: 16px; }
.hero h1 { font-size: 32px; line-height: 1.05; }
.tiles { display: flex; align-items: stretch; gap: 16px; }
.tiles > i { align-self: center; }
.tile { flex: 1 1 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 18px 20px; border-radius: 20px; background: var(--surface); }
.tile.old s { font: 500 40px/1.15 var(--display); overflow-wrap: anywhere; }
.tile.new { background: var(--ok); color: #fff; transition: box-shadow .15s; }
.tile.new:focus-within { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ok); }
.tile.new .cap, .tile.new .was, .tile.new s { color: #dcebd2; }
.tile.new .was button { color: #fff; }
.cap { font-size: 13px; color: var(--ink-2); }
.in { width: 100%; min-width: 0; margin: 0; padding: 0; border: 0; outline: 0; background: none; color: inherit; font: 600 16px/1.4 var(--ui); resize: none; field-sizing: content; overflow-wrap: anywhere; }
select.in { appearance: none; cursor: pointer; }
.big { display: flex; align-items: center; gap: 12px; }
.big .in { font-size: 40px; line-height: 1.15; cursor: text; }
.big .in.long { font-size: 23px; line-height: 1.3; }
.big .ic { opacity: .75; }
.title-field .big .in { font-size: 32px; border-radius: 10px; }
.title-field:focus-within .big { box-shadow: 0 2px 0 var(--lagune); }
.row { display: flex; align-items: center; gap: 15px; min-height: 76px; padding: 12px 14px 12px 18px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); min-width: 0; transition: box-shadow .15s; }
.row[data-edit]:hover .pen { background: var(--creux); color: var(--ink); }
.row:focus-within:has(.in:focus) { box-shadow: 0 0 0 2px var(--lagune), var(--shadow); }
.row .m { gap: 2px; }
.row .m b { font-weight: 600; }
.row.changed { box-shadow: inset 4px 0 0 var(--ok), var(--shadow); }
.row.changed:has(.in:focus) { box-shadow: 0 0 0 2px var(--ok), var(--shadow); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.disc { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; }
.pen { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 14px; color: var(--ink-2); cursor: pointer; transition: background .15s; }
.was { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 13px; color: var(--ok); }
.was button { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; margin: -10px 0; padding: 0 6px; border: 0; background: none; font: 600 13px var(--ui); color: var(--ok); cursor: pointer; }
.was .ic { width: 15px; height: 15px; }
.group { display: flex; flex-direction: column; gap: 10px; }
.group legend { margin-bottom: 10px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 15px; border-radius: 999px; background: none; box-shadow: inset 0 0 0 1.5px #bcd2cd; font-size: 15px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.pill input { position: absolute; opacity: 0; }
.pill img { border-radius: 50%; margin-left: -5px; }
.pill:not(:has(:checked)) img { filter: grayscale(1); opacity: .6; }
.pill:has(:checked) { background: var(--surface); box-shadow: var(--shadow); color: var(--ink); }
.pill:has(:checked)::after { content: '✓'; color: var(--ok); font-weight: 600; }
.pill:has(:focus-visible) { outline: 2px solid var(--lagune); outline-offset: 2px; }
.add { appearance: none; min-height: 44px; max-width: 170px; padding: 0 10px; border: 0; border-radius: 999px; background: none; font: 600 15px var(--ui); color: var(--lagune); cursor: pointer; }
.side { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 12px; padding: 26px 24px; border-radius: 24px; background: var(--creux); }
.side h2 { font-size: 26px; line-height: 1.15; }
.side ul { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 10px; font-size: 15px; }
.side li { display: flex; gap: 10px; color: var(--ink-2); }
.side li .ic { margin-top: 2px; color: var(--ok); }
.side li:last-child .ic { color: var(--safran-text); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-height: 52px; padding: 0 20px; border: 0; border-radius: 16px; font: 600 16px/1 var(--ui); cursor: pointer; list-style: none; white-space: nowrap; }
.btn::-webkit-details-marker { display: none; }
.btn.small { width: auto; min-height: 44px; padding: 0 18px; border-radius: 14px; font-size: 15px; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ok:hover { background: var(--ok-deep); }
.btn.plain { background: var(--surface); box-shadow: var(--shadow); color: var(--ok); }
.btn.bad { background: none; color: var(--bad); }
.btn.bad:hover { background: var(--bad-bg); }
.btn.badfull { margin-top: 10px; background: var(--bad); color: #fff; }
.refuse[open] { padding: 8px 18px 18px; border-radius: 18px; background: var(--surface); }
.refuse legend { font: 500 21px/1.2 var(--display); margin-bottom: 4px; }
.refuse[open] summary { display: none; }
.reason { display: flex; align-items: center; gap: 11px; min-height: 44px; font-size: 15px; font-weight: 600; cursor: pointer; }
.reason input { width: 20px; height: 20px; margin: 0; accent-color: var(--bad); }
.nothing { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 36px; border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); }
.nothing .ic { width: 34px; height: 34px; color: var(--ok); }
.nothing h1, .nothing h2 { font-size: 34px; line-height: 1.1; }
.nothing p { color: var(--ink-2); }

@media (max-width: 899px) {
.bar, main { padding-left: 16px; padding-right: 16px; }
.bar { gap: 10px; padding-top: 14px; padding-bottom: 14px; }
.brand { gap: 8px; font-size: 21px; }
.mark { width: 30px; height: 30px; border-radius: 9px; }
.tag { padding: 0 10px; font-size: 12px; }
.out { font-size: 13px; }
main { gap: 14px; padding-bottom: 32px; }
.head { gap: 12px; }
.head h1 { font-size: 38px; }
.tabs { width: 100%; border-radius: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs { padding: 4px; gap: 0; }
.tabs a { flex: auto; justify-content: center; padding: 0 7px; gap: 4px; font-size: 13px; white-space: nowrap; }
.item { grid-template-columns: 54px minmax(0, 1fr) 20px; gap: 4px 14px; padding: 14px; }
.item .m { grid-column: 2; }
.item .v, .item .w { grid-column: 2; }
.item .w { flex-direction: row; flex-wrap: wrap; align-items: center; }
.item > i { grid-column: 3; grid-row: 1; }
.card { padding: 16px; }
.card .top { grid-template-columns: 54px minmax(0, 1fr); gap: 6px 14px; }
.card .v, .card .open { grid-column: 2; }
.track { gap: 5px; }
.track li { flex: auto; gap: 5px; padding: 9px 8px; font-size: 12px; }
.track .ic { width: 14px; height: 14px; }
.foot .btn.small, .foot form { width: 100%; }
.grid { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.hero { gap: 16px; padding: 18px; }
.hero .top { flex-wrap: wrap; gap: 8px 14px; }
.hero h1, .title-field .big .in { font-size: 26px; }
.tiles { gap: 8px; }
.tile { padding: 14px; }
.tile.old s, .big .in { font-size: 30px; }
.big .in.long { font-size: 19px; }
.tile .big { gap: 6px; }
.two { grid-template-columns: 1fr; }
.row { gap: 12px; padding: 10px 8px 10px 14px; flex-wrap: wrap; }
.row .m { flex: 1 1 60%; }
.row .open, .row .opens { order: 9; width: 100%; padding-left: 52px; margin-top: -8px; }
.row .opens .open { padding-left: 0; margin: 0; }
.side { position: static; padding: 22px 18px; }
.notice { flex-wrap: wrap; padding: 12px 16px; }
.notice span { flex: 1; }
.notice a { margin-left: 30px; }
}
76 changes: 76 additions & 0 deletions service/assets/review/review.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Corrections are marked as they are typed. Without this script the form still works.
const form = document.querySelector('[data-form]');
if (form !== null) {
const save = form.querySelector('[data-save]');

const controls = (field) => [...field.querySelectorAll('[name]')];
const values = (field) =>
controls(field)
.filter((control) => control.type !== 'checkbox' || control.checked)
.map((control) => control.value.trim())
.filter(Boolean);
const text = (list) => JSON.stringify([...list].sort());
const received = (field) => JSON.parse(field.querySelector('[data-received]').dataset.received);
const start = new Map([...form.querySelectorAll('[data-edit]')].map((field) => [field, text(values(field))]));

const refresh = () => {
let touched = false;
for (const [field, opened] of start) {
const now = text(values(field));
const changed = now !== text(received(field).map((value) => value.trim()));
const was = field.querySelector('.was');
field.classList.toggle('changed', changed);
was.hidden = !changed;
was.querySelector('[data-restore]').hidden = false;
touched ||= now !== opened;
}
save.hidden = !touched;
};

const tick = (field, code, on) => {
const box = controls(field).find((control) => control.value === code);
if (box !== undefined) box.checked = on;
};

form.addEventListener('input', refresh);
form.addEventListener('click', (event) => {
const button = event.target.closest('[data-restore]');
if (button === null) return;

const field = button.closest('[data-edit]');
const back = received(field);
for (const control of controls(field)) {
if (control.type === 'checkbox') control.checked = back.includes(control.value);
else control.value = back[0] ?? '';
}
refresh();
controls(field)[0]?.focus();
});

form.querySelector('[data-add-country]')?.addEventListener('change', (event) => {
const select = event.target;
const { value, selectedOptions } = select;
if (value === '') return;

const field = select.closest('[data-edit]');
if (controls(field).some((control) => control.value === value)) {
tick(field, value, true);
} else {
const pill = document.createElement('label');
pill.className = 'pill';
const box = Object.assign(document.createElement('input'), { type: 'checkbox', name: 'countries', value, checked: true });
const flag = Object.assign(document.createElement('img'), { src: selectedOptions[0].dataset.flag, alt: '', width: 22, height: 22 });
pill.append(box, flag, selectedOptions[0].textContent);
select.before(pill);
}
select.value = '';
refresh();
});

// Enter in a field must not send the contribution by accident.
form.addEventListener('keydown', (event) => {
if (event.key === 'Enter' && event.target.matches('input:not([type="checkbox"]):not([type="radio"])')) event.preventDefault();
});

refresh();
}
Loading
Loading