1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-12-04 18:56:44 +01:00

feat: remove PDF from export (HTML and Markdown only)

This commit is contained in:
TheGeneralist 2026-10-12 21:40:09 +02:00
parent f7e9a0ef25
commit b8397ad8f8
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4
12 changed files with 81 additions and 1121 deletions

403
Cargo.lock generated
View file

@ -2,23 +2,6 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 4 version = 4
[[package]]
name = "adler2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "aes"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32"
dependencies = [
"cipher",
"cpubits",
"cpufeatures 0.3.1",
]
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.8.12" version = "0.8.12"
@ -40,21 +23,6 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "alloc-no-stdlib"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
[[package]]
name = "alloc-stdlib"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195"
dependencies = [
"alloc-no-stdlib",
]
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@ -142,7 +110,6 @@ dependencies = [
"chrono", "chrono",
"hex", "hex",
"libc", "libc",
"lopdf",
"regex", "regex",
"reqwest", "reqwest",
"rusqlite", "rusqlite",
@ -166,7 +133,7 @@ dependencies = [
"base64", "base64",
"chrono", "chrono",
"parking_lot", "parking_lot",
"rand 0.8.6", "rand",
"regex", "regex",
"reqwest", "reqwest",
"rusqlite", "rusqlite",
@ -190,7 +157,7 @@ checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072"
dependencies = [ dependencies = [
"base64ct", "base64ct",
"blake2", "blake2",
"cpufeatures 0.2.17", "cpufeatures",
"password-hash", "password-hash",
] ]
@ -202,7 +169,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]
@ -321,7 +288,7 @@ version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"
dependencies = [ dependencies = [
"digest 0.10.7", "digest",
] ]
[[package]] [[package]]
@ -333,34 +300,6 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "block-buffer"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"
dependencies = [
"hybrid-array",
]
[[package]]
name = "block-padding"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "710f1dd022ef4e93f8a438b4ba958de7f64308434fa6a87104481645cc30068b"
dependencies = [
"hybrid-array",
]
[[package]]
name = "brotli-decompressor"
version = "5.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a32acac15fe1967bc3986b2a6347dffc965602354ea6f450ad07e8bfd253583"
dependencies = [
"alloc-no-stdlib",
"alloc-stdlib",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.19.0" version = "3.19.0"
@ -373,15 +312,6 @@ version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
[[package]]
name = "cbc"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896"
dependencies = [
"cipher",
]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.41" version = "1.2.41"
@ -398,17 +328,6 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
[[package]]
name = "chacha20"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
dependencies = [
"cfg-if",
"cpufeatures 0.3.1",
"rand_core 0.10.1",
]
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.42" version = "0.4.42"
@ -422,16 +341,6 @@ dependencies = [
"windows-link", "windows-link",
] ]
[[package]]
name = "cipher"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"
dependencies = [
"crypto-common 0.2.2",
"inout",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.48" version = "4.5.48"
@ -463,7 +372,7 @@ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]
@ -478,12 +387,6 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
[[package]]
name = "const-oid"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
[[package]] [[package]]
name = "cookie" name = "cookie"
version = "0.18.1" version = "0.18.1"
@ -521,12 +424,6 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "cpubits"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.17" version = "0.2.17"
@ -536,15 +433,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "cpufeatures"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.5.2" version = "1.5.2"
@ -564,15 +452,6 @@ dependencies = [
"typenum", "typenum",
] ]
[[package]]
name = "crypto-common"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
dependencies = [
"hybrid-array",
]
[[package]] [[package]]
name = "deranged" name = "deranged"
version = "0.5.8" version = "0.5.8"
@ -585,22 +464,11 @@ version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [ dependencies = [
"block-buffer 0.10.4", "block-buffer",
"crypto-common 0.1.6", "crypto-common",
"subtle", "subtle",
] ]
[[package]]
name = "digest"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
dependencies = [
"block-buffer 0.12.1",
"const-oid",
"crypto-common 0.2.2",
]
[[package]] [[package]]
name = "displaydoc" name = "displaydoc"
version = "0.2.6" version = "0.2.6"
@ -609,16 +477,7 @@ checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
]
[[package]]
name = "ecb"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26f2a8b3e564eba0877223dc343703ad0385794e882e6d13f3a4dd5c6b1f41ac"
dependencies = [
"cipher",
] ]
[[package]] [[package]]
@ -676,8 +535,6 @@ version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb"
dependencies = [ dependencies = [
"crc32fast",
"miniz_oxide",
"zlib-rs", "zlib-rs",
] ]
@ -789,22 +646,10 @@ checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"r-efi 5.3.0", "r-efi",
"wasi 0.14.7+wasi-0.2.4", "wasi 0.14.7+wasi-0.2.4",
] ]
[[package]]
name = "getrandom"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
dependencies = [
"cfg-if",
"libc",
"r-efi 6.0.0",
"rand_core 0.10.1",
]
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.4.15" version = "0.4.15"
@ -911,15 +756,6 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "hybrid-array"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3944cf8cf766b40e2a1a333ee5e9b563f854d5fa49d6a8ca2764e97c6eddb214"
dependencies = [
"typenum",
]
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "1.10.1" version = "1.10.1"
@ -1134,16 +970,6 @@ dependencies = [
"hashbrown 0.17.1", "hashbrown 0.17.1",
] ]
[[package]]
name = "inout"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"
dependencies = [
"block-padding",
"hybrid-array",
]
[[package]] [[package]]
name = "ipnet" name = "ipnet"
version = "2.12.0" version = "2.12.0"
@ -1178,7 +1004,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654"
dependencies = [ dependencies = [
"cpufeatures 0.2.17", "cpufeatures",
] ]
[[package]] [[package]]
@ -1225,49 +1051,12 @@ version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
[[package]]
name = "lopdf"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfffda0fe1ab0157e1a13c14bebd3f28671f2fccb7922f0722ec53926e6922d3"
dependencies = [
"aes",
"bitflags",
"brotli-decompressor",
"cbc",
"ecb",
"encoding_rs",
"flate2",
"getrandom 0.4.3",
"indexmap",
"itoa",
"log",
"md-5",
"nom",
"rand 0.10.3",
"rangemap",
"sha2",
"stringprep",
"thiserror",
"weezl",
]
[[package]] [[package]]
name = "matchit" name = "matchit"
version = "0.7.3" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
[[package]]
name = "md-5"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69b6441f590336821bb897fb28fc622898ccceb1d6cea3fde5ea86b090c4de98"
dependencies = [
"cfg-if",
"digest 0.11.3",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.7.6" version = "2.7.6"
@ -1290,16 +1079,6 @@ dependencies = [
"unicase", "unicase",
] ]
[[package]]
name = "miniz_oxide"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
dependencies = [
"adler2",
"simd-adler32",
]
[[package]] [[package]]
name = "mio" name = "mio"
version = "1.2.1" version = "1.2.1"
@ -1345,15 +1124,6 @@ dependencies = [
"tempfile", "tempfile",
] ]
[[package]]
name = "nom"
version = "8.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "num-conv" name = "num-conv"
version = "0.2.2" version = "0.2.2"
@ -1403,7 +1173,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]
@ -1454,7 +1224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166"
dependencies = [ dependencies = [
"base64ct", "base64ct",
"rand_core 0.6.4", "rand_core",
"subtle", "subtle",
] ]
@ -1524,12 +1294,6 @@ version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "r-efi"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.6" version = "0.8.6"
@ -1538,18 +1302,7 @@ checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
dependencies = [ dependencies = [
"libc", "libc",
"rand_chacha", "rand_chacha",
"rand_core 0.6.4", "rand_core",
]
[[package]]
name = "rand"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
dependencies = [
"chacha20",
"getrandom 0.4.3",
"rand_core 0.10.1",
] ]
[[package]] [[package]]
@ -1559,7 +1312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [ dependencies = [
"ppv-lite86", "ppv-lite86",
"rand_core 0.6.4", "rand_core",
] ]
[[package]] [[package]]
@ -1571,18 +1324,6 @@ dependencies = [
"getrandom 0.2.17", "getrandom 0.2.17",
] ]
[[package]]
name = "rand_core"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
[[package]]
name = "rangemap"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d"
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.5.18" version = "0.5.18"
@ -1814,7 +1555,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]
@ -1863,24 +1604,13 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "sha2"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4"
dependencies = [
"cfg-if",
"cpufeatures 0.3.1",
"digest 0.11.3",
]
[[package]] [[package]]
name = "sha3" name = "sha3"
version = "0.10.8" version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60"
dependencies = [ dependencies = [
"digest 0.10.7", "digest",
"keccak", "keccak",
] ]
@ -1890,12 +1620,6 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "simd-adler32"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.12" version = "0.4.12"
@ -1930,17 +1654,6 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
[[package]]
name = "stringprep"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1"
dependencies = [
"unicode-bidi",
"unicode-normalization",
"unicode-properties",
]
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.11.1" version = "0.11.1"
@ -1964,17 +1677,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "syn"
version = "3.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]] [[package]]
name = "sync_wrapper" name = "sync_wrapper"
version = "1.0.2" version = "1.0.2"
@ -1992,7 +1694,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]
@ -2029,26 +1731,6 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "thiserror"
version = "2.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.51" version = "0.3.51"
@ -2089,12 +1771,6 @@ dependencies = [
"zerovec", "zerovec",
] ]
[[package]]
name = "tinyvec"
version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.52.3" version = "1.52.3"
@ -2118,7 +1794,7 @@ checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]
@ -2295,33 +1971,12 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
[[package]]
name = "unicode-bidi"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.19" version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
[[package]]
name = "unicode-normalization"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-properties"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d"
[[package]] [[package]]
name = "untrusted" name = "untrusted"
version = "0.9.0" version = "0.9.0"
@ -2431,7 +2086,7 @@ dependencies = [
"log", "log",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -2466,7 +2121,7 @@ checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -2490,12 +2145,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "weezl"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4ca08e5ef825b65b056d9efbd95c8750683f0a6d0466d02e96dc2e4e360f3d2"
[[package]] [[package]]
name = "windows-core" name = "windows-core"
version = "0.62.2" version = "0.62.2"
@ -2517,7 +2166,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]
@ -2528,7 +2177,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]
@ -2762,7 +2411,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
"synstructure", "synstructure",
] ]
@ -2783,7 +2432,7 @@ checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]
@ -2803,7 +2452,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
"synstructure", "synstructure",
] ]
@ -2843,7 +2492,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.106", "syn",
] ]
[[package]] [[package]]

