mirror of
https://github.com/thegeneralist01/archivr
synced 2026-12-04 18:56:44 +01:00
Adds a self-contained export feature across core, server, CLI, and frontend.
Users can export one or more archived entries as a shareable bundle without
exposing the Archivr instance. A small 'Preserved with archivr' credit is
included by default and can be toggled off per export.
Core (crates/archivr-core/src/export/):
- brand.rs — export CSS (palette from style-guide), CREDIT_HTML,
CREDIT_INLINE_HTML (for snapshot injection)
- model.rs — ExportEntry / ExportBody / Asset loading; tweet thread
reconstruction (reply-graph DFS, sibling ordering)
- html.rs — full HTML document renderer: all body kinds, AssetMode
Bundle vs Print, render_cover for PDF cover pages
- markdown.rs — Markdown renderer with poster-linked video, blockquoted
quote tweets, credit sub-tag
- bundle.rs — ZIP writer (Deflated for text, Stored for binary,
large_file for >= 4 GiB assets)
- pdf.rs — print_pdf (headless Chrome), merge_documents (lopdf
ID-offset merge), entry_pdf (snapshot injection,
PDF-merge, HTML fallback)
- mod.rs — export_entries, prune_stale_export_dirs, ExportFile,
ffmpeg poster generation, full assembly dispatch
summarizer.rs: extract pub(crate) article_parts so the export module
reuses the article title/body logic without duplication.
Server (crates/archivr-server/src/exports.rs):
- GET /api/archives/:archive_id/export?entries=&format=&layout=&credit=
- Auth required (guests -> 401); per-UID ensure_entry_visible check
- Blocking spawn_blocking task; streaming response via ReaderStream
- ARCHIVR_EXPORT_PDF_TIMEOUT added to ENV_VARS (default 120 s)
- ARCHIVR_CHROME description updated to mention PDF export
- prune_stale_export_dirs called at startup (6 h TTL)
CLI (crates/archivr-cli/src/main.rs):
archivr export <UIDs...> [--format html|pdf|markdown]
[--separate] [--no-credit] [-o DIR]
Frontend:
- api.js: downloadEntryExport (blob + filename from Content-Disposition)
- ExportDialog.jsx: native <dialog>; format selector; Combine toggle
(>= 2 entries); credit toggle (on by default); error display
- ContextRail.jsx: single-entry Export... button after Preview; bulk
Export N entries... section before delete zone; orderedSelection
helper for DOM-order UIDs; ExportDialog mounted once per rail
- styles.css: .rail-export-btn, .export-dialog .export-format rules
Tests:
- 9 new cargo tests in export/mod.rs (HTML, Markdown, PDF merge,
parent-child dedupe, separate layout, credit on/off, validation)
- 4 new cargo tests in exports.rs (401 no-auth, 200 ZIP, 400 bad
format, 400 too many entries)
- 4 new bun tests in ExportDialog.test.jsx (single/multi uid, credit
default, closed state)
- 2 new bun tests in api.test.js (query string, error propagation)
All 247 Rust tests and 50 frontend tests pass.
MCP follow-up: archivr-mcp export_entries tool (GET /api/.../export,
read-scope tokens accepted) — not built here.
39 lines
1.3 KiB
TOML
39 lines
1.3 KiB
TOML
[workspace]
|
|
members = [
|
|
"crates/archivr-core",
|
|
"crates/archivr-cli",
|
|
"crates/archivr-server",
|
|
]
|
|
resolver = "2"
|
|
|
|
[workspace.package]
|
|
version = "0.1.0"
|
|
edition = "2024"
|
|
|
|
[workspace.dependencies]
|
|
anyhow = "1.0.100"
|
|
axum = { version = "0.7.9", features = ["multipart"] }
|
|
chrono = "0.4.42"
|
|
clap = { version = "4.5.48", features = ["derive"] }
|
|
hex = "0.4.3"
|
|
regex = "1.12.2"
|
|
rusqlite = { version = "0.32.1", features = ["bundled"] }
|
|
serde = { version = "1.0.228", features = ["derive"] }
|
|
serde_json = { version = "1.0.132", features = ["preserve_order"] }
|
|
sha3 = "0.10.8"
|
|
tempfile = "3.13.0"
|
|
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "net", "fs", "io-util"] }
|
|
toml = "0.8.19"
|
|
tower = "0.5.1"
|
|
tower-http = { version = "0.6.2", features = ["fs", "trace"] }
|
|
uuid = { version = "1.18.1", features = ["v4"] }
|
|
reqwest = { version = "0.12", features = ["blocking"] }
|
|
base64 = "0.22"
|
|
argon2 = { version = "0.5", features = ["std"] }
|
|
rand = { version = "0.8", features = ["std"] }
|
|
axum-extra = { version = "0.9", features = ["cookie"] }
|
|
parking_lot = "0.12"
|
|
zip = { version = "8.6", default-features = false, features = ["deflate-flate2-zlib-rs"] }
|
|
libc = "0.2"
|
|
lopdf = { version = "0.45", default-features = false }
|
|
tokio-util = { version = "0.7", features = ["io"] }
|