Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4784fd174 | ||
|
|
094ea5cdd8 | ||
|
|
f60758b770 | ||
|
|
9d390d021f | ||
|
|
18db79c063 | ||
|
|
1612f53966 | ||
|
|
4d5f1a56b1 | ||
|
|
274e392708 | ||
|
|
84ca506961 | ||
|
|
6db61b0cc7 | ||
|
|
57689ddfbb | ||
|
|
7770ba9844 | ||
|
|
55b8e438ad | ||
|
|
1607a22f0c | ||
|
|
8a5dfef41a | ||
|
|
1a610eaac4 | ||
|
|
c2d4ce0179 | ||
|
|
a1b8cc6ddc | ||
|
|
8a2c46f5ea | ||
|
|
8d42f34065 | ||
|
|
905ceebc06 | ||
|
|
87c557941a | ||
|
|
0e1e803486 | ||
|
|
1dc9751a33 | ||
|
|
b81f8f67cc | ||
|
|
f62ffc8d92 | ||
|
|
73ee93deab | ||
|
|
b2fcc0b104 | ||
|
|
8dc601d09a | ||
|
|
85e769a603 | ||
|
|
0363d5f422 | ||
|
|
05b7dac713 | ||
|
|
cfd382e3df | ||
|
|
bbcff40401 | ||
|
|
01001d0980 | ||
|
|
4ac7180cda | ||
|
|
e1683ef09d | ||
|
|
f89fb21502 | ||
|
|
ec147cd1ba | ||
|
|
1f9f14099b | ||
|
|
6cf63113df | ||
|
|
e24a0fa849 | ||
|
|
1c223a2c26 | ||
|
|
a9c90ee6f1 | ||
|
|
dc4a584d5f | ||
|
|
378980de0c | ||
|
|
04c7a52a5a | ||
|
|
52df528994 | ||
|
|
2f00246d6f | ||
|
|
acec77a20c | ||
|
|
59413a8b64 | ||
|
|
cf69cac410 | ||
|
|
b0998fe524 | ||
|
|
8dfab618f7 | ||
|
|
c0c1281415 | ||
|
|
247277e139 |
@@ -103,7 +103,7 @@ Apple Reminders, forward mail into it, and add it to Claude as a connector.
|
||||
| CalDAV server (two-way VTODO) | Done, tested |
|
||||
| Mail-to-task | Done, tested |
|
||||
| AI layer (Anthropic/OpenAI/Google/local) | Built, degrades when unconfigured |
|
||||
| Gmail: OAuth2 with PKCE, polling, one-way to tasks | Done, tested |
|
||||
| Gmail: OAuth2 with PKCE, polling to tasks, unstars what it imports | Done, tested |
|
||||
| Google Calendar: read-only, laid over the task calendar | Built, never run against Google |
|
||||
| Calendar subscriptions: ICS and webcal, several per person | Done, tested |
|
||||
| Times on tasks, set by dragging in the week grid | Done, tested |
|
||||
|
||||
@@ -80,6 +80,16 @@ func run() error {
|
||||
log.Info("notes sealed", "count", sealed)
|
||||
}
|
||||
|
||||
// Names created before the app capitalised them on the way in — "andreas"
|
||||
// rather than "Andreas". Idempotent, so it is a cheap pass of names once it has
|
||||
// caught up. A failure here does not stop the start: a lower-case first name is
|
||||
// a blemish, not a broken instance.
|
||||
if fixed, err := db.NormalizeUserNames(context.Background()); err != nil {
|
||||
log.Error("normalize user names", "err", err)
|
||||
} else if fixed > 0 {
|
||||
log.Info("user names normalized", "count", fixed)
|
||||
}
|
||||
|
||||
httpapi.Version = version
|
||||
api := httpapi.New(cfg, db, log, webAssets(log))
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ what a person reads is decided by the client, which knows what language they are
|
||||
curl -X POST https://todo.example.dk/api/v1/tasks/quick-add \
|
||||
-H "Authorization: Bearer vrd_..." \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"text": "betal moms i morgen kl 10 p1 #Firma @regnskab"}'
|
||||
-d '{"text": "file the VAT return tomorrow at 10am p1 #Accounts @tax"}'
|
||||
```
|
||||
|
||||
### Projects and sections
|
||||
@@ -108,7 +108,7 @@ curl -X POST https://todo.example.dk/api/v1/tasks/quick-add \
|
||||
| Method | Path | |
|
||||
|---|---|---|
|
||||
| `GET` | `/today` | Overdue and due today, in your timezone. |
|
||||
| `GET` | `/upcoming?days=7` | One entry per day, empty days included. |
|
||||
| `GET` | `/upcoming?days=7` | One entry per day, empty days included. Up to 31; over that is capped. |
|
||||
| `GET` | `/search?q=` | Across everything you can see. |
|
||||
| `GET` `POST` | `/filters` | |
|
||||
| `GET` | `/filters/{id}/tasks` | Run one. |
|
||||
|
||||
@@ -74,7 +74,7 @@ Then enable the APIs and scopes for whichever you want:
|
||||
|
||||
| For | Enable | Scope |
|
||||
|---|---|---|
|
||||
| Mailboxes | Gmail API | `gmail.readonly` |
|
||||
| Mailboxes | Gmail API | `gmail.modify` |
|
||||
| Calendar | Google Calendar API | `calendar.readonly` |
|
||||
|
||||
| Variable | What it does |
|
||||
|
||||
@@ -18,9 +18,10 @@ forward mail to, and an MCP endpoint so Claude can work your task list directly.
|
||||
|
||||
## What it does
|
||||
|
||||
- **[Quick add](quick-add.md) that reads what you type.** `betal moms i morgen kl
|
||||
10 p1 #Firma @regnskab` becomes a task due tomorrow at 10:00, priority 1, in
|
||||
Firma, labelled regnskab. Danish and English, mixed freely in one line.
|
||||
- **[Quick add](quick-add.md) that reads what you type.** `file the VAT return
|
||||
tomorrow at 10am p1 #Accounts @tax` becomes a task due tomorrow at 10:00,
|
||||
priority 1, in Accounts, labelled tax. Danish and English, mixed freely in one
|
||||
line.
|
||||
- **Projects, sections, sub-tasks, labels, [saved filters](filters.md).** List,
|
||||
board and calendar views, and foldable groups over the projects in the sidebar.
|
||||
The calendar draws each task to its length — drag the foot to resize, the body
|
||||
@@ -39,8 +40,17 @@ forward mail to, and an MCP endpoint so Claude can work your task list directly.
|
||||
- **Live sync** — a change made by somebody else appears without a refresh.
|
||||
- **Repeating tasks** as RRULE, comments and attachments, and reminders that go
|
||||
out as Web Push to an iPhone or a Mac.
|
||||
- **[Calendar](caldav.md), [mail](mail.md) and [Claude](mcp.md)** connected over
|
||||
open standards rather than private formats.
|
||||
- **[Your mail as an inbox](mailboxes.md).** Star a mail in Gmail, or flag one
|
||||
over IMAP in iCloud or Fastmail, and it becomes a task — and the star or flag
|
||||
comes off once it has, so a starred inbox empties as the tasks are made instead
|
||||
of only filling up.
|
||||
- **[Calendar](caldav.md) and [Claude](mcp.md)** connected over open standards
|
||||
rather than private formats.
|
||||
- **Six themes**, three dark and three light — including *Charcoal*, a warm
|
||||
near-black after Apple Notes — and a size and typeface chosen apart from them.
|
||||
- **Holds through a short network drop.** A save rides out a few seconds of no
|
||||
signal and goes through when it comes back; a reload opens from what it last saw
|
||||
rather than the browser's offline page. It installs as a PWA.
|
||||
|
||||
## What it looks like
|
||||
|
||||
@@ -60,6 +70,16 @@ columns.*
|
||||
marked with an arrow to them, so a delegated task reads as delegated wherever you
|
||||
meet it.*
|
||||
|
||||

|
||||
|
||||
*Charcoal, the newest of six themes — a warm near-black after Apple Notes, with
|
||||
amber where the accent green usually is.*
|
||||
|
||||

|
||||
|
||||
*Six themes — three dark, three light — chosen on the settings page, with the
|
||||
typeface and how tightly it sits set apart from them.*
|
||||
|
||||

