Documentation
¶
Overview ¶
Package web is the HTTP adapter: a localhost notes viewer (`nt web`). It is a read adapter over the same domain (note/links/mutate) the CLI, TUI, and MCP server use — so it shows exactly what they store. It is deliberately structured to make editing a future additive change: state lives on the Server struct, notes are addressed by stable id, and the render path is one reusable function.
Index ¶
Constants ¶
const DefaultPort = 4321
DefaultPort is the stable port `nt web` binds by default, so the URL stays the same across runs (bookmarkable). If it's already in use, Serve falls back to a free port rather than failing — the address only changes on an actual conflict.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backlink ¶
type Backlink struct {
Title string `json:"title"` // note title, or "" for a task source
URL string `json:"url"` // /n/<id> for a note source; "" for a task
Text string `json:"text"` // the matching line (shown for task sources)
IsNote bool `json:"isNote"`
}
Backlink is one "Linked from" entry for the note page.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds the shared state for the viewer. (Editing, when added, hangs write routes and a CSRF token here — seam #1.)
func (*Server) Handler ¶ added in v0.4.0
Handler returns the viewer's HTTP handler so another host can serve the UI without nt binding a TCP port — e.g. a Wails desktop shell wiring it into assetserver.Options.Handler. This is the seam that lets the exact same server-rendered UI run as a native app. Call SetEdit/StartWatch first if you want editing or live-reload.
func (*Server) SetEdit ¶ added in v0.4.0
SetEdit toggles in-app editing (CSRF-guarded). Read-only by default.
func (*Server) SetSPA ¶ added in v0.4.0
SetSPA is a no-op retained for embedder compatibility; the SPA is always served.
func (*Server) StartWatch ¶ added in v0.4.0
func (s *Server) StartWatch()
StartWatch begins watching the store and pushing SSE live-reload events. Serve calls this itself; embedders call it when they want live-reload.