Skip to content

Commit e9d6c92

Browse files
committed
feat: pluggable wiki export/share system (zip + PDF)
Add a pluggable export system that lets users share wiki pages as self-contained archives. The system follows wikilinks (BFS traversal) from a starting page to collect pages with no broken links. Backend: - Sharer interface and registry (internal/share/share.go) - Zip exporter with include_assets and flatten settings - PDF exporter via chromedp + goldmark (registers only if browser found) - BFS wikilink traversal in wiki.ExportPages (depth: -1/0/N) - HTTP endpoints: GET /api/export, GET /api/export/formats - MCP tool: export_pages WebUI: - Export button in page header (ShareIcon) - ExportPanel with depth picker and format selection - ShareSettings in Settings panel (generic per-plugin schema renderer) DevContainer: - Symlink Playwright Chromium to /usr/local/bin for PDF support - Fix git safe.directory for VCS stamping in builds Docs: - README updated with Export & Share section and screenshots - Playwright screenshot script (tools/screenshots.mjs) - 8 feature screenshots in docs/screenshots/
1 parent 44f7f52 commit e9d6c92

32 files changed

Lines changed: 2444 additions & 6 deletions

‎.devcontainer/devcontainer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
// [[preferences/devcontainer-ports]] for the full rationale and the
3535
// consumer recipes (launch.json, tasks.json, host scripts).
3636
"initializeCommand": ".devcontainer/initializeCommand.sh",
37-
"postCreateCommand": "go version && node --version",
37+
"postCreateCommand": "git config --global --add safe.directory /workspaces/mind-map && go version && node --version && { CHROME=$(find ~/.cache/ms-playwright/chromium-*/chrome-linux/chrome 2>/dev/null | head -1) && [ -n \"$CHROME\" ] && sudo ln -sf \"$CHROME\" /usr/local/bin/chromium || true; }",
3838
"postAttachCommand": "npm install --prefix webui",
3939
"customizations": {
4040
"vscode": {

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
webui/dist/*
1111
!webui/dist/.gitkeep
1212
webui/node_modules/
13+
tools/node_modules/
1314

1415
# VS Code cache
1516
.vscode/cache/

‎README.md‎

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ The web UI is a static Preact app served by `mind-map serve` over HTTP. It uses
8484

8585
Both modes use the same wiki engine and the same wiki directory (`~/.mind-map/wiki` by default). Multiple stdio processes can safely share the same wiki via SQLite page locking.
8686

87-
## MCP Tools (11 total)
87+
## MCP Tools (12 total)
8888

8989
| Tool | Description |
9090
|------|-------------|
@@ -100,6 +100,7 @@ Both modes use the same wiki engine and the same wiki directory (`~/.mind-map/wi
100100
| `get_backlinks` | Get all pages that link to a given page |
101101
| `register_sync` | Register a wiki path prefix to sync with a git remote |
102102
| `reindex_wiki` | Force a reindex pass against on-disk markdown (rarely needed; useful after edits made outside the wiki API) |
103+
| `export_pages` | Export a page (and linked pages up to N hops) as zip or PDF |
103104

104105
## Wiki Features
105106

@@ -110,6 +111,50 @@ Both modes use the same wiki engine and the same wiki directory (`~/.mind-map/wi
110111
- **Full-text search**: SQLite FTS5 with ranked results and snippets
111112
- **Multi-process safe**: SQLite page locking for concurrent agent access
112113
- **Git sync**: sync wiki pages to GitHub repo wikis via configurable mappings
114+
- **Export / Share**: export pages as zip or PDF — see below
115+
116+
## Export & Share
117+
118+
Export one or more wiki pages for sharing outside the wiki. The system follows **wikilinks** from a starting page (BFS traversal) to collect a self-contained set of pages with no broken links.
119+
120+
### Depth control
121+
122+
| Depth | Meaning |
123+
|-------|---------|
124+
| `0` | Just the selected page |
125+
| `1` | The page + all pages it links to |
126+
| `N` | N hops of outgoing links |
127+
| `-1` | Unlimited — follow all reachable links |
128+
129+
### Formats
130+
131+
Export is **pluggable** — formats register themselves at startup:
132+
133+
| Format | Description | Requirements |
134+
|--------|-------------|--------------|
135+
| **zip** | Archive of markdown files + assets | None |
136+
| **pdf** | Multi-page PDF with table of contents | Chrome, Edge, or Chromium on `$PATH` |
137+
138+
PDF export uses [chromedp](https://github.com/chromedp/chromedp) to render markdown → HTML → PDF via a headless browser. It includes a clickable TOC, embedded images, and a print-friendly stylesheet. The PDF sharer only registers if a supported browser is detected — no browser, no PDF option.
139+
140+
### Using export
141+
142+
**Web UI**: Click the share icon in the page header → pick depth and format → download.
143+
144+
**REST API**:
145+
```
146+
GET /api/export?format=zip&page=projects/my-project&depth=1
147+
GET /api/export/formats # list available formats with settings schemas
148+
```
149+
150+
**MCP tool**:
151+
```
152+
export_pages(format: "pdf", page: "architecture/auth", depth: -1)
153+
```
154+
155+
### Adding new formats
156+
157+
Implement the `Sharer` interface in `internal/share/` and call `Register()` in an `init()` function. The format automatically appears in the UI, REST API, and MCP tool.
113158

114159
## Web UI
115160

@@ -119,10 +164,60 @@ The built-in web UI is a lightning-fast, Metro-inspired, chromeless Preact app:
119164
- Markdown rendering with wikilinks as clickable links
120165
- Backlinks section on every page
121166
- Edit mode with raw markdown editor
167+
- Export / share panel for zip and PDF export
168+
- Interactive graph view of the wiki link structure
122169
- Dark / light theme toggle
123170

124171
The web UI speaks the same language as the wiki engine. If an agent creates a page via stdio, it appears in the browser. If you edit in the browser, the agent sees the change on its next read.
125172

173+
### Page view
174+
175+
<p align="center">
176+
<img src="docs/screenshots/page-view.png" alt="Page view" width="720">
177+
</p>
178+
179+
### Dark theme
180+
181+
<p align="center">
182+
<img src="docs/screenshots/page-view-dark.png" alt="Page view (dark theme)" width="720">
183+
</p>
184+
185+
### Search
186+
187+
<p align="center">
188+
<img src="docs/screenshots/search.png" alt="Search" width="720">
189+
</p>
190+
191+
### Edit mode
192+
193+
<p align="center">
194+
<img src="docs/screenshots/edit-mode.png" alt="Edit mode" width="720">
195+
</p>
196+
197+
### Export panel
198+
199+
<p align="center">
200+
<img src="docs/screenshots/export-panel.png" alt="Export panel" width="720">
201+
</p>
202+
203+
### Graph view
204+
205+
<p align="center">
206+
<img src="docs/screenshots/graph-view.png" alt="Graph view" width="720">
207+
</p>
208+
209+
### Backlinks
210+
211+
<p align="center">
212+
<img src="docs/screenshots/backlinks.png" alt="Backlinks" width="720">
213+
</p>
214+
215+
### Settings
216+
217+
<p align="center">
218+
<img src="docs/screenshots/settings.png" alt="Settings" width="720">
219+
</p>
220+
126221
## Service Management
127222

128223
The installer can set up mind-map as a persistent system service that starts on boot:

‎docs/screenshots/backlinks.png‎

243 KB
Loading

‎docs/screenshots/edit-mode.png‎

205 KB
Loading

‎docs/screenshots/export-panel.png‎

152 KB
Loading

‎docs/screenshots/graph-view.png‎

1010 KB
Loading
214 KB
Loading

‎docs/screenshots/page-view.png‎

214 KB
Loading

‎docs/screenshots/search.png‎

267 KB
Loading

0 commit comments

Comments
 (0)