View file

@ -35,5 +35,4 @@ axum-extra = { version = "0.9", features = ["cookie"] }
parking_lot = "0.12" parking_lot = "0.12"
zip = { version = "8.6", default-features = false, features = ["deflate-flate2-zlib-rs"] } zip = { version = "8.6", default-features = false, features = ["deflate-flate2-zlib-rs"] }
libc = "0.2" libc = "0.2"
lopdf = { version = "0.45", default-features = false }
tokio-util = { version = "0.7", features = ["io"] } tokio-util = { version = "0.7", features = ["io"] }

View file

@ -52,7 +52,7 @@ enum Command {
#[arg(long = "force-with-info-removal")] #[arg(long = "force-with-info-removal")]
force_with_info_removal: bool, force_with_info_removal: bool,
}, },
/// Export entries as a shareable HTML/Markdown bundle or PDF /// Export entries as a shareable HTML or Markdown bundle
Export { Export {
/// Entry UIDs to export, in output order /// Entry UIDs to export, in output order
#[arg(required = true)] #[arg(required = true)]
@ -81,7 +81,6 @@ enum Command {
#[derive(clap::ValueEnum, Debug, Clone, Copy)] #[derive(clap::ValueEnum, Debug, Clone, Copy)]
enum ExportFormatArg { enum ExportFormatArg {
Html, Html,
Pdf,
Markdown, Markdown,
} }
@ -89,7 +88,6 @@ impl From<ExportFormatArg> for ExportFormat {
fn from(a: ExportFormatArg) -> Self { fn from(a: ExportFormatArg) -> Self {
match a { match a {
ExportFormatArg::Html => ExportFormat::Html, ExportFormatArg::Html => ExportFormat::Html,
ExportFormatArg::Pdf => ExportFormat::Pdf,
ExportFormatArg::Markdown => ExportFormat::Markdown, ExportFormatArg::Markdown => ExportFormat::Markdown,
} }
} }

View file

@ -17,7 +17,6 @@ reqwest = { workspace = true }
base64.workspace = true base64.workspace = true
zip.workspace = true zip.workspace = true
tempfile.workspace = true tempfile.workspace = true
lopdf.workspace = true
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
libc.workspace = true libc.workspace = true

View file

@ -48,9 +48,3 @@ h2.ax-title{font-size:30px}h3.ax-title{font-size:23px}
pub(crate) const CREDIT_HTML: &str = r#"<footer class="ax-colophon"><a class="ax-credit" href="https://github.com/thegeneralist01/archivr" rel="noopener"> pub(crate) const CREDIT_HTML: &str = r#"<footer class="ax-colophon"><a class="ax-credit" href="https://github.com/thegeneralist01/archivr" rel="noopener">
<span class="ax-mark" aria-hidden="true">A</span><span>Preserved with <span class="ax-wordmark">archivr</span></span></a></footer>"#; <span class="ax-mark" aria-hidden="true">A</span><span>Preserved with <span class="ax-wordmark">archivr</span></span></a></footer>"#;
/// Inline-style credit div injected into SingleFile snapshots for PDF export.
/// The wrapper uses `all:initial` so the host page cannot restyle it.
pub(crate) const CREDIT_INLINE_HTML: &str = r#"<div style="all:initial;display:block;max-width:760px;margin:48px auto 0;padding:22px 28px 56px;border-top:1px solid #d2c6b5;text-align:center;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">
<a style="display:inline-flex;align-items:center;gap:8px;font-size:11px;letter-spacing:.08em;color:#6b6f66;text-decoration:none" href="https://github.com/thegeneralist01/archivr" rel="noopener">
<span style="display:inline-grid;place-items:center;width:16px;height:16px;border-radius:2.5px;background:#8d3f30;color:#f4ead8;font:600 12px/1 Georgia,serif" aria-hidden="true">A</span>
<span>Preserved with <span style="font:600 15px/1 Georgia,serif;letter-spacing:.01em;color:#20251f">archivr</span></span></a></div>"#;

View file

@ -130,30 +130,6 @@ pub(crate) fn write_zip_multi_with_extra(
Ok(()) Ok(())
} }
/// Build a ZIP that holds multiple PDFs: `<folder>/<NN>-<slug>.pdf`.
pub(crate) fn write_pdf_zip(
zip_path: &Path,
folder: &str,
pdfs: &[(String, PathBuf)], // (name_in_zip, source_path)
) -> Result<()> {
let file = std::fs::File::create(zip_path)
.with_context(|| format!("failed to create zip: {}", zip_path.display()))?;
let mut zip = ZipWriter::new(file);
for (name, source) in pdfs {
let entry_path = format!("{folder}/{name}");
let size = source.metadata().map(|m| m.len()).unwrap_or(0);
let opts = asset_options(name, size);
zip.start_file(&entry_path, opts)
.with_context(|| format!("failed to start {entry_path}"))?;
let mut f = std::fs::File::open(source)
.with_context(|| format!("failed to open pdf: {}", source.display()))?;
io::copy(&mut f, &mut zip)?;
}
zip.finish().context("failed to finish pdf zip")?;
Ok(())
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Helpers // Helpers

View file

@ -14,44 +14,15 @@ use crate::export::model::{Asset, ExportBody, ExportEntry, Post, Span, ext_of_s}
pub(crate) enum AssetMode { pub(crate) enum AssetMode {
/// `assets/<name>` — for ZIP bundles. /// `assets/<name>` — for ZIP bundles.
Bundle, Bundle,
/// `file://<percent-encoded absolute path>` — for Chrome PDF printing.
Print,
} }
pub(crate) fn asset_src(mode: AssetMode, asset: &Asset) -> String { pub(crate) fn asset_src(mode: AssetMode, asset: &Asset) -> String {
match mode { match mode {
AssetMode::Bundle => format!("assets/{}", asset.name), AssetMode::Bundle => format!("assets/{}", asset.name),
AssetMode::Print => file_url(&asset.source),
} }
} }
pub(crate) fn asset_src_path(mode: AssetMode, path: &std::path::Path) -> String {
match mode {
AssetMode::Bundle => {
// Fallback: use the file name.
path.file_name()
.map(|n| format!("assets/{}", n.to_string_lossy()))
.unwrap_or_default()
}
AssetMode::Print => file_url(path),
}
}
/// Percent-encodes a file path into a `file://` URL.
fn file_url(path: &std::path::Path) -> String {
let s = path.to_string_lossy();
let mut out = String::with_capacity(s.len() + 7);
out.push_str("file://");
for byte in s.as_bytes() {
match byte {
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'/' | b'.' | b'_' | b'-' | b'~' => {
out.push(*byte as char)
}
b => out.push_str(&format!("%{b:02X}")),
}
}
out
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Shared helpers // Shared helpers
@ -257,54 +228,6 @@ pub(crate) fn render_document(
html html
} }
/// Render a PDF cover page (collection header + TOC, no anchors per entry).
pub(crate) fn render_cover(
entries: &[ExportEntry],
include_credit: bool,
) -> String {
let generator_meta = if include_credit {
r#"<meta name="generator" content="Archivr">"#
} else {
""
};
let mut html = format!(
r#"<!doctype html><html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="referrer" content="no-referrer">
{generator_meta}
<title>{n} archived entries</title><style>{css}</style></head>
<body><main class="ax-doc">
"#,
n = entries.len(),
css = brand::EXPORT_CSS,
generator_meta = generator_meta,
);
html.push_str(&format!(
r#"<header class="ax-collection"><p class="ax-eyebrow">Collection</p><h1 class="ax-title">{n} archived entries</h1>
<ol class="ax-toc">"#,
n = entries.len(),
));
for entry in entries {
let title = entry_title(entry);
let label = source_label(&entry.summary.source_kind, &entry.summary.entity_kind);
html.push_str(&format!(
r#"<li>{title} <span class="ax-muted">{label}</span></li>"#,
title = esc(&title),
label = esc(&label),
));
}
html.push_str("</ol></header>\n");
html.push_str("</main>");
if include_credit {
html.push('\n');
html.push_str(brand::CREDIT_HTML);
html.push('\n');
}
html.push_str("</body></html>\n");
html
}
fn render_collection_header(entries: &[ExportEntry]) -> String { fn render_collection_header(entries: &[ExportEntry]) -> String {
let mut s = format!( let mut s = format!(
@ -404,70 +327,39 @@ fn render_video(
) -> String { ) -> String {
let src = asset_src(mode, asset); let src = asset_src(mode, asset);
let poster = posters.get(&asset.name); let poster = posters.get(&asset.name);
let poster_attr = poster
match mode { .map(|p| {
AssetMode::Bundle => { let pname = p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
let poster_attr = poster format!(r#" poster="assets/{pname}""#)
.map(|p| { })
let pname = p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(); .unwrap_or_default();
format!(r#" poster="assets/{pname}""#) let tracks: String = subtitles
}) .iter()
.enumerate()
.map(|(i, sub)| {
let sub_src = asset_src(mode, sub);
let label = sub.name.clone();
let srclang_attr = label
.split('-')
.next()
.map(|l| format!(r#" srclang="{l}""#))
.unwrap_or_default(); .unwrap_or_default();
let tracks: String = subtitles let default_attr = if i == 0 { r#" default"# } else { "" };
.iter()
.enumerate()
.map(|(i, sub)| {
let sub_src = asset_src(mode, sub);
let label = sub.name.clone();
let srclang_attr = label
.split('-')
.next()
.map(|l| format!(r#" srclang="{l}""#))
.unwrap_or_default();
let default_attr = if i == 0 { r#" default"# } else { "" };
format!(
r#"<track kind="subtitles" src="{sub_src}" label="{label}"{srclang_attr}{default_attr}>"#,
label = esc(&label),
)
})
.collect();
format!( format!(
r#"<figure class="ax-media"><video controls preload="metadata" playsinline{poster_attr} src="{src}">{tracks}</video></figure>"#, r#"<track kind="subtitles" src="{sub_src}" label="{label}"{srclang_attr}{default_attr}>"#,
src = esc(&src), label = esc(&label),
) )
} })
AssetMode::Print => { .collect();
if let Some(poster_path) = poster { format!(
let poster_src = asset_src_path(mode, poster_path); r#"<figure class="ax-media"><video controls preload="metadata" playsinline{poster_attr} src="{src}">{tracks}</video></figure>"#,
let name = asset.name.clone(); src = esc(&src),
format!( )
r#"<figure class="ax-media"><img src="{poster_src}" alt=""><figcaption>Video · {name}</figcaption></figure>"#,
poster_src = esc(&poster_src),
name = esc(&name),
)
} else {
format!(
r#"<div class="ax-placeholder">Video · {}</div>"#,
esc(&asset.name)
)
}
}
}
} }
fn render_audio(asset: &Asset, mode: AssetMode) -> String { fn render_audio(asset: &Asset, mode: AssetMode) -> String {
match mode { let src = asset_src(mode, asset);
AssetMode::Bundle => { format!(r#"<audio controls preload="metadata" src="{}"></audio>"#, esc(&src))
let src = asset_src(mode, asset);
format!(r#"<audio controls preload="metadata" src="{}"></audio>"#, esc(&src))
}
AssetMode::Print => {
format!(
r#"<div class="ax-placeholder">Audio · {}</div>"#,
esc(&asset.name)
)
}
}
} }
fn render_image(asset: &Asset, mode: AssetMode, title: &str) -> String { fn render_image(asset: &Asset, mode: AssetMode, title: &str) -> String {
@ -479,39 +371,23 @@ fn render_image(asset: &Asset, mode: AssetMode, title: &str) -> String {
) )
} }
fn render_pdf(asset: &Asset, mode: AssetMode, title: &str) -> String { fn render_pdf(asset: &Asset, mode: AssetMode, _title: &str) -> String {
match mode { let src = asset_src(mode, asset);
AssetMode::Bundle => { format!(
let src = asset_src(mode, asset); r#"<object class="ax-frame" data="{src}" type="application/pdf"></object>
format!(
r#"<object class="ax-frame" data="{src}" type="application/pdf"></object>
<p class="ax-aside"><a href="{src}">Open the PDF</a></p>"#, <p class="ax-aside"><a href="{src}">Open the PDF</a></p>"#,
src = esc(&src), src = esc(&src),
) )
}
AssetMode::Print => {
// Handled separately in pdf.rs: the PDF asset is merged directly.
format!(r#"<p class="ax-aside">{}</p>"#, esc(title))
}
}
} }
fn render_page(asset: &Asset, mode: AssetMode, title: &str) -> String { fn render_page(asset: &Asset, mode: AssetMode, title: &str) -> String {
match mode { let src = asset_src(mode, asset);
AssetMode::Bundle => { format!(
let src = asset_src(mode, asset); r#"<iframe class="ax-frame" src="{src}" title="{title}" sandbox="allow-same-origin allow-popups" referrerpolicy="no-referrer" loading="lazy"></iframe>
format!(
r#"<iframe class="ax-frame" src="{src}" title="{title}" sandbox="allow-same-origin allow-popups" referrerpolicy="no-referrer" loading="lazy"></iframe>
<p class="ax-aside"><a href="{src}">Open the archived page on its own</a></p>"#, <p class="ax-aside"><a href="{src}">Open the archived page on its own</a></p>"#,
src = esc(&src), src = esc(&src),
title = esc(title), title = esc(title),
) )
}
AssetMode::Print => {
// Handled in pdf.rs: the snapshot gets masthead/colophon injected.
format!(r#"<p class="ax-aside">{}</p>"#, esc(title))
}
}
} }
fn render_download_link(asset: &Asset, mode: AssetMode) -> String { fn render_download_link(asset: &Asset, mode: AssetMode) -> String {
@ -627,36 +503,17 @@ fn render_post(
)); ));
} }
for (video, is_gif) in &post.videos { for (video, is_gif) in &post.videos {
match mode { let src = asset_src(mode, video);
AssetMode::Bundle => { if *is_gif {
let src = asset_src(mode, video); s.push_str(&format!(
if *is_gif { r#"<video autoplay loop muted playsinline src="{src}"></video>"#,
s.push_str(&format!( src = esc(&src)
r#"<video autoplay loop muted playsinline src="{src}"></video>"#, ));
src = esc(&src) } else {
)); s.push_str(&format!(
} else { r#"<video controls src="{src}"></video>"#,
s.push_str(&format!( src = esc(&src)
r#"<video controls src="{src}"></video>"#, ));
src = esc(&src)
));
}
}
AssetMode::Print => {
let poster = posters.get(&video.name);
if let Some(poster_path) = poster {
let poster_src = asset_src_path(mode, poster_path);
s.push_str(&format!(
r#"<img src="{poster_src}" alt="" loading="lazy">"#,
poster_src = esc(&poster_src)
));
} else {
s.push_str(&format!(
r#"<div class="ax-placeholder">Video · {}</div>"#,
esc(&video.name)
));
}
}
} }
} }
s.push_str("</div>"); s.push_str("</div>");

View file

@ -1,4 +1,4 @@
//! Entry export: HTML ZIP, PDF, Markdown ZIP. //! Entry export: HTML ZIP and Markdown ZIP.
//! //!
//! The public entry point is [`export_entries`]. //! The public entry point is [`export_entries`].
@ -7,7 +7,6 @@ mod bundle;
mod html; mod html;
mod markdown; mod markdown;
mod model; mod model;
mod pdf;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs; use std::fs;
@ -32,7 +31,6 @@ use crate::process;
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ExportFormat { pub enum ExportFormat {
Html, Html,
Pdf,
Markdown, Markdown,
} }
@ -40,7 +38,6 @@ impl ExportFormat {
pub fn parse(s: &str) -> Option<Self> { pub fn parse(s: &str) -> Option<Self> {
match s.to_lowercase().as_str() { match s.to_lowercase().as_str() {
"html" => Some(Self::Html), "html" => Some(Self::Html),
"pdf" => Some(Self::Pdf),
"markdown" => Some(Self::Markdown), "markdown" => Some(Self::Markdown),
_ => None, _ => None,
} }
@ -202,7 +199,7 @@ pub fn export_entries(
// 7. Dispatch. // 7. Dispatch.
let (out_path, filename, content_type) = let (out_path, filename, content_type) =
assemble(&entries, options, &wpath, &posters, &paths.store_path)?; assemble(&entries, options, &wpath, &posters)?;
Ok(ExportFile { Ok(ExportFile {
path: out_path, path: out_path,
@ -374,7 +371,6 @@ fn assemble(
options: &ExportOptions, options: &ExportOptions,
work_dir: &Path, work_dir: &Path,
posters: &HashMap<String, PathBuf>, posters: &HashMap<String, PathBuf>,
store_path: &Path,
) -> Result<(PathBuf, String, &'static str)> { ) -> Result<(PathBuf, String, &'static str)> {
let date = Utc::now().format("%Y-%m-%d").to_string(); let date = Utc::now().format("%Y-%m-%d").to_string();
let n = entries.len(); let n = entries.len();
@ -384,7 +380,6 @@ fn assemble(
ExportFormat::Markdown => { ExportFormat::Markdown => {
assemble_markdown(entries, options, work_dir, posters, &date, n) assemble_markdown(entries, options, work_dir, posters, &date, n)
} }
ExportFormat::Pdf => assemble_pdf(entries, options, work_dir, posters, store_path, &date, n),
} }
} }
@ -503,74 +498,6 @@ fn assemble_markdown(
} }
} }
// ---------------------------------------------------------------------------
// PDF assembly
// ---------------------------------------------------------------------------
fn assemble_pdf(
entries: &[model::ExportEntry],
options: &ExportOptions,
work_dir: &Path,
posters: &HashMap<String, PathBuf>,
_store_path: &Path,
date: &str,
n: usize,
) -> Result<(PathBuf, String, &'static str)> {
if n == 1 {
let slug = entry_slug(entries[0].summary.title.as_deref().unwrap_or(""));
let filename = format!("{slug}.pdf");
let pdf_path = work_dir.join(&filename);
let entry_path =
pdf::entry_pdf(&entries[0], 0, options.include_credit, work_dir, posters)?;
fs::rename(&entry_path, &pdf_path)
.or_else(|_| fs::copy(&entry_path, &pdf_path).map(|_| ()))?;
return Ok((pdf_path, filename, "application/pdf"));
}
match options.layout {
ExportLayout::Together => {
let filename = format!("export-{n}-entries-{date}.pdf");
let out = work_dir.join(&filename);
// Cover page.
let cover_html = html::render_cover(entries, options.include_credit);
let cover_html_path = work_dir.join("cover.html");
fs::write(&cover_html_path, &cover_html)?;
let cover_pdf_path = work_dir.join("cover.pdf");
let profile_dir = work_dir.join("chrome-profile");
fs::create_dir_all(&profile_dir)?;
pdf::print_pdf(&cover_html_path, &cover_pdf_path, &profile_dir)?;
// Per-entry PDFs (no credit: it's on the cover).
let mut pdf_paths: Vec<PathBuf> = vec![cover_pdf_path];
for (i, entry) in entries.iter().enumerate() {
let p = pdf::entry_pdf(entry, i, false, work_dir, posters)?;
pdf_paths.push(p);
}
pdf::merge_pdf_files(&pdf_paths, &out)?;
Ok((out, filename, "application/pdf"))
}
ExportLayout::Separate => {
// A ZIP of individual PDFs.
let outer = format!("export-{date}");
let filename = format!("export-{n}-entries-{date}.zip");
let zip_path = work_dir.join(&filename);
let mut pdf_names: Vec<(String, PathBuf)> = Vec::new();
for (i, entry) in entries.iter().enumerate() {
let nn = format!("{:02}", i + 1);
let slug = entry_slug(entry.summary.title.as_deref().unwrap_or(""));
let pdf_path = pdf::entry_pdf(entry, i, options.include_credit, work_dir, posters)?;
let name_in_zip = format!("{nn}-{slug}.pdf");
pdf_names.push((name_in_zip, pdf_path));
}
bundle::write_pdf_zip(&zip_path, &outer, &pdf_names)?;
Ok((zip_path, filename, "application/zip"))
}
}
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Asset collection // Asset collection
@ -762,7 +689,6 @@ pub fn prune_stale_export_dirs(store_path: &Path, older_than: Duration) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use super::pdf::merge_documents;
use crate::archive::initialize_archive; use crate::archive::initialize_archive;
use crate::database; use crate::database;
@ -1031,45 +957,4 @@ mod tests {
assert_eq!(entry_slug("my-entry"), "my-entry"); assert_eq!(entry_slug("my-entry"), "my-entry");
} }
#[test]
fn test_merge_pdfs_page_count() {
use lopdf::{Dictionary, Document, Object, Stream};
let make_doc = |content: &[u8]| -> Document {
let mut doc = Document::with_version("1.4");
let stream_id = doc.add_object(Object::Stream(Stream::new(Dictionary::new(), content.to_vec())));
let mut page_dict = Dictionary::new();
page_dict.set("Type", Object::Name(b"Page".to_vec()));
page_dict.set("Contents", Object::Reference(stream_id));
page_dict.set("MediaBox", Object::Array(vec![
Object::Integer(0), Object::Integer(0),
Object::Integer(612), Object::Integer(792),
]));
let page_id = doc.add_object(Object::Dictionary(page_dict));
let mut pages_dict = Dictionary::new();
pages_dict.set("Type", Object::Name(b"Pages".to_vec()));
pages_dict.set("Kids", Object::Array(vec![Object::Reference(page_id)]));
pages_dict.set("Count", Object::Integer(1));
let pages_id = doc.add_object(Object::Dictionary(pages_dict));
if let Some(Object::Dictionary(pd)) = doc.objects.get_mut(&page_id) {
pd.set("Parent", Object::Reference(pages_id));
}
let mut catalog = Dictionary::new();
catalog.set("Type", Object::Name(b"Catalog".to_vec()));
catalog.set("Pages", Object::Reference(pages_id));
let catalog_id = doc.add_object(Object::Dictionary(catalog));
doc.trailer.set("Root", Object::Reference(catalog_id));
doc
};
let doc1 = make_doc(b"BT /F1 12 Tf 100 700 Td (Page one) Tj ET");
let doc2_p1 = make_doc(b"BT /F1 12 Tf 100 700 Td (Page two) Tj ET");
let doc2_p2 = make_doc(b"BT /F1 12 Tf 100 700 Td (Page three) Tj ET");
let doc2 = merge_documents(vec![doc2_p1, doc2_p2]).unwrap();
let mut merged = merge_documents(vec![doc1, doc2]).unwrap();
let mut bytes: Vec<u8> = Vec::new();
merged.save_to(&mut bytes).unwrap();
let reloaded = lopdf::Document::load_mem(&bytes).unwrap();
assert_eq!(reloaded.get_pages().len(), 3, "merged PDF should have 3 pages");
}
} }

View file

@ -1,395 +0,0 @@
//! PDF generation via headless Chrome and lopdf merging.
use std::collections::HashMap;
use std::ffi::OsString;
use std::path::{Path, PathBuf};
use std::time::Duration;
use anyhow::{Context, Result, bail};
use lopdf::{Dictionary, Document, Object, ObjectId, Stream};
use crate::env_config::{env_or, env_timeout};
use crate::export::brand;
use crate::export::html::{AssetMode, entry_title, render_document, source_label};
use crate::export::model::{Asset, ExportBody, ExportEntry};
use crate::process;
// ---------------------------------------------------------------------------
// Chrome PDF printing
// ---------------------------------------------------------------------------
/// Print an HTML file to PDF using headless Chrome.
pub(crate) fn print_pdf(html_path: &Path, out: &Path, profile_dir: &Path) -> Result<()> {
let chrome = env_or("ARCHIVR_CHROME", "chromium");
let chrome_path = PathBuf::from(&chrome);
let timeout_secs = env_timeout("ARCHIVR_EXPORT_PDF_TIMEOUT", 120);
let extra_args: Vec<String> = std::env::var("ARCHIVR_CHROME_ARGS")
.unwrap_or_default()
.split_whitespace()
.filter(|s| !s.is_empty())
.map(str::to_string)
.collect();
let html_url = percent_encode_path(html_path);
let mut args: Vec<OsString> = vec![
"--headless=new".into(),
"--disable-gpu".into(),
"--no-first-run".into(),
"--no-default-browser-check".into(),
"--hide-scrollbars".into(),
format!("--user-data-dir={}", profile_dir.display()).into(),
"--no-pdf-header-footer".into(),
"--run-all-compositor-stages-before-draw".into(),
"--virtual-time-budget=15000".into(),
format!("--print-to-pdf={}", out.display()).into(),
];
for a in &extra_args {
args.push(a.into());
}
args.push(html_url.into());
process::run_with_timeout(&chrome_path, &args, None, Duration::from_secs(timeout_secs))
.with_context(|| "PDF export needs Chromium: set ARCHIVR_CHROME")?;
if !out.exists() || out.metadata().map(|m| m.len()).unwrap_or(0) == 0 {
bail!(
"Chromium produced no PDF (set ARCHIVR_CHROME to a Chromium/Chrome binary); \
tried: {chrome}"
);
}
Ok(())
}
fn percent_encode_path(path: &Path) -> String {
let s = path.to_string_lossy();
let mut out = String::with_capacity(s.len() + 7);
out.push_str("file://");
for byte in s.as_bytes() {
match byte {
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'/' | b'.' | b'_' | b'-' | b'~' => {
out.push(*byte as char)
}
b => out.push_str(&format!("%{b:02X}")),
}
}
out
}
// ---------------------------------------------------------------------------
// lopdf merging
// ---------------------------------------------------------------------------
/// Merge PDF files on disk into a single output PDF.
pub(crate) fn merge_pdf_files(inputs: &[PathBuf], output: &Path) -> Result<()> {
if inputs.is_empty() {
bail!("merge_pdf_files: no inputs");
}
if inputs.len() == 1 {
std::fs::copy(&inputs[0], output)
.with_context(|| format!("failed to copy PDF to {}", output.display()))?;
return Ok(());
}
let docs: Vec<Document> = inputs
.iter()
.map(|p| Document::load(p).with_context(|| format!("failed to load PDF: {}", p.display())))
.collect::<Result<Vec<_>>>()?;
let mut merged = merge_documents(docs)?;
merged
.save(output)
.with_context(|| format!("failed to save merged PDF to {}", output.display()))?;
Ok(())
}
/// Merge multiple `Document` values into one, appending pages in order.
///
/// Follows the lopdf `examples/merge.rs` pattern: each source document's
/// object IDs are shifted by an offset so they do not collide, then all
/// objects are copied into a fresh document with a new Pages tree and Catalog.
pub(crate) fn merge_documents(docs: Vec<Document>) -> Result<Document> {
if docs.is_empty() {
bail!("merge_documents: no documents provided");
}
if docs.len() == 1 {
return Ok(docs.into_iter().next().unwrap());
}
let mut merged = Document::with_version("1.5");
let mut all_page_ids: Vec<ObjectId> = Vec::new();
// next_id tracks the next free object number so we can assign the Pages
// and Catalog objects after all source objects have been copied in.
let mut next_id: u32 = 0;
for doc in docs {
let offset = next_id;
// Collect pages in page-number order before we consume the doc.
let pages = doc.get_pages(); // BTreeMap<u32, ObjectId>
for (_page_num, page_oid) in &pages {
all_page_ids.push((page_oid.0 + offset, page_oid.1));
}
let doc_max = doc.objects.keys().map(|(n, _)| *n).max().unwrap_or(0);
for (oid, obj) in &doc.objects {
let new_oid: ObjectId = (oid.0 + offset, oid.1);
let remapped = remap_refs(obj, offset);
merged.objects.insert(new_oid, remapped);
}
next_id += doc_max + 1;
}
// Build the Pages dictionary.
let pages_oid: ObjectId = (next_id, 0);
next_id += 1;
// Point every collected page at the new Pages parent.
for page_id in &all_page_ids {
if let Some(Object::Dictionary(dict)) = merged.objects.get_mut(page_id) {
dict.set("Parent", Object::Reference(pages_oid));
}
}
let mut pages_dict = Dictionary::new();
pages_dict.set("Type", Object::Name(b"Pages".to_vec()));
pages_dict.set(
"Kids",
Object::Array(all_page_ids.iter().map(|id| Object::Reference(*id)).collect()),
);
pages_dict.set("Count", Object::Integer(all_page_ids.len() as i64));
merged.objects.insert(pages_oid, Object::Dictionary(pages_dict));
// Build the Catalog.
let catalog_oid: ObjectId = (next_id, 0);
let mut catalog = Dictionary::new();
catalog.set("Type", Object::Name(b"Catalog".to_vec()));
catalog.set("Pages", Object::Reference(pages_oid));
merged.objects.insert(catalog_oid, Object::Dictionary(catalog));
merged.trailer.set("Root", Object::Reference(catalog_oid));
merged.trailer.set("Size", Object::Integer((next_id + 1) as i64));
merged.max_id = next_id;
Ok(merged)
}
/// Recursively remap all `Reference` object IDs by adding `offset` to the
/// object number component.
fn remap_refs(obj: &Object, offset: u32) -> Object {
match obj {
Object::Reference(id) => Object::Reference((id.0 + offset, id.1)),
Object::Array(arr) => Object::Array(arr.iter().map(|o| remap_refs(o, offset)).collect()),
Object::Dictionary(dict) => {
let mut new_dict = Dictionary::new();
for (k, v) in dict.iter() {
new_dict.set(k.clone(), remap_refs(v, offset));
}
Object::Dictionary(new_dict)
}
Object::Stream(stream) => {
let mut new_dict = Dictionary::new();
for (k, v) in stream.dict.iter() {
new_dict.set(k.clone(), remap_refs(v, offset));
}
Object::Stream(Stream::new(new_dict, stream.content.clone()))
}
other => other.clone(),
}
}
// ---------------------------------------------------------------------------
// Per-entry PDF generation
// ---------------------------------------------------------------------------
/// Generate a PDF for a single entry. Returns the path inside `work_dir`.
pub(crate) fn entry_pdf(
entry: &ExportEntry,
index: usize,
with_credit: bool,
work_dir: &Path,
posters: &HashMap<String, PathBuf>,
) -> Result<PathBuf> {
let profile_dir = work_dir.join("chrome-profile");
std::fs::create_dir_all(&profile_dir)?;
match &entry.body {
ExportBody::Page(asset) => {
entry_pdf_from_page(entry, index, with_credit, work_dir, &profile_dir, asset)
}
ExportBody::Pdf(asset) => {
entry_pdf_from_existing_pdf(entry, index, with_credit, work_dir, &profile_dir, asset)
}
_ => entry_pdf_from_html(entry, index, with_credit, work_dir, &profile_dir, posters),
}
}
fn entry_pdf_from_html(
entry: &ExportEntry,
index: usize,
with_credit: bool,
work_dir: &Path,
profile_dir: &Path,
posters: &HashMap<String, PathBuf>,
) -> Result<PathBuf> {
let html = render_document(std::slice::from_ref(entry), AssetMode::Print, posters, with_credit);
let html_path = work_dir.join(format!("print-{index}.html"));
std::fs::write(&html_path, &html)
.with_context(|| format!("failed to write print HTML: {}", html_path.display()))?;
let out = work_dir.join(format!("entry-{index}.pdf"));
print_pdf(&html_path, &out, profile_dir)?;
Ok(out)
}
fn entry_pdf_from_page(
entry: &ExportEntry,
index: usize,
with_credit: bool,
work_dir: &Path,
profile_dir: &Path,
asset: &Asset,
) -> Result<PathBuf> {
let snapshot_bytes = std::fs::read(&asset.source)
.with_context(|| format!("failed to read snapshot: {}", asset.source.display()))?;
let snapshot = String::from_utf8_lossy(&snapshot_bytes);
let title = entry_title(entry);
let label = source_label(&entry.summary.source_kind, &entry.summary.entity_kind);
let masthead = build_masthead_div(&title, &label, &entry.summary.archived_at);
let injected = inject_after_body_open(&snapshot, &masthead);
let injected = if with_credit {
inject_before_body_close(&injected, brand::CREDIT_INLINE_HTML)
} else {
injected
};
let html_path = work_dir.join(format!("print-page-{index}.html"));
std::fs::write(&html_path, injected.as_bytes())
.with_context(|| format!("failed to write page HTML: {}", html_path.display()))?;
let out = work_dir.join(format!("entry-{index}.pdf"));
print_pdf(&html_path, &out, profile_dir)?;
Ok(out)
}
fn entry_pdf_from_existing_pdf(
entry: &ExportEntry,
index: usize,
with_credit: bool,
work_dir: &Path,
profile_dir: &Path,
asset: &Asset,
) -> Result<PathBuf> {
// Print the masthead as its own page.
let title = entry_title(entry);
let label = source_label(&entry.summary.source_kind, &entry.summary.entity_kind);
let mhtml = build_masthead_page(&title, &label, &entry.summary.archived_at, with_credit);
let mhtml_path = work_dir.join(format!("masthead-{index}.html"));
std::fs::write(&mhtml_path, mhtml.as_bytes()).context("failed to write masthead HTML")?;
let mast_pdf_path = work_dir.join(format!("masthead-{index}.pdf"));
print_pdf(&mhtml_path, &mast_pdf_path, profile_dir)?;
let out = work_dir.join(format!("entry-{index}.pdf"));
match Document::load(&asset.source) {
Ok(orig_doc) => {
let mast_doc = Document::load(&mast_pdf_path).context("failed to reload masthead PDF")?;
let mut merged = merge_documents(vec![mast_doc, orig_doc])?;
merged.save(&out).context("failed to save merged PDF")?;
Ok(out)
}
Err(e) => {
eprintln!("warn: export: failed to load PDF artifact: {e:#}");
// Fallback: render a plain HTML page for this entry.
let html = render_document(
std::slice::from_ref(entry),
AssetMode::Print,
&HashMap::new(),
with_credit,
);
let html_path = work_dir.join(format!("print-{index}.html"));
std::fs::write(&html_path, &html)?;
print_pdf(&html_path, &out, profile_dir)?;
Ok(out)
}
}
}
// ---------------------------------------------------------------------------
// Masthead injection helpers
// ---------------------------------------------------------------------------
fn build_masthead_div(title: &str, label: &str, archived_at: &str) -> String {
use chrono::DateTime;
let date = DateTime::parse_from_rfc3339(archived_at)
.map(|dt| dt.format("%-d %B %Y").to_string())
.unwrap_or_else(|_| archived_at.to_string());
format!(
r#"<div style="all:initial;display:block;max-width:760px;margin:0 auto 28px;padding:0 0 22px;border-bottom:1px solid #d2c6b5;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">
<p style="all:initial;display:block;margin:0 0 10px;font-size:10.5px;letter-spacing:.16em;text-transform:uppercase;color:#6b6f66">{label}</p>
<h1 style="all:initial;display:block;margin:0;font:600 38px/1.12 'Cormorant Garamond','Cormorant',Georgia,serif;letter-spacing:.005em;color:#20251f">{title}</h1>
<p style="all:initial;display:block;margin:12px 0 0;font-size:13px;color:#6b6f66">Archived {date}</p>
</div>"#,
label = html_esc(label),
title = html_esc(title),
date = html_esc(&date),
)
}
fn build_masthead_page(title: &str, label: &str, archived_at: &str, with_credit: bool) -> String {
let masthead = build_masthead_div(title, label, archived_at);
let credit = if with_credit { brand::CREDIT_HTML } else { "" };
format!(
r#"<!doctype html><html lang="en"><head><meta charset="utf-8"><style>body{{margin:0;font:17px/1.65 Georgia,serif;background:#f5f0e7;color:#20251f}}.ax-doc{{max-width:760px;margin:0 auto;padding:64px 28px 32px}}</style></head>
<body><main class="ax-doc">{masthead}</main>{credit}</body></html>"#,
)
}
fn inject_after_body_open(html: &str, to_inject: &str) -> String {
let lower = html.to_lowercase();
if let Some(body_start) = lower.find("<body") {
if let Some(rel_end) = lower[body_start..].find('>') {
let insert_at = body_start + rel_end + 1;
let mut out = String::with_capacity(html.len() + to_inject.len() + 1);
out.push_str(&html[..insert_at]);
out.push('\n');
out.push_str(to_inject);
out.push_str(&html[insert_at..]);
return out;
}
}
let mut out = String::with_capacity(html.len() + to_inject.len() + 1);
out.push_str(to_inject);
out.push('\n');
out.push_str(html);
out
}
fn inject_before_body_close(html: &str, to_inject: &str) -> String {
let lower = html.to_lowercase();
if let Some(close_pos) = lower.rfind("</body>") {
let mut out = String::with_capacity(html.len() + to_inject.len() + 1);
out.push_str(&html[..close_pos]);
out.push('\n');
out.push_str(to_inject);
out.push_str(&html[close_pos..]);
return out;
}
let mut out = html.to_string();
out.push('\n');
out.push_str(to_inject);
out
}
fn html_esc(s: &str) -> String {
s.replace('&', "&amp;")
.replace('<', "&lt;")
.replace('>', "&gt;")
.replace('"', "&quot;")
.replace('\'', "&#39;")
}

View file

@ -69,9 +69,8 @@ pub(crate) static ENV_VARS: &[EnvSpec] = &[
spec("ARCHIVR_DENO", "tools", None, "Pinned Deno binary offered to the JS runtime resolver."), spec("ARCHIVR_DENO", "tools", None, "Pinned Deno binary offered to the JS runtime resolver."),
spec("ARCHIVR_JS_RUNTIME", "tools", None, "Forced JS runtime for yt-dlp as RUNTIME[:ABS_PATH] (deno, node, bun, quickjs)."), spec("ARCHIVR_JS_RUNTIME", "tools", None, "Forced JS runtime for yt-dlp as RUNTIME[:ABS_PATH] (deno, node, bun, quickjs)."),
spec("ARCHIVR_SINGLE_FILE", "tools", Some("single-file"), "single-file-cli binary for web page archiving."), spec("ARCHIVR_SINGLE_FILE", "tools", Some("single-file"), "single-file-cli binary for web page archiving."),
spec("ARCHIVR_CHROME", "tools", Some("chromium"), "Chromium executable used by single-file and PDF export."), spec("ARCHIVR_CHROME", "tools", Some("chromium"), "Chromium executable used by single-file captures."),
spec("ARCHIVR_CHROME_ARGS", "tools", None, "Extra space-separated Chromium flags."), spec("ARCHIVR_CHROME_ARGS", "tools", None, "Extra space-separated Chromium flags."),
spec("ARCHIVR_EXPORT_PDF_TIMEOUT", "tools", Some("120"), "Seconds allowed for each Chromium PDF render during entry export."),
spec("ARCHIVR_UBLOCK", "tools", Some("true"), "Default for the uBlock extension toggle when no instance setting overrides it (false or 0 disables)."), spec("ARCHIVR_UBLOCK", "tools", Some("true"), "Default for the uBlock extension toggle when no instance setting overrides it (false or 0 disables)."),
spec("ARCHIVR_UBLOCK_EXT", "tools", None, "Directory of the unpacked uBlock extension."), spec("ARCHIVR_UBLOCK_EXT", "tools", None, "Directory of the unpacked uBlock extension."),
spec("ARCHIVR_COOKIE_CONSENT", "tools", Some("true"), "Default for the cookie-consent extension toggle when no instance setting overrides it (false or 0 disables)."), spec("ARCHIVR_COOKIE_CONSENT", "tools", Some("true"), "Default for the cookie-consent extension toggle when no instance setting overrides it (false or 0 disables)."),

View file

@ -42,7 +42,7 @@ async fn export_handler(
// 2. Parse format, layout, and credit. // 2. Parse format, layout, and credit.
let format = export::ExportFormat::parse(&q.format) let format = export::ExportFormat::parse(&q.format)
.ok_or_else(|| ApiError::bad_request("format must be html, pdf, or markdown"))?; .ok_or_else(|| ApiError::bad_request("format must be html or markdown"))?;
let layout = match q.layout.as_deref().unwrap_or("together") { let layout = match q.layout.as_deref().unwrap_or("together") {
"together" => export::ExportLayout::Together, "together" => export::ExportLayout::Together,

View file

@ -101,7 +101,6 @@ export default function ExportDialog({ open, archiveId, entryUids, onClose }) {
disabled={status === 'running'} disabled={status === 'running'}
> >
<option value="html">Web page — HTML (.zip)</option> <option value="html">Web page — HTML (.zip)</option>
<option value="pdf">PDF</option>
<option value="markdown">Markdown (.zip)</option> <option value="markdown">Markdown (.zip)</option>
</select> </select>
</label> </label>