Add announcements, and record when members last logged in

A single place to say "downloads work again" without messaging everyone.
The body is markdown, stored as typed and rendered on the way out, so a post
survives editing without a lossy round trip through HTML. goldmark drops raw
HTML rather than rendering it, which matters because the body reaches the
page through template.HTML with Go's own escaping switched off.

The front page carries the three newest under the queue, newest expanded,
and links to /news only when there is a fourth. News is decoration there: if
the query fails the queue still renders. Drafts exist so a post can be
written before it is sent, and hiding is the same toggle as publishing.

Ages read as "5 minuuttia sitten" for a week and then become a date, since
past that the exact age stops being the interesting part.

last_login_at is unrelated to the feed — it answers "does anyone actually
use this", and stays null until a real login, which is how an unused invite
shows up in the members table.

Ago and HTML take value receivers on purpose: templates reach them through
dict, which boxes the item in an interface, and a pointer method on a
non-addressable value is invisible there. That failure renders as a 500 and
is invisible to go vet, so TestFrontPageRendersNews renders the real page.
This commit is contained in:
Esa Kataja
2026-09-05 16:00:01 +03:00
parent 522827879b
commit deaadd2f5c
16 changed files with 635 additions and 39 deletions
+1
View File
@@ -3,6 +3,7 @@ module git.kessinen.com/kessinen/levyraati26-go
go 1.27.0
require (
github.com/yuin/goldmark v1.8.6
golang.org/x/crypto v0.32.0
modernc.org/sqlite v1.54.0
)