|
||||
|
||||
*Where [Gmail](mailboxes.md), the [calendar feed](caldav.md) and the
|
||||
|
||||
@@ -57,9 +57,9 @@ Both endpoints run the same server and reach the same things.
|
||||
| `complete_task` | Tick one off. |
|
||||
| `add_comment` | Comment on a task. |
|
||||
|
||||
`create_task` prefers natural language, so *"add betal moms i morgen kl 10 p1
|
||||
#Firma"* goes through the same parser the app uses — dates, priorities, projects,
|
||||
labels and recurrence in either language.
|
||||
`create_task` prefers natural language, so *"add file the VAT return tomorrow at
|
||||
10am p1 #Accounts"* goes through the same parser the app uses — dates, priorities,
|
||||
projects, labels and recurrence in either language.
|
||||
|
||||
## What it can reach
|
||||
|
||||
|
||||
@@ -832,9 +832,9 @@ paths:
|
||||
tags: [tasks]
|
||||
summary: Create a task from one line of natural language.
|
||||
description: |
|
||||
Danish and English. `betal moms i morgen kl 10 p1 #Firma @vigtigt` becomes
|
||||
a task due tomorrow at 10:00, priority 1, in the project Firma, labelled
|
||||
vigtigt. An unknown `#project` is not an error — the task goes to the
|
||||
Danish and English. `file the VAT return tomorrow at 10am p1 #Accounts @tax`
|
||||
becomes a task due tomorrow at 10:00, priority 1, in the project Accounts,
|
||||
labelled tax. An unknown `#project` is not an error — the task goes to the
|
||||
Inbox rather than a thought being thrown away over a typo.
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -1250,7 +1250,7 @@ paths:
|
||||
|
||||
The one click that opens Google's consent screen already exists. What it
|
||||
needs behind it is a registered client, and no app can conjure one: Google
|
||||
issues no Gmail access to an unregistered client, and `gmail.readonly` is a
|
||||
issues no Gmail access to an unregistered client, and `gmail.modify` is a
|
||||
restricted scope, so an id shipped inside a public image would be both
|
||||
extractable from it and unusable without Google's security review of every
|
||||
deployment that used it.
|
||||
@@ -2365,7 +2365,12 @@ paths:
|
||||
tags: [views]
|
||||
summary: The next few days, empty ones included.
|
||||
parameters:
|
||||
- { name: days, in: query, schema: { type: integer, default: 7 } }
|
||||
- {
|
||||
name: days,
|
||||
in: query,
|
||||
description: "How many days to return, counting today. Above the maximum is capped, not refused.",
|
||||
schema: { type: integer, default: 7, minimum: 1, maximum: 31 },
|
||||
}
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
One line in, a fully-formed task out.
|
||||
|
||||
```
|
||||
betal moms i morgen kl 10 p1 #Firma @regnskab
|
||||
file the VAT return tomorrow at 10am p1 #Accounts @tax
|
||||
```
|
||||
|
||||
becomes a task called **betal moms**, due tomorrow at 10:00, priority 1, in the
|
||||
Firma project, labelled regnskab.
|
||||
becomes a task called **file the VAT return**, due tomorrow at 10:00, priority 1,
|
||||
in the Accounts project, labelled tax.
|
||||
|
||||
The parts it understands are tinted underneath the text as you type, so you can see
|
||||
it being read before you commit to it.
|
||||
@@ -16,8 +16,8 @@ it being read before you commit to it.
|
||||
|
||||
| You type | It means |
|
||||
|---|---|
|
||||
| `#Firma` | Put it in that project. `#"Q3 rapport"` for a name with spaces. |
|
||||
| `@regnskab` | Add that label. As many as you like. |
|
||||
| `#Accounts` | Put it in that project. `#"Q3 report"` for a name with spaces. |
|
||||
| `@tax` | Add that label. As many as you like. |
|
||||
| `p1` … `p4` | Priority. `!!!`, `!!` and `!` also work. |
|
||||
| `i dag`, `i morgen`, `i overmorgen` | Today, tomorrow, the day after. |
|
||||
| `mandag`, `på fredag` | The next such weekday. |
|
||||
|
||||
|
Before Width: | Height: | Size: 240 KiB After Width: | Height: | Size: 248 KiB |
|
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 308 KiB |
|
Before Width: | Height: | Size: 219 KiB After Width: | Height: | Size: 221 KiB |
|
Before Width: | Height: | Size: 138 KiB After Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 325 KiB After Width: | Height: | Size: 334 KiB |
|
Before Width: | Height: | Size: 237 KiB After Width: | Height: | Size: 245 KiB |
|
After Width: | Height: | Size: 346 KiB |
|
Before Width: | Height: | Size: 262 KiB After Width: | Height: | Size: 283 KiB |
|
Before Width: | Height: | Size: 350 KiB After Width: | Height: | Size: 367 KiB |
|
Before Width: | Height: | Size: 335 KiB After Width: | Height: | Size: 352 KiB |
|
Before Width: | Height: | Size: 220 KiB After Width: | Height: | Size: 232 KiB |
|
Before Width: | Height: | Size: 244 KiB After Width: | Height: | Size: 260 KiB |
|
After Width: | Height: | Size: 237 KiB |
|
After Width: | Height: | Size: 232 KiB |
|
After Width: | Height: | Size: 245 KiB |
|
After Width: | Height: | Size: 244 KiB |
|
After Width: | Height: | Size: 244 KiB |
|
After Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 229 KiB After Width: | Height: | Size: 245 KiB |
|
Before Width: | Height: | Size: 234 KiB After Width: | Height: | Size: 245 KiB |
|
Before Width: | Height: | Size: 234 KiB After Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 220 KiB |
|
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 220 KiB |
@@ -3,8 +3,10 @@ module github.com/kristianwind/verdande
|
||||
go 1.26.3
|
||||
|
||||
require (
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc
|
||||
github.com/coder/websocket v1.8.15
|
||||
github.com/emersion/go-imap/v2 v2.0.0-beta.8
|
||||
github.com/emersion/go-message v0.18.2
|
||||
github.com/go-chi/chi/v5 v5.3.1
|
||||
github.com/go-webauthn/webauthn v0.17.4
|
||||
github.com/pquerna/otp v1.5.0
|
||||
@@ -14,9 +16,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/emersion/go-message v0.18.2 // indirect
|
||||
github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.9.2 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/boombuler/barcode/qr"
|
||||
"github.com/pquerna/otp"
|
||||
"github.com/pquerna/otp/totp"
|
||||
)
|
||||
@@ -50,6 +51,41 @@ func NewTOTPSecret(issuer, account string) (secret, uri string, err error) {
|
||||
return key.Secret(), key.URL(), nil
|
||||
}
|
||||
|
||||
// TOTPQRSVG renders the otpauth:// URI as a QR code, as an SVG a phone camera can
|
||||
// read. SVG rather than a PNG data URI so it stays crisp at any size and adds no
|
||||
// base64 blob to the page — one dark path on a white square, which is what a scanner
|
||||
// needs whatever theme the page is in.
|
||||
//
|
||||
// The barcode encoder is already in the module graph (pquerna/otp draws on it), so
|
||||
// this borrows a dependency rather than adding one.
|
||||
func TOTPQRSVG(uri string) (string, error) {
|
||||
code, err := qr.Encode(uri, qr.M, qr.Auto)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("auth: encode totp qr: %w", err)
|
||||
}
|
||||
b := code.Bounds()
|
||||
n := b.Dx()
|
||||
// A four-module quiet zone all round, which the spec requires and scanners rely
|
||||
// on — without it the code runs to the edge and a reader cannot find its border.
|
||||
const quiet = 4
|
||||
size := n + quiet*2
|
||||
|
||||
var sb strings.Builder
|
||||
fmt.Fprintf(&sb, `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %d %d" shape-rendering="crispEdges">`, size, size)
|
||||
sb.WriteString(`<rect width="100%" height="100%" fill="#ffffff"/><path fill="#111312" d="`)
|
||||
for y := 0; y < n; y++ {
|
||||
for x := 0; x < n; x++ {
|
||||
// Dark modules are black; the red channel is 0 for those and full for the
|
||||
// light ones. One 1×1 rect per dark module, merged into a single path.
|
||||
if r, _, _, _ := code.At(b.Min.X+x, b.Min.Y+y).RGBA(); r == 0 {
|
||||
fmt.Fprintf(&sb, "M%d %dh1v1h-1z", x+quiet, y+quiet)
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.WriteString(`"/></svg>`)
|
||||
return sb.String(), nil
|
||||
}
|
||||
|
||||
// TOTPURI rebuilds the otpauth:// URI for an existing secret, for showing the QR
|
||||
// code again before enrolment is confirmed.
|
||||
func TOTPURI(secret, issuer, account string) string {
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
// Package gmail is the small slice of the Gmail API verdande needs, and the scope
|
||||
// it asks for.
|
||||
//
|
||||
// The connection is one-way on purpose: a starred or labelled message becomes a
|
||||
// task, and nothing verdande does afterwards touches the mailbox. Unstarring the
|
||||
// message does not delete the task, completing the task does not unstar the
|
||||
// message. Two-way would mean deciding what to do when both sides changed, and the
|
||||
// only honest answer to that is a synchronisation model far bigger than the feature.
|
||||
// The one thing verdande writes back is the star. A starred message becomes a
|
||||
// task, and once it has, the star comes off — exactly as the IMAP side takes the
|
||||
// flag off a mail it has imported, and for the same reason: the star meant "turn
|
||||
// this into a task", the task now exists, so the star is no longer true. Nothing
|
||||
// else is touched. Completing the task does not reach back to the mail; the mail
|
||||
// is a pointer the task was made from, not a copy the two have to be kept in step.
|
||||
//
|
||||
// Scope is gmail.readonly. verdande never needs to send, modify or delete, and
|
||||
// asking for less is what makes the consent screen something a person can agree to.
|
||||
// That one write is why the scope is gmail.modify rather than gmail.readonly.
|
||||
// Removing the STARRED label is a modify, and Gmail offers no narrower scope that
|
||||
// can do it — so the consent screen asks for more than it used to, and the trade
|
||||
// is deliberate: a starred inbox that empties itself as the tasks are made, rather
|
||||
// than one that fills with stars nothing ever clears. Still not send, still not
|
||||
// delete — modify is labels, and the only label verdande removes is the one that
|
||||
// triggered the task.
|
||||
//
|
||||
// The OAuth flow itself moved to internal/google when Calendar needed the same one.
|
||||
// The names below are aliases so that every call site — and this package's own
|
||||
@@ -27,8 +33,10 @@ import (
|
||||
"github.com/kristianwind/verdande/internal/google"
|
||||
)
|
||||
|
||||
// Read-only, and only mail. Not profile, not contacts, not send.
|
||||
const Scope = "https://www.googleapis.com/auth/gmail.readonly"
|
||||
// Read mail and change its labels, and only mail. Not profile, not contacts, not
|
||||
// send, not delete. The single write is removing the STARRED label from a message
|
||||
// that has become a task; see the package comment for why that costs modify.
|
||||
const Scope = "https://www.googleapis.com/auth/gmail.modify"
|
||||
|
||||
const defaultAPIBase = "https://gmail.googleapis.com/gmail/v1"
|
||||
|
||||
@@ -169,6 +177,25 @@ func (c *Client) get(ctx context.Context, url string, out any) error {
|
||||
return google.Get(ctx, c.http, c.accessToken, url, out)
|
||||
}
|
||||
|
||||
// Unstar takes the star off the given messages — one call for all of them, the way
|
||||
// the IMAP side unflags a batch, so a sweep that made ten tasks is one write and
|
||||
// not ten.
|
||||
//
|
||||
// STARRED is a system label whose id is its name, so no lookup is needed; a custom
|
||||
// label would need one, and verdande removes none. batchModify answers 204 with no
|
||||
// body on success. An empty list is a no-op, not a call: batchModify with no ids is
|
||||
// an error on Google's side and nothing worth making a round trip to hear.
|
||||
func (c *Client) Unstar(ctx context.Context, ids []string) error {
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
body := struct {
|
||||
IDs []string `json:"ids"`
|
||||
RemoveLabelIDs []string `json:"removeLabelIds"`
|
||||
}{IDs: ids, RemoveLabelIDs: []string{"STARRED"}}
|
||||
return google.Post(ctx, c.http, c.accessToken, c.api()+"/users/me/messages/batchModify", body, nil)
|
||||
}
|
||||
|
||||
// SenderName pulls "Anders Jensen" out of "Anders Jensen <[email protected]>",
|
||||
// falling back to the address when there is no display name.
|
||||
func SenderName(from string) string {
|
||||
|
||||
@@ -1,16 +1,81 @@
|
||||
package gmail
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The scope is the one thing verdande chooses about the connection, and it is the
|
||||
// one the person reads on the consent screen. The flow itself is exercised in
|
||||
// internal/google; what belongs here is that Gmail still asks for read-only mail.
|
||||
func TestTheScopeIsReadOnlyMail(t *testing.T) {
|
||||
if !strings.HasSuffix(Scope, "gmail.readonly") {
|
||||
t.Errorf("scope = %q; verdande never needs to send or modify", Scope)
|
||||
// internal/google; what belongs here is that Gmail asks for modify — read plus the
|
||||
// one write it makes, taking the star off an imported message — and nothing wider.
|
||||
func TestTheScopeIsModifyMail(t *testing.T) {
|
||||
if !strings.HasSuffix(Scope, "gmail.modify") {
|
||||
t.Errorf("scope = %q; want gmail.modify — read, plus removing the star", Scope)
|
||||
}
|
||||
// Modify is the ceiling. Send, or the full account, would be a different promise
|
||||
// to the person on the consent screen than the one this feature needs.
|
||||
for _, wider := range []string{"gmail.send", "mail.google.com", "gmail.settings"} {
|
||||
if strings.Contains(Scope, wider) {
|
||||
t.Errorf("scope = %q; must not include %q", Scope, wider)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unstar removes the star from a batch in one call, and it addresses the messages
|
||||
// it was given and only the STARRED label.
|
||||
func TestUnstarRemovesOnlyTheStar(t *testing.T) {
|
||||
var gotPath string
|
||||
var gotBody struct {
|
||||
IDs []string `json:"ids"`
|
||||
AddLabelIDs []string `json:"addLabelIds"`
|
||||
RemoveLabelIDs []string `json:"removeLabelIds"`
|
||||
}
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
gotPath = r.URL.Path
|
||||
raw, _ := io.ReadAll(r.Body)
|
||||
_ = json.Unmarshal(raw, &gotBody)
|
||||
w.WriteHeader(http.StatusNoContent) // what batchModify answers on success
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
err := NewClient("token").At(srv.URL).Unstar(context.Background(), []string{"a", "b"})
|
||||
if err != nil {
|
||||
t.Fatalf("Unstar: %v", err)
|
||||
}
|
||||
if !strings.HasSuffix(gotPath, "/users/me/messages/batchModify") {
|
||||
t.Errorf("path = %q, want the batchModify endpoint", gotPath)
|
||||
}
|
||||
if strings.Join(gotBody.IDs, ",") != "a,b" {
|
||||
t.Errorf("ids = %v, want [a b]", gotBody.IDs)
|
||||
}
|
||||
if strings.Join(gotBody.RemoveLabelIDs, ",") != "STARRED" {
|
||||
t.Errorf("removeLabelIds = %v, want [STARRED]", gotBody.RemoveLabelIDs)
|
||||
}
|
||||
if len(gotBody.AddLabelIDs) != 0 {
|
||||
t.Errorf("addLabelIds = %v, want none — verdande adds no label", gotBody.AddLabelIDs)
|
||||
}
|
||||
}
|
||||
|
||||
// An empty batch is not a request: Gmail rejects a batchModify with no ids, and
|
||||
// there is nothing to say to it anyway.
|
||||
func TestUnstarOfNothingMakesNoCall(t *testing.T) {
|
||||
called := false
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {
|
||||
called = true
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
if err := NewClient("token").At(srv.URL).Unstar(context.Background(), nil); err != nil {
|
||||
t.Fatalf("Unstar(nil): %v", err)
|
||||
}
|
||||
if called {
|
||||
t.Error("Unstar(nil) made a request; it should make none")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -215,6 +215,40 @@ func Get(ctx context.Context, client *http.Client, accessToken, url string, out
|
||||
return json.NewDecoder(resp.Body).Decode(out)
|
||||
}
|
||||
|
||||
// Post sends a JSON body to a Google API and, unlike Get, does not insist on a
|
||||
// body coming back. A write call — modifying labels on a message — answers with
|
||||
// 204 No Content when it worked, so anything 2xx is success and only the body is
|
||||
// decoded, and only when the caller asked for one.
|
||||
func Post(ctx context.Context, client *http.Client, accessToken, url string, body, out any) error {
|
||||
payload, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(string(payload)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+accessToken)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == http.StatusUnauthorized {
|
||||
return ErrUnauthorized
|
||||
}
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
return fmt.Errorf("google: %s", resp.Status)
|
||||
}
|
||||
if out == nil || resp.StatusCode == http.StatusNoContent {
|
||||
return nil
|
||||
}
|
||||
return json.NewDecoder(resp.Body).Decode(out)
|
||||
}
|
||||
|
||||
func randomString(n int) (string, error) {
|
||||
b := make([]byte, n)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
|
||||
@@ -251,10 +251,12 @@ func (s *Server) handleGmailSyncNow(w http.ResponseWriter, r *http.Request) {
|
||||
// takes a context and a user rather than a request.
|
||||
// maxGmailSeen bounds the list of message ids already turned into tasks.
|
||||
//
|
||||
// Gmail is read-only here — the scope is `gmail.readonly`, deliberately, because
|
||||
// asking for less is what makes the consent screen something a person can agree
|
||||
// to — so verdande cannot unstar a message the way the IMAP side unflags one. The
|
||||
// record has to live on this side, and a record on this side has to be bounded.
|
||||
// The star is taken off an imported message now, so on a starred trigger the mail
|
||||
// leaves the query on its own and this list is a safety net rather than the only
|
||||
// record. It still earns its place: it covers the window between making the task
|
||||
// and the star coming off, and it is the whole of the dedup for a label trigger,
|
||||
// where the label is the person's and not ours to remove. A record on this side
|
||||
// has to be bounded.
|
||||
//
|
||||
// A count rather than the previous rule of "whatever Gmail returned this run",
|
||||
// which was not a bound but a way of forgetting.
|
||||
@@ -381,6 +383,29 @@ func (s *Server) SyncGmail(ctx context.Context, user *store.User) (int, error) {
|
||||
s.hub.Publish(projectID, "task.created", toTaskJSON(*task))
|
||||
}
|
||||
|
||||
// The star comes off every message this query returned that now has a task —
|
||||
// the ones made this run and the ones a run before it already made. Gated to the
|
||||
// triggers that are about the star: for a label trigger the star is the person's
|
||||
// own and not ours to touch, and dedup there rests on the seen list alone.
|
||||
//
|
||||
// Best effort, exactly like the IMAP unflag: a task made is not undone by a star
|
||||
// that would not come off. The likeliest reason it will not, right after this
|
||||
// ships, is a connection still holding the old read-only grant — the write is a
|
||||
// 403 until the account is reconnected, and this logs it rather than failing the
|
||||
// sync. It self-heals: the mail stays starred, stays in the next query, and is
|
||||
// tried again once the grant is there.
|
||||
if box.Trigger == "starred" || box.Trigger == "both" {
|
||||
unstar := make([]string, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
if seen[id] {
|
||||
unstar = append(unstar, id)
|
||||
}
|
||||
}
|
||||
if err := client.Unstar(ctx, unstar); err != nil {
|
||||
s.log.Warn("gmail unstar", "err", err, "user", user.ID, "count", len(unstar))
|
||||
}
|
||||
}
|
||||
|
||||
if created > 0 {
|
||||
// The ids this run saw, on top of the ones already known.
|
||||
//
|
||||
@@ -442,8 +467,8 @@ func (s *Server) handleVersion(w http.ResponseWriter, r *http.Request) {
|
||||
//
|
||||
// The one click that opens Google's consent screen already exists; what it needs
|
||||
// behind it is a registered client, and that is not something any app can conjure:
|
||||
// Google issues no Gmail access to an unregistered client, and `gmail.readonly` is
|
||||
// a restricted scope, so an id shipped inside a public image would be both
|
||||
// Google issues no Gmail access to an unregistered client, and `gmail.modify` is a
|
||||
// restricted scope, so an id shipped inside a public image would be both
|
||||
// extractable from it and unusable without Google's security review of every
|
||||
// deployment. The registration is a one-off. Having to edit a Rune's manifest and
|
||||
// recreate the container to paste the result was not.
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"github.com/kristianwind/verdande/internal/store"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kristianwind/verdande/internal/config"
|
||||
"github.com/kristianwind/verdande/internal/store"
|
||||
)
|
||||
|
||||
// A Gmail failure has to survive being reported.
|
||||
@@ -150,6 +153,84 @@ func TestASlowMailboxDoesNotHangTheRequest(t *testing.T) {
|
||||
t.Logf("came back in %s with %d", took.Round(time.Millisecond), resp.StatusCode)
|
||||
}
|
||||
|
||||
// A message that becomes a task has its star taken off — the write that the whole
|
||||
// gmail.modify scope is for. The mail's own inbox empties as the tasks are made,
|
||||
// the way the IMAP side unflags what it imports.
|
||||
func TestASyncedGmailMessageIsUnstarred(t *testing.T) {
|
||||
var unstarred struct {
|
||||
hit bool
|
||||
body struct {
|
||||
IDs []string `json:"ids"`
|
||||
RemoveLabelIDs []string `json:"removeLabelIds"`
|
||||
}
|
||||
}
|
||||
google := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch {
|
||||
case r.Method == "POST" && strings.HasSuffix(r.URL.Path, "/messages/batchModify"):
|
||||
unstarred.hit = true
|
||||
raw, _ := io.ReadAll(r.Body)
|
||||
_ = json.Unmarshal(raw, &unstarred.body)
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
case strings.Contains(r.URL.Path, "/messages/") && r.URL.Query().Get("format") == "metadata":
|
||||
writeTestJSON(w, map[string]any{
|
||||
"id": "m1", "threadId": "t1", "snippet": "kort tekst",
|
||||
"payload": map[string]any{"headers": []map[string]string{
|
||||
{"name": "From", "value": "Anders <[email protected]>"},
|
||||
{"name": "Subject", "value": "Møde på fredag"},
|
||||
}},
|
||||
})
|
||||
case strings.HasSuffix(r.URL.Path, "/messages"):
|
||||
writeTestJSON(w, map[string]any{"messages": []map[string]string{{"id": "m1"}}})
|
||||
default:
|
||||
http.Error(w, "unexpected "+r.Method+" "+r.URL.Path, http.StatusNotFound)
|
||||
}
|
||||
}))
|
||||
defer google.Close()
|
||||
|
||||
ts := newTestServerWith(t, func(cfg *config.Config) {
|
||||
cfg.GmailClientID = "test-client"
|
||||
cfg.GmailClientSecret = "test-secret"
|
||||
cfg.GoogleTokenURL = google.URL + "/token"
|
||||
cfg.GmailAPIURL = google.URL
|
||||
})
|
||||
ts.bootstrap(t)
|
||||
|
||||
user, err := ts.db.UserByEmail(t.Context(), "[email protected]")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// A live access token, so the run goes straight to the list without a refresh.
|
||||
if err := ts.db.SaveMailbox(t.Context(), &store.Mailbox{
|
||||
UserID: user.ID, Kind: "gmail", RefreshToken: "r", AccessToken: "a",
|
||||
Trigger: "starred", ExpiresAt: time.Now().Add(time.Hour),
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, body := ts.do(t, "POST", "/api/v1/gmail/sync", nil)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("sync: status %d, want 200", resp.StatusCode)
|
||||
}
|
||||
if created, _ := body["created"].(float64); created != 1 {
|
||||
t.Fatalf("created = %v, want 1", body["created"])
|
||||
}
|
||||
|
||||
if !unstarred.hit {
|
||||
t.Fatal("the message was never unstarred; its star is the one thing modify is for")
|
||||
}
|
||||
if strings.Join(unstarred.body.IDs, ",") != "m1" {
|
||||
t.Errorf("unstarred ids = %v, want [m1]", unstarred.body.IDs)
|
||||
}
|
||||
if strings.Join(unstarred.body.RemoveLabelIDs, ",") != "STARRED" {
|
||||
t.Errorf("removed = %v, want [STARRED]", unstarred.body.RemoveLabelIDs)
|
||||
}
|
||||
}
|
||||
|
||||
func writeTestJSON(w http.ResponseWriter, v any) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(w).Encode(v)
|
||||
}
|
||||
|
||||
func mustParse(t *testing.T, raw string) *url.URL {
|
||||
t.Helper()
|
||||
u, err := url.Parse(raw)
|
||||
|
||||
@@ -285,6 +285,49 @@ func TestTodayAndUpcoming(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The horizon is the list's, and it is asked for per request: seven days is the
|
||||
// default, thirty is what Kommende offers for "when does this month get busy", and
|
||||
// anything past the cap is trimmed rather than refused — a client that asks for a
|
||||
// year gets a month, not a 400.
|
||||
func TestUpcomingHorizon(t *testing.T) {
|
||||
ts := newTestServer(t)
|
||||
ts.bootstrap(t)
|
||||
|
||||
resp, out := ts.do(t, "POST", "/api/v1/tasks", map[string]any{
|
||||
"content": "om tyve dage",
|
||||
"due_date": userDate(t, 20),
|
||||
})
|
||||
if resp.StatusCode != http.StatusCreated {
|
||||
t.Fatalf("create: %d %v", resp.StatusCode, out)
|
||||
}
|
||||
|
||||
count := func(query string) (int, int) {
|
||||
t.Helper()
|
||||
_, view := ts.do(t, "GET", "/api/v1/upcoming"+query, nil)
|
||||
days, _ := view["days"].([]any)
|
||||
var tasks int
|
||||
for _, d := range days {
|
||||
day, _ := d.(map[string]any)
|
||||
list, _ := day["tasks"].([]any)
|
||||
tasks += len(list)
|
||||
}
|
||||
return len(days), tasks
|
||||
}
|
||||
|
||||
if n, found := count(""); n != 7 || found != 0 {
|
||||
t.Errorf("default horizon returned %d days and %d tasks, want 7 and 0", n, found)
|
||||
}
|
||||
if n, found := count("?days=30"); n != 30 || found != 1 {
|
||||
t.Errorf("days=30 returned %d days and %d tasks, want 30 and 1", n, found)
|
||||
}
|
||||
if n, _ := count("?days=365"); n != 31 {
|
||||
t.Errorf("days=365 returned %d days, want it capped at 31", n)
|
||||
}
|
||||
if n, _ := count("?days=nonsense"); n != 7 {
|
||||
t.Errorf("an unreadable days returned %d days, want the default 7", n)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchFindsAcrossProjects(t *testing.T) {
|
||||
ts := newTestServer(t)
|
||||
ts.bootstrap(t)
|
||||
|
||||
@@ -17,6 +17,9 @@ import (
|
||||
type totpSetupResponse struct {
|
||||
Secret string `json:"secret"`
|
||||
URI string `json:"uri"`
|
||||
// The URI as a scannable QR code (SVG). The secret and URI stay for typing in by
|
||||
// hand on a device that cannot scan.
|
||||
QR string `json:"qr"`
|
||||
}
|
||||
|
||||
func (s *Server) handleTOTPSetup(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -54,7 +57,12 @@ func (s *Server) handleTOTPSetup(w http.ResponseWriter, r *http.Request) {
|
||||
s.internal(w, r, "store totp secret", err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, totpSetupResponse{Secret: secret, URI: uri})
|
||||
qrSVG, err := auth.TOTPQRSVG(uri)
|
||||
if err != nil {
|
||||
s.internal(w, r, "render totp qr", err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, totpSetupResponse{Secret: secret, URI: uri, QR: qrSVG})
|
||||
}
|
||||
|
||||
type totpConfirmResponse struct {
|
||||
|
||||
@@ -51,7 +51,8 @@ type upcomingDay struct {
|
||||
Tasks []taskJSON `json:"tasks"`
|
||||
}
|
||||
|
||||
// handleUpcoming returns the next seven days, one entry per day.
|
||||
// handleUpcoming returns the next `days` days, one entry per day, seven by default
|
||||
// and at most a month.
|
||||
//
|
||||
// Empty days are included on purpose: the view is a calendar strip, and a Thursday
|
||||
// missing from the response because nothing is due would collapse the layout and
|
||||
@@ -65,10 +66,14 @@ func (s *Server) handleUpcoming(w http.ResponseWriter, r *http.Request) {
|
||||
from := start.Format("2006-01-02")
|
||||
to := start.AddDate(0, 0, days-1).Format("2006-01-02")
|
||||
|
||||
// The row limit follows the window rather than sitting at a constant, or a
|
||||
// month asked for with the same ceiling as a week would truncate the last days
|
||||
// silently — and a day cut off the end of the answer looks exactly like a day
|
||||
// with nothing due.
|
||||
tasks, err := s.db.ListTasks(r.Context(), user.ID, store.TaskFilter{
|
||||
DueFrom: from,
|
||||
DueBefore: to,
|
||||
Limit: 1000,
|
||||
Limit: 200 * days,
|
||||
})
|
||||
if err != nil {
|
||||
s.internal(w, r, "upcoming", err)
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNormalizeName(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"andreas": "Andreas",
|
||||
"Andreas": "Andreas",
|
||||
"anne mette": "Anne Mette",
|
||||
" kristian ": "Kristian",
|
||||
"anne mette": "Anne Mette",
|
||||
"McDonald": "McDonald", // an existing inner capital is kept
|
||||
"óscar": "Óscar", // Unicode initial
|
||||
"æblegaard": "Æblegaard",
|
||||
"": "",
|
||||
" ": "",
|
||||
"mette-marie sø": "Mette-marie Sø", // only word-initials are raised
|
||||
"iPhone listen": "IPhone Listen", // deliberately: the first letter is raised
|
||||
}
|
||||
for in, want := range cases {
|
||||
if got := NormalizeName(in); got != want {
|
||||
t.Errorf("NormalizeName(%q) = %q, want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateUserCapitalisesName(t *testing.T) {
|
||||
db := openTest(t)
|
||||
ctx := context.Background()
|
||||
|
||||
u := &User{Email: "[email protected]", Name: "andreas", PasswordHash: "x"}
|
||||
if err := db.CreateUser(ctx, u, "Inbox"); err != nil {
|
||||
t.Fatalf("create user: %v", err)
|
||||
}
|
||||
got, err := db.UserByEmail(ctx, "[email protected]")
|
||||
if err != nil {
|
||||
t.Fatalf("read back: %v", err)
|
||||
}
|
||||
if got.Name != "Andreas" {
|
||||
t.Errorf("stored name = %q, want %q", got.Name, "Andreas")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeUserNamesBackfill(t *testing.T) {
|
||||
db := openTest(t)
|
||||
ctx := context.Background()
|
||||
|
||||
// An account as it looked before the app capitalised names: made properly,
|
||||
// then set back to lower case behind the store's back to stand in for an old row.
|
||||
u := &User{Email: "[email protected]", Name: "Andreas", PasswordHash: "x"}
|
||||
if err := db.CreateUser(ctx, u, "Inbox"); err != nil {
|
||||
t.Fatalf("create user: %v", err)
|
||||
}
|
||||
if _, err := db.ExecContext(ctx, `UPDATE users SET name = 'andreas' WHERE id = ?`, u.ID); err != nil {
|
||||
t.Fatalf("downgrade name: %v", err)
|
||||
}
|
||||
|
||||
fixed, err := db.NormalizeUserNames(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("normalize: %v", err)
|
||||
}
|
||||
if fixed != 1 {
|
||||
t.Fatalf("fixed = %d, want 1", fixed)
|
||||
}
|
||||
got, _ := db.UserByID(ctx, u.ID)
|
||||
if got.Name != "Andreas" {
|
||||
t.Errorf("name after backfill = %q, want %q", got.Name, "Andreas")
|
||||
}
|
||||
|
||||
// Idempotent: nothing left to do on a second pass.
|
||||
again, err := db.NormalizeUserNames(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("normalize again: %v", err)
|
||||
}
|
||||
if again != 0 {
|
||||
t.Errorf("second pass fixed = %d, want 0", again)
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/kristianwind/verdande/internal/auth"
|
||||
)
|
||||
@@ -62,6 +63,26 @@ func NormalizeEmail(email string) string {
|
||||
return strings.ToLower(strings.TrimSpace(email))
|
||||
}
|
||||
|
||||
// NormalizeName trims a display name and capitalises the first letter of every
|
||||
// word, leaving the rest of each word exactly as typed. So "andreas" becomes
|
||||
// "Andreas" and "anne mette" becomes "Anne Mette", while a name that already
|
||||
// carries a capital in the middle — "McDonald", an "iPhone" — keeps it: only the
|
||||
// first letter of a word is ever raised, never lowered.
|
||||
//
|
||||
// A name is the person's to spell; the one thing the instance insists on is that
|
||||
// it does not start in lower case, because a column of lower-case first names
|
||||
// reads as a bug the person cannot fix from their own keyboard. Unicode-aware, so
|
||||
// "æblegaard" and "óscar" are raised the same as an ASCII initial.
|
||||
func NormalizeName(name string) string {
|
||||
fields := strings.Fields(name)
|
||||
for i, f := range fields {
|
||||
r := []rune(f)
|
||||
r[0] = unicode.ToUpper(r[0])
|
||||
fields[i] = string(r)
|
||||
}
|
||||
return strings.Join(fields, " ")
|
||||
}
|
||||
|
||||
// CreateUser inserts a user and gives them an Inbox, in one transaction.
|
||||
//
|
||||
// The Inbox is created here rather than lazily on first use because every other
|
||||
@@ -70,6 +91,7 @@ func NormalizeEmail(email string) string {
|
||||
// of them end up racing to create the second one.
|
||||
func (db *DB) CreateUser(ctx context.Context, u *User, inboxName string) error {
|
||||
u.Email = NormalizeEmail(u.Email)
|
||||
u.Name = NormalizeName(u.Name)
|
||||
if u.ID == "" {
|
||||
u.ID = NewID()
|
||||
}
|
||||
@@ -473,6 +495,7 @@ func (db *DB) UpdatePasswordHash(ctx context.Context, userID, hash, keepSessionI
|
||||
// invites were sent to, and changing it is a re-verification flow rather than a
|
||||
// field. Neither is is_admin — an account cannot promote itself.
|
||||
func (db *DB) UpdateProfile(ctx context.Context, userID, name, timezone, locale string) error {
|
||||
name = NormalizeName(name)
|
||||
res, err := db.ExecContext(ctx,
|
||||
`UPDATE users SET name = ?, timezone = ?, locale = ?, updated_at = ? WHERE id = ?`,
|
||||
name, timezone, locale, time.Now().Unix(), userID)
|
||||
@@ -485,6 +508,56 @@ func (db *DB) UpdateProfile(ctx context.Context, userID, name, timezone, locale
|
||||
return nil
|
||||
}
|
||||
|
||||
// NormalizeUserNames capitalises the first letter of every existing user's name,
|
||||
// for the accounts created before the app started doing it on the way in.
|
||||
//
|
||||
// Idempotent: a name already normalised is left untouched, so it costs one pass
|
||||
// of names at each start and writes nothing once it has caught up. Like SealNotes
|
||||
// it runs at boot rather than as a migration, because the rule lives in Go —
|
||||
// Unicode-aware and per word — and SQLite's own UPPER cannot spell it.
|
||||
//
|
||||
// `updated_at` is not touched: fixing the spelling of a name the person chose is
|
||||
// the instance tidying up after itself, not the person editing their profile.
|
||||
func (db *DB) NormalizeUserNames(ctx context.Context) (int, error) {
|
||||
rows, err := db.QueryContext(ctx, `SELECT id, name FROM users`)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
type pending struct{ id, name string }
|
||||
var todo []pending
|
||||
for rows.Next() {
|
||||
var id, name string
|
||||
if err := rows.Scan(&id, &name); err != nil {
|
||||
rows.Close()
|
||||
return 0, err
|
||||
}
|
||||
if n := NormalizeName(name); n != name {
|
||||
todo = append(todo, pending{id, n})
|
||||
}
|
||||
}
|
||||
rows.Close()
|
||||
if err := rows.Err(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if len(todo) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
err = db.Tx(ctx, func(tx *sql.Tx) error {
|
||||
for _, p := range todo {
|
||||
if _, err := tx.ExecContext(ctx,
|
||||
`UPDATE users SET name = ? WHERE id = ?`, p.name, p.id); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return len(todo), nil
|
||||
}
|
||||
|
||||
func (db *DB) SetTOTPSecret(ctx context.Context, userID, secret string, enabled bool) error {
|
||||
// Sealed, like a mailbox password and for the same reason: the copies, not the
|
||||
// server. A TOTP secret in a downloadable backup lets whoever holds the copy
|
||||
|
||||
@@ -992,12 +992,22 @@
|
||||
<figure class="shot">
|
||||
<img
|
||||
src="screenshots/themes.webp"
|
||||
alt="The settings page showing five themes as swatches and, below them, four looks written in the typeface each one selects."
|
||||
alt="The settings page showing six themes as swatches and, below them, four looks written in the typeface each one selects."
|
||||
width="1400"
|
||||
height="900"
|
||||
loading="lazy"
|
||||
/>
|
||||
<figcaption>Five themes and four looks: how bright, and how it reads.</figcaption>
|
||||
<figcaption>Six themes and four looks: how bright, and how it reads.</figcaption>
|
||||
</figure>
|
||||
<figure class="shot">
|
||||
<img
|
||||
src="screenshots/notes-charcoal.webp"
|
||||
alt="Notes in the Charcoal theme: a warm near-black modelled on Apple Notes, the note list on the left and a note open on the right, with amber where the accent green usually is."
|
||||
width="1400"
|
||||
height="900"
|
||||
loading="lazy"
|
||||
/>
|
||||
<figcaption>Charcoal — the newest theme, a warm near-black after Apple Notes, amber for the accent.</figcaption>
|
||||
</figure>
|
||||
<figure class="shot">
|
||||
<img
|
||||
@@ -1040,6 +1050,75 @@
|
||||
<figcaption>Integrations: your mailbox, your calendar feed, your address.</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<h3 class="sub">Six themes, the same day</h3>
|
||||
<p class="muted">
|
||||
Three dark and three light — a property of the screen you are sitting at, a
|
||||
laptop in the sun and a monitor in a dark room wanting different answers. The
|
||||
typeface and how tight it sits are chosen apart from them.
|
||||
</p>
|
||||
<div class="shots">
|
||||
<figure class="shot">
|
||||
<img
|
||||
src="screenshots/theme-northern-lights.webp"
|
||||
alt="The Today view in the Northern lights theme: dark, with a green accent."
|
||||
width="1400"
|
||||
height="900"
|
||||
loading="lazy"
|
||||
/>
|
||||
<figcaption>Northern lights — dark, a green accent. The default.</figcaption>
|
||||
</figure>
|
||||
<figure class="shot">
|
||||
<img
|
||||
src="screenshots/theme-charcoal.webp"
|
||||
alt="The Today view in the Charcoal theme: a warm near-black modelled on Apple Notes, with amber for the accent."
|
||||
width="1400"
|
||||
height="900"
|
||||
loading="lazy"
|
||||
/>
|
||||
<figcaption>Charcoal — a warm near-black after Apple Notes, amber accent.</figcaption>
|
||||
</figure>
|
||||
<figure class="shot">
|
||||
<img
|
||||
src="screenshots/theme-dusk.webp"
|
||||
alt="The Today view in the Dusk theme: dark and warm, with an amber accent."
|
||||
width="1400"
|
||||
height="900"
|
||||
loading="lazy"
|
||||
/>
|
||||
<figcaption>Dusk — dark and warm.</figcaption>
|
||||
</figure>
|
||||
<figure class="shot">
|
||||
<img
|
||||
src="screenshots/theme-daylight.webp"
|
||||
alt="The Today view in the Daylight theme: light and coolly neutral."
|
||||
width="1400"
|
||||
height="900"
|
||||
loading="lazy"
|
||||
/>
|
||||
<figcaption>Daylight — light and coolly neutral.</figcaption>
|
||||
</figure>
|
||||
<figure class="shot">
|
||||
<img
|
||||
src="screenshots/theme-paper.webp"
|
||||
alt="The Today view in the Paper theme: light and warm, like paper."
|
||||
width="1400"
|
||||
height="900"
|
||||
loading="lazy"
|
||||
/>
|
||||
<figcaption>Paper — light and warm, like paper.</figcaption>
|
||||
</figure>
|
||||
<figure class="shot">
|
||||
<img
|
||||
src="screenshots/theme-contrast.webp"
|
||||
alt="The Today view in the Contrast theme: black on white, for bright light."
|
||||
width="1400"
|
||||
height="900"
|
||||
loading="lazy"
|
||||
/>
|
||||
<figcaption>Contrast — black on white, for bright light.</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="features">
|
||||
@@ -1120,6 +1199,15 @@
|
||||
by itself — without touching when it is actually due.
|
||||
</p>
|
||||
</div>
|
||||
<div class="cell">
|
||||
<h3>Holds through a drop</h3>
|
||||
<p>
|
||||
A tunnel, a lift, a base station handing over — the app does not go
|
||||
blank when the signal does. A save you make rides out a few seconds of
|
||||
no connection and goes through when it comes back, and a reload opens
|
||||
from what it last saw rather than the browser's offline page.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="group-label">Connected to what you already use</p>
|
||||
@@ -1154,9 +1242,10 @@
|
||||
<h3>Your mail, as an inbox</h3>
|
||||
<p>
|
||||
Star a mail in Gmail, or flag one over IMAP in iCloud or Fastmail, and
|
||||
it becomes a task. Forward one to your own address instead and the
|
||||
subject is parsed like anything else you type. One way: unstarring it
|
||||
later does nothing to the task you made.
|
||||
it becomes a task — and the star or flag comes off once it has, so a
|
||||
starred inbox empties as the tasks are made instead of only filling up.
|
||||
Forward one to your own address instead and the subject is parsed like
|
||||
anything else you type.
|
||||
</p>
|
||||
</div>
|
||||
<div class="cell">
|
||||
@@ -1237,6 +1326,25 @@
|
||||
<a href="https://github.com/kristianwind/verdande/releases">the releases page</a>.
|
||||
</p>
|
||||
<ul class="lately">
|
||||
<li>
|
||||
<span class="ver">0.42</span>
|
||||
A sixth theme, <strong>Charcoal</strong> — a warm near-black after Apple
|
||||
Notes, with amber for the accent. And the app now holds through a short
|
||||
network drop: a save rides out a few seconds of no signal, and a reload
|
||||
opens from what it last saw rather than the browser's offline page.
|
||||
</li>
|
||||
<li>
|
||||
<span class="ver">0.42</span>
|
||||
A starred Gmail message loses its star once it has become a task, the way
|
||||
a flagged IMAP mail already did — so a starred inbox empties itself as the
|
||||
tasks are made instead of only filling up.
|
||||
</li>
|
||||
<li>
|
||||
<span class="ver">0.42</span>
|
||||
Notes read as three lines, the last one the project they are filed under;
|
||||
the calendar lightened to pastel days with today marked at the top; and
|
||||
two-factor set-up shows a QR code to scan.
|
||||
</li>
|
||||
<li>
|
||||
<span class="ver">0.41</span>
|
||||
A task you have delegated is marked where you meet it, not only on the
|
||||
|
||||
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
@@ -64,6 +64,60 @@ function watchForTrouble(page) {
|
||||
return trouble;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kommendes liste kan se længere frem end en uge.
|
||||
*
|
||||
* Syv dage er stadig det, den åbner på — det er den vandring, der er værd at gå om
|
||||
* morgenen. Men "hvornår bliver den her måned travl" er et andet spørgsmål, og
|
||||
* månedsgitteret svarer på det med form frem for med rækkefølge. Derfor kan
|
||||
* listen sættes til 14 og 30 dage, og valget bliver liggende: horisonten er et
|
||||
* spørgsmål om, hvor langt man planlægger, ikke om hvilken skærm man sidder ved —
|
||||
* men det er den samme slags valg som gitter eller liste, så det ligger samme sted.
|
||||
*/
|
||||
test('Kommende kan se en måned frem, og horisonten huskes', async ({ page }) => {
|
||||
const trouble = watchForTrouble(page);
|
||||
await page.goto('/');
|
||||
|
||||
const box = page.getByLabel('Ny opgave');
|
||||
await box.fill('skifte olie om 20 dage');
|
||||
await box.press('Enter');
|
||||
await expect(box).toHaveValue('');
|
||||
|
||||
await page.goto('/upcoming');
|
||||
await page.getByRole('button', { name: 'Liste', exact: true }).click();
|
||||
|
||||
const days = page.locator('section:has(> h2)');
|
||||
const task = page.getByText('skifte olie', { exact: true });
|
||||
|
||||
// Syv dage er udgangspunktet, og opgaven ligger uden for dem. At den er væk her
|
||||
// er halvdelen af prøven: uden den kunne de tredive dage nedenfor være syv, der
|
||||
// tilfældigvis viste den.
|
||||
await expect(days).toHaveCount(7);
|
||||
await expect(task).toBeHidden();
|
||||
|
||||
await page.getByRole('button', { name: '30 dage', exact: true }).click();
|
||||
await expect(days).toHaveCount(30);
|
||||
await expect(task).toBeVisible();
|
||||
|
||||
// Ugenummeret står kun, når strimlen er længere end en uge — ellers siger det
|
||||
// ingenting, man ikke kunne se i forvejen.
|
||||
await expect(days.first().getByText(/uge \d+/i)).toBeVisible();
|
||||
|
||||
// Og valget overlever en genindlæsning.
|
||||
await page.reload();
|
||||
await expect(days).toHaveCount(30);
|
||||
await expect(
|
||||
page.getByRole('button', { name: '30 dage', exact: true }),
|
||||
'horisonten blev ikke husket'
|
||||
).toHaveAttribute('aria-pressed', 'true');
|
||||
|
||||
await page.getByRole('button', { name: '7 dage', exact: true }).click();
|
||||
await expect(days).toHaveCount(7);
|
||||
await expect(days.first().getByText(/uge \d+/i)).toBeHidden();
|
||||
|
||||
expect(trouble).toEqual([]);
|
||||
});
|
||||
|
||||
test('hurtig tilføjelse opretter en opgave, og den kan lukkes', async ({ page }) => {
|
||||
const trouble = watchForTrouble(page);
|
||||
await page.goto('/');
|
||||
@@ -245,6 +299,38 @@ test('hver fane under indstillinger renderer', async ({ page }) => {
|
||||
expect(trouble).toEqual([]);
|
||||
});
|
||||
|
||||
test('menu- og brødtekststørrelse sættes hver for sig og overlever en genindlæsning', async ({
|
||||
page
|
||||
}) => {
|
||||
const trouble = watchForTrouble(page);
|
||||
await page.goto('/indstillinger');
|
||||
|
||||
// Two independent knobs under Udseende — the sidebar's size, and the body text's.
|
||||
await page.getByLabel('Menu', { exact: true }).selectOption('large');
|
||||
await page.getByLabel('Brødtekst', { exact: true }).selectOption('xl');
|
||||
await expect(page.getByLabel('Menu', { exact: true })).toHaveValue('large');
|
||||
|
||||
const attrs = () =>
|
||||
page.evaluate(() => [
|
||||
document.documentElement.dataset.menuSize,
|
||||
document.documentElement.dataset.textSize
|
||||
]);
|
||||
expect(await attrs()).toEqual(['large', 'xl']);
|
||||
|
||||
// They live in localStorage like the theme, so they survive a reload — and are
|
||||
// applied before first paint, so the picker comes back showing the saved choice.
|
||||
await page.reload();
|
||||
expect(await attrs()).toEqual(['large', 'xl']);
|
||||
await expect(page.getByLabel('Menu', { exact: true })).toHaveValue('large');
|
||||
|
||||
// Put them back, so the shared account does not leak a size into other tests.
|
||||
await page.getByLabel('Menu', { exact: true }).selectOption('default');
|
||||
await page.getByLabel('Brødtekst', { exact: true }).selectOption('default');
|
||||
expect(await attrs()).toEqual([undefined, undefined]);
|
||||
|
||||
expect(trouble).toEqual([]);
|
||||
});
|
||||
|
||||
/**
|
||||
* The PWA's own files. Both of the bugs found last in this project were of this
|
||||
* kind — a manifest promising icons that were never generated — and they are
|
||||
@@ -266,11 +352,65 @@ test('manifestet og service workeren findes, og ikonerne findes også', async ({
|
||||
const appleIcon = await request.get('/apple-touch-icon.png');
|
||||
expect(appleIcon.ok(), 'apple-touch-icon.png findes ikke').toBeTruthy();
|
||||
|
||||
// The service worker is what Web Push needs; without it a subscription cannot
|
||||
// be created at all.
|
||||
const worker = await request.get('/sw.js');
|
||||
// The service worker is what Web Push needs — and, since it also caches, what
|
||||
// carries the app through a short network drop. SvelteKit serves it under this
|
||||
// name and registers it itself; the old hand-registered /sw.js is gone.
|
||||
const worker = await request.get('/service-worker.js');
|
||||
expect(worker.ok()).toBeTruthy();
|
||||
expect(await worker.text()).toContain("addEventListener('push'");
|
||||
// The source is minified, so the quotes around the event names are whatever the
|
||||
// minifier chose — match either kind rather than one it might change under us.
|
||||
const source = await worker.text();
|
||||
expect(source).toMatch(/addEventListener\(['"`]push['"`]/);
|
||||
expect(source).toMatch(/addEventListener\(['"`]fetch['"`]/);
|
||||
});
|
||||
|
||||
/**
|
||||
* The app survives a network drop: reloaded with the network cut, it opens from
|
||||
* the cache and still shows the tasks it last saw, instead of the browser's own
|
||||
* "you are offline" page.
|
||||
*
|
||||
* This is the whole point of the service worker's cache — not offline authoring,
|
||||
* which the app does not claim, but a reload through a tunnel or a handover coming
|
||||
* back to the app rather than to a dead tab. The retry in api.js covers the write
|
||||
* side of the same drop; this covers the read side.
|
||||
*/
|
||||
test.describe('med service worker', () => {
|
||||
// The rest of the suite blocks the worker (see playwright.config.js); this one
|
||||
// test is about the worker, so it turns it back on for its own context.
|
||||
test.use({ serviceWorkers: 'allow' });
|
||||
|
||||
test('appen overlever et netværksudfald og åbner fra cachen', async ({ page, context }) => {
|
||||
// First load, online: the worker installs, and once it controls the page the
|
||||
// shell and the reads it serves are in the cache.
|
||||
await page.goto('/');
|
||||
await expect(page.getByRole('link', { name: 'I dag' })).toBeVisible();
|
||||
|
||||
// Wait until the worker actually controls this page. Until it does, a reload
|
||||
// still goes to the network and the test proves nothing — the first load
|
||||
// registers the worker but the page that triggered the install is not itself
|
||||
// controlled until it activates and claims.
|
||||
await page.waitForFunction(() => navigator.serviceWorker?.controller != null, null, {
|
||||
timeout: 15000
|
||||
});
|
||||
|
||||
// A controlled reload, still online: now the navigation and its API reads pass
|
||||
// through the worker and land in the cache, ready for the drop.
|
||||
await page.reload();
|
||||
await expect(page.getByRole('link', { name: 'I dag' })).toBeVisible();
|
||||
|
||||
// The network is gone.
|
||||
await context.setOffline(true);
|
||||
try {
|
||||
await page.reload();
|
||||
// The shell came from the cache — the sidebar is here, not a browser error
|
||||
// page — and so did the task list the app renders into it.
|
||||
await expect(page.getByRole('link', { name: 'I dag' })).toBeVisible({ timeout: 15000 });
|
||||
await expect(page.getByRole('link', { name: 'Indbakke' })).toBeVisible();
|
||||
} finally {
|
||||
// Never leave the shared context offline for whatever test runs next.
|
||||
await context.setOffline(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -339,9 +479,9 @@ test('en projektgruppe kan foldes, fyldes og slettes uden at tage projekterne me
|
||||
await sidebar.getByLabel('Gruppens navn').fill('Arbejde');
|
||||
await sidebar.getByLabel('Gruppens navn').press('Enter');
|
||||
|
||||
// The name is a link to the group's own page; the chevron beside it is a
|
||||
// The name is a link to the group's own page; the folder icon beside it is a
|
||||
// separate button that folds. Two intentions, two targets — the single one they
|
||||
// used to share could only ever serve the smaller.
|
||||
// used to share could only ever serve the smaller, and neither wears an arrow.
|
||||
//
|
||||
// `exact` on the link, because a group's name is a user-chosen word that can
|
||||
// turn up inside another control's name, and Playwright matches an accessible
|
||||
@@ -351,19 +491,20 @@ test('en projektgruppe kan foldes, fyldes og slettes uden at tage projekterne me
|
||||
await expect(heading).toBeVisible();
|
||||
await expect(sidebar.getByText('Træk et projekt herop')).toBeVisible();
|
||||
|
||||
// A group's name must be readable in full, and must start where a project's
|
||||
// name starts.
|
||||
// A group's name must be readable in full, and must line up with the other
|
||||
// headings — not with the projects filed under it.
|
||||
//
|
||||
// Both halves are here because both were once broken at the same time and for
|
||||
// different reasons. "Omdøb" and "Slet" sat in the flow reserving their width
|
||||
// even while invisible, so ARBEJDE was drawn as "ARBE"; and the fold chevron
|
||||
// sat before the name, pushing a group 22px further in than the projects it
|
||||
// contains — so a group read as if it were filed under them. Every assertion
|
||||
// in this file passed through both, because both buttons still worked.
|
||||
// The clipping half is here because it was once broken: "Omdøb" and "Slet" sat
|
||||
// in the flow reserving their width even while invisible, so ARBEJDE was drawn
|
||||
// as "ARBE". The alignment half changed meaning with the redesign: a group now
|
||||
// carries a section icon just like "Projekter" above it, and belongs to that
|
||||
// heading tier rather than to the project rows below.
|
||||
const shape = await sidebar.locator('.folder-head').evaluate((el) => {
|
||||
const link = el.querySelector('h2 a');
|
||||
const name = { ...link.querySelector('.dot').getBoundingClientRect().toJSON() };
|
||||
// The last child of the link is the name itself; the dot is a span before it.
|
||||
// The leading mark is the section icon in its own fold button, the same
|
||||
// folder/funnel/tag glyph the system headings carry — a group and a section
|
||||
// read identically, and the icon sits before the name, not inside the link.
|
||||
const name = { ...el.querySelector('.head-icon').getBoundingClientRect().toJSON() };
|
||||
return {
|
||||
clipped: link.scrollWidth > link.clientWidth + 1,
|
||||
left: name.left,
|
||||
@@ -375,17 +516,17 @@ test('en projektgruppe kan foldes, fyldes og slettes uden at tage projekterne me
|
||||
expect(shape.clipped, 'gruppens navn bliver klippet').toBe(false);
|
||||
expect(shape.count, 'navnet og tallet overlapper').toBeGreaterThanOrEqual(shape.right);
|
||||
|
||||
// Measured dot to dot, not box to box: both rows begin with the same coloured
|
||||
// mark, and it is the only thing in them that means the same on both sides.
|
||||
// Comparing the group's inner link with the project's outer box reported the
|
||||
// row's own padding as a misalignment.
|
||||
const projectLeft = await sidebar
|
||||
.getByRole('link', { name: 'Regnskab' })
|
||||
.evaluate((el) => el.querySelector('.dot').getBoundingClientRect().left);
|
||||
// A group is a heading, not a project row: it belongs to the same tier as
|
||||
// "Projekter" and the other system sections — icon, bold name, no arrow — and
|
||||
// starts where they start, not where the projects filed under it do. Measured
|
||||
// icon to icon, the one mark both headings share.
|
||||
const sectionLeft = await sidebar
|
||||
.getByRole('heading', { name: 'Projekter' })
|
||||
.evaluate((el) => el.querySelector('.head-icon').getBoundingClientRect().left);
|
||||
expect(
|
||||
Math.abs(shape.left - projectLeft),
|
||||
`gruppen starter ${Math.round(shape.left - projectLeft)}px fra projekterne`
|
||||
).toBeLessThanOrEqual(2);
|
||||
Math.abs(shape.left - sectionLeft),
|
||||
`gruppen starter ${Math.round(shape.left - sectionLeft)}px fra sektionsoverskrifterne`
|
||||
).toBeLessThanOrEqual(4);
|
||||
|
||||
// Dragged in, then dragged back out onto "Projekter" — which is the reason
|
||||
// that heading is a drop target at all: with every project filed away there
|
||||
@@ -408,18 +549,13 @@ test('en projektgruppe kan foldes, fyldes og slettes uden at tage projekterne me
|
||||
'false'
|
||||
);
|
||||
|
||||
// En foldet gruppe står med sin chevron fremme permanent, og den lå oven i
|
||||
// prikken med et felt i --surface bag sig — en lys firkant ud for navnet på
|
||||
// den sænkede bjælke, hele tiden. Nu tones prikken ud i stedet, så der er
|
||||
// ingenting at male henover den med.
|
||||
const chevron = await sidebar
|
||||
.locator('.folder-head .chevron-button')
|
||||
.evaluate((el) => ({
|
||||
background: getComputedStyle(el).backgroundColor,
|
||||
dot: getComputedStyle(el.closest('.folder-head').querySelector('.group-dot')).opacity
|
||||
}));
|
||||
expect(chevron.background, 'chevronen har en firkant bag sig').toBe('rgba(0, 0, 0, 0)');
|
||||
expect(chevron.dot, 'prikken ligger stadig under chevronen').toBe('0');
|
||||
// The fold control is the bare folder icon now — no chevron, and no --surface
|
||||
// field behind it, so a folded group leaves no pale square beside its name on
|
||||
// the sunken bar.
|
||||
const foldBg = await sidebar
|
||||
.locator('.folder-head .fold-icon')
|
||||
.evaluate((el) => getComputedStyle(el).backgroundColor);
|
||||
expect(foldBg, 'foldeknappen har en firkant bag sig').toBe('rgba(0, 0, 0, 0)');
|
||||
|
||||
await sidebar.getByRole('button', { name: /^Fold Arbejde/ }).click();
|
||||
|
||||
@@ -435,11 +571,7 @@ test('en projektgruppe kan foldes, fyldes og slettes uden at tage projekterne me
|
||||
// button on click.
|
||||
await expect(sidebar.getByLabel('Gruppens navn')).toBeVisible();
|
||||
await sidebar.getByLabel('Gruppens navn').press('Enter');
|
||||
|
||||
const painted = await sidebar
|
||||
.locator('.folder-head .group-dot')
|
||||
.evaluate((el) => getComputedStyle(el).backgroundColor);
|
||||
expect(painted, 'gruppens prik fik ikke sin farve').not.toBe('rgba(0, 0, 0, 0)');
|
||||
await expect(sidebar.getByRole('link', { name: 'Arbejde', exact: true })).toBeVisible();
|
||||
|
||||
// The heading itself is *not* indented — only what is filed under it. A heading
|
||||
// that starts further in than the rows above it says the heading is inside
|
||||
@@ -453,10 +585,10 @@ test('en projektgruppe kan foldes, fyldes og slettes uden at tage projekterne me
|
||||
.evaluate((el) => el.getBoundingClientRect().left + parseFloat(getComputedStyle(el).paddingLeft));
|
||||
expect(headLeft, 'gruppehovedet er rykket ind').toBeLessThanOrEqual(looseLeft);
|
||||
|
||||
// A project inside a group starts further in than a row outside one. Measured
|
||||
// rather than asserted on a class, because indentation is a fact about where
|
||||
// the row's contents land — and measured at the *content* edge, not the box:
|
||||
// the indent is padding, so the element's own left edge does not move.
|
||||
// A project sits at the same left margin whether or not it is in a group — one
|
||||
// straight edge down the sidebar, with the bold heading doing the grouping the
|
||||
// indent used to. Measured at the *content* edge, not the box, because what the
|
||||
// eye follows is where the text lands.
|
||||
await sidebar.getByRole('link', { name: 'Regnskab' }).dragTo(heading);
|
||||
const contentLeft = (el) =>
|
||||
el.getBoundingClientRect().left + parseFloat(getComputedStyle(el).paddingLeft);
|
||||
@@ -464,7 +596,10 @@ test('en projektgruppe kan foldes, fyldes og slettes uden at tage projekterne me
|
||||
sidebar.locator('.folder > a').first().evaluate(contentLeft),
|
||||
sidebar.locator('.views a').first().evaluate(contentLeft)
|
||||
]);
|
||||
expect(inside, 'et projekt i en gruppe er ikke rykket ind').toBeGreaterThan(outside);
|
||||
expect(
|
||||
Math.abs(inside - outside),
|
||||
'et projekt i en gruppe står ikke i flugt med de faste visninger'
|
||||
).toBeLessThan(2);
|
||||
|
||||
await sidebar
|
||||
.getByRole('link', { name: 'Regnskab' })
|
||||
@@ -538,8 +673,13 @@ test('en opgave kan trækkes ned i en tom sektion, og en fejlet indlæsning sige
|
||||
await expect(section.getByText('brænde kaffe')).toBeVisible();
|
||||
await expect(page.locator('.toast')).toHaveCount(0);
|
||||
|
||||
// A load that fails says so, and offers to try again.
|
||||
await page.route('**/api/v1/projects/*', (r) => r.abort());
|
||||
// A load that fails with a server error says so at once and offers to try again.
|
||||
// A 500 is the server answering, not a dropped connection, so it is not a blip to
|
||||
// wait out — it is not retried, and the message is immediate. (A dropped
|
||||
// connection now retries for a few seconds first; that is the self-heal test.)
|
||||
await page.route('**/api/v1/projects/*', (r) =>
|
||||
r.fulfill({ status: 500, contentType: 'application/json', body: '{"code":"internal_error"}' })
|
||||
);
|
||||
await page.reload();
|
||||
await expect(page.getByText('Serveren svarede ikke')).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Prøv igen' })).toBeVisible();
|
||||
@@ -550,6 +690,52 @@ test('en opgave kan trækkes ned i en tom sektion, og en fejlet indlæsning sige
|
||||
expect(trouble.filter((t) => !t.includes('projects'))).toEqual([]);
|
||||
});
|
||||
|
||||
/**
|
||||
* A save made during a short drop is not lost to it.
|
||||
*
|
||||
* This is the whole of what "offline" means here: not a cache to work in with no
|
||||
* server, but a save that rides out a few seconds of no connection and goes through
|
||||
* when it comes back — with a quiet "reconnecting" while it waits, and no error and
|
||||
* no reverted change once it heals. A drop that outlasts the retry window is a real
|
||||
* outage and takes the normal error path; that is not this test.
|
||||
*/
|
||||
test('en kort netaudsætning under en handling genoprettes af sig selv', async ({ page }) => {
|
||||
const trouble = watchForTrouble(page);
|
||||
await page.goto('/');
|
||||
|
||||
// Wait for the app to finish loading before cutting the line — `goto` resolves at
|
||||
// the load event, but the data load runs after hydration, and aborting that would
|
||||
// test a cold start, not a blip mid-use.
|
||||
const box = page.getByLabel('Ny opgave');
|
||||
await expect(box).toBeVisible();
|
||||
|
||||
// The app is loaded and online. Now the connection drops — every call fails, the
|
||||
// way it does in a tunnel, rather than one endpoint erroring.
|
||||
let down = true;
|
||||
await page.route('**/api/v1/**', (route) => (down ? route.abort() : route.continue()));
|
||||
|
||||
// A task captured during the drop. Its save fails on the network and starts
|
||||
// retrying rather than giving up.
|
||||
await box.fill('under et udfald');
|
||||
await box.press('Enter');
|
||||
|
||||
// The quiet pill, once the retry has lasted long enough to be worth showing.
|
||||
await expect(page.locator('.netstatus')).toBeVisible();
|
||||
|
||||
// The drop ends. The retry goes through on its own and the pill leaves — no
|
||||
// error, nothing toasted as failed.
|
||||
down = false;
|
||||
await expect(page.locator('.netstatus')).toHaveCount(0, { timeout: 10000 });
|
||||
await expect(page.locator('.toast')).toHaveCount(0);
|
||||
|
||||
// And the save landed: an undated quick capture goes to the Inbox, and there it
|
||||
// is, saved across the drop rather than lost to it.
|
||||
await page.getByRole('link', { name: /Indbakke/ }).click();
|
||||
await expect(page.getByText('under et udfald')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
expect(trouble).toEqual([]);
|
||||
});
|
||||
|
||||
/**
|
||||
* A task can be dragged onto another day, and onto another project.
|
||||
*
|
||||
@@ -925,6 +1111,8 @@ test('en rolle kan rettes uden at fjerne personen', async ({ browser, page }) =>
|
||||
const context = await browser.newContext({ storageState: { cookies: [], origins: [] } });
|
||||
const andreas = await context.newPage();
|
||||
await andreas.goto(link);
|
||||
// Typed in lower case on purpose: the instance capitalises a name on the way
|
||||
// in, so from here on this person is "Andreas" everywhere they are shown.
|
||||
await andreas.getByLabel('Navn', { exact: true }).fill('andreas');
|
||||
await andreas.getByLabel(/Adgangskode/).fill('et langt kodeord til test');
|
||||
await andreas.getByRole('button', { name: 'Opret konto' }).click();
|
||||
@@ -943,7 +1131,7 @@ test('en rolle kan rettes uden at fjerne personen', async ({ browser, page }) =>
|
||||
await page.reload();
|
||||
await projectAction(page, /Delt/);
|
||||
await expect(page.getByText('Ejer')).toBeVisible();
|
||||
await page.getByLabel('Rolle for andreas').selectOption('editor');
|
||||
await page.getByLabel('Rolle for Andreas').selectOption('editor');
|
||||
|
||||
await andreas.reload();
|
||||
await expect(andreas.getByLabel('Ny opgave')).toBeVisible();
|
||||
@@ -956,11 +1144,11 @@ test('en rolle kan rettes uden at fjerne personen', async ({ browser, page }) =>
|
||||
await page.getByLabel('Ny opgave').press('Enter');
|
||||
await page.getByText('brænde kaffe', { exact: true }).click();
|
||||
const drawer = page.getByRole('complementary', { name: 'Opgave' });
|
||||
await drawer.getByLabel('Ansvarlig').selectOption({ label: 'andreas' });
|
||||
await drawer.getByLabel('Ansvarlig').selectOption({ label: 'Andreas' });
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
const row = page.locator('.row').filter({ hasText: 'brænde kaffe' });
|
||||
await expect(row.getByTitle('Uddelegeret til andreas')).toBeVisible();
|
||||
await expect(row.getByTitle('Uddelegeret til Andreas')).toBeVisible();
|
||||
// And not on a task that is nobody's.
|
||||
await page.getByLabel('Ny opgave').fill('min egen');
|
||||
await page.getByLabel('Ny opgave').press('Enter');
|
||||
@@ -1488,9 +1676,18 @@ test('en gruppe er en side med sine projekter, en beskrivelse og filer', async (
|
||||
// Into the group, then onto its page — which is what the heading is a link to
|
||||
// now. The chevron beside it still folds; they are two intentions and the old
|
||||
// single target could only serve the smaller one.
|
||||
await sidebar
|
||||
.getByRole('link', { name: 'Drejebænk' })
|
||||
.dragTo(sidebar.getByRole('link', { name: 'Værksted' }));
|
||||
//
|
||||
// The drop is retried until the project actually nests under the group: a native
|
||||
// HTML5 drag occasionally does not register the first time under CI load, and a
|
||||
// single dragTo then leaves the group empty and the page assertion failing for a
|
||||
// reason that has nothing to do with what the test is about.
|
||||
const nested = sidebar.locator('.folder > a').filter({ hasText: 'Drejebænk' });
|
||||
await expect(async () => {
|
||||
await sidebar
|
||||
.getByRole('link', { name: 'Drejebænk' })
|
||||
.dragTo(sidebar.getByRole('link', { name: 'Værksted' }));
|
||||
await expect(nested).toHaveCount(1, { timeout: 1000 });
|
||||
}).toPass({ timeout: 10000 });
|
||||
await sidebar.getByRole('link', { name: 'Værksted' }).click();
|
||||
|
||||
await expect(page.getByRole('heading', { name: 'Værksted', level: 1 })).toBeVisible();
|
||||
@@ -1941,7 +2138,12 @@ test('en passkey kan registreres og logges ind med', async ({ browser, browserNa
|
||||
// Now sign out and back in with it. No email typed: the device knows which
|
||||
// account its key belongs to, which is also why this page cannot be used to
|
||||
// find out who has an account here.
|
||||
await page.getByRole('navigation', { name: 'Hovedmenu' }).getByText('Log ud').click();
|
||||
// Signing out asks first now: one click arms it, a second within a few seconds
|
||||
// does it. The whole account row is the button; its label changes to the prompt.
|
||||
const signOut = page.getByRole('navigation', { name: 'Hovedmenu' }).locator('.user');
|
||||
await signOut.click();
|
||||
await expect(signOut).toContainText('Tryk igen for at logge ud');
|
||||
await signOut.click();
|
||||
// `exact`, because "Log ind" is a substring of "Log ind med en passkey" and
|
||||
// Playwright matches an accessible name loosely unless told otherwise.
|
||||
await expect(page.getByRole('button', { name: 'Log ind', exact: true })).toBeVisible();
|
||||
|
||||
@@ -51,6 +51,12 @@ export default defineConfig({
|
||||
|
||||
use: {
|
||||
baseURL,
|
||||
// Off by default. The app now ships a caching service worker, and once it
|
||||
// controls a page Playwright's page.route() no longer sees the fetches it
|
||||
// makes — so a test that forces a 500 to check the error path gets the real
|
||||
// 200 through the worker instead, and reads as a broken feature. The one test
|
||||
// that needs the real worker turns it back on for its own context.
|
||||
serviceWorkers: 'block',
|
||||
trace: 'retain-on-failure',
|
||||
screenshot: 'only-on-failure',
|
||||
// Pinned, because the app reads both. The sign-up form sends
|
||||
|
||||
@@ -73,6 +73,19 @@ const SHOTS = [
|
||||
{ name: 'detail', path: (ids) => `/opgave/${ids.detail}`, theme: 'dark' },
|
||||
{ name: 'notes', path: '/noter', theme: 'dark', prepare: openMeetingNote },
|
||||
{ name: 'notes-source', path: '/noter', theme: 'dark', prepare: showNoteSource },
|
||||
// Charcoal, the newest theme — a warm near-black modelled on Apple Notes, with
|
||||
// amber where the green usually is. The notes list shows a theme's surfaces, text
|
||||
// and one accent at once, so that is where the landing page carries it up close.
|
||||
{ name: 'notes-charcoal', path: '/noter', theme: 'charcoal', prepare: openMeetingNote },
|
||||
// The same Today view in each of the six themes, for a gallery that shows the
|
||||
// whole range at a glance. One view throughout, so the only thing that changes
|
||||
// from picture to picture is the theme itself. Names are the themes' own.
|
||||
{ name: 'theme-northern-lights', path: '/', theme: 'dark' },
|
||||
{ name: 'theme-charcoal', path: '/', theme: 'charcoal' },
|
||||
{ name: 'theme-dusk', path: '/', theme: 'dusk' },
|
||||
{ name: 'theme-daylight', path: '/', theme: 'light' },
|
||||
{ name: 'theme-paper', path: '/', theme: 'paper' },
|
||||
{ name: 'theme-contrast', path: '/', theme: 'contrast' },
|
||||
// The new work, and in the light theme, which is what most people want to look
|
||||
// at a landing page in. The calendar drawing tasks to their length, and a note
|
||||
// somebody shared into the "Shared with me" group.
|
||||
|
||||
@@ -86,6 +86,12 @@
|
||||
--text-xl: 1.375rem;
|
||||
--text-2xl: 1.75rem;
|
||||
|
||||
/* The sidebar's own text size, its own knob (Settings → Appearance) so the menu
|
||||
can be made easier to read without dragging the whole list with it. Default is
|
||||
a step up from the old --text-sm the nav used, at medium weight, so the menu
|
||||
items read as menu items. [data-menu-size] on <html> overrides it. */
|
||||
--menu-size: 0.9375rem;
|
||||
|
||||
/* Spacing on a 4px grid. */
|
||||
--s1: 0.25rem;
|
||||
--s2: 0.5rem;
|
||||
@@ -204,6 +210,52 @@
|
||||
--shadow-lg: 0 8px 32px rgb(0 0 0 / 0.4);
|
||||
}
|
||||
|
||||
/* Kul — the greys of Apple Notes' dark mode, to Kristian's own sampled values.
|
||||
Three panel greys, lightest sidebar to darkest editor — the reverse of the usual
|
||||
sunken-is-darkest order, which is why the editor gets its own --editor-bg rather
|
||||
than sharing --surface-raised with the list. The accent turns amber, and the
|
||||
selected menu item, selected note and section headings each get a fallback token
|
||||
so this theme can hit its colours without touching any other. */
|
||||
[data-theme='charcoal'] {
|
||||
--ground: #1e1e1e;
|
||||
--surface: #2a3033;
|
||||
--surface-raised: #242b2e; /* the note list */
|
||||
--surface-sunken: #2d3133; /* the menu / sidebar — lightest here */
|
||||
--line: #34393b;
|
||||
--line-strong: #414749;
|
||||
|
||||
--ink: #ffffff;
|
||||
--ink-muted: #dcdcdc;
|
||||
--ink-faint: #9ba0a2;
|
||||
|
||||
/* Amber, Apple's Notes accent. The bright value is the selected menu item; the
|
||||
dark text rides on top of it. */
|
||||
--accent: #ffce35;
|
||||
--accent-hover: #ffd75a;
|
||||
--accent-sunken: #ffce35;
|
||||
--accent-ink: #1e1e1e;
|
||||
|
||||
/* Per-element, and only here — every other theme falls back to the shared token
|
||||
in the var() calls that read these. */
|
||||
--editor-bg: #1e1e1e; /* the text field, a shade below the list */
|
||||
--note-on-bg: #a78c26; /* a selected note in the list — gold */
|
||||
--note-on-ink: #1e1e1e; /* dark text on the gold */
|
||||
--nav-active-ink: #1e1e1e; /* dark text on the amber menu item */
|
||||
--heading-ink: #8a8e90; /* PROJEKTER and the group names — quiet grey */
|
||||
--note-group-bg: #2d3133; /* day separators take the menu's resting grey, not the darker ground */
|
||||
|
||||
--p1: #cf6b6b;
|
||||
--p2: #d69f5c;
|
||||
--p3: #6b9ecf;
|
||||
--p4: var(--ink-faint);
|
||||
|
||||
--danger: #cf6b6b;
|
||||
--danger-sunken: #33201f;
|
||||
|
||||
--shadow: 0 1px 2px rgb(0 0 0 / 0.25);
|
||||
--shadow-lg: 0 8px 32px rgb(0 0 0 / 0.4);
|
||||
}
|
||||
|
||||
/* Papir — warm light, closer to paper than to a screen. */
|
||||
[data-theme='paper'] {
|
||||
--ground: #f6f1e7;
|
||||
@@ -369,9 +421,13 @@ button {
|
||||
søgefelt. */
|
||||
}
|
||||
|
||||
/* A translucent wash of the accent, not a solid block and not the old near-invisible
|
||||
tint. --accent-sunken sat a hair off the editor's own surface in dark, so a
|
||||
selection could not be seen; a solid accent could, but read as a heavy slab. Mixing
|
||||
the accent part-way into transparent lays a clear green film over the text while it
|
||||
keeps its own colour — visible on white and on the dark surfaces alike. */
|
||||
::selection {
|
||||
background: var(--accent-sunken);
|
||||
color: var(--ink);
|
||||
background: color-mix(in oklab, var(--accent) 42%, transparent);
|
||||
}
|
||||
|
||||
/* Scrollbars, made quiet. The default on Windows is a wide grey slab that
|
||||
@@ -516,3 +572,41 @@ button {
|
||||
line-height: 1.5;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
/* Body text size — its own control in Settings → Appearance, for reading the list
|
||||
and the notes larger (or smaller) without touching the menu. It re-scales the
|
||||
shared type tokens the same way a look does; placed after the looks so that an
|
||||
explicit size choice wins the tokens they both set. The menu has its own knob
|
||||
below and does not move with this one. */
|
||||
[data-text-size='small'] {
|
||||
--text-base: 0.875rem;
|
||||
--text-sm: 0.75rem;
|
||||
--text-lg: 1rem;
|
||||
}
|
||||
|
||||
[data-text-size='large'] {
|
||||
--text-base: 1.0625rem;
|
||||
--text-sm: 0.9375rem;
|
||||
--text-lg: 1.1875rem;
|
||||
}
|
||||
|
||||
[data-text-size='xl'] {
|
||||
--text-base: 1.1875rem;
|
||||
--text-sm: 1.0625rem;
|
||||
--text-lg: 1.3125rem;
|
||||
}
|
||||
|
||||
/* Menu (sidebar) font size — independent of the body size above, because the two
|
||||
are separate questions: a menu you can read at a glance, and a list you can read
|
||||
a paragraph of. */
|
||||
[data-menu-size='small'] {
|
||||
--menu-size: 0.8125rem;
|
||||
}
|
||||
|
||||
[data-menu-size='large'] {
|
||||
--menu-size: 1.0625rem;
|
||||
}
|
||||
|
||||
[data-menu-size='xl'] {
|
||||
--menu-size: 1.1875rem;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,14 @@
|
||||
// face and again in another, which is a visible jump.
|
||||
const look = localStorage.getItem('verdande:look');
|
||||
if (look && look !== 'verdande') document.documentElement.dataset.look = look;
|
||||
|
||||
// The font-size choices change layout too, so they belong before first
|
||||
// paint for the same reason: otherwise the sidebar and the list are drawn
|
||||
// once at one size and again at another.
|
||||
const menuSize = localStorage.getItem('verdande:menu-size');
|
||||
if (menuSize && menuSize !== 'default') document.documentElement.dataset.menuSize = menuSize;
|
||||
const textSize = localStorage.getItem('verdande:text-size');
|
||||
if (textSize && textSize !== 'default') document.documentElement.dataset.textSize = textSize;
|
||||
} catch (e) {
|
||||
// Private browsing can refuse localStorage; the dark default stands.
|
||||
}
|
||||
|
||||
@@ -23,6 +23,57 @@ export class ApiError extends Error {
|
||||
}
|
||||
|
||||
import { t } from './i18n.svelte.js';
|
||||
import { connectivity, sleepOrOnline } from './connectivity.svelte.js';
|
||||
|
||||
/**
|
||||
* How long a request keeps retrying a network failure before giving up.
|
||||
*
|
||||
* This is the whole of the "offline" feature and its whole limit: it rides out a
|
||||
* blip of a few seconds so a save is not lost to it, and then — because the app is
|
||||
* a live view of a shared list, not a local database — it stops and says so rather
|
||||
* than holding an edit for a network that is not coming back. Fifteen seconds is
|
||||
* long enough for a handover or a tunnel and short enough that a real outage fails
|
||||
* while the user is still looking at what they did.
|
||||
*/
|
||||
const RETRY_WINDOW_MS = 15000;
|
||||
|
||||
/** Backoff between attempts: 0.5s, 1s, 2s, then 3s, capped. A waiting sleep also
|
||||
* wakes the instant the OS reports a link again, so most blips end on the first. */
|
||||
const backoff = (attempt) => Math.min(500 * 2 ** attempt, 3000);
|
||||
|
||||
/**
|
||||
* Runs `send` (a fetch), retrying only network failures for a short window.
|
||||
*
|
||||
* A network failure is fetch rejecting — no HTTP status ever arrived. An HTTP
|
||||
* error (4xx/5xx) is the server answering, so it is returned, not retried: retrying
|
||||
* a 400 just asks the same wrong question again. An abort is the caller changing
|
||||
* its mind (a superseded search), so it is left to propagate.
|
||||
*
|
||||
* Retrying is not free of risk: a create whose request reached the server but whose
|
||||
* response was lost would be made twice. For a drop of seconds that is rare, and the
|
||||
* alternative — losing the save every time the network hiccups — is the thing this
|
||||
* exists to stop. A server-side idempotency key would remove even that; it is a
|
||||
* larger change noted for later.
|
||||
*/
|
||||
async function withRetry(send, noRetry = false) {
|
||||
const deadline = Date.now() + (noRetry ? 0 : RETRY_WINDOW_MS);
|
||||
let attempt = 0;
|
||||
for (;;) {
|
||||
try {
|
||||
const res = await send();
|
||||
connectivity.reachable();
|
||||
return res;
|
||||
} catch (e) {
|
||||
if (e?.name === 'AbortError') throw e;
|
||||
if (Date.now() >= deadline) {
|
||||
connectivity.lost();
|
||||
throw new ApiError(0, 'offline', 'ingen forbindelse');
|
||||
}
|
||||
connectivity.retrying();
|
||||
await sleepOrOnline(backoff(attempt++));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The key for each code the API can return.
|
||||
@@ -110,14 +161,10 @@ async function request(method, path, body, options = {}) {
|
||||
init.body = JSON.stringify(body);
|
||||
}
|
||||
|
||||
let res;
|
||||
try {
|
||||
res = await fetch(`/api/v1${path}`, init);
|
||||
} catch (e) {
|
||||
// A network failure is not an HTTP status; give it one the app can handle
|
||||
// the same way as everything else.
|
||||
throw new ApiError(0, 'offline', 'ingen forbindelse');
|
||||
}
|
||||
// Retries a network failure for a few seconds so a short drop does not lose the
|
||||
// call; `withRetry` turns an exhausted window into the same `offline` error the
|
||||
// app already handles. `options.noRetry` opts a call out — used by nothing yet.
|
||||
const res = await withRetry(() => fetch(`/api/v1${path}`, init), options.noRetry);
|
||||
|
||||
if (res.status === 204) return null;
|
||||
|
||||
@@ -157,12 +204,9 @@ async function upload(path, file, field = 'file') {
|
||||
const form = new FormData();
|
||||
form.append(field, file);
|
||||
|
||||
let res;
|
||||
try {
|
||||
res = await fetch(`/api/v1${path}`, { method: 'POST', body: form, credentials: 'same-origin' });
|
||||
} catch {
|
||||
throw new ApiError(0, 'offline', 'ingen forbindelse');
|
||||
}
|
||||
const res = await withRetry(() =>
|
||||
fetch(`/api/v1${path}`, { method: 'POST', body: form, credentials: 'same-origin' })
|
||||
);
|
||||
|
||||
const text = await res.text();
|
||||
let payload = null;
|
||||
|
||||
@@ -651,6 +651,7 @@
|
||||
<div
|
||||
class="allday"
|
||||
data-allday={iso(date)}
|
||||
class:today={iso(date) === todayISO}
|
||||
class:over={over === iso(date)}
|
||||
ondragover={(e) => onDragOver(e, date)}
|
||||
ondragleave={() => (over = null)}
|
||||
@@ -876,12 +877,16 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* White, not the sidebar's sunken ground: a calendar reads lightest when the
|
||||
day itself is the brightest thing on the screen and the events are the soft
|
||||
colour laid on it — the opposite of the grey grid it was, where the events
|
||||
had to shout to be seen at all. */
|
||||
.corner,
|
||||
.head,
|
||||
.gutter,
|
||||
.allday,
|
||||
.daycol {
|
||||
background: var(--ground);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.head {
|
||||
@@ -889,6 +894,16 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Today's whole column, faintly, so the eye finds it before it reads a number —
|
||||
the marker on the date above is the label, this is the glow it sits in. Kept
|
||||
under the events, so a pastel block still reads as its own calendar's colour
|
||||
rather than as this wash tinted. */
|
||||
.head.today,
|
||||
.allday.today,
|
||||
.daycol.today {
|
||||
background: color-mix(in oklab, var(--accent) 6%, var(--surface));
|
||||
}
|
||||
|
||||
.head .wd {
|
||||
display: block;
|
||||
font-size: var(--text-xs);
|
||||
@@ -901,9 +916,19 @@
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
/* The marker at the top the day is named by: today's number in a filled disc,
|
||||
the same one the month grid gives today, so "this is today" is one glance in
|
||||
either view rather than a colour you have to already know to read. */
|
||||
.head.today .num {
|
||||
color: var(--accent);
|
||||
color: var(--accent-ink);
|
||||
background: var(--accent);
|
||||
border-radius: var(--radius-full);
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
font-weight: 560;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.gutter {
|
||||
@@ -977,6 +1002,10 @@
|
||||
/* Placeringen kommer fra `place()` som en inline `style`; alt andet står her.
|
||||
To ting på samme tid deler bredden, så `margin-right` er den ene hårstrå
|
||||
luft, der gør to kasser til to kasser. */
|
||||
/* A soft wash of the calendar's own colour rather than a grey block edged in it:
|
||||
each calendar keeps a dusty, unmistakable nuance, and a screen of them reads
|
||||
as colour laid on white instead of a grid of grey bars. The left edge stays,
|
||||
a shade stronger than the fill, so the block still has a spine. */
|
||||
.tevent {
|
||||
position: absolute;
|
||||
margin-right: 2px;
|
||||
@@ -984,16 +1013,20 @@
|
||||
padding: 1px var(--s1);
|
||||
border-radius: var(--radius-sm);
|
||||
border-left: 3px solid var(--event-colour, var(--line-strong));
|
||||
background: var(--surface-sunken);
|
||||
color: var(--ink-muted);
|
||||
background: color-mix(in oklab, var(--event-colour, var(--line-strong)) 16%, var(--surface));
|
||||
color: var(--ink);
|
||||
font-size: var(--text-xs);
|
||||
line-height: 1.3;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* A task is a card you can pick up, not an event you cannot — so on the white
|
||||
column it is an outlined card, where an event is a solid wash. The priority
|
||||
colour rides the left edge, as it does everywhere else. */
|
||||
.tevent.task {
|
||||
background: var(--surface-raised);
|
||||
background: var(--surface);
|
||||
box-shadow: inset 0 0 0 1px var(--line);
|
||||
border-left-color: var(--line-strong);
|
||||
color: var(--ink);
|
||||
cursor: grab;
|
||||
@@ -1101,7 +1134,8 @@
|
||||
text-align: left;
|
||||
padding: 1px var(--s1);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--surface-raised);
|
||||
background: var(--surface);
|
||||
box-shadow: inset 0 0 0 1px var(--line);
|
||||
border-left: 2px solid var(--line-strong);
|
||||
color: var(--ink);
|
||||
overflow: hidden;
|
||||
@@ -1120,7 +1154,7 @@
|
||||
}
|
||||
|
||||
.chip:hover {
|
||||
background: var(--surface);
|
||||
background: var(--surface-sunken);
|
||||
}
|
||||
|
||||
/* An event reads as a different kind of thing at a glance, before any of the
|
||||
@@ -1140,8 +1174,8 @@
|
||||
padding: 1px var(--s1);
|
||||
border-radius: var(--radius-sm);
|
||||
border-left: 3px solid var(--event-colour);
|
||||
background: var(--surface-sunken);
|
||||
color: var(--ink-muted);
|
||||
background: color-mix(in oklab, var(--event-colour) 16%, var(--surface));
|
||||
color: var(--ink);
|
||||
text-decoration: none;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@@ -1156,7 +1190,7 @@
|
||||
}
|
||||
|
||||
.event:hover {
|
||||
background: var(--surface);
|
||||
background: color-mix(in oklab, var(--event-colour) 26%, var(--surface));
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
@@ -1165,7 +1199,7 @@
|
||||
every calendar anybody has used. */
|
||||
.event.allday {
|
||||
border-left: none;
|
||||
background: color-mix(in oklab, var(--event-colour) 22%, var(--ground));
|
||||
background: color-mix(in oklab, var(--event-colour) 22%, var(--surface));
|
||||
box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--event-colour) 45%, transparent);
|
||||
}
|
||||
|
||||
@@ -1267,20 +1301,18 @@
|
||||
padding: 1px var(--s1);
|
||||
border-radius: var(--radius-sm);
|
||||
border-left: 2px solid var(--line-strong);
|
||||
background: var(--surface-raised);
|
||||
background: var(--surface);
|
||||
box-shadow: inset 0 0 0 1px var(--line);
|
||||
}
|
||||
|
||||
.calendar.week .chip[data-priority='1'] {
|
||||
border-left-color: var(--p1);
|
||||
background: var(--surface-raised);
|
||||
}
|
||||
.calendar.week .chip[data-priority='2'] {
|
||||
border-left-color: var(--p2);
|
||||
background: var(--surface-raised);
|
||||
}
|
||||
.calendar.week .chip[data-priority='3'] {
|
||||
border-left-color: var(--p3);
|
||||
background: var(--surface-raised);
|
||||
}
|
||||
|
||||
/* Readable again in the week, for the reason the task chips are: a
|
||||
@@ -1292,12 +1324,12 @@
|
||||
padding: 1px var(--s1);
|
||||
border-radius: var(--radius-sm);
|
||||
border-left: 3px solid var(--event-colour);
|
||||
background: var(--surface-sunken);
|
||||
background: color-mix(in oklab, var(--event-colour) 16%, var(--surface));
|
||||
}
|
||||
|
||||
.calendar.week .event.allday {
|
||||
border-left: none;
|
||||
background: color-mix(in oklab, var(--event-colour) 22%, var(--ground));
|
||||
background: color-mix(in oklab, var(--event-colour) 22%, var(--surface));
|
||||
}
|
||||
|
||||
.calendar.week .at {
|
||||
|
||||
@@ -31,9 +31,36 @@
|
||||
|
||||
async function signOut() {
|
||||
await api.logout();
|
||||
// Empty the offline data cache before leaving: the service worker keeps the
|
||||
// last-seen task and note lists so a network drop does not blank the app, and
|
||||
// the next person to sign in on this browser must not find them.
|
||||
try {
|
||||
navigator.serviceWorker?.controller?.postMessage({ type: 'clear-api-cache' });
|
||||
await caches?.delete('verdande-api');
|
||||
} catch {
|
||||
// No service worker / no Cache API (older browser, private mode): nothing
|
||||
// was cached, so nothing to clear.
|
||||
}
|
||||
location.href = '/';
|
||||
}
|
||||
|
||||
// Signing out is one click from a button the pointer passes over on its way to
|
||||
// everything below it, and it drops you at the login screen — so it asks first.
|
||||
// A second click within a few seconds confirms; anything else lets it lapse. Not
|
||||
// a dialog: a two-step button is lighter and stays where the eye already is.
|
||||
let confirmSignOut = $state(false);
|
||||
let signOutTimer;
|
||||
function onSignOutClick() {
|
||||
if (confirmSignOut) {
|
||||
clearTimeout(signOutTimer);
|
||||
signOut();
|
||||
return;
|
||||
}
|
||||
confirmSignOut = true;
|
||||
clearTimeout(signOutTimer);
|
||||
signOutTimer = setTimeout(() => (confirmSignOut = false), 3500);
|
||||
}
|
||||
|
||||
let filters = $state([]);
|
||||
let labels = $state([]);
|
||||
|
||||
@@ -487,6 +514,7 @@
|
||||
it, which is the second time that drop has earned its test. -->
|
||||
<a
|
||||
href={item.href}
|
||||
data-view={item.key}
|
||||
class:active={current === item.href}
|
||||
class:receiving={item.key === 'today' && overToday}
|
||||
onclick={onnavigate}
|
||||
@@ -529,6 +557,52 @@
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
{:else if item.key === 'today'}
|
||||
<!-- A star, the way Things marks Today: the one view you open first. -->
|
||||
<svg class="mark" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
d="M8 2l1.7 3.6 3.9.5-2.9 2.7.7 3.9L8 10.9 4.6 13.4l.7-3.9L2.4 6.1l3.9-.5z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.3"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
{:else if item.key === 'upcoming'}
|
||||
<!-- A calendar with a day marked — the Calendar view carries the plain
|
||||
grid, so the marked day keeps the two apart. -->
|
||||
<svg class="mark" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<rect
|
||||
x="2.2"
|
||||
y="3.2"
|
||||
width="11.6"
|
||||
height="10.6"
|
||||
rx="1.4"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
/>
|
||||
<path
|
||||
d="M2.2 6.4h11.6M5.6 2.2v2M10.4 2.2v2"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
<rect x="8.8" y="8.6" width="2.6" height="2.6" rx="0.5" fill="currentColor" />
|
||||
</svg>
|
||||
{:else if item.key === 'delegated'}
|
||||
<!-- A person: the tasks you are waiting on someone else for. -->
|
||||
<svg class="mark" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<circle cx="8" cy="5.4" r="2.5" fill="none" stroke="currentColor" stroke-width="1.4" />
|
||||
<path
|
||||
d="M3.4 13.4c0-2.6 2.1-4.2 4.6-4.2s4.6 1.6 4.6 4.2"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
{:else}
|
||||
<span class="dot" class:today={item.key === 'today'} aria-hidden="true"></span>
|
||||
{/if}
|
||||
@@ -570,6 +644,7 @@
|
||||
{#snippet projectRow(project, sortable)}
|
||||
<a
|
||||
href="/projekt/{project.id}"
|
||||
data-view={project.is_inbox ? 'inbox' : undefined}
|
||||
class:sortable
|
||||
class:active={current === `/projekt/${project.id}`}
|
||||
class:dragging={draggingId === project.id}
|
||||
@@ -593,7 +668,29 @@
|
||||
? onTaskDrop(e, project)
|
||||
: sortable && onDrop(e, project)}
|
||||
>
|
||||
<span class="dot" style="background: {colorVar(project.color)}" aria-hidden="true"></span>
|
||||
{#if project.is_inbox}
|
||||
<!-- A tray, not a coloured dot: the Inbox is a fixed view that happens to
|
||||
be a project, and it reads as one of the views above, not as the first
|
||||
of the projects below. -->
|
||||
<svg class="mark" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
d="M2.3 9.2L4 3.4a1.1 1.1 0 011-.8h6a1.1 1.1 0 011 .8l1.7 5.8"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.3"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
<path
|
||||
d="M2.3 9.2v2.9A1.3 1.3 0 003.6 13.4h8.8a1.3 1.3 0 001.3-1.3V9.2h-3.3l-1 1.7H6.6l-1-1.7z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.3"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
{:else}
|
||||
<span class="dot" style="background: {colorVar(project.color)}" aria-hidden="true"></span>
|
||||
{/if}
|
||||
{projectName(project)}
|
||||
<!-- Open tasks, not people. The same grey number meant three things in this
|
||||
one column — people at a project, projects at a group, tasks at a label
|
||||
@@ -612,28 +709,84 @@
|
||||
<!--
|
||||
A fixed heading that folds, the same way a project group's does.
|
||||
|
||||
One snippet for all four rather than four copies of a chevron and an aria
|
||||
One snippet for all four rather than four copies of an icon and an aria
|
||||
attribute: they have to behave identically, and the group heading is already
|
||||
the proof that they drift otherwise — it grew a fold, a colour and two
|
||||
actions while these stayed plain text.
|
||||
|
||||
The whole heading is the target, not the chevron. At this size a lone chevron
|
||||
is something you miss, and the name is where the eye already is.
|
||||
The whole heading is the target, and the icon is the mark: no arrow beside it.
|
||||
At this size an extra glyph is clutter, and the name is where the eye already
|
||||
is.
|
||||
-->
|
||||
<!-- One monochrome mark per kind of heading, so a section and a group read as the
|
||||
same kind of thing — a folder of projects, a funnel of filters, a tag of
|
||||
labels — instead of one being a faint label and the other a coloured dot. -->
|
||||
{#snippet sectionIcon(key)}
|
||||
{#if key === 'filters'}
|
||||
<svg class="head-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
d="M2.2 3.4h11.6L9.3 8.8v3.4L6.7 10.9V8.8z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
{:else if key === 'labels'}
|
||||
<svg class="head-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
d="M7.7 2.3H13v5.3l-5.3 5.3-5.3-5.3z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
<circle cx="10.2" cy="4.9" r="0.95" fill="currentColor" />
|
||||
</svg>
|
||||
{:else if key === 'shared'}
|
||||
<svg class="head-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<circle cx="6.2" cy="5.6" r="2.1" fill="none" stroke="currentColor" stroke-width="1.4" />
|
||||
<path
|
||||
d="M2.6 12.8c0-2.1 1.7-3.3 3.6-3.3s3.6 1.2 3.6 3.3"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
<path
|
||||
d="M11 9.6c1.5.2 2.6 1.3 2.6 3.2"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
<circle cx="11.2" cy="5.6" r="1.7" fill="none" stroke="currentColor" stroke-width="1.4" />
|
||||
</svg>
|
||||
{:else}
|
||||
<!-- Projekter and every group: a folder of projects. -->
|
||||
<svg class="head-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
d="M2 4.6a1 1 0 011-1h3.1l1.4 1.5H13a1 1 0 011 1v6.3a1 1 0 01-1 1H3a1 1 0 01-1-1z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#snippet foldHeading(key, label)}
|
||||
<!-- No chevron: a system section has no page and nothing to rename, so the
|
||||
whole heading is one button that folds it. The icon and the bold name are
|
||||
the whole control — an arrow beside them was only ever saying "clickable"
|
||||
twice. -->
|
||||
<h2 class="fold">
|
||||
<button
|
||||
onclick={() => app.toggleSection(key)}
|
||||
aria-expanded={!app.sectionCollapsed(key)}
|
||||
>
|
||||
<svg
|
||||
class="chevron"
|
||||
class:collapsed={app.sectionCollapsed(key)}
|
||||
viewBox="0 0 24 24"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path d="M6 9l6 6 6-6" />
|
||||
</svg>
|
||||
{@render sectionIcon(key)}
|
||||
{label}
|
||||
</button>
|
||||
</h2>
|
||||
@@ -656,7 +809,7 @@
|
||||
and with every project filed there would be no loose row left to aim at. -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="group-head"
|
||||
class="group-head sticky-head"
|
||||
class:over={overGroup === ''}
|
||||
ondragover={(e) => {
|
||||
if (!carries(e, PROJECT)) return;
|
||||
@@ -801,31 +954,22 @@
|
||||
</div>
|
||||
</form>
|
||||
{:else}
|
||||
<!-- The button sits inside the heading, not around it, the same way a
|
||||
project's title does: a group *is* a heading in the sidebar, and
|
||||
wrapping an h2 in a button both invalidates the markup and takes
|
||||
the heading away from a screen reader. The whole heading folds —
|
||||
at this size a lone chevron is a target you miss, and the name is
|
||||
where the eye already is. -->
|
||||
<!-- The chevron folds; the name opens the group's own page. Two
|
||||
targets in one heading, because they are two different intentions
|
||||
and the old single one could only ever serve the smaller. -->
|
||||
<!-- No chevron: the folder icon itself folds the group, and the name
|
||||
beside it opens the group's own page. Two intentions, two targets,
|
||||
but no arrow to clutter the rail — the icon a section carries is
|
||||
the same one that folds it here. The button sits inside the
|
||||
heading, not around it: a group *is* a heading, and wrapping an h2
|
||||
in a button both invalidates the markup and takes the heading from
|
||||
a screen reader. -->
|
||||
<button
|
||||
class="chevron-button"
|
||||
class="fold-icon"
|
||||
onclick={() => app.toggleGroup(group.id)}
|
||||
aria-expanded={!group.collapsed}
|
||||
aria-label={group.collapsed
|
||||
? t('sidebar.unfold', { name: group.name })
|
||||
: t('sidebar.fold', { name: group.name })}
|
||||
>
|
||||
<svg
|
||||
class="chevron"
|
||||
class:collapsed={group.collapsed}
|
||||
viewBox="0 0 24 24"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path d="M6 9l6 6 6-6" />
|
||||
</svg>
|
||||
{@render sectionIcon('group')}
|
||||
</button>
|
||||
<h2 class="fold">
|
||||
<!-- Navigation waits two tenths of a second for a second click. A
|
||||
@@ -846,11 +990,6 @@
|
||||
}, 200);
|
||||
}}
|
||||
>
|
||||
<span
|
||||
class="dot group-dot"
|
||||
style="background: {colorVar(group.color)}"
|
||||
aria-hidden="true"
|
||||
></span>
|
||||
{group.name}
|
||||
</a>
|
||||
</h2>
|
||||
@@ -938,12 +1077,12 @@
|
||||
{#if !app.connected}
|
||||
<span class="offline" title={t('nav.offlineHint')}>{t('nav.offline')}</span>
|
||||
{/if}
|
||||
<button class="user" onclick={signOut}>
|
||||
<button class="user" class:confirming={confirmSignOut} onclick={onSignOutClick}>
|
||||
<span class="avatar" style="background: {app.user?.avatar_color}">
|
||||
{app.user?.name?.[0]?.toUpperCase() ?? '?'}
|
||||
</span>
|
||||
<span class="user-name">{app.user?.name}</span>
|
||||
<span class="signout">{t('nav.signOut')}</span>
|
||||
<span class="user-name">{confirmSignOut ? t('nav.signOutConfirm') : app.user?.name}</span>
|
||||
<span class="signout">{confirmSignOut ? '' : t('nav.signOut')}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -979,14 +1118,16 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--s5);
|
||||
padding: var(--s4) var(--s3);
|
||||
/* A few pixels more air down each side than the rows strictly need, so the
|
||||
menu breathes rather than sitting flush against its own edges. */
|
||||
padding: var(--s4) calc(var(--s3) + 3px);
|
||||
background: var(--surface-sunken);
|
||||
border-right: 1px solid var(--line);
|
||||
/* Selve bjælken ruller ikke længere — .scroller gør. `hidden` frem for
|
||||
ingenting, fordi den stadig er den yderste kant: løber en række over,
|
||||
skal den klippes her og ikke skubbe kolonnen bredere. */
|
||||
overflow: hidden;
|
||||
padding-left: max(var(--s3), env(safe-area-inset-left));
|
||||
padding-left: max(calc(var(--s3) + 3px), env(safe-area-inset-left));
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -1005,6 +1146,32 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--s5);
|
||||
/* The sidebar is padded, so the scrollbar sat a pad-width inside the edge and
|
||||
read as floating in the middle. Pull the scroller out to the border and pad
|
||||
the content back, so the bar sits against the edge where a scrollbar
|
||||
belongs — the rows do not move. Thin and dim, so it is present without
|
||||
drawing the eye. */
|
||||
margin-right: calc(var(--s3) * -1);
|
||||
padding-right: var(--s3);
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--line-strong) transparent;
|
||||
}
|
||||
|
||||
.scroller::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
/* No transparent border and no padding-box clip: those centred a 4px bar in a
|
||||
10px track, so the thumb floated three pixels shy of the divider. The bar is
|
||||
the track now — a thin rounded thumb sitting flush against the line on the
|
||||
right, which is where a scrollbar belongs. */
|
||||
.scroller::-webkit-scrollbar-thumb {
|
||||
background: var(--line-strong);
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.scroller::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* Wider than it looks: a 1px target is a target you miss. The visible line stays
|
||||
@@ -1133,8 +1300,26 @@
|
||||
flex: none;
|
||||
}
|
||||
|
||||
a.active .mark {
|
||||
color: var(--accent);
|
||||
/* The fixed views carry a colour of their own, the way Things does — the star
|
||||
amber, the Inbox blue — and keep it whether or not they are the active row.
|
||||
So no active-state override here; the colour is the icon's identity. */
|
||||
[data-view='inbox'] .mark {
|
||||
color: var(--color-blue);
|
||||
}
|
||||
[data-view='today'] .mark {
|
||||
color: var(--color-amber);
|
||||
}
|
||||
[data-view='upcoming'] .mark {
|
||||
color: var(--color-tomato);
|
||||
}
|
||||
[data-view='delegated'] .mark {
|
||||
color: var(--color-violet);
|
||||
}
|
||||
[data-view='notes'] .mark {
|
||||
color: var(--color-teal);
|
||||
}
|
||||
[data-view='calendar'] .mark {
|
||||
color: var(--color-indigo);
|
||||
}
|
||||
|
||||
.group-head {
|
||||
@@ -1144,12 +1329,35 @@
|
||||
padding: 0 var(--s2) var(--s2);
|
||||
}
|
||||
|
||||
/* The Projekter heading holds the only way to add a project or a group, so it
|
||||
must not scroll away with a long list. Pinned to the top of the scroller, on
|
||||
the sidebar's own ground so the rows pass under it. */
|
||||
.sticky-head {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 3;
|
||||
padding-top: var(--s2);
|
||||
background: var(--surface-sunken);
|
||||
}
|
||||
|
||||
/* Every heading — the system sections and the user's groups — reads the same:
|
||||
a mark, then a bold plainly-cased name. What used to set them apart (one a
|
||||
faint uppercase label, the other a bold name with a coloured dot) is gone. */
|
||||
h2 {
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 560;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
color: var(--ink-faint);
|
||||
font-size: var(--menu-size);
|
||||
font-weight: 600;
|
||||
/* Kul sets these headings to a quiet grey (--heading-ink); every other theme
|
||||
falls back to the reading ink and keeps them bold and bright. */
|
||||
color: var(--heading-ink, var(--ink));
|
||||
}
|
||||
|
||||
/* The heading's mark, in the muted ink so the bold name still leads. Sized and
|
||||
nudged like a row's own mark, so the icons line up down the sidebar. */
|
||||
.head-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
flex: none;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
/* Only the square icon buttons — "+" and the folder — and asked for by class
|
||||
@@ -1235,57 +1443,17 @@
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* The chevron on its own, so the name beside it can be a link to the group's
|
||||
page. Sized as a target rather than as a glyph: 11px of arrow is something
|
||||
you miss. */
|
||||
/* The chevron sits on top of the group's dot rather than before it. In the flow
|
||||
it pushed the name 22px further in than a project's, so groups read as if
|
||||
they were filed under the projects above them — the opposite of what they
|
||||
are. Out of the flow, a group's name starts exactly where a project's does.
|
||||
The dot is the resting state; the chevron takes over on hover or focus, and
|
||||
stays put while the group is folded, so a folded group still shows the way
|
||||
back open. */
|
||||
/* Uden baggrund. Knappen dækkede prikken med et felt i --surface, og på den
|
||||
sænkede bjælke er det en lys firkant: en foldet gruppe stod med en hvid
|
||||
klods ud for navnet permanent, fordi chevronen bliver stående, når gruppen
|
||||
er lukket. Prikken tones ud i stedet for at blive dækket — det er samme
|
||||
skifte, uden noget at male henover den med. */
|
||||
.chevron-button {
|
||||
position: absolute;
|
||||
left: calc(var(--s2) - 5px);
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
/* The folder icon is the fold toggle now — no chevron beside it. A bare icon
|
||||
button the size of the icon it holds: the name next to it opens the group's
|
||||
page, this folds it, and neither wears an arrow to say so. */
|
||||
.fold-icon {
|
||||
flex: none;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: var(--radius-sm);
|
||||
color: inherit;
|
||||
opacity: 0;
|
||||
/* Fordi prikken herunder tones ud frem for at blive dækket. En `opacity`
|
||||
under 1 laver en stakkontekst og maler elementet, som var det placeret
|
||||
med `z-index: 0` — så prikken, der står senere i DOM'en, lagde sig oven
|
||||
på knappen i det øjeblik den forsvandt. Den var usynlig og tog stadig
|
||||
klikket: prøven brugte tredive sekunder på at folde en gruppe, der ikke
|
||||
ville foldes. Ét lag op, og rækkefølgen er den samme som før. */
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.folder-head:hover .chevron-button,
|
||||
.chevron-button:focus-visible,
|
||||
.chevron-button[aria-expanded='false'] {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Præcis de tre tilfælde ovenfor, læst nedad i stedet for opad: står chevronen
|
||||
der, er prikken væk. `opacity` og ikke `display`, for de to ligger oven i
|
||||
hinanden — forsvandt prikken ud af flowet, ville navnet rykke sig hver gang
|
||||
pilen kom frem. */
|
||||
.folder-head:hover .group-dot,
|
||||
.folder-head:has(.chevron-button:focus-visible) .group-dot,
|
||||
.folder-head:has(.chevron-button[aria-expanded='false']) .group-dot {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.chevron-button:hover {
|
||||
.fold-icon:hover {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
@@ -1314,22 +1482,6 @@
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.chevron {
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
flex: none;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 2.4;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
transition: transform var(--fast) var(--ease);
|
||||
}
|
||||
|
||||
.chevron.collapsed {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
/* Hidden until the heading is hovered, like the section actions on a project
|
||||
page: two buttons permanently beside a label stop it reading as a label. */
|
||||
.folder-head .count {
|
||||
@@ -1362,29 +1514,19 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* The group's own mark, between the chevron and the name — inside the fold
|
||||
button, so it cannot push the heading in. It is a mark now and not a
|
||||
control: the colour is chosen while renaming, which is the other edit to
|
||||
the same thing. */
|
||||
.group-dot {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
/* Projects inside a group are indented to the group's name, not to its dot:
|
||||
the eye follows the text, and lining up under the dot leaves the names
|
||||
looking a step short of where the heading starts. */
|
||||
/* Projects sit at the same left margin whether or not they are in an area —
|
||||
one straight edge down the whole sidebar reads calmer than a staircase, and
|
||||
the bold area heading above already does the grouping the indent used to. */
|
||||
.folder > a {
|
||||
padding-left: calc(var(--s2) + var(--s4));
|
||||
padding-left: var(--s2);
|
||||
}
|
||||
|
||||
/* The line is indented with them, so a drop between two projects in a group
|
||||
reads as landing in the group rather than across the whole sidebar. */
|
||||
.folder > a.sortable::before {
|
||||
left: calc(var(--s2) + var(--s4));
|
||||
left: var(--s2);
|
||||
}
|
||||
|
||||
.folder > .empty {
|
||||
padding-left: calc(var(--s2) + var(--s4));
|
||||
padding-left: var(--s2);
|
||||
}
|
||||
|
||||
/* Inside the rename form now, so it needs no padding of its own — the form
|
||||
@@ -1441,7 +1583,10 @@
|
||||
border-radius: var(--radius);
|
||||
color: var(--ink-muted);
|
||||
text-decoration: none;
|
||||
font-size: var(--text-sm);
|
||||
/* Its own size (Settings → Appearance) and medium weight, so the menu items
|
||||
carry more than the muted small text they used to and read at a glance. */
|
||||
font-size: var(--menu-size);
|
||||
font-weight: 500;
|
||||
transition:
|
||||
background var(--fast) var(--ease),
|
||||
color var(--fast) var(--ease);
|
||||
@@ -1452,10 +1597,17 @@
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
/* An accent-tinted selection, not a half-step of surface: on the sunken dark
|
||||
sidebar --surface-raised was all but invisible, so the active row read as no
|
||||
different from the rest. --accent-sunken carries the accent hue and stands out
|
||||
in both themes. */
|
||||
a.active {
|
||||
background: var(--surface-raised);
|
||||
color: var(--ink);
|
||||
font-weight: 500;
|
||||
background: var(--accent-sunken);
|
||||
/* On a solid accent (Kul's amber menu item) the label goes dark via
|
||||
--nav-active-ink; on the tinted accent-sunken every other theme uses, it
|
||||
falls back to the reading ink. */
|
||||
color: var(--nav-active-ink, var(--ink));
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Only your own projects reorder. A shared one sits where its owner put it —
|
||||
@@ -1577,6 +1729,16 @@
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
/* Asking to confirm: the row goes to the danger tint and the name is replaced by
|
||||
"click again", so the second click is plainly the one that signs out. */
|
||||
.user.confirming {
|
||||
background: var(--danger-sunken);
|
||||
}
|
||||
|
||||
.user.confirming .user-name {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
|
||||
@@ -228,13 +228,21 @@
|
||||
align-items: flex-start;
|
||||
padding: var(--s3) var(--s2);
|
||||
border-bottom: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
transition:
|
||||
opacity var(--medium) var(--ease),
|
||||
transform var(--medium) var(--ease);
|
||||
}
|
||||
|
||||
.row:hover {
|
||||
background: var(--surface);
|
||||
/* Hover only where there is a real pointer. On a touch screen a :hover on the tap
|
||||
target makes iOS spend the first tap applying the hover and only open on the
|
||||
second — the "double-tap" on iPhone. With no hover to apply, the first tap opens
|
||||
the task. The rounded corners are on the row itself, so the highlight is a
|
||||
rounded box like a note in the list. */
|
||||
@media (hover: hover) {
|
||||
.row:hover {
|
||||
background: var(--surface);
|
||||
}
|
||||
}
|
||||
|
||||
/* The exit: a short lift and fade, so completing something reads as the task
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Connectivity, as the app experiences it — not as the browser reports it.
|
||||
*
|
||||
* This is the WRITE side of surviving a short drop — a few seconds of lost Wi-Fi, a
|
||||
* tunnel, a base station handing over. The READ side lives in the service worker,
|
||||
* which keeps the last-seen task and note lists so a reload through a drop is not a
|
||||
* blank screen. This store is the other half: it is what keeps the save you just made
|
||||
* from being reverted under your hands while the network is briefly gone.
|
||||
*
|
||||
* The request layer drives this: it retries a failed request for a short window
|
||||
* (see api.js) and tells this store while it is trying, so the interface can say
|
||||
* "reconnecting" rather than reverting the change under the user's hands. If the
|
||||
* window runs out it is a real outage, and then the normal error path takes over.
|
||||
*
|
||||
* `navigator.onLine` is only a hint — it goes false when the machine has no route,
|
||||
* but it stays true for a dead gateway or a server that is down, so it cannot be
|
||||
* the source of truth. It is used here only to wake a waiting retry the moment the
|
||||
* OS sees a link again, which is the one thing it is reliable for.
|
||||
*/
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
class Connectivity {
|
||||
/** 'online' — every recent request reached the server.
|
||||
* 'retrying' — a request failed on the network and is being retried.
|
||||
* 'lost' — a request gave up after the retry window; a real outage. */
|
||||
status = $state('online');
|
||||
|
||||
/** A request reached the server. The network is up, whatever it was doing. */
|
||||
reachable() {
|
||||
this.status = 'online';
|
||||
}
|
||||
|
||||
/** A request failed on the network and is about to be tried again. */
|
||||
retrying() {
|
||||
if (this.status !== 'lost') this.status = 'retrying';
|
||||
}
|
||||
|
||||
/** A request used up its retry window without reaching the server. */
|
||||
lost() {
|
||||
this.status = 'lost';
|
||||
}
|
||||
}
|
||||
|
||||
export const connectivity = new Connectivity();
|
||||
|
||||
if (browser) {
|
||||
// The OS lost its link: say so at once rather than waiting for the next request
|
||||
// to fail. It does not, on its own, mean the server is unreachable — but with no
|
||||
// route there is nothing a save can do but wait, and the honest thing is to show
|
||||
// it waiting.
|
||||
window.addEventListener('offline', () => connectivity.retrying());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sleeps for `ms`, but wakes early the moment the OS reports a link again — so a
|
||||
* retry that is biding its time does not sit out the last two seconds of a blip
|
||||
* that has already ended.
|
||||
*/
|
||||
export function sleepOrOnline(ms) {
|
||||
return new Promise((resolve) => {
|
||||
let timer;
|
||||
const done = () => {
|
||||
clearTimeout(timer);
|
||||
if (browser) window.removeEventListener('online', done);
|
||||
resolve();
|
||||
};
|
||||
timer = setTimeout(done, ms);
|
||||
if (browser) window.addEventListener('online', done, { once: true });
|
||||
});
|
||||
}
|
||||
@@ -119,6 +119,7 @@ export const da = {
|
||||
'nav.calendar': 'Kalender',
|
||||
'nav.settings': 'Indstillinger',
|
||||
'nav.signOut': 'Log ud',
|
||||
'nav.signOutConfirm': 'Tryk igen for at logge ud',
|
||||
'nav.main': 'Hovedmenu',
|
||||
'nav.search': 'Søg',
|
||||
'nav.searchLong': 'Søg i opgaver og projekter',
|
||||
@@ -130,6 +131,8 @@ export const da = {
|
||||
'nav.toggleTheme': 'Skift mellem lyst og mørkt tema',
|
||||
'nav.offline': 'Offline',
|
||||
'nav.offlineHint': 'Ændringer fra andre vises ikke lige nu',
|
||||
'net.reconnecting': 'Genopretter forbindelse…',
|
||||
'net.offline': 'Ingen forbindelse',
|
||||
'nav.doItToday': 'Gør det i dag',
|
||||
|
||||
// --- the sidebar's own sections ------------------------------------------------
|
||||
@@ -230,6 +233,14 @@ export const da = {
|
||||
'Gemmes i denne browser. Det er en egenskab ved den skærm, du sidder ved — en bærbar i solen og en skærm i et mørkt rum vil have hvert sit svar.',
|
||||
'account.look': 'Udseende',
|
||||
'account.lookHint': 'Temaet siger hvor lyst. Det her siger hvordan det læses — skrift, luft og hjørner. De to kan kombineres frit.',
|
||||
'account.sizes': 'Skriftstørrelse',
|
||||
'account.sizesHint': 'Menuen og brødteksten kan sættes hver for sig — den ene er et blik ned over en liste, den anden en tekst, man læser.',
|
||||
'account.menuSize': 'Menu',
|
||||
'account.textSize': 'Brødtekst',
|
||||
'size.small': 'Lille',
|
||||
'size.default': 'Standard',
|
||||
'size.large': 'Stor',
|
||||
'size.xl': 'Størst',
|
||||
'look.verdande': 'Verdande',
|
||||
'look.verdandeNote': 'Som du kender den.',
|
||||
'look.rolig': 'Rolig',
|
||||
@@ -440,6 +451,8 @@ export const da = {
|
||||
'view.filterEmpty': 'Ingenting matcher lige nu.',
|
||||
'view.filterFailed': 'Filteret kunne ikke køres.',
|
||||
'view.upcoming': 'Kommende',
|
||||
'view.horizon': 'Periode',
|
||||
'view.days': '{n} dage',
|
||||
'view.mode': 'Visning',
|
||||
'view.list': 'Liste',
|
||||
'view.week': 'Uge',
|
||||
@@ -649,7 +662,7 @@ export const da = {
|
||||
// --- settings: integrations --------------------------------------------------------
|
||||
'int.mailboxes': 'Postkasser',
|
||||
'int.mailboxesHint':
|
||||
'Flag en mail i iCloud, Fastmail eller enhver anden udbyder, og den bliver en opgave. Én vej: fjerner du flaget, sker der ikke noget med opgaven. Office 365 kan ikke bruges her — Microsoft har lukket for kodeord på IMAP.',
|
||||
'Flag en mail i iCloud, Fastmail eller enhver anden udbyder, og den bliver en opgave — flaget fjernes, når opgaven er oprettet. Kun én vej: gør du selv noget ved mailen bagefter, sker der ikke noget med opgaven. Office 365 kan ikke bruges her — Microsoft har lukket for kodeord på IMAP.',
|
||||
'int.addMailbox': 'Tilføj en postkasse',
|
||||
'int.host': 'IMAP-server',
|
||||
'int.username': 'Brugernavn',
|
||||
@@ -665,7 +678,7 @@ export const da = {
|
||||
'int.fetching': 'Henter …',
|
||||
'int.gmail': 'Gmail',
|
||||
'int.gmailHint':
|
||||
'Stjernemarkér en mail, eller giv den en etiket, og den bliver en opgave. Envejs: at fjerne stjernen gør ikke noget ved opgaven.',
|
||||
'Stjernemarkér en mail, eller giv den en etiket, og den bliver en opgave — stjernen fjernes så (en etiket bliver, hvor den er). Det du selv gør ved mailen bagefter, ændrer ikke opgaven.',
|
||||
'int.connectGmail': 'Forbind Gmail',
|
||||
'int.fromEnv':
|
||||
'Klienten er sat i miljøet (VERDANDE_GMAIL_CLIENT_ID), så den kan ikke ændres her. Det er med vilje: en værdi i runens manifest er en beslutning, der bliver anvendt igen ved hver genstart, og en formular, der kunne overskrive den, ville gøre manifestet til en løgn.',
|
||||
@@ -833,6 +846,8 @@ export const da = {
|
||||
// --- the themes -------------------------------------------------------------------
|
||||
'theme.dark': 'Nordlys',
|
||||
'theme.darkNote': 'Mørk med grøn accent.',
|
||||
'theme.charcoal': 'Kul',
|
||||
'theme.charcoalNote': 'Neutral mørkegrå.',
|
||||
'theme.dusk': 'Skumring',
|
||||
'theme.duskNote': 'Mørk og varm, med rav.',
|
||||
'theme.light': 'Dagslys',
|
||||
|
||||
@@ -115,6 +115,7 @@ export const en = {
|
||||
'nav.calendar': 'Calendar',
|
||||
'nav.settings': 'Settings',
|
||||
'nav.signOut': 'Sign out',
|
||||
'nav.signOutConfirm': 'Click again to sign out',
|
||||
'nav.main': 'Main menu',
|
||||
'nav.search': 'Search',
|
||||
'nav.searchLong': 'Search tasks and projects',
|
||||
@@ -126,6 +127,8 @@ export const en = {
|
||||
'nav.toggleTheme': 'Switch between light and dark',
|
||||
'nav.offline': 'Offline',
|
||||
'nav.offlineHint': 'Changes from other people are not showing right now',
|
||||
'net.reconnecting': 'Reconnecting…',
|
||||
'net.offline': 'No connection',
|
||||
'nav.doItToday': 'Do it today',
|
||||
|
||||
// --- the sidebar's own sections ------------------------------------------------
|
||||
@@ -226,6 +229,14 @@ export const en = {
|
||||
'Kept in this browser. It is a property of the screen you are sitting at — a laptop in the sun and a monitor in a dark room want different answers.',
|
||||
'account.look': 'Appearance',
|
||||
'account.lookHint': 'The theme says how bright. This says how it reads — typeface, air and corners. The two combine freely.',
|
||||
'account.sizes': 'Text size',
|
||||
'account.sizesHint': 'The menu and the body text set separately — one is a glance down a list, the other a paragraph you read.',
|
||||
'account.menuSize': 'Menu',
|
||||
'account.textSize': 'Body text',
|
||||
'size.small': 'Small',
|
||||
'size.default': 'Default',
|
||||
'size.large': 'Large',
|
||||
'size.xl': 'Largest',
|
||||
'look.verdande': 'Verdande',
|
||||
'look.verdandeNote': 'As you know it.',
|
||||
'look.rolig': 'Calm',
|
||||
@@ -435,6 +446,8 @@ export const en = {
|
||||
'view.filterEmpty': 'Nothing matches right now.',
|
||||
'view.filterFailed': 'The filter could not be run.',
|
||||
'view.upcoming': 'Upcoming',
|
||||
'view.horizon': 'Range',
|
||||
'view.days': '{n} days',
|
||||
'view.mode': 'View',
|
||||
'view.list': 'List',
|
||||
'view.week': 'Week',
|
||||
@@ -645,7 +658,7 @@ export const en = {
|
||||
// --- settings: integrations --------------------------------------------------------
|
||||
'int.mailboxes': 'Mailboxes',
|
||||
'int.mailboxesHint':
|
||||
'Flag an email in iCloud, Fastmail or any other provider and it becomes a task. One way: removing the flag does nothing to the task. Office 365 cannot be used here — Microsoft has closed IMAP to passwords.',
|
||||
'Flag an email in iCloud, Fastmail or any other provider and it becomes a task — the flag comes off once it has. One way only: what you do to the mail afterwards does not change the task. Office 365 cannot be used here — Microsoft has closed IMAP to passwords.',
|
||||
'int.addMailbox': 'Add a mailbox',
|
||||
'int.host': 'IMAP server',
|
||||
'int.username': 'Username',
|
||||
@@ -661,7 +674,7 @@ export const en = {
|
||||
'int.fetching': 'Fetching …',
|
||||
'int.gmail': 'Gmail',
|
||||
'int.gmailHint':
|
||||
'Star an email, or give it a label, and it becomes a task. One way: removing the star does nothing to the task.',
|
||||
'Star an email, or give it a label, and it becomes a task — the star then comes off (a label stays where it is). What you do to the mail afterwards does not change the task.',
|
||||
'int.connectGmail': 'Connect Gmail',
|
||||
'int.fromEnv':
|
||||
'The client is set in the environment (VERDANDE_GMAIL_CLIENT_ID), so it cannot be changed here. That is deliberate: a value in the Rune’s manifest is a decision reapplied on every restart, and a form that could overwrite it would make the manifest a lie.',
|
||||
@@ -826,6 +839,8 @@ export const en = {
|
||||
// --- the themes -------------------------------------------------------------------
|
||||
'theme.dark': 'Northern lights',
|
||||
'theme.darkNote': 'Dark, with a green accent.',
|
||||
'theme.charcoal': 'Charcoal',
|
||||
'theme.charcoalNote': 'Neutral dark grey.',
|
||||
'theme.dusk': 'Dusk',
|
||||
'theme.duskNote': 'Dark and warm, with amber.',
|
||||
'theme.light': 'Daylight',
|
||||
|
||||
@@ -26,9 +26,13 @@ export function permission() {
|
||||
}
|
||||
|
||||
async function registration() {
|
||||
// `ready` waits for an active worker; register() alone resolves while the
|
||||
// worker is still installing, and subscribing against that fails.
|
||||
await navigator.serviceWorker.register('/sw.js');
|
||||
// SvelteKit registers src/service-worker.js itself on load, so normally there
|
||||
// is already a registration here. Register it by hand only if there is not yet
|
||||
// one — a push subscribe that races the app's own registration would otherwise
|
||||
// find nothing. `ready` waits for an active worker; register() alone resolves
|
||||
// while the worker is still installing, and subscribing against that fails.
|
||||
const existing = await navigator.serviceWorker.getRegistration();
|
||||
if (!existing) await navigator.serviceWorker.register('/service-worker.js');
|
||||
return navigator.serviceWorker.ready;
|
||||
}
|
||||
|
||||
|
||||
@@ -865,8 +865,8 @@ class SidebarLayout {
|
||||
export const sidebar = new SidebarLayout();
|
||||
|
||||
/**
|
||||
* Whether Kommende shows the next seven days as a list, one week as a grid, or the
|
||||
* whole month.
|
||||
* Whether Kommende shows a run of days as a list, one week as a grid, or the whole
|
||||
* month.
|
||||
*
|
||||
* In localStorage rather than on the account, and for the same reason as the
|
||||
* sidebar's width: a grid of seven columns needs room, and the answer on a phone is
|
||||
@@ -878,24 +878,48 @@ export const sidebar = new SidebarLayout();
|
||||
*/
|
||||
const UPCOMING_MODES = ['list', 'week', 'calendar'];
|
||||
|
||||
/**
|
||||
* How far the list looks ahead, in days.
|
||||
*
|
||||
* Seven days is a week's horizon and answers "what is coming"; thirty answers
|
||||
* "when does this month get busy", which is the question a month grid answers by
|
||||
* shape but not in order. The list is the only mode that takes a horizon — the
|
||||
* grids are anchored to a week and a month, and a fortnight is neither.
|
||||
*
|
||||
* The server caps the window at 31 days, so nothing here may exceed that.
|
||||
*/
|
||||
export const UPCOMING_DAYS = [7, 14, 30];
|
||||
|
||||
class UpcomingView {
|
||||
mode = $state(read());
|
||||
mode = $state(readChoice('verdande:upcoming', UPCOMING_MODES, 'list'));
|
||||
days = $state(readChoice('verdande:upcoming-days', UPCOMING_DAYS, 7, Number));
|
||||
|
||||
set(next) {
|
||||
if (!UPCOMING_MODES.includes(next)) return;
|
||||
this.mode = next;
|
||||
try {
|
||||
localStorage.setItem('verdande:upcoming', next);
|
||||
} catch {
|
||||
// Private browsing; the choice simply will not persist.
|
||||
}
|
||||
writeChoice('verdande:upcoming', next);
|
||||
}
|
||||
|
||||
setDays(next) {
|
||||
const n = Number(next);
|
||||
if (!UPCOMING_DAYS.includes(n)) return;
|
||||
this.days = n;
|
||||
writeChoice('verdande:upcoming-days', n);
|
||||
}
|
||||
}
|
||||
|
||||
function read() {
|
||||
if (typeof localStorage === 'undefined') return 'list';
|
||||
const stored = localStorage.getItem('verdande:upcoming');
|
||||
return UPCOMING_MODES.includes(stored) ? stored : 'list';
|
||||
function readChoice(key, allowed, fallback, parse = String) {
|
||||
if (typeof localStorage === 'undefined') return fallback;
|
||||
const stored = parse(localStorage.getItem(key));
|
||||
return allowed.includes(stored) ? stored : fallback;
|
||||
}
|
||||
|
||||
function writeChoice(key, value) {
|
||||
try {
|
||||
localStorage.setItem(key, String(value));
|
||||
} catch {
|
||||
// Private browsing; the choice simply will not persist.
|
||||
}
|
||||
}
|
||||
|
||||
export const upcomingView = new UpcomingView();
|
||||
@@ -1006,6 +1030,7 @@ export const completedView = new CompletedView();
|
||||
*/
|
||||
export const THEMES = [
|
||||
{ id: 'dark', name: 'theme.dark', note: 'theme.darkNote', dark: true },
|
||||
{ id: 'charcoal', name: 'theme.charcoal', note: 'theme.charcoalNote', dark: true },
|
||||
{ id: 'dusk', name: 'theme.dusk', note: 'theme.duskNote', dark: true },
|
||||
{ id: 'light', name: 'theme.light', note: 'theme.lightNote', dark: false },
|
||||
{ id: 'paper', name: 'theme.paper', note: 'theme.paperNote', dark: false },
|
||||
@@ -1051,6 +1076,52 @@ class Look {
|
||||
|
||||
export const look = new Look();
|
||||
|
||||
/**
|
||||
* The font-size steps, shared by the menu and the body-text controls. `default`
|
||||
* carries no attribute, so the base tokens in app.css stand unchanged.
|
||||
*/
|
||||
export const SIZES = [
|
||||
{ id: 'small', name: 'size.small' },
|
||||
{ id: 'default', name: 'size.default' },
|
||||
{ id: 'large', name: 'size.large' },
|
||||
{ id: 'xl', name: 'size.xl' }
|
||||
];
|
||||
|
||||
/**
|
||||
* A font-size preference — the same shape as Look: kept in localStorage and
|
||||
* mirrored onto <html>, where app.html sets it before first paint so a chosen size
|
||||
* does not flash in at the default and resize. Two instances below, because the
|
||||
* menu and the body text are separate questions.
|
||||
*/
|
||||
class Sizing {
|
||||
current = $state('default');
|
||||
#key;
|
||||
#attr;
|
||||
|
||||
constructor(key, attr) {
|
||||
this.#key = key;
|
||||
this.#attr = attr;
|
||||
if (typeof document !== 'undefined') {
|
||||
this.current = document.documentElement.dataset[attr] ?? 'default';
|
||||
}
|
||||
}
|
||||
|
||||
set(id) {
|
||||
if (!SIZES.some((s) => s.id === id)) return;
|
||||
this.current = id;
|
||||
if (id === 'default') delete document.documentElement.dataset[this.#attr];
|
||||
else document.documentElement.dataset[this.#attr] = id;
|
||||
try {
|
||||
localStorage.setItem(this.#key, id);
|
||||
} catch {
|
||||
// Private browsing; the choice simply will not persist.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const menuSize = new Sizing('verdande:menu-size', 'menuSize');
|
||||
export const textSize = new Sizing('verdande:text-size', 'textSize');
|
||||
|
||||
/** Theme, kept in localStorage and applied to the document element. */
|
||||
class Theme {
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script>
|
||||
import '../app.css';
|
||||
import { app, theme, sidebar } from '$lib/stores.svelte.js';
|
||||
import { connectivity } from '$lib/connectivity.svelte.js';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import Sidebar from '$lib/components/Sidebar.svelte';
|
||||
@@ -14,6 +15,29 @@
|
||||
let paletteOpen = $state(false);
|
||||
let sidebarOpen = $state(false);
|
||||
|
||||
/**
|
||||
* Whether to show the "reconnecting" pill.
|
||||
*
|
||||
* Held back seven tenths of a second while merely retrying, so a blip that ends
|
||||
* on the first retry never flashes a pill nobody needed to see. A retry that has
|
||||
* already given up ('lost') is a real error and shown at once — the delay is only
|
||||
* for the hopeful case.
|
||||
*/
|
||||
let showNet = $state(false);
|
||||
$effect(() => {
|
||||
const s = connectivity.status;
|
||||
if (s === 'online') {
|
||||
showNet = false;
|
||||
return;
|
||||
}
|
||||
if (s === 'lost') {
|
||||
showNet = true;
|
||||
return;
|
||||
}
|
||||
const timer = setTimeout(() => (showNet = true), 700);
|
||||
return () => clearTimeout(timer);
|
||||
});
|
||||
|
||||
/**
|
||||
* The two pages that arrive by email, and are for somebody who is not signed in.
|
||||
*
|
||||
@@ -204,6 +228,16 @@
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<!-- A short drop, said quietly: it appears only if a save is still retrying after
|
||||
the better part of a second, and leaves the moment the connection is back — so
|
||||
a two-second blip that heals itself is felt as nothing at all. -->
|
||||
{#if showNet}
|
||||
<div class="netstatus" class:lost={connectivity.status === 'lost'} role="status">
|
||||
<span class="net-dot" aria-hidden="true"></span>
|
||||
{connectivity.status === 'lost' ? t('net.offline') : t('net.reconnecting')}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
@@ -378,6 +412,62 @@
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
/* The reconnecting pill: at the top, small, centred. Not a toast — a toast is a
|
||||
thing that happened and is over, this is a thing still happening. */
|
||||
.netstatus {
|
||||
position: fixed;
|
||||
top: calc(var(--s3) + env(safe-area-inset-top));
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 60;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--s2);
|
||||
padding: var(--s1) var(--s3);
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--surface-raised);
|
||||
border: 1px solid var(--line-strong);
|
||||
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.net-dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
flex: none;
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--color-amber);
|
||||
animation: net-pulse 1.1s ease-in-out infinite;
|
||||
}
|
||||
|
||||
/* Given up: an amber pulse becomes a still red, the same red a failed toast
|
||||
carries, so "still trying" and "gave up" do not look alike. */
|
||||
.netstatus.lost {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.netstatus.lost .net-dot {
|
||||
background: var(--p1);
|
||||
animation: none;
|
||||
}
|
||||
|
||||
@keyframes net-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.35;
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.net-dot {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
.toast {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
/** Konto: who you are, your password, and the second factor. */
|
||||
import { api, humanMessage } from '$lib/api.js';
|
||||
import { app, theme, THEMES, look, LOOKS } from '$lib/stores.svelte.js';
|
||||
import { app, theme, THEMES, look, LOOKS, menuSize, textSize, SIZES } from '$lib/stores.svelte.js';
|
||||
import { t, plural, i18n } from '$lib/i18n.svelte.js';
|
||||
import { supported, register } from '$lib/passkey.js';
|
||||
import { ago } from '$lib/when.js';
|
||||
@@ -138,6 +138,7 @@
|
||||
|
||||
let totpSecret = $state('');
|
||||
let totpURI = $state('');
|
||||
let totpQR = $state('');
|
||||
let totpCode = $state('');
|
||||
let totpErrors = $state({});
|
||||
let recoveryCodes = $state([]);
|
||||
@@ -163,6 +164,7 @@
|
||||
enablePassword = '';
|
||||
totpSecret = r.secret;
|
||||
totpURI = r.uri;
|
||||
totpQR = r.qr;
|
||||
} catch (e) {
|
||||
totpErrors = e.fields ?? {};
|
||||
if (!Object.keys(totpErrors).length) app.toast(humanMessage(e));
|
||||
@@ -177,6 +179,7 @@
|
||||
recoveryCodes = r.recovery_codes;
|
||||
totpSecret = '';
|
||||
totpURI = '';
|
||||
totpQR = '';
|
||||
totpCode = '';
|
||||
app.user = await api.me();
|
||||
} catch (e) {
|
||||
@@ -362,6 +365,40 @@
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Two more axes: how large the menu reads and how large the body text reads.
|
||||
Separate on purpose — one is a glance down a list of names, the other is a
|
||||
paragraph you sit and read. -->
|
||||
<div class="sizes">
|
||||
<h3>{t('account.sizes')}</h3>
|
||||
<p class="hint">{t('account.sizesHint')}</p>
|
||||
<div class="size-row">
|
||||
<div class="size-field">
|
||||
<label for="menu-size">{t('account.menuSize')}</label>
|
||||
<select
|
||||
id="menu-size"
|
||||
value={menuSize.current}
|
||||
onchange={(e) => menuSize.set(e.currentTarget.value)}
|
||||
>
|
||||
{#each SIZES as option (option.id)}
|
||||
<option value={option.id}>{t(option.name)}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
<div class="size-field">
|
||||
<label for="text-size">{t('account.textSize')}</label>
|
||||
<select
|
||||
id="text-size"
|
||||
value={textSize.current}
|
||||
onchange={(e) => textSize.set(e.currentTarget.value)}
|
||||
>
|
||||
{#each SIZES as option (option.id)}
|
||||
<option value={option.id}>{t(option.name)}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
@@ -458,8 +495,13 @@
|
||||
{:else if totpSecret}
|
||||
<div class="field">
|
||||
<p class="hint">{t('account.scanHint')}</p>
|
||||
{#if totpQR}
|
||||
<!-- The server renders the otpauth URI as an SVG QR — one dark path on a
|
||||
white square, so it scans in either theme. It is the URI it already
|
||||
sent, drawn; nothing here builds it. -->
|
||||
<div class="qr">{@html totpQR}</div>
|
||||
{/if}
|
||||
<p class="mono secret">{totpSecret}</p>
|
||||
<p class="hint mono uri">{totpURI}</p>
|
||||
</div>
|
||||
|
||||
<form onsubmit={confirmTOTP}>
|
||||
@@ -480,7 +522,14 @@
|
||||
|
||||
<div class="row">
|
||||
<button class="primary" type="submit">{t('account.confirm')}</button>
|
||||
<button class="secondary" onclick={() => (totpSecret = '')}>{t('account.cancel')}</button>
|
||||
<button
|
||||
class="secondary"
|
||||
onclick={() => {
|
||||
totpSecret = '';
|
||||
totpURI = '';
|
||||
totpQR = '';
|
||||
}}>{t('account.cancel')}</button
|
||||
>
|
||||
</div>
|
||||
</form>
|
||||
{:else}
|
||||
@@ -619,6 +668,37 @@
|
||||
margin-bottom: var(--s1);
|
||||
}
|
||||
|
||||
.sizes {
|
||||
margin-top: var(--s4);
|
||||
padding-top: var(--s3);
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.sizes h3 {
|
||||
font-size: var(--text-sm);
|
||||
margin-bottom: var(--s1);
|
||||
}
|
||||
|
||||
.size-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
gap: var(--s3);
|
||||
margin-top: var(--s3);
|
||||
}
|
||||
|
||||
.size-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--s1);
|
||||
}
|
||||
|
||||
.size-field label {
|
||||
font-size: var(--text-xs);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
color: var(--ink-faint);
|
||||
}
|
||||
|
||||
.look-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
|
||||
@@ -794,6 +874,23 @@
|
||||
color: var(--ink-faint);
|
||||
}
|
||||
|
||||
/* On its own white card whatever the theme: a QR is dark-on-light or it does not
|
||||
scan, so the square keeps its own background rather than taking the page's. */
|
||||
.qr {
|
||||
width: 176px;
|
||||
height: 176px;
|
||||
padding: var(--s2);
|
||||
background: #ffffff;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.qr :global(svg) {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.secret {
|
||||
margin: 0;
|
||||
padding: var(--s3);
|
||||
@@ -804,10 +901,6 @@
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.uri {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
/* The understated variant: present, not loud. Bordered and in the muted ink so
|
||||
it reads as a footnote, brightening on hover. The cup is outline-only. */
|
||||
.bmc {
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
<p class="hint">{t('data.doneHint')}</p>
|
||||
</header>
|
||||
<div class="row">
|
||||
<a class="ghost" href="/faerdige">{t('data.openDone')}</a>
|
||||
<a class="link" href="/faerdige">{t('data.openDone')}</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@
|
||||
|
||||
<!-- The registration behind the button, for whoever can do something about
|
||||
it. Google issues no Gmail access to an unregistered client, and
|
||||
gmail.readonly is a restricted scope — so this step cannot be skipped by
|
||||
gmail.modify is a restricted scope — so this step cannot be skipped by
|
||||
any app. It can stop requiring a redeploy, which is what this is. -->
|
||||
{#if app.user?.is_admin && client}
|
||||
{#if client.from_env}
|
||||
|
||||
@@ -132,7 +132,10 @@
|
||||
if (days === 1) return { key: 'i-gaar', label: t('notes.groupYesterday') };
|
||||
if (days < 7) return { key: 'ugen', label: t('notes.groupWeek') };
|
||||
|
||||
const label = at.toLocaleDateString(tag(), { month: 'long', year: 'numeric' });
|
||||
// Stort forbogstav på måneden: Intl giver "august 2026" på dansk, og en
|
||||
// overskrift begynder med stort.
|
||||
const month = at.toLocaleDateString(tag(), { month: 'long', year: 'numeric' });
|
||||
const label = month.charAt(0).toUpperCase() + month.slice(1);
|
||||
return { key: `m-${at.getFullYear()}-${at.getMonth()}`, label };
|
||||
}
|
||||
|
||||
@@ -704,7 +707,10 @@
|
||||
}}
|
||||
/>
|
||||
|
||||
<div class="notes">
|
||||
<!-- `has-note` drives the phone layout: one column, showing the list until a note
|
||||
is opened and the editor once one is. On a wide screen both are always up and
|
||||
the class does nothing. -->
|
||||
<div class="notes" class:has-note={selectedId}>
|
||||
<aside>
|
||||
<div class="head">
|
||||
<h1>{t('notes.title')}</h1>
|
||||
@@ -810,7 +816,11 @@
|
||||
</svg>
|
||||
</span>
|
||||
{:else}
|
||||
<span class="mark" class:closed={folded.has(group.key)} aria-hidden="true">▾</span>
|
||||
<!-- No arrow, to match the sidebar: the box folds on a click,
|
||||
the star and the people icon are the marks that mean
|
||||
something, and a date group has none — an empty spacer, so
|
||||
every label still starts at the same place. -->
|
||||
<span class="mark" aria-hidden="true"></span>
|
||||
{/if}
|
||||
{group.label}
|
||||
<span class="count">{group.notes.length}</span>
|
||||
@@ -831,41 +841,38 @@
|
||||
ondragstart={(e) => onDragStart(e, note)}
|
||||
ondragend={() => (dragging = null)}
|
||||
>
|
||||
<!-- Titel og projekt på linje ét, uddrag på linje to. Datoen står
|
||||
i gruppens overskrift og ikke her — undtagen når der er sorteret
|
||||
på navn, for så er der ingen overskrift, der siger den, og så er
|
||||
den det eneste tilbage, der gør. -->
|
||||
<!-- Tre linjer, som Apple Noter: titlen, så datoen og uddraget, og
|
||||
nederst hvor noten er lagt. Datoen står forrest på linje to og
|
||||
venstrestillet, ikke ude til højre. -->
|
||||
<span class="head">
|
||||
<strong>{note.title || t('notes.untitled')}</strong>
|
||||
{#if order === 'title'}
|
||||
<span class="when" title={stamp(note)}>{when(shownDate(note))}</span>
|
||||
{/if}
|
||||
{#if note.project_id}
|
||||
<!-- Projektets egen farve, den samme som prikken i sidebjælken.
|
||||
Mærkaten sagde det samme som alle de andre i en grå, der var
|
||||
lysere end uddraget — og projektet er dét, man skanner efter,
|
||||
når man leder i tolv hundrede noter. Nu kan Hjem kendes fra
|
||||
Claude uden at læse ordet. -->
|
||||
<span class="filed" style="--project: {projectColour(note.project_id)}">
|
||||
<span class="dot" aria-hidden="true"></span>
|
||||
{projectName(note.project_id)}
|
||||
</span>
|
||||
{/if}
|
||||
</span>
|
||||
<span class="preview">
|
||||
<span class="when" title={stamp(note)}>{when(shownDate(note))}</span>
|
||||
<span class="snippet">{preview(note)}</span>
|
||||
</span>
|
||||
<!-- Linje tre: hvor noten er lagt, med den samme mappe som grupperne i
|
||||
menuen — projektets navn, ejerens hvis den er en andens, ellers bare
|
||||
"Noter", når den ikke hører til et projekt. -->
|
||||
<span class="filed">
|
||||
{#if note.shared_with_me && note.owner}
|
||||
<!-- Hvis note delt med mig: hvem den kom fra, i personens egen
|
||||
avatar-farve. Samme form som projekt-mærkaten, så listen har
|
||||
ét sprog for "det her hører til nogen". -->
|
||||
<span
|
||||
class="filed person"
|
||||
style="--project: {note.owner.avatar_color}"
|
||||
title={t('notes.sharedBy', { name: note.owner.name })}
|
||||
>
|
||||
<span class="dot" aria-hidden="true"></span>
|
||||
{note.owner.name}
|
||||
</span>
|
||||
<svg class="filed-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<circle cx="8" cy="6" r="2.3" fill="none" stroke="currentColor" stroke-width="1.4" />
|
||||
<path d="M3.6 13c0-2.5 2-4 4.4-4s4.4 1.5 4.4 4" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||||
</svg>
|
||||
<span class="filed-name" title={t('notes.sharedBy', { name: note.owner.name })}>{note.owner.name}</span>
|
||||
{:else if note.project_id}
|
||||
<svg class="filed-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path d="M2 4.6a1 1 0 011-1h3.1l1.4 1.5H13a1 1 0 011 1v6.3a1 1 0 01-1 1H3a1 1 0 01-1-1z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<span class="filed-name">{projectName(note.project_id)}</span>
|
||||
{:else}
|
||||
<svg class="filed-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path d="M2 4.6a1 1 0 011-1h3.1l1.4 1.5H13a1 1 0 011 1v6.3a1 1 0 01-1 1H3a1 1 0 01-1-1z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<span class="filed-name">{t('notes.title')}</span>
|
||||
{/if}
|
||||
</span>
|
||||
<span class="preview">{preview(note)}</span>
|
||||
</button>
|
||||
<!-- De to knapper står oven på hinanden i en smal søjle.
|
||||
Ved siden af hinanden tog de toogfyrre pixels af en liste,
|
||||
@@ -912,7 +919,15 @@
|
||||
</aside>
|
||||
|
||||
<section class="editor">
|
||||
{#if selected}
|
||||
{#if selectedId}
|
||||
<!-- Keyed on the id, which is set the instant a row is tapped — not on the
|
||||
loaded note, which arrives a moment later. On a phone that moment was the
|
||||
whole bug: the pane did not switch until the body had loaded, so the first
|
||||
tap looked like nothing and people tapped again. -->
|
||||
<!-- Phone only (hidden on a wide screen by CSS): the way back to the list,
|
||||
since there the editor fills the screen and the list is not beside it. -->
|
||||
<button class="back" onclick={() => open(null)}>‹ {t('notes.title')}</button>
|
||||
{#if selected}
|
||||
<NoteEditor
|
||||
note={selected}
|
||||
notes={notes}
|
||||
@@ -1046,6 +1061,12 @@
|
||||
{/if}
|
||||
</div>
|
||||
</footer>
|
||||
{:else}
|
||||
<!-- Chosen, but its full text is still loading. Keep the pane (so the tap
|
||||
felt like it landed) and stay quiet — the "pick a note" line is for
|
||||
when nothing is chosen at all, not for this half-second. -->
|
||||
<p class="empty" aria-busy="true"></p>
|
||||
{/if}
|
||||
{:else}
|
||||
<p class="empty">{t('notes.pickOne')}</p>
|
||||
{/if}
|
||||
@@ -1064,8 +1085,9 @@
|
||||
against the sidebar's rule, which reads as a rendering fault rather than
|
||||
as a layout. */
|
||||
/* Luft hele vejen rundt om arket. Højre og bund var nul, dengang editoren
|
||||
ingen kant havde og ingenting kunne støde imod. */
|
||||
padding: var(--s3) var(--s4) var(--s3) var(--s4);
|
||||
ingen kant havde og ingenting kunne støde imod. Et par pixels mere om
|
||||
notelisten, så kortet ikke ligger klods op ad menuen. */
|
||||
padding: var(--s3) var(--s4) var(--s3) calc(var(--s4) + 3px);
|
||||
display: grid;
|
||||
grid-template-columns: minmax(220px, 300px) 1fr;
|
||||
gap: var(--s4);
|
||||
@@ -1079,8 +1101,15 @@
|
||||
gap: var(--s2);
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
border-right: 1px solid var(--line);
|
||||
padding-right: var(--s3);
|
||||
/* A rounded card, the same corner and border as the editor beside it — the
|
||||
list is its own sheet, not a column ruled off the page. */
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
/* White in light, a nuance lighter than the ground in dark — the note list
|
||||
is a surface you read down, so it lifts off the page like the editor does.
|
||||
--surface-raised is #fff in the light themes and one step up in the dark. */
|
||||
background: var(--surface-raised);
|
||||
padding: var(--s3);
|
||||
}
|
||||
|
||||
.head {
|
||||
@@ -1317,13 +1346,20 @@
|
||||
* målt på en rigtig række: titel plus én linje uddrag. */
|
||||
li {
|
||||
content-visibility: auto;
|
||||
contain-intrinsic-size: auto 54px;
|
||||
contain-intrinsic-size: auto 74px;
|
||||
}
|
||||
|
||||
/* A faint hairline between notes, as Apple Notes has — the group boxes give the
|
||||
coarse structure, this separates one note from the next inside a group. */
|
||||
.rowline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--s1);
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
li:last-child .rowline {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* De sjældne handlinger i en søjle, ikke en række. To knapper ved siden af
|
||||
@@ -1362,43 +1398,51 @@
|
||||
*
|
||||
* Baggrunden er ikke gennemsigtig. En klæbende overskrift uden en er en
|
||||
* overskrift med rækkerne kørende igennem sig. */
|
||||
/* One design with the sidebar headings: a rounded box, the same corner as an
|
||||
active menu item, filled just enough to separate one group of notes from the
|
||||
next. The hard rule underneath is gone — the box is the separation now. */
|
||||
h3.group {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
margin: 0;
|
||||
background: var(--ground);
|
||||
border-bottom: 1px solid var(--line);
|
||||
margin: 0 0 var(--s1);
|
||||
/* --ground everywhere but Kul, where the ground is the darkest thing on screen
|
||||
and a day separator on it reads as a dark bar. There it takes the menu's own
|
||||
resting colour instead, via --note-group-bg. */
|
||||
background: var(--note-group-bg, var(--ground));
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
/* Bold and plainly cased, in the reading ink — the faint uppercase label read as
|
||||
a different app's heading beside the sidebar's. Menu size, so the two tiers of
|
||||
heading in front of the eye at once are the same size. */
|
||||
h3.group button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--s2);
|
||||
width: 100%;
|
||||
padding: var(--s2) var(--s2);
|
||||
font-size: var(--text-xs);
|
||||
font-size: var(--menu-size);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.07em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-faint);
|
||||
letter-spacing: normal;
|
||||
text-transform: none;
|
||||
color: var(--ink);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
h3.group button:hover {
|
||||
color: var(--ink-muted);
|
||||
background: var(--surface-sunken);
|
||||
}
|
||||
|
||||
/* The mark, or an empty box the same width where a date group has none, so every
|
||||
label starts at the same place. The star and the people icon fill it; the
|
||||
arrow that used to is gone — the box folds on a click. */
|
||||
h3.group .mark {
|
||||
flex: none;
|
||||
width: 0.75em;
|
||||
font-size: 0.85em;
|
||||
line-height: 1;
|
||||
color: var(--ink-faint);
|
||||
transition: transform var(--fast) var(--ease);
|
||||
}
|
||||
|
||||
h3.group .mark.closed {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
/* Sit eget navn og ikke `.star`. Rækkens favoritknap hedder også det og er
|
||||
@@ -1414,6 +1458,7 @@
|
||||
margin-left: auto;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
/* Stregen mellem rækkerne er væk.
|
||||
@@ -1450,13 +1495,38 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.row:hover {
|
||||
background: var(--surface);
|
||||
/* Pointer only. On a touch screen a :hover on the tap target costs a tap — iOS
|
||||
spends the first applying the hover and opens on the second. Gated, the first
|
||||
tap opens the note. The row's buttons are shown outright on touch below, since
|
||||
there is no hover to reveal them. */
|
||||
@media (hover: hover) {
|
||||
.row:hover {
|
||||
background: var(--surface);
|
||||
}
|
||||
}
|
||||
|
||||
@media (hover: none) {
|
||||
.star,
|
||||
.archive-one {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.row.on {
|
||||
background: var(--surface-raised);
|
||||
color: var(--ink);
|
||||
background: var(--note-on-bg, var(--surface-raised));
|
||||
color: var(--note-on-ink, var(--ink));
|
||||
}
|
||||
|
||||
/* On a themed selection colour (Kul's gold), the row's own quieter tiers go dark
|
||||
too, or the date and the filed line vanish into it. Other themes have no
|
||||
--note-on-ink, so these fall back to their normal muted inks. */
|
||||
.row.on .when,
|
||||
.row.on .filed {
|
||||
color: var(--note-on-ink, var(--ink-muted));
|
||||
}
|
||||
|
||||
.row.on .filed-icon {
|
||||
color: var(--note-on-ink, var(--ink-faint));
|
||||
}
|
||||
|
||||
/* Samme størrelse som en opgavetitel. En note og en opgave er to ting af samme
|
||||
@@ -1475,19 +1545,25 @@
|
||||
/* Dato og begyndelse på samme linje, som Apple Noter gør det. To linjer pr.
|
||||
note frem for tre, og datoen først, fordi det er den, man skanner efter. */
|
||||
|
||||
/* Datoen forrest på linje to og venstrestillet, som Apple Noter — ikke skubbet
|
||||
ud til højre. Tabular-tal, så en søjle af datoer står på lige linjer. */
|
||||
.when {
|
||||
flex: none;
|
||||
color: var(--ink-muted);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* `display: block`, og det er ikke pynt.
|
||||
*
|
||||
* Uddraget lå før inde i en flex-boks, der ejede afkortningen. Da datoen flyttede
|
||||
* op i gruppens overskrift, forsvandt den boks — og et inline-element klippes
|
||||
* ikke af `overflow: hidden`, så den sidste sætning løb videre ind under
|
||||
* favoritstjernen. Reglerne skal stå på det element, der faktisk skal klippes. */
|
||||
/* Linje to er en flex-række: datoen, der ikke krymper, og uddraget, der klippes.
|
||||
Afkortningen skal stå på uddraget selv — et inline-element klippes ikke af
|
||||
`overflow: hidden`. */
|
||||
.preview {
|
||||
display: block;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 0.45em;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.snippet {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@@ -1504,31 +1580,30 @@
|
||||
* Prikken bærer farven, ikke teksten. Fem projekters farver som skriftfarve på
|
||||
* en lys flade er fem forskellige grader af læsbarhed, og den lyseste af dem er
|
||||
* ikke læsbar. */
|
||||
/* Linje tre: hvor noten er lagt. En mappe som grupperne i menuen og et navn,
|
||||
venstrestillet under uddraget — ikke en mærkat skubbet ud til højre. */
|
||||
.filed {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375em;
|
||||
flex: none;
|
||||
margin-left: auto;
|
||||
max-width: 45%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
gap: 0.4em;
|
||||
min-width: 0;
|
||||
margin-top: 1px;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.filed .dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
.filed-icon {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
flex: none;
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--project, var(--line-strong));
|
||||
color: var(--ink-faint);
|
||||
}
|
||||
|
||||
.filed::before {
|
||||
content: '▸ ';
|
||||
opacity: 0.7;
|
||||
.filed-name {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Noten er et ark, ikke en flade i appen.
|
||||
@@ -1546,7 +1621,11 @@
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
background: var(--surface);
|
||||
/* A nuance lighter than the ground in dark, still white in light — matches
|
||||
the note list beside it so the two read as one writing surface. Kul gives
|
||||
the text field its own darker grey via --editor-bg; other themes fall back
|
||||
to the shared surface so the list and the editor stay the same colour. */
|
||||
background: var(--editor-bg, var(--surface-raised));
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
/* Luft nok til at teksten ikke rører kanten.
|
||||
@@ -1746,17 +1825,6 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* The person chip: the project mark's shape in a person's own colour. No ▸
|
||||
before it — the coloured dot already says "belongs to", and two markers on
|
||||
one short chip is noise. It sits next to the title rather than pushed to the
|
||||
right, so in the Delt med mig group it reads as "Ferieplan — Sofie". */
|
||||
.filed.person {
|
||||
margin-left: 0.5em;
|
||||
max-width: 40%;
|
||||
}
|
||||
.filed.person::before {
|
||||
content: none;
|
||||
}
|
||||
|
||||
.sharepanel .none {
|
||||
font-size: var(--text-xs);
|
||||
@@ -1876,14 +1944,48 @@
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
/* The way back to the list on a phone — an iOS-style "‹ Noter" at the top of the
|
||||
editor. Hidden on a wide screen, where the list is always beside the editor. */
|
||||
.back {
|
||||
display: none;
|
||||
align-self: flex-start;
|
||||
align-items: center;
|
||||
gap: var(--s1);
|
||||
margin-bottom: var(--s2);
|
||||
padding: var(--s1) 0;
|
||||
font-size: var(--text-base);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.notes {
|
||||
grid-template-columns: 1fr;
|
||||
padding: 0;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
aside {
|
||||
border-right: 0;
|
||||
padding-right: 0;
|
||||
/* One pane at a time. The two-column card layout has no room on a phone, so
|
||||
the list shows until a note is opened and the editor takes over once one is
|
||||
— the back button is the way between them. Without this the editor stacked
|
||||
below a full-height list, so a tapped note opened out of sight. */
|
||||
.notes.has-note aside {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.notes:not(.has-note) .editor {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Full-bleed: the card border and rounded corners are for sitting beside
|
||||
another card, and on one column there is nothing beside it. */
|
||||
aside,
|
||||
.editor {
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.back {
|
||||
display: inline-flex;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
/**
|
||||
* Kommende: the next seven days as a list, one week as a grid, or the month.
|
||||
* Kommende: a run of days as a list, one week as a grid, or the month.
|
||||
*
|
||||
* The views ask for different things and none is a subset of the others — seven
|
||||
* days from today, against a chosen week, against six whole weeks around a
|
||||
@@ -15,7 +15,7 @@
|
||||
* A week that straddles the 31st and the 1st has both days in the same row.
|
||||
*/
|
||||
import { api } from '$lib/api.js';
|
||||
import { app, upcomingView } from '$lib/stores.svelte.js';
|
||||
import { app, upcomingView, UPCOMING_DAYS } from '$lib/stores.svelte.js';
|
||||
import { TASK, startDrag, carries, dragged, accept } from '$lib/dnd.js';
|
||||
import TaskRow from '$lib/components/TaskRow.svelte';
|
||||
import QuickAdd from '$lib/components/QuickAdd.svelte';
|
||||
@@ -24,9 +24,12 @@
|
||||
|
||||
let days = $state([]);
|
||||
|
||||
// Reads `upcomingView.days` inside the effect on purpose: that is what makes
|
||||
// choosing a longer horizon reload, rather than extending the strip with days
|
||||
// nobody asked the server about.
|
||||
$effect(() => {
|
||||
if (upcomingView.mode !== 'list') return;
|
||||
api.upcoming().then((data) => {
|
||||
api.upcoming(upcomingView.days).then((data) => {
|
||||
days = data.days;
|
||||
app.tasks = data.days.flatMap((d) => d.tasks);
|
||||
});
|
||||
@@ -53,6 +56,21 @@
|
||||
return day.toLocaleDateString(tag(), { weekday: 'long', day: 'numeric', month: 'short' });
|
||||
}
|
||||
|
||||
// A month of headings repeats every weekday four times, and "mandag 6. okt"
|
||||
// alone does not say which mandag. The week number is the label that does, and
|
||||
// it only earns its place once the strip is longer than a week.
|
||||
function weekOf(date) {
|
||||
if (upcomingView.days <= 7) return null;
|
||||
const day = new Date(date + 'T00:00:00');
|
||||
// ISO weeks: Thursday decides which year and which week a row belongs to.
|
||||
const thursday = new Date(day);
|
||||
thursday.setDate(day.getDate() - ((day.getDay() + 6) % 7) + 3);
|
||||
const firstThursday = new Date(thursday.getFullYear(), 0, 4);
|
||||
firstThursday.setDate(firstThursday.getDate() - ((firstThursday.getDay() + 6) % 7) + 3);
|
||||
const n = 1 + Math.round((thursday - firstThursday) / (7 * 86400000));
|
||||
return t('view.weekNumber', { n });
|
||||
}
|
||||
|
||||
// Reading tasks back out of the store keeps a completed row disappearing
|
||||
// immediately rather than on the next load. It is also what makes a task
|
||||
// dragged from one day to another land in its new section straight away: the
|
||||
@@ -82,6 +100,19 @@
|
||||
<div class="view" class:wide={upcomingView.mode !== 'list'}>
|
||||
<header>
|
||||
<h1>{t('view.upcoming')}</h1>
|
||||
{#if upcomingView.mode === 'list'}
|
||||
<!-- Only the list takes a horizon. A week grid is a week and a month grid
|
||||
is a month; there is no fortnight for them to show. -->
|
||||
<div class="views" role="group" aria-label={t('view.horizon')}>
|
||||
{#each UPCOMING_DAYS as n}
|
||||
<button
|
||||
class:active={upcomingView.days === n}
|
||||
onclick={() => upcomingView.setDays(n)}
|
||||
aria-pressed={upcomingView.days === n}>{t('view.days', { n })}</button
|
||||
>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="views" role="group" aria-label={t('view.mode')}>
|
||||
{#each [['list', t('view.list')], ['week', t('view.week')], ['calendar', t('view.month')]] as [value, label]}
|
||||
<button
|
||||
@@ -102,6 +133,7 @@
|
||||
{:else}
|
||||
{#each days as day (day.date)}
|
||||
{@const tasks = live(day.date)}
|
||||
{@const week = weekOf(day.date)}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<section
|
||||
class:over={over === day.date}
|
||||
@@ -109,7 +141,10 @@
|
||||
ondragleave={() => (over = null)}
|
||||
ondrop={(e) => onDrop(e, day.date)}
|
||||
>
|
||||
<h2>{heading(day.date)}</h2>
|
||||
<h2>
|
||||
{heading(day.date)}
|
||||
{#if week}<span class="week">{week}</span>{/if}
|
||||
</h2>
|
||||
{#if tasks.length}
|
||||
{#each tasks as task (task.id)}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
@@ -210,6 +245,10 @@
|
||||
}
|
||||
|
||||
h2 {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: var(--s2);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 560;
|
||||
text-transform: uppercase;
|
||||
@@ -220,6 +259,14 @@
|
||||
margin-bottom: var(--s2);
|
||||
}
|
||||
|
||||
/* Lighter than the day it sits beside: it is there to be found when you are
|
||||
lost in the fourth week, not read on every row. */
|
||||
.week {
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.04em;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* An em dash rather than "ingen opgaver": seven repetitions of a sentence is
|
||||
noise, and the reader only needs to know the day is clear. */
|
||||
.empty {
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
/// <reference types="@sveltejs/kit" />
|
||||
/* global self, caches, fetch, Response */
|
||||
|
||||
/**
|
||||
* verdande's service worker: Web Push, and a cache that holds through a short
|
||||
* network drop.
|
||||
*
|
||||
* It used to do Push and nothing else, with a note that a cache serving yesterday's
|
||||
* data was worse than an honest "cannot connect". The cache here does not do that.
|
||||
* It is network-FIRST for everything that can go stale — a reader online always gets
|
||||
* the live answer, and the cache is only reached for when the network is not — so it
|
||||
* is not a copy of the app you work in offline, it is the app surviving a tunnel, a
|
||||
* lift, a base-station handover. The five themes' worth of live task list stays live;
|
||||
* it just no longer goes blank the moment the signal does.
|
||||
*
|
||||
* Writes are never touched here — they go straight to the network, and api.js already
|
||||
* retries them across a short drop. Caching a write would mean a queue and conflicts,
|
||||
* which is a different and much larger feature.
|
||||
*/
|
||||
import { build, files, version } from '$service-worker';
|
||||
|
||||
// Versioned, so a deploy's worth of new hashed assets lands in a fresh cache and the
|
||||
// old one is dropped on activate — the app can never be served half of two builds.
|
||||
const SHELL = `verdande-shell-${version}`;
|
||||
// Not versioned: the data does not belong to a build, and clearing it every deploy
|
||||
// would throw away the very copy that lets a reload survive a drop. Cleared on sign-out.
|
||||
const API = 'verdande-api';
|
||||
|
||||
// The shell: every hashed build asset, the static files, and the SPA fallback so a
|
||||
// navigation can be answered from the cache when the network cannot answer it.
|
||||
const SHELL_ASSETS = [...build, ...files, '/'];
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const cache = await caches.open(SHELL);
|
||||
await cache.addAll(SHELL_ASSETS);
|
||||
// Take over at the next opportunity rather than waiting for every tab to
|
||||
// close — paired with clients.claim below and the versioned cache, a deploy
|
||||
// reaches the user on their next load.
|
||||
await self.skipWaiting();
|
||||
})()
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
for (const key of await caches.keys()) {
|
||||
// Drop old shell versions; keep this shell and the data cache.
|
||||
if (key !== SHELL && key !== API) await caches.delete(key);
|
||||
}
|
||||
await self.clients.claim();
|
||||
})()
|
||||
);
|
||||
});
|
||||
|
||||
const isAsset = (pathname) => build.includes(pathname) || files.includes(pathname);
|
||||
|
||||
self.addEventListener('fetch', (event) => {
|
||||
const { request } = event;
|
||||
|
||||
// Writes go to the network, full stop — the app retries them itself, and a cached
|
||||
// write is a promise this cannot keep. Cross-origin is none of our business.
|
||||
if (request.method !== 'GET') return;
|
||||
const url = new URL(request.url);
|
||||
if (url.origin !== self.location.origin) return;
|
||||
|
||||
// Hashed build assets and static files never change for a given URL: cache-first,
|
||||
// so a repeat load and an offline load are both instant.
|
||||
if (isAsset(url.pathname)) {
|
||||
event.respondWith(cacheFirst(request, SHELL));
|
||||
return;
|
||||
}
|
||||
|
||||
// The data: network-first so an online reader always sees the live list, with the
|
||||
// last good copy kept for when the network is gone.
|
||||
if (url.pathname.startsWith('/api/v1/')) {
|
||||
event.respondWith(networkFirst(request, API));
|
||||
return;
|
||||
}
|
||||
|
||||
// A navigation (reload, or opening the app): the live page when there is one, the
|
||||
// cached shell when there is not — so the app opens through a drop instead of
|
||||
// showing the browser's dinosaur.
|
||||
if (request.mode === 'navigate') {
|
||||
event.respondWith(navigate(request));
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
async function cacheFirst(request, cacheName) {
|
||||
const cache = await caches.open(cacheName);
|
||||
const hit = await cache.match(request);
|
||||
if (hit) return hit;
|
||||
const res = await fetch(request);
|
||||
if (res.ok) cache.put(request, res.clone());
|
||||
return res;
|
||||
}
|
||||
|
||||
async function networkFirst(request, cacheName) {
|
||||
const cache = await caches.open(cacheName);
|
||||
try {
|
||||
const res = await fetch(request);
|
||||
// Only a real answer is worth keeping — a 401 or a 500 must not overwrite the
|
||||
// last good copy, or an expired session would be served back offline as fact.
|
||||
if (res.ok) cache.put(request, res.clone());
|
||||
return res;
|
||||
} catch (err) {
|
||||
const hit = await cache.match(request);
|
||||
if (hit) return hit;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async function navigate(request) {
|
||||
try {
|
||||
return await fetch(request);
|
||||
} catch {
|
||||
const cache = await caches.open(SHELL);
|
||||
const shell = await cache.match('/');
|
||||
return shell ?? Response.error();
|
||||
}
|
||||
}
|
||||
|
||||
// Sign-out asks for the data cache to be emptied: the next person on this browser must
|
||||
// not find the last one's tasks sitting in it.
|
||||
self.addEventListener('message', (event) => {
|
||||
if (event.data?.type === 'clear-api-cache') {
|
||||
event.waitUntil(caches.delete(API));
|
||||
}
|
||||
});
|
||||
|
||||
// --- Web Push (unchanged in behaviour, moved here from the old static/sw.js) --------
|
||||
|
||||
self.addEventListener('push', (event) => {
|
||||
let payload = {};
|
||||
try {
|
||||
payload = event.data ? event.data.json() : {};
|
||||
} catch {
|
||||
// A push whose body is not our JSON still deserves to be shown: browsers show
|
||||
// their own "site updated in the background" notice otherwise, which looks like
|
||||
// a bug in the app.
|
||||
payload = { title: 'verdande', body: event.data ? event.data.text() : '' };
|
||||
}
|
||||
|
||||
const title = payload.title || 'verdande';
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(title, {
|
||||
body: payload.body || '',
|
||||
icon: '/icon.svg',
|
||||
badge: '/icon.svg',
|
||||
// The tag collapses repeats: five comments on one task should replace each
|
||||
// other rather than stack into five separate notifications.
|
||||
tag: payload.tag || payload.url || 'verdande',
|
||||
data: { url: payload.url || '/' }
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.notification.close();
|
||||
const target = event.notification.data?.url || '/';
|
||||
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const clientList = await self.clients.matchAll({
|
||||
type: 'window',
|
||||
includeUncontrolled: true
|
||||
});
|
||||
|
||||
// Focus a tab that already has the app open rather than opening a second one.
|
||||
// Somebody with the app pinned does not want a new tab per reminder.
|
||||
for (const client of clientList) {
|
||||
if (new URL(client.url).origin === self.location.origin) {
|
||||
await client.focus();
|
||||
if ('navigate' in client) await client.navigate(target);
|
||||
return;
|
||||
}
|
||||
}
|
||||
await self.clients.openWindow(target);
|
||||
})()
|
||||
);
|
||||
});
|
||||
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
@@ -1,9 +1,13 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<!-- Wunjo, the rune Verdande's name begins with. Drawn as strokes rather than
|
||||
as a filled glyph so it stays legible at 16px in a browser tab. -->
|
||||
as a filled glyph so it stays legible at 16px in a browser tab. Bigger and
|
||||
heavier than it was, to read clearly as a home-screen icon, and nudged right
|
||||
of the geometric centre so the heavy stave and the light flag balance about
|
||||
the middle of the tile — a bounding box centred on 32 leaves the stave
|
||||
looking left-hung. -->
|
||||
<rect width="64" height="64" rx="14" fill="#111312"/>
|
||||
<g fill="none" stroke="#5fbf8f" stroke-width="4.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M22 14v36"/>
|
||||
<path d="M22 17l17 8-17 8"/>
|
||||
<g fill="none" stroke="#5fbf8f" stroke-width="6.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M26 11v42"/>
|
||||
<path d="M26 15l17 9.5L26 34"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 447 B After Width: | Height: | Size: 734 B |
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* verdande's service worker.
|
||||
*
|
||||
* It exists for Web Push and nothing else. There is deliberately no offline cache:
|
||||
* the app is a live view of a task list that other people are editing, and a cached
|
||||
* shell serving yesterday's data is worse than a browser saying it cannot connect.
|
||||
* Adding one later means versioning and invalidating it, which is a real feature
|
||||
* rather than a few lines here.
|
||||
*/
|
||||
|
||||
// Take over as soon as the browser is willing. Without these two, the first push
|
||||
// after granting permission arrives with no worker in control to show it.
|
||||
self.addEventListener('install', () => self.skipWaiting());
|
||||
self.addEventListener('activate', (event) => event.waitUntil(self.clients.claim()));
|
||||
|
||||
self.addEventListener('push', (event) => {
|
||||
let payload = {};
|
||||
try {
|
||||
payload = event.data ? event.data.json() : {};
|
||||
} catch {
|
||||
// A push whose body is not our JSON still deserves to be shown: browsers
|
||||
// display their own "site updated in the background" notice otherwise, which
|
||||
// looks like a bug in the app.
|
||||
payload = { title: 'verdande', body: event.data ? event.data.text() : '' };
|
||||
}
|
||||
|
||||
const title = payload.title || 'verdande';
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(title, {
|
||||
body: payload.body || '',
|
||||
icon: '/icon.svg',
|
||||
badge: '/icon.svg',
|
||||
// The tag collapses repeats: five comments on one task should replace each
|
||||
// other rather than stack into five separate notifications.
|
||||
tag: payload.tag || payload.url || 'verdande',
|
||||
data: { url: payload.url || '/' }
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.notification.close();
|
||||
const target = event.notification.data?.url || '/';
|
||||
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const clientList = await self.clients.matchAll({
|
||||
type: 'window',
|
||||
includeUncontrolled: true
|
||||
});
|
||||
|
||||
// Focus a tab that already has the app open rather than opening a second
|
||||
// one. Somebody with the app pinned does not want a new tab per reminder.
|
||||
for (const client of clientList) {
|
||||
if (new URL(client.url).origin === self.location.origin) {
|
||||
await client.focus();
|
||||
if ('navigate' in client) await client.navigate(target);
|
||||
return;
|
||||
}
|
||||
}
|
||||
await self.clients.openWindow(target);
|
||||
})()
|
||||
);
|
||||
});
|
||||