Compare commits

...
12 Commits
Author SHA1 Message Date
Bendik Aagaard Lynghaug c8901558b2 Release 0.6.10
Test / test (push) Successful in 1m18s
Publish release / publish (push) Successful in 2m1s
2026-09-30 21:52:28 +02:00
Bendik Aagaard LynghaugandClaude Opus 5.5 02c94ae5dc Changelog: 0.6.10
docs / deploy (push) Successful in 2s
Test / test (push) Successful in 1m11s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GT37Z1Xtfd9pUuQtMTg6Yt
2026-09-30 21:52:25 +02:00
bl 5fc29fe5a6 Merge pull request 'Who we are, on its own page; inside forms ask real questions' (#19) from present-yourself into main
docs / deploy (push) Successful in 3s
Test / test (push) Successful in 1m10s
2026-09-30 19:52:24 +00:00
Bendik Aagaard LynghaugandClaude Opus 5.5 e6c4f67db7 Who a business is gets a page of its own; inside forms ask real questions; build names untried needs
Test / test (pull_request) Successful in 1m12s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GT37Z1Xtfd9pUuQtMTg6Yt
2026-09-30 21:52:23 +02:00
Bendik Aagaard Lynghaug 19b7750292 Release 0.6.9
Test / test (push) Successful in 1m8s
Publish release / publish (push) Successful in 1m54s
2026-09-30 21:38:59 +02:00
Bendik Aagaard LynghaugandClaude Opus 5.5 1a1723f8bb Changelog: 0.6.9
docs / deploy (push) Successful in 3s
Test / test (push) Successful in 1m9s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GT37Z1Xtfd9pUuQtMTg6Yt
2026-09-30 21:38:56 +02:00
bl 0d67675456 Merge pull request 'A bio is markdown, on stricter rules' (#18) from bio-markdown into main
docs / deploy (push) Successful in 3s
Test / test (push) Successful in 1m8s
2026-09-30 19:38:55 +00:00
Bendik Aagaard LynghaugandClaude Opus 5.5 eb982ec6e6 A bio is markdown, on stricter rules than the site's own
Test / test (pull_request) Successful in 1m9s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GT37Z1Xtfd9pUuQtMTg6Yt
2026-09-30 21:38:54 +02:00
Bendik Aagaard Lynghaug c6dffc384c Release 0.6.8
Test / test (push) Successful in 1m9s
Publish release / publish (push) Successful in 2m0s
2026-09-30 21:08:33 +02:00
Bendik Aagaard LynghaugandClaude Opus 5.5 db0972974f Changelog: 0.6.8
docs / deploy (push) Successful in 4s
Test / test (push) Successful in 1m17s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GT37Z1Xtfd9pUuQtMTg6Yt
2026-09-30 21:08:30 +02:00
bl 72faf44559 Merge pull request 'An upload that did not arrive says why' (#17) from upload-messages into main
docs / deploy (push) Successful in 3s
Test / test (push) Successful in 1m16s
2026-09-30 19:08:30 +00:00
Bendik Aagaard LynghaugandClaude Opus 5.5 db89ea6400 An upload that did not arrive says why
Test / test (pull_request) Successful in 1m21s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GT37Z1Xtfd9pUuQtMTg6Yt
2026-09-30 21:08:28 +02:00
13 changed files with 455 additions and 73 deletions
+15
View File
@@ -4,6 +4,21 @@ One line per change, grouped by the release that shipped it. Newest
first. A release is a Cargo.toml bump plus a `v<version>` tag; the
content repos pin the tag they run (see the end of this file).
## 0.6.10 (2026-09-30)
- Trainer: who a business is gets a page of its own ("who are we?", `/hvem` in Norwegian), with nothing to do on it. It has one card per need that `presents` (the people, the work, each shown as picture cards) and one for the plan's `values`. The front door leads there instead of carrying it all.
- Trainer: the words model is told that a form page from the inside asks a real question and says where the answer ends up ("How do you present yourself?", not "Your card on the front page"), and that a `one_per_person` form is the colleague's own.
- Trainer: `portal build` names every need no persona tries. Klingenberg Bygg's plan had personas only for customers, so nobody ever played the office filling in its own forms.
- Klingenberg Bygg: "Hvem består Klingenberg Bygg av?" with Menneskene, Erfaringer (projects with pictures, added from the office) and Verdier (a first draft for Fredrik to replace).
## 0.6.9 (2026-09-30)
- What a person wrote on a card (a bio) is shown as markdown: paragraphs, line breaks as typed, lists, emphasis, and links to https, mailto or tel marked `rel="nofollow ugc"`. No images and no raw HTML, which is stricter than the site's own descriptions. The desk still shows the text as written.
## 0.6.8 (2026-09-30)
- An upload that did not arrive says why: larger than 20 MB (checked in the browser before anything is sent), a site that takes no files (no Garage configured), not allowed from here, or anything else. It used to say "try again, or with a smaller file" whatever the reason, which sent people looking for a smaller file when the site had no storage at all.
## 0.6.7 (2026-09-30)
- `leaves_after: { minutes: 10 }` on a state: a record that has been there that long leaves its bucket's lists (days, hours and minutes add up; swept every minute; the event log keeps it). Trainer: `leaves_after` per stage on a need. A Klingenberg Bygg card taken off the front page leaves the office's list ten minutes later instead of standing there greyed out.
Generated
+1 -1
View File
@@ -3357,7 +3357,7 @@ dependencies = [
[[package]]
name = "portal"
version = "0.6.7"
version = "0.6.10"
dependencies = [
"anyhow",
"arc-swap",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "portal"
version = "0.6.7"
version = "0.6.10"
edition = "2021"
[lib]
+4 -1
View File
@@ -275,7 +275,10 @@ time. The cards appear in the order the records were put up. That is
how a site shows the people who work there, or a gallery of what it
has built. On a desk, the same picture is a thumbnail that opens.
`accept: image/jpeg,image/png,image/webp` on the field makes a phone
send a JPEG whatever it keeps its photos as.
send a JPEG whatever it keeps its photos as. What the person wrote is shown as
markdown on stricter rules than the site's own: paragraphs, line
breaks as typed, lists, emphasis and links to https, mailto or tel
(marked `nofollow ugc`); no images, no raw HTML.
`states` and `where` narrow a listing. They matter most for a register
that is public by law — public about what was decided, not about what
+37 -9
View File
@@ -38,16 +38,18 @@ does:
godkjenning innen flere fagområder. Når tilbudet er godtatt,
følger du oppdraget og henter dokumentene innlogget.
# Hvem vi er: erfaringen, i våre egne ord, og menneskene. Verdiene
# skriver Fredrik selv; de legges inn her som en `values`-linje til.
# Hvem vi er: en egen side med menneskene, erfaringene (oppdrag med
# bilder, lagt inn fra kontoret) og verdiene under. Verdiene er et
# utkast i husets tone; Fredrik bytter dem ut når han vil.
values:
- id: erfaring
text: >
Skoler i drift, brannstasjoner, omsorgsboliger, kantina på Det
Norske Teatret og en Munch-eiendom på Hvitsten. Vi har gått over,
prosjektert og fulgt opp bygg for kommuner, borettslag, bedrifter
og private, fra borprøver i gammel mur til kunstgress på
Fredrikstad stasjon.
- id: mal-to-ganger
text: Vi måler to ganger og skriver én gang. Det gjelder betong, og det gjelder rapporter.
- id: bygget-forst
text: Et bygg bryr seg ikke om hvem som har rett. Vi skriver det bygget trenger, ikke det som er lettest å si.
- id: ingen-overraskelser
text: Det vi finner, får du vite. Også sprekkene.
- id: vannet
text: Vannet finner alltid en vei. Derfor leter vi etter den først.
needs:
- id: tilstand
@@ -170,6 +172,27 @@ needs:
- { name: erfaring, type: textarea }
- { name: portrett, type: picture }
# Erfaringene: oppdrag vi vil vise fram, med bilde og noen løse ord.
- id: erfaring
who: en av oss på kontoret, når et oppdrag er verdt å vise fram
wants: at den som vurderer oss ser hva vi har gjort
enters_as: kontor
lands_in: erfaringer
handled_by: kontor
watched_by: [public]
presents: true
public_states: [open]
stages: [open, fjernet]
stages_text: { open: "vises", fjernet: "fjernet" }
done_when: [fjernet]
success: [fjernet]
leaves_after: { fjernet: { minutes: 10 } }
max_fields: 3
collects:
- { name: tittel }
- { name: bilde, type: picture }
- { name: om, type: textarea }
personas:
- { id: kommune-skole, need: tilstand, text: "Vi i kommunen skal legge fram en sak om rehabilitering av en barneskole fra 1972 og trenger en tilstandsanalyse politikerne kan beslutte ut fra." }
- { id: borettslag, need: tilstand, text: "Styret i borettslaget lurer på hva som haster mest av tak, fasade og rør. Vi trenger noen som kan gå over byggene og si hva det står til." }
@@ -178,6 +201,11 @@ personas:
- { id: skole-i-drift, need: prosjekt, text: "Skolen skal utvides mens den er i drift. Vi trenger en beskrivelse og en fremdriftsplan med byggetrinn." }
- { id: soke-garasje, need: soknad, text: "Tegningene til garasjen er ferdige, men jeg aner ikke hvordan jeg søker kommunen. Kan dere ta søknaden?" }
- { id: ansvarsrett, need: soknad, text: "Vi har prosjektert ombyggingen selv, men mangler noen med ansvarsrett som kan stå for søknaden." }
# Innenfra: det kontoret selv fyller ut.
- { id: rapport-klar, need: leveranse, text: "Tilstandsrapporten til borettslaget er ferdig. Jeg vil at styreleder skal få den og vite at den ligger der." }
- { id: ny-hos-oss, need: ansatt, text: "Jeg har nettopp begynt hos Klingenberg Bygg og vil at kundene skal se hvem jeg er og hva jeg kan." }
- { id: nytt-portrett, need: ansatt, text: "Portrettet mitt på forsiden er fra da jeg begynte. Jeg vil bytte det uten å skrive alt det andre på nytt." }
- { id: brannstasjonen, need: erfaring, text: "Brannstasjonen i Ytre Enebakk står ferdig, og vi har gode bilder fra fundamenteringen. Den vil jeg vise fram." }
slideshow:
max_height: 60
+118 -22
View File
@@ -115,20 +115,8 @@
},
"who": {
"heading": "Hvem består Klingenberg Bygg av?",
"description": "Mennesker, verdier og erfaringer.",
"items": {
"erfaring": {
"heading": "Erfaringene",
"description": "Skoler i drift, brannstasjoner, omsorgsboliger, kantina på Det Norske Teatret og en Munch-eiendom på Hvitsten. Vi har gått over, prosjektert og fulgt opp bygg for kommuner, borettslag, bedrifter og private, fra borprøver i gammel mur til kunstgress på Fredrikstad stasjon.",
"icon": "award"
},
"people-ansatte": {
"heading": "Menneskene",
"description": "De som går befaringene, skriver rapportene og står for søknadene.",
"empty": "Snart presenterer vi oss her.",
"icon": "users"
}
}
"description": "Mennesker, erfaringer og verdier.",
"button": "Bli kjent med oss"
}
},
"questions/received/tilstand.yaml": {
@@ -264,6 +252,15 @@
},
"list_title": "Ansatte",
"list_note": "Hver rad er én person på forsiden."
},
"erfaringer": {
"heading": "Erfaringer",
"description": "Oppdragene slik besøkende ser dem.",
"moves": {
"open->fjernet": "Fjern"
},
"list_title": "Erfaringer",
"list_note": "Hver rad er ett oppdrag som vises nå."
}
},
"links": {
@@ -273,8 +270,13 @@
"button": "Ny leveranse"
},
"ansatt": {
"heading": "Ditt kort på forsiden",
"description": "Rolle, erfaring og portrett, slik besøkende ser deg.",
"heading": "Hvordan presenterer du deg?",
"description": "Kortet ditt på forsiden: rolle, erfaring og portrett.",
"button": "Åpne"
},
"erfaring": {
"heading": "Hvilket oppdrag vil du vise fram?",
"description": "Et bilde og noen løse ord, blant erfaringene.",
"button": "Åpne"
}
},
@@ -474,7 +476,7 @@
"question": "Kortet ditt er lagret",
"description": "Slik står du nå på forsiden.",
"next_heading": "Vil du endre noe?",
"next_description": "Åpne «Ditt kort på forsiden» igjen: det er fylt ut med det du har, og det du lagrer erstatter det.",
"next_description": "Åpne «Hvordan presenterer du deg?» igjen: kortet ditt er fylt ut med det du har, og det du lagrer erstatter det.",
"see_all": {
"heading": "Se alle ansatte",
"description": "",
@@ -482,8 +484,8 @@
}
},
"questions/kontor/ansatt.yaml": {
"heading": "Ditt kort på forsiden",
"description": "Slik står du blant menneskene på forsiden. Rett det du vil og lagre; du har ett kort, og det nye erstatter det gamle.",
"heading": "Kortet ditt",
"description": "Rett det du vil og lagre. Du har ett kort, og det du lagrer erstatter det som står der nå.",
"button": "Lagre kortet",
"encouragement": "",
"icon": "id-card",
@@ -507,11 +509,11 @@
"hints": {
"name": "",
"rolle": "For eksempel daglig leder, rådgivende ingeniør",
"erfaring": "Utdanning, fagområder, år i faget, bygg du er stolt av",
"erfaring": "Utdanning, fagområder, bygg du er stolt av. Du kan skrive **fet**, *kursiv*, lister med - og [lenker](https://…).",
"portrett": "Et stående bilde, gjerne tatt i dagslys. Velger du ikke noe nytt, beholder du det du har."
},
"question": "Ditt kort på forsiden",
"page_description": "Det du skriver her, står under portrettet ditt på forsiden."
"question": "Hvordan presenterer du deg?",
"page_description": "Det du skriver her, står på kortet ditt blant menneskene på forsiden."
},
"questions/status/ansatte/index.yaml": {
"question": "Hvem består Klingenberg Bygg av?",
@@ -522,5 +524,99 @@
"list_note": "",
"empty": "Snart presenterer vi oss her.",
"answer": ""
},
"questions/hvem.yaml": {
"question": "Hvem består Klingenberg Bygg av?",
"description": "Menneskene som gjør jobben, oppdragene vi har gjort, og det vi står for.",
"presents": {
"ansatte": {
"heading": "Menneskene",
"description": "De som går befaringene, skriver rapportene og står for søknadene.",
"empty": "Snart presenterer vi oss her."
},
"erfaringer": {
"heading": "Erfaringer",
"description": "Et utvalg oppdrag, med bilder.",
"empty": "Snart viser vi fram oppdrag her."
}
},
"values": {
"heading": "Verdier",
"description": "Det vi står for.",
"items": {
"mal-to-ganger": {
"heading": "Mål to ganger",
"description": "Vi måler to ganger og skriver én gang. Det gjelder betong, og det gjelder rapporter.",
"icon": "ruler"
},
"bygget-forst": {
"heading": "Bygget først",
"description": "Et bygg bryr seg ikke om hvem som har rett. Vi skriver det bygget trenger, ikke det som er lettest å si.",
"icon": "building"
},
"ingen-overraskelser": {
"heading": "Ingen overraskelser i veggen",
"description": "Det vi finner, får du vite. Også sprekkene.",
"icon": "search"
},
"vannet": {
"heading": "Vannet finner en vei",
"description": "Vannet finner alltid en vei. Derfor leter vi etter den først.",
"icon": "droplet"
}
}
}
},
"questions/kontor/erfaring.yaml": {
"heading": "Et oppdrag med bilde",
"description": "Et bilde og noen løse ord om hva vi gjorde. Det vises med en gang.",
"button": "Vis fram",
"encouragement": "",
"icon": "image-plus",
"paused": "",
"requires_title": "",
"requires_description": "",
"requires_icon": "",
"road_title": "Når du sender",
"road_description": "Oppdraget vises blant erfaringene med en gang, til noen på kontoret fjerner det.",
"road_icon": "route",
"who_title": "Hvem ser det",
"who_description": "Alle som besøker siden. Skriv ikke noe om kunden de ikke ville lest selv.",
"who_icon": "users",
"form_title": "Oppdraget",
"form_description": "",
"labels": {
"tittel": "Hva var det?",
"bilde": "Bilde",
"om": "Noen ord om det"
},
"hints": {
"tittel": "For eksempel: Brannstasjonen i Ytre Enebakk",
"bilde": "Et bilde fra oppdraget, gjerne liggende",
"om": "Hva vi gjorde, og hva som var verdt å gjøre skikkelig. **Fet**, *kursiv*, lister og lenker går an."
},
"question": "Hvilket oppdrag vil du vise fram?",
"page_description": "Det du legger inn her, står blant erfaringene på «Hvem består Klingenberg Bygg av?»."
},
"questions/kontor/erfaring-sent.yaml": {
"question": "Oppdraget vises nå",
"description": "Det står blant erfaringene på «Hvem består Klingenberg Bygg av?».",
"next_heading": "Skal det ned igjen?",
"next_description": "Trykk «Fjern» på raden i listen over erfaringer her på kontoret. Det forsvinner fra listen ti minutter etter.",
"see_all": {
"heading": "Se alle erfaringer",
"description": "",
"button": "Åpne"
}
},
"questions/status/erfaringer/index.yaml": {
"question": "Hva har Klingenberg Bygg gjort?",
"description": "Et utvalg oppdrag, med bilder.",
"heading": "Erfaringer",
"list_description": "",
"list_title": "Erfaringer",
"list_note": "",
"empty": "Snart viser vi fram oppdrag her.",
"answer": ""
}
}
+47 -2
View File
@@ -1310,6 +1310,12 @@ fn AlternativeCard(
};
let Some(files) = input.files() else { continue };
let Some(file) = files.get(0) else { continue };
// Too big is known before a byte is sent.
if file.size() > MAX_UPLOAD_BYTES as f64 {
send_error.set(Some(t(&lang().get_untracked(), "upload_too_large").to_string()));
sending.set(false);
return;
}
match upload_file(&file, &question_id_for_submit, &alt_name_for_submit).await {
Ok(key) => {
map.insert(name.clone(), serde_json::Value::String(key));
@@ -1319,7 +1325,8 @@ fn AlternativeCard(
// say so.
Err(e) => {
leptos::logging::error!("upload of {name} failed: {e:?}");
send_error.set(Some(t(&lang().get_untracked(), "upload_failed").to_string()));
let status = e.as_string().and_then(|m| m.rsplit(' ').next().and_then(|n| n.parse().ok()));
send_error.set(Some(t(&lang().get_untracked(), upload_refusal(status)).to_string()));
sending.set(false);
return;
}
@@ -2283,6 +2290,24 @@ pub fn uploaded_filename(value: &str) -> Option<&str> {
rest.strip_prefix('-').filter(|name| shaped && !name.is_empty())
}
/// The largest file one upload may carry. Here, not in `upload.rs`,
/// so the browser checks the same number before it sends anything.
pub const MAX_UPLOAD_BYTES: usize = 20 * 1024 * 1024;
/// Why an upload did not arrive, in words a person can act on, from
/// the status `POST /upload` answered with (see `upload.rs`): too big,
/// a site that takes no files, a page they may not send from, or
/// anything else.
#[cfg_attr(not(feature = "hydrate"), allow(dead_code))]
fn upload_refusal(status: Option<u16>) -> &'static str {
match status {
Some(413) => "upload_too_large",
Some(503) => "upload_unavailable",
Some(403) => "upload_forbidden",
_ => "upload_failed",
}
}
/// What a refused server call says, without the wrapping a person
/// has no use for.
fn server_message(e: &ServerFnError) -> String {
@@ -2528,7 +2553,12 @@ fn AnswerCard(answer: Answer, picture: String, link: Option<RowLink>) -> impl In
<img class="answer-picture" src=picture alt=heading.clone() loading="lazy" />
<div class="answer-card-text">
<h4 class="answer-card-heading">{heading}</h4>
{rest.into_iter().map(|t| view! { <p>{t}</p> }).collect_view()}
// What the person wrote, as they wrote it: markdown, on
// the stricter rules for text that is not the site's.
{rest
.into_iter()
.map(|t| view! { <div class="card-field" inner_html=crate::content::render_written_markdown(&t)></div> })
.collect_view()}
</div>
{link.map(|(href, label)| view! { <a class="answer-link" href=href>{label}</a> })}
</article>
@@ -3241,6 +3271,21 @@ mod responsible_tests {
mod picture_tests {
use super::*;
#[test]
fn an_upload_refusal_says_which_it_was() {
assert_eq!(upload_refusal(Some(413)), "upload_too_large");
assert_eq!(upload_refusal(Some(503)), "upload_unavailable");
assert_eq!(upload_refusal(Some(403)), "upload_forbidden");
assert_eq!(upload_refusal(Some(502)), "upload_failed");
assert_eq!(upload_refusal(None), "upload_failed");
for lang in ["en", "no"] {
for status in [Some(413), Some(503), Some(403), None] {
let key = upload_refusal(status);
assert_ne!(crate::i18n::t(lang, key), key, "{lang} has words for {key}");
}
}
}
#[test]
fn a_record_with_a_picture_is_shown_by_it() {
assert!(is_picture("Portrett.JPG") && is_picture("a.webp") && !is_picture("rapport.pdf"));
+64
View File
@@ -118,3 +118,67 @@ pub(crate) fn rewrite_img_tag(tag: &str) -> String {
cleaned.replacen("<img", &format!("<img{attrs}"), 1)
}
/// Markdown that a person wrote into a record - a bio on a card - as
/// opposed to the site's own content. Paragraphs, line breaks as they
/// were typed, lists, emphasis and links; no images (a picture has its
/// own field, and an image in text is a way to load something from
/// elsewhere into every visitor's page), no raw HTML, headings as plain
/// paragraphs. Links go to https, mailto or tel only, and say they are
/// the writer's, not the site's (`rel="nofollow ugc"`).
pub fn render_written_markdown(text: &str) -> String {
use pulldown_cmark::{html, Event, Options, Parser, Tag, TagEnd};
let parser = Parser::new_ext(text, Options::ENABLE_STRIKETHROUGH);
let mut in_dropped_link = 0usize;
let mut in_image = 0usize;
let filtered = parser.filter_map(|event| match event {
Event::Html(_) | Event::InlineHtml(_) => None,
Event::Start(Tag::Image { .. }) => {
in_image += 1;
None
}
Event::End(TagEnd::Image) => {
in_image = in_image.saturating_sub(1);
None
}
_ if in_image > 0 => None,
Event::Start(Tag::Heading { .. }) => Some(Event::Start(Tag::Paragraph)),
Event::End(TagEnd::Heading(_)) => Some(Event::End(TagEnd::Paragraph)),
// What someone typed on a new line is on a new line.
Event::SoftBreak => Some(Event::HardBreak),
Event::Start(Tag::Link { dest_url, .. })
if !(dest_url.starts_with("https://") || dest_url.starts_with("mailto:") || dest_url.starts_with("tel:")) =>
{
in_dropped_link += 1;
None
}
Event::End(TagEnd::Link) if in_dropped_link > 0 => {
in_dropped_link -= 1;
None
}
other => Some(other),
});
let mut out = String::new();
html::push_html(&mut out, filtered);
out.trim().replace("<a href=", "<a rel=\"nofollow ugc\" href=")
}
#[cfg(test)]
mod written_tests {
use super::render_written_markdown as md;
#[test]
fn a_bio_keeps_what_a_person_would_write_and_nothing_that_reaches_out() {
assert_eq!(md("Line one\nline two"), "<p>Line one<br />\nline two</p>");
assert!(md("- NS 3424\n- NS 3423").contains("<ul>\n<li>NS 3424</li>"));
assert!(md("**Sivilingeniør**, *NTNU*").contains("<strong>Sivilingeniør</strong>, <em>NTNU</em>"));
assert_eq!(md("[Westra](https://westra.no)"), "<p><a rel=\"nofollow ugc\" href=\"https://westra.no\">Westra</a></p>");
// Everything that would put something else in the page is gone.
assert_eq!(md("<script>alert(1)</script>"), "");
assert_eq!(md("hi <img src=x onerror=alert(1)>"), "<p>hi </p>");
assert_eq!(md("[click](javascript:alert(1))"), "<p>click</p>");
assert_eq!(md("[home](/kontor)"), "<p>home</p>", "a site path is the site's to link, not a bio's");
assert_eq!(md("before ![pixel](https://tracker.example/p.gif) after"), "<p>before after</p>");
assert_eq!(md("# Shouting"), "<p>Shouting</p>");
}
}
+11 -2
View File
@@ -24,7 +24,10 @@ fn lookup(lang: &str, key: &str) -> Option<&'static str> {
("en", "sign_in") => "Sign in",
("en", "sign_out") => "Sign out",
("en", "nothing_here_yet") => "Nothing here yet.",
("en", "upload_failed") => "The file could not be sent, so nothing was. Try again, or with a smaller file.",
("en", "upload_failed") => "The file did not arrive, so nothing was sent. Try again.",
("en", "upload_too_large") => "The file is larger than 20 MB, so nothing was sent. Choose a smaller one, or a picture taken at a lower resolution.",
("en", "upload_unavailable") => "This site cannot take files at the moment, so nothing was sent. Let whoever runs the site know.",
("en", "upload_forbidden") => "Files cannot be sent from here by you, so nothing was sent. Are you signed in?",
("en", "current_file") => "Now:",
("en", "keep_file") => "Choose a new one to replace it, or leave it as it is.",
("en", "nothing_here") => "Nothing here",
@@ -57,7 +60,10 @@ fn lookup(lang: &str, key: &str) -> Option<&'static str> {
("no", "sign_in") => "Logg inn",
("no", "sign_out") => "Logg ut",
("no", "nothing_here_yet") => "Ingenting her ennå.",
("no", "upload_failed") => "Filen kom ikke fram, så ingenting ble sendt. Prøv igjen, eller med en mindre fil.",
("no", "upload_failed") => "Filen kom ikke fram, så ingenting ble sendt. Prøv igjen.",
("no", "upload_too_large") => "Filen er større enn 20 MB, så ingenting ble sendt. Velg en mindre fil, eller et bilde med lavere oppløsning.",
("no", "upload_unavailable") => "Siden kan ikke ta imot filer akkurat nå, så ingenting ble sendt. Si fra til den som har siden.",
("no", "upload_forbidden") => "Du kan ikke sende filer herfra, så ingenting ble sendt. Er du logget inn?",
("no", "current_file") => "Nå:",
("no", "keep_file") => "Velg en ny for å bytte, eller la den være.",
("no", "nothing_here") => "Ingenting her",
@@ -109,6 +115,9 @@ mod tests {
"sign_out",
"nothing_here_yet",
"upload_failed",
"upload_too_large",
"upload_unavailable",
"upload_forbidden",
"current_file",
"keep_file",
"nothing_here",
+120 -23
View File
@@ -1177,21 +1177,31 @@ pub fn fallback_words(plan: &Plan) -> BTreeMap<String, Value> {
}),
);
}
if has_who_page(plan) {
words.insert(
who_page_path(plan),
json!({
"question": loc(lang, "Who are we?", "Hvem er vi?"),
"description": "",
"presents": presenting_buckets(plan).into_iter().map(|b| (b.to_string(), json!({
"heading": humanize(b), "description": "", "empty": loc(lang, "Nothing here yet.", "Ingenting her ennå."),
}))).collect::<Map<String, Value>>(),
"values": {
"heading": loc(lang, "What we stand for", "Det vi står for"),
"description": "",
"items": plan.values.iter().map(|v| (v.id.clone(), json!({ "heading": humanize(&v.id), "description": v.text, "icon": "" }))).collect::<Map<String, Value>>(),
},
}),
);
}
words.insert(
"questions/index.yaml".to_string(),
json!({
"question": "What brings you here?",
"description": plan.about,
"opener": { "heading": "What we do", "description": "", "features": does },
"who": {
"heading": loc(lang, "Who we are", "Hvem vi er"),
"description": "",
"items": plan.values.iter().map(|v| (v.id.clone(), json!({ "heading": humanize(&v.id), "description": v.text, "icon": "" })))
.chain(public_buckets(plan).into_iter().filter(|(_, n)| n.iter().any(|n| n.presents)).map(|(bucket, _)| (format!("people-{bucket}"), json!({
"heading": humanize(bucket), "description": "", "empty": loc(lang, "Nothing here yet.", "Ingenting her ennå."), "icon": "",
}))))
.collect::<Map<String, Value>>(),
},
// The way to the page about who the business is.
"who": { "heading": loc(lang, "Who we are", "Hvem vi er"), "description": "", "button": loc(lang, "Meet us", "Bli kjent med oss") },
// Named for what it shows, never an invitation to look.
"shopping": { "heading": format!("{} {}", loc(lang, "Latest from", "Siste fra"), plan.business), "description": "", "items": shopping },
// A door's feature says what is behind it, from the needs
@@ -2115,20 +2125,14 @@ pub fn render(plan: &Plan, words: &BTreeMap<String, Value>) -> anyhow::Result<BT
.collect();
// A public list is shown, not pointed at: its newest few records
// inline, and a link to the whole list.
// Who the business is: its values in its own words, and every
// record of what it presents - the people - shown, not listed.
let mut who: Vec<Value> = plan.values.iter().map(|v| card(&front["who"]["items"][&v.id])).collect();
for (bucket, needs) in public_buckets(plan).into_iter().filter(|(_, n)| n.iter().any(|n| n.presents)) {
let w = &front["who"]["items"][&format!("people-{bucket}")];
let mut f = card(w);
f["resource"] = public_resource(bucket, &needs, s(&w["empty"]), None, "");
who.push(f);
}
if !who.is_empty() {
// Who the business is has a page of its own (see `who_page`);
// the front door only leads there.
if has_who_page(plan) {
alternatives.push(json!({
"name": text(&front["who"]["heading"]),
"description": text(&front["who"]["description"]),
"features": who,
"action": format!("/{}", who_page_id(plan)),
"consequence": button(&front["who"]["button"]),
}));
}
for (bucket, needs) in public_buckets(plan).into_iter().filter(|(_, n)| !n.iter().any(|n| n.presents)) {
@@ -2186,6 +2190,9 @@ pub fn render(plan: &Plan, words: &BTreeMap<String, Value>) -> anyhow::Result<BT
front_page["slideshow"] = slideshow.clone();
}
files.insert("questions/index.yaml".into(), front_page);
if has_who_page(plan) {
files.insert(who_page_path(plan), who_page(plan, words));
}
// A door's page: a nav page (index.yaml), public, holding the
// forms of the needs behind it.
@@ -2519,6 +2526,74 @@ pub fn render(plan: &Plan, words: &BTreeMap<String, Value>) -> anyhow::Result<BT
const DESK_PURPOSE: &str = "a desk: the page one role inside the business works from. Under `buckets`, each entry is a list of cases; `moves` are the buttons that move a case from one stage to the next (key `from->to`), so label each with what the person has just done. Under `links` are pages this role can open. Under `invites`, each entry is a form that invites a person into that group - they get an account and a one-time link - and `invited` is the list of invites sent, where `again` is the button that sends an invite whose link ran out once more. `suggestions`, on the desk that has it, is the list of changes the people responsible for a page have suggested: `looking`, `changed` and `declined` are its buttons.";
/// The page about who the business is: a question with nothing to do
/// on it, only things to read. One card per need that `presents` (the
/// people, the work), each showing every record as a card, and one for
/// the business's own statements (`values`), carried word for word.
fn who_page(plan: &Plan, words: &BTreeMap<String, Value>) -> Value {
let w = &words[&who_page_path(plan)];
let mut alternatives: Vec<Value> = Vec::new();
for (bucket, needs) in public_buckets(plan).into_iter().filter(|(_, n)| n.iter().any(|n| n.presents)) {
let pw = &w["presents"][bucket];
alternatives.push(json!({
"name": text(&pw["heading"]),
"description": text(&pw["description"]),
"features": [{ "name": "", "description": "", "resource": public_resource(bucket, &needs, s(&pw["empty"]), None, "") }],
}));
}
if !plan.values.is_empty() {
let vw = &w["values"];
alternatives.push(json!({
"name": text(&vw["heading"]),
"description": text(&vw["description"]),
"features": plan.values.iter().map(|v| {
let iw = &vw["items"][&v.id];
let mut f = json!({ "name": text(&iw["heading"]), "description": text(&iw["description"]) });
if let Some(icon) = icon_name(s(&iw["icon"])) {
f["icon"] = json!(icon);
}
f
}).collect::<Vec<_>>(),
}));
}
json!({
"name": text(&w["question"]),
"description": text(&w["description"]),
"responsible": { "name": plan.contact.name, "contact": plan.contact.email },
"alternatives": alternatives,
})
}
fn presenting_buckets(plan: &Plan) -> Vec<&str> {
public_buckets(plan).into_iter().filter(|(_, n)| n.iter().any(|n| n.presents)).map(|(b, _)| b).collect()
}
fn has_who_page(plan: &Plan) -> bool {
!plan.values.is_empty() || !presenting_buckets(plan).is_empty()
}
fn who_page_id(plan: &Plan) -> String {
loc(&plan.language, "who", "hvem")
}
fn who_page_path(plan: &Plan) -> String {
format!("questions/{}.yaml", who_page_id(plan))
}
/// The needs no persona tries, paused ones aside. A need nobody plays
/// is one whose page is only ever read for the first time by the
/// person it is for: the forms a business fills in from the inside
/// are the easy ones to forget, and where "is this my own card?" goes
/// unasked.
pub fn untried_needs(plan: &Plan) -> Vec<&str> {
plan.needs
.iter()
.filter(|n| !n.paused)
.filter(|n| !plan.personas.iter().any(|p| p.get("need").and_then(|v| v.as_str()) == Some(n.id.as_str())))
.map(|n| n.id.as_str())
.collect()
}
fn words_prompt(plan: &Plan, path: &str, fallback: &Value, tone: Option<&str>) -> String {
let voice = match tone {
Some(tone) => format!("\n\nTone of voice for every word on this page: {tone}. The site is told in more than one tone, each written in a pass of its own, so keep to this one throughout and do not hedge between tones."),
@@ -2543,20 +2618,33 @@ fn words_prompt(plan: &Plan, path: &str, fallback: &Value, tone: Option<&str>) -
if !own.is_empty() {
desk_purpose.push_str(&format!(" On this page, the list(s) {} show the signed-in person ONLY the cases they sent in themselves: they are following their own case, not working through other people's, so head those lists as theirs ('Your cases') and say nothing of a queue.", own.iter().map(|b| format!("`{b}`")).collect::<Vec<_>>().join(", ")));
}
// A form a role fills in from inside: its page still asks a
// question, the one the form answers, and says where the answer
// goes - a heading like "Your card on the front page" names a
// place, and the colleague reading it does not know what they are
// being asked.
let own_form = plan.needs.iter().find(|n| n.enters_as.as_deref().is_some_and(|g| path == format!("questions/{g}/{}.yaml", n.id)));
let mut inside_purpose = "a page only one role inside the business can open, holding one form. `question` is a real question, the one the form answers, asked of the colleague in their own terms (\"What has been delivered?\"), never a label or the name of a place; where their answer ends up - who sees it, on which page - belongs in `page_description`.".to_string();
if own_form.is_some_and(|n| n.one_per_person) {
inside_purpose.push_str(" This form is the colleague's own record, one each: it opens filled in with what they have, and saving replaces it, so ask about them (\"How do you present yourself?\"), say where it shows, and make the button save.");
}
// A form a role enters from inside is sent by a colleague at work,
// not by a visitor waiting on an answer.
let sent_purpose = match plan.needs.iter().find(|n| n.enters_as.as_deref().is_some_and(|g| path == format!("questions/{g}/{}-sent.yaml", n.id))) {
Some(n) => format!("a page shown right after someone in the group `{}` has sent a form from inside the business. The reader is that colleague, at work, not a visitor: nobody comes back to them. Say what has now happened to what they entered, and who it reaches.", n.enters_as.as_deref().unwrap_or_default()),
None => "a page shown right after someone has sent a form. Say who reads it, when they answer, and what happens next.".to_string(),
};
let purpose = if path == "site.yaml" {
let who_purpose = "the page about who the business is, with nothing to do on it, only things to read. `question` asks it as a question (\"Who are we?\"). Under `presents`, each entry heads one list shown as cards with a picture each - the people who work there, the work they have done - loosely, as a person would introduce them. `values` heads the business's own statements, which are its facts: head them, never add to them.".to_string();
let purpose = if path == who_page_path(plan) {
who_purpose.as_str()
} else if path == "site.yaml" {
"the invite mail: the first mail a person gets when a member of the business brings them in to help (onto a desk, into a committee), carrying the one-time link that lets them set a password. `subject` and `body` under `invite`. They did not ask for it, so say who brought them in and to what, then the link and when it runs out, then where they sign in afterwards. Plain text, short lines. Keep every `{...}` placeholder exactly as it is: `{name}`, `{username}`, `{group}`, `{link}`, `{expires}`, `{site}`, `{site_name}` are filled in by the site, and `{link}` must stay on a line of its own."
} else if path == "aggregates.yaml" {
"the mails the site sends. Under each bucket, each stage that sends one has a `subject` and a `body`: the mail a person gets the moment their case enters that stage, saying what happened and what, if anything, they can do now. Plain text, at most three short sentences plus the link line, no greeting longer than one word, in the business's voice. Keep every `{...}` placeholder exactly as it is - `{site}`, `{chain}`, `{email}` and any field name are filled in by the site - and keep any line with a link in it. The person reads the mail alone, days later, maybe among others, so what works is a mail that says what it is about in their terms - a field they filled in, as a `{placeholder}`, names their case far better than `this` or `your message` (each bucket's fields are listed under the needs above) - and ends with the business's name so they know who wrote. Short fields (a name, a place, a choice) make good subjects; a field marked `(long)` is a whole answer and a field marked `(optional)` may be blank, so those serve better elsewhere or not at all. A desk's decision carries no written reason, but a reply to the mail reaches the people who decided, so inviting a reply is the honest way to offer an explanation."
} else if path.contains("/decide/") {
"a page the person who sent a form reaches later, through a private link, to make a decision that is theirs: under `moves`, each entry is one thing they can decide."
} else if path == "questions/index.yaml" {
"the front door: the first page any visitor sees. `question` is the page's one question. It opens modestly: `opener` is the first card, what the business does in several features and no button at all - a stranger reads it and decides whether to trust the place, so say what is true and useful, not what to press. `shopping` is the second card: the site's live content, presented as it is - the latest records, a figure that matters, what has been built. It works best presented plainly: a heading that names what it shows ('Latest from the noticeboard', 'What we have built'), each item headed by its own content, `link` naming the full list. The content does the persuading; the card only has to label it, so it needs no invitation to look around and no word about forms. `who`, when there is one, is who the business is: its heading asks or names that plainly ('Who we are'), each item under it heads one of the business's own statements (values, experience) or the list of its people, and those statements are the business's facts - head them, never add to them. Only then come the offers: under `doors`, each entry is one alternative that leads to a page of its own for one kind of visitor, and its heading must let that visitor recognise themselves from the heading alone; under `needs`, each entry is one alternative with a form behind it."
"the front door: the first page any visitor sees. `question` is the page's one question. It opens modestly: `opener` is the first card, what the business does in several features and no button at all - a stranger reads it and decides whether to trust the place, so say what is true and useful, not what to press. `shopping` is the second card: the site's live content, presented as it is - the latest records, a figure that matters, what has been built. It works best presented plainly: a heading that names what it shows ('Latest from the noticeboard', 'What we have built'), each item headed by its own content, `link` naming the full list. The content does the persuading; the card only has to label it, so it needs no invitation to look around and no word about forms. `who`, when there is one, is a card that leads to the page about who the business is: its heading asks that plainly, and `button` goes there. Only then come the offers: under `doors`, each entry is one alternative that leads to a page of its own for one kind of visitor, and its heading must let that visitor recognise themselves from the heading alone; under `needs`, each entry is one alternative with a form behind it."
} else if path.starts_with("questions/status/") {
status_purpose.as_str()
} else if plan.doors.iter().any(|d| door_path(d) == path) {
@@ -2568,7 +2656,7 @@ fn words_prompt(plan: &Plan, path: &str, fallback: &Value, tone: Option<&str>) -
} else if path.contains("/received/") || path.ends_with("-sent.yaml") {
sent_purpose.as_str()
} else {
"a page only one role inside the business can open, holding one form."
inside_purpose.as_str()
};
let mut context: Vec<String> = plan
.doors
@@ -2689,6 +2777,9 @@ pub fn run(argv: &[String]) -> anyhow::Result<()> {
// The words as used, so the next rebuild can start from them.
std::fs::write(out.join("words.json"), serde_json::to_string_pretty(&words)?)?;
println!("content repo written to {}", out.display());
for need in untried_needs(&plan) {
eprintln!("note: no persona tries need {need:?}; nobody will find out whether its page reads right until a person does");
}
if let Some(lint) = value("--lint") {
let output = std::process::Command::new(&lint).arg("--path").arg(out.join("questions")).output().with_context(|| format!("running {lint}"))?;
@@ -3132,6 +3223,12 @@ mod tests {
assert!(bad.validate().unwrap_err().to_string().contains("multiple is for select"));
}
#[test]
fn a_need_no_persona_tries_is_named() {
let plan: Plan = serde_yaml::from_str("business: B\ncontact: { name: I, email: i@b.example }\nmail: { from: post@b.example }\nneeds:\n - id: ask\n who: a customer\n wants: an answer\n lands_in: asks\n handled_by: desk\n stages: [open, done]\n done_when: [done]\n max_fields: 2\n collects:\n - { name: email, type: email }\n - id: card\n who: one of us\n wants: to be seen\n enters_as: desk\n lands_in: cards\n handled_by: desk\n stages: [open, gone]\n done_when: [gone]\n max_fields: 1\n collects:\n - { name: name }\n - id: later\n who: someone\n wants: something\n paused: true\n lands_in: later\n handled_by: desk\n stages: [open, done]\n done_when: [done]\n max_fields: 1\n collects:\n - { name: email, type: email }\npersonas:\n - { id: p, need: ask, text: I need an answer }\n").unwrap();
assert_eq!(untried_needs(&plan), vec!["card"], "the inside need is untried; the paused one is not asked for");
}
#[test]
fn a_public_watcher_gets_a_read_only_page_without_contact_details() {
let yaml = "business: B\ncontact: { name: I, email: i@b.example }\nneeds:\n - id: traffic\n who: someone who saw a hazard\n wants: at det tas opp\n lands_in: meldinger\n handled_by: traffic\n stages: [open, fixed]\n done_when: [fixed]\n watched_by: [board, public]\n max_fields: 2\n collects:\n - { name: where }\n - { name: what, type: textarea }\n - { name: epost, type: email, optional: true }\n - { name: name, optional: true, private: true }\n";
+10 -7
View File
@@ -184,13 +184,16 @@ rest. Each is one line in the plan, and the builder does the wiring:
- **Carry a text word for word.** `documents` puts bylaws or terms on
a page of their own, one card per section, from a markdown file
beside the plan. Nothing rewords them.
- **Say who you are.** `values` are the business's own statements -
what it stands on, the experience behind it - carried word for word
into a "who we are" card on the front door. A need with `presents:
true` and `watched_by: [public]` puts its records in that card, all
of them, as cards: the people who work there, entered from inside
(`enters_as`), each with a `picture` field that shows as their
portrait.
- **Say who you are.** A need with `presents: true` and
`watched_by: [public]` (the people who work there, the work they
have done, each with a `picture` field) and `values` (the business's
own statements, carried word for word) make a page of their own,
"who are we?", with nothing to do on it: one card per presented list
and one for the values. The front door leads there.
- **Give every need someone to play it.** A persona per need,
including the ones a business fills in from the inside (a delivery,
a card on the front page): a page nobody plays is first read by the
person it is for. `portal build` names the needs no persona tries.
- **Let people keep their own.** `one_per_person: true` on a need
entered from inside gives each signed-in person one record there:
their own, which the form opens with and which sending again
+1 -1
View File
@@ -15,7 +15,7 @@ use serde::Serialize;
use crate::server::AppState;
pub const MAX_UPLOAD_BYTES: usize = 20 * 1024 * 1024;
pub const MAX_UPLOAD_BYTES: usize = crate::app::MAX_UPLOAD_BYTES;
#[derive(Clone)]
pub struct Garage {
+26 -4
View File
@@ -1300,14 +1300,36 @@ textarea:focus {
font-size: 1.05rem;
}
.answer-card-text p {
margin: 0;
.card-field {
font-size: 0.92rem;
color: var(--ink-dim);
white-space: pre-line;
}
.answer-card-text p:first-of-type {
.card-field > :first-child {
margin-top: 0;
}
.card-field > :last-child {
margin-bottom: 0;
}
.card-field p,
.card-field ul,
.card-field ol {
margin: 0 0 0.5em;
}
.card-field ul,
.card-field ol {
padding-left: 1.2em;
}
.card-field a {
color: var(--accent);
}
/* The field right under the name - a role - reads as part of the name. */
.answer-card-text .card-field:first-of-type {
color: var(--ink);
font-weight: 600;
}