Editor:
- Toggles (Tiptap Details). Open state is per reader, not saved.
- Embeds for YouTube, Vimeo, Loom, Figma, CodePen, Spotify, Google Docs
and Maps, in sandboxed frames. Other addresses become link cards.
- Link cards with title, description and picture read by docwell-server
(GET /link-preview). The fetcher refuses private, loopback, link-local
and CGNAT addresses after DNS resolution, redirects included.
- Block links: a margin button gives a block a short id and copies
/p/<id>#b-<block>. Opening one jumps to the block and flashes it.
- Markdown, HTML and PDF exports handle the new blocks; HTML import reads
<details> as a toggle.
Pages and spaces:
- History gets a Changes view: block and word diff against the previous
version or the page as it is now.
- Archive: archived pages leave the tree and become read-only but stay
readable; a space's Archive lists them with Unarchive. New migration
(pages.archived_at) and page.archived / page.unarchived webhook events.
- Full space export (GET /spaces/{id}/export): a zip of Markdown or HTML
files with subpages in folders, an index, and attachments under _files/.
Links between exported pages and to attachments become relative paths.
Desktop 1.0:
- Several servers, each with its own sign-in; old settings files carry over.
- Session tokens in the system keychain (go-keyring), moved out of
localStorage on first start.
- Native menu bar (File, Edit, View, Window, Help) with a Server submenu.
- docwell:// links may point at a block.
- Release workflow builds Windows NSIS, macOS DMG and Linux deb, rpm and
AppImage installers and attaches them to the release;
build/set-version.mjs stamps the version into their metadata.
Not yet run: the release workflow, the desktop menus by eye, and macOS or
Linux builds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.0 KiB
Go
73 lines
2.0 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package main
|
|
|
|
import "testing"
|
|
|
|
func TestRouteFromDeepLink(t *testing.T) {
|
|
ok := map[string]string{
|
|
"docwell://": "/",
|
|
"docwell://p/abc123": "/p/abc123",
|
|
"docwell://p/abc123/": "/p/abc123",
|
|
"DOCWELL://s/space01": "/s/space01",
|
|
"docwell:///p/abc123": "/p/abc123",
|
|
"docwell://p/abc123#b-x1y2z3w4": "/p/abc123#b-x1y2z3w4",
|
|
" docwell://p/abc123\n ": "/p/abc123",
|
|
}
|
|
for in, want := range ok {
|
|
got, err := routeFromDeepLink(in)
|
|
if err != nil || got != want {
|
|
t.Errorf("routeFromDeepLink(%q) = %q, %v; want %q", in, got, err, want)
|
|
}
|
|
}
|
|
|
|
bad := []string{
|
|
"https://p/abc123",
|
|
"docwell://settings/server",
|
|
"docwell://p/../../etc",
|
|
"docwell://p/abc123/extra",
|
|
"docwell://p/",
|
|
"docwell://p/a%2Fb",
|
|
"docwell://p/javascript:alert(1)",
|
|
"docwell://s/space01#b-x1y2z3w4",
|
|
"docwell://p/abc123#settings",
|
|
"not a url",
|
|
}
|
|
for _, in := range bad {
|
|
if got, err := routeFromDeepLink(in); err == nil {
|
|
t.Errorf("routeFromDeepLink(%q) = %q, want an error", in, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestDeepLinkFromArgs(t *testing.T) {
|
|
if got, ok := deepLinkFromArgs([]string{`C:\Docwell\docwell.exe`, "docwell://p/abc"}); !ok || got != "docwell://p/abc" {
|
|
t.Errorf("got %q, %v", got, ok)
|
|
}
|
|
if _, ok := deepLinkFromArgs([]string{"docwell.exe", "--verbose"}); ok {
|
|
t.Error("found a link where there is none")
|
|
}
|
|
}
|
|
|
|
func TestLinkServiceKeepsEarlyLinkUntilTaken(t *testing.T) {
|
|
var s LinkService
|
|
var sent []string
|
|
s.setEmitter(func(r string) { sent = append(sent, r) })
|
|
s.open("docwell://p/early")
|
|
s.open("docwell://settings/server") // ignored
|
|
if got := s.TakePending(); got != "/p/early" {
|
|
t.Fatalf("pending = %q", got)
|
|
}
|
|
if got := s.TakePending(); got != "" {
|
|
t.Fatalf("pending taken twice: %q", got)
|
|
}
|
|
if len(sent) != 0 {
|
|
t.Fatalf("emitted before the frontend listened: %v", sent)
|
|
}
|
|
|
|
s.open("docwell://s/space1")
|
|
if len(sent) != 1 || sent[0] != "/s/space1" || s.TakePending() != "" {
|
|
t.Fatalf("sent = %v", sent)
|
|
}
|
|
}
|