Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cmd/mind-map/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ func runHTTPServer(addr, dir, webuiDir string, idleTimeout time.Duration, stopCh
jsonResponse(rw, backlinks)
})

mux.HandleFunc("GET /api/links", func(rw http.ResponseWriter, r *http.Request) {
links, err := w.AllLinks(r.Context())
if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError)
return
}
jsonResponse(rw, links)
})

// Settings API endpoints (UI only, not MCP)
mux.HandleFunc("GET /api/settings", func(rw http.ResponseWriter, r *http.Request) {
current, err := config.Load(cfgPath)
Expand Down
31 changes: 31 additions & 0 deletions internal/wiki/pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,37 @@ func (w *Wiki) GetBacklinks(ctx context.Context, pagePath string) ([]string, err
return w.getBacklinks(ctx, pagePath)
}

// Link is a single source→target edge between two pages.
type Link struct {
Source string `json:"source"`
Target string `json:"target"`
}

// AllLinks returns every wikilink edge in the index. Used by the graph
// view to render reference edges without a per-page round-trip.
func (w *Wiki) AllLinks(ctx context.Context) ([]Link, error) {
if err := ctx.Err(); err != nil {
return nil, err
}

rows, err := w.db.QueryContext(ctx, "SELECT source, target FROM links")
if err != nil {
return nil, err
}
defer rows.Close()

var links []Link
for rows.Next() {
var l Link
if err := rows.Scan(&l.Source, &l.Target); err != nil {
slog.Warn("all links scan error", slog.Any("error", err))
continue
}
links = append(links, l)
}
return links, nil
}

// Context returns a WikiContext overview.
func (w *Wiki) Context(ctx context.Context) (*WikiContext, error) {
if err := ctx.Err(); err != nil {
Expand Down
133 changes: 133 additions & 0 deletions webui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"dev": "webpack --mode development --config webpack.config.js --watch"
},
"dependencies": {
"force-graph": "^1.51.4",
"marked": "^15.0.0",
"mermaid": "^11.14.0",
"preact": "^10.25.0"
Expand Down
Loading