static site generator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

many changes

IamPyu 802d4d60 190d3c02

+675 -533
+438 -325
Cargo.lock
··· 18 18 ] 19 19 20 20 [[package]] 21 + name = "android_system_properties" 22 + version = "0.1.5" 23 + source = "registry+https://github.com/rust-lang/crates.io-index" 24 + checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" 25 + dependencies = [ 26 + "libc", 27 + ] 28 + 29 + [[package]] 21 30 name = "anstream" 22 31 version = "0.6.21" 23 32 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 74 83 checksum = "5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75ea" 75 84 76 85 [[package]] 86 + name = "autocfg" 87 + version = "1.5.0" 88 + source = "registry+https://github.com/rust-lang/crates.io-index" 89 + checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" 90 + 91 + [[package]] 77 92 name = "base64" 78 93 version = "0.22.1" 79 94 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 134 149 source = "registry+https://github.com/rust-lang/crates.io-index" 135 150 checksum = "89ec27229c38ed0eb3c0feee3d2c1d6a4379ae44f418a29a658890e062d8f365" 136 151 dependencies = [ 137 - "darling 0.23.0", 152 + "darling", 138 153 "ident_case", 139 154 "prettyplease", 140 155 "proc-macro2", ··· 144 159 ] 145 160 146 161 [[package]] 162 + name = "bstr" 163 + version = "1.12.1" 164 + source = "registry+https://github.com/rust-lang/crates.io-index" 165 + checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" 166 + dependencies = [ 167 + "memchr", 168 + "serde", 169 + ] 170 + 171 + [[package]] 172 + name = "bumpalo" 173 + version = "3.19.1" 174 + source = "registry+https://github.com/rust-lang/crates.io-index" 175 + checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" 176 + 177 + [[package]] 147 178 name = "caseless" 148 179 version = "0.2.2" 149 180 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 169 200 checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" 170 201 171 202 [[package]] 203 + name = "chrono" 204 + version = "0.4.43" 205 + source = "registry+https://github.com/rust-lang/crates.io-index" 206 + checksum = "fac4744fb15ae8337dc853fee7fb3f4e48c0fbaa23d0afe49c447b4fab126118" 207 + dependencies = [ 208 + "iana-time-zone", 209 + "num-traits", 210 + "windows-link", 211 + ] 212 + 213 + [[package]] 214 + name = "chrono-tz" 215 + version = "0.9.0" 216 + source = "registry+https://github.com/rust-lang/crates.io-index" 217 + checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" 218 + dependencies = [ 219 + "chrono", 220 + "chrono-tz-build", 221 + "phf 0.11.3", 222 + ] 223 + 224 + [[package]] 225 + name = "chrono-tz-build" 226 + version = "0.3.0" 227 + source = "registry+https://github.com/rust-lang/crates.io-index" 228 + checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" 229 + dependencies = [ 230 + "parse-zoneinfo", 231 + "phf 0.11.3", 232 + "phf_codegen 0.11.3", 233 + ] 234 + 235 + [[package]] 172 236 name = "clap" 173 237 version = "4.5.57" 174 238 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 228 292 "entities", 229 293 "fmt2io", 230 294 "jetscii", 231 - "phf", 232 - "phf_codegen", 295 + "phf 0.13.1", 296 + "phf_codegen 0.13.1", 233 297 "rustc-hash", 234 298 "shell-words", 235 299 "smallvec", ··· 240 304 ] 241 305 242 306 [[package]] 307 + name = "core-foundation-sys" 308 + version = "0.8.7" 309 + source = "registry+https://github.com/rust-lang/crates.io-index" 310 + checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" 311 + 312 + [[package]] 243 313 name = "cpufeatures" 244 314 version = "0.2.17" 245 315 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 258 328 ] 259 329 260 330 [[package]] 261 - name = "crypto-common" 262 - version = "0.1.7" 331 + name = "crossbeam-deque" 332 + version = "0.8.6" 263 333 source = "registry+https://github.com/rust-lang/crates.io-index" 264 - checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" 334 + checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" 265 335 dependencies = [ 266 - "generic-array", 267 - "typenum", 336 + "crossbeam-epoch", 337 + "crossbeam-utils", 268 338 ] 269 339 270 340 [[package]] 271 - name = "darling" 272 - version = "0.20.11" 341 + name = "crossbeam-epoch" 342 + version = "0.9.18" 273 343 source = "registry+https://github.com/rust-lang/crates.io-index" 274 - checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" 344 + checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" 275 345 dependencies = [ 276 - "darling_core 0.20.11", 277 - "darling_macro 0.20.11", 346 + "crossbeam-utils", 278 347 ] 279 348 280 349 [[package]] 281 - name = "darling" 282 - version = "0.23.0" 350 + name = "crossbeam-utils" 351 + version = "0.8.21" 283 352 source = "registry+https://github.com/rust-lang/crates.io-index" 284 - checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" 353 + checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" 354 + 355 + [[package]] 356 + name = "crypto-common" 357 + version = "0.1.7" 358 + source = "registry+https://github.com/rust-lang/crates.io-index" 359 + checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" 285 360 dependencies = [ 286 - "darling_core 0.23.0", 287 - "darling_macro 0.23.0", 361 + "generic-array", 362 + "typenum", 288 363 ] 289 364 290 365 [[package]] 291 - name = "darling_core" 292 - version = "0.20.11" 366 + name = "darling" 367 + version = "0.23.0" 293 368 source = "registry+https://github.com/rust-lang/crates.io-index" 294 - checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" 369 + checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" 295 370 dependencies = [ 296 - "fnv", 297 - "ident_case", 298 - "proc-macro2", 299 - "quote", 300 - "strsim", 301 - "syn", 371 + "darling_core", 372 + "darling_macro", 302 373 ] 303 374 304 375 [[package]] ··· 316 387 317 388 [[package]] 318 389 name = "darling_macro" 319 - version = "0.20.11" 320 - source = "registry+https://github.com/rust-lang/crates.io-index" 321 - checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" 322 - dependencies = [ 323 - "darling_core 0.20.11", 324 - "quote", 325 - "syn", 326 - ] 327 - 328 - [[package]] 329 - name = "darling_macro" 330 390 version = "0.23.0" 331 391 source = "registry+https://github.com/rust-lang/crates.io-index" 332 392 checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" 333 393 dependencies = [ 334 - "darling_core 0.23.0", 394 + "darling_core", 335 395 "quote", 336 396 "syn", 337 397 ] ··· 346 406 ] 347 407 348 408 [[package]] 349 - name = "derive_builder" 350 - version = "0.20.2" 409 + name = "deunicode" 410 + version = "1.6.2" 351 411 source = "registry+https://github.com/rust-lang/crates.io-index" 352 - checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" 353 - dependencies = [ 354 - "derive_builder_macro", 355 - ] 356 - 357 - [[package]] 358 - name = "derive_builder_core" 359 - version = "0.20.2" 360 - source = "registry+https://github.com/rust-lang/crates.io-index" 361 - checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" 362 - dependencies = [ 363 - "darling 0.20.11", 364 - "proc-macro2", 365 - "quote", 366 - "syn", 367 - ] 368 - 369 - [[package]] 370 - name = "derive_builder_macro" 371 - version = "0.20.2" 372 - source = "registry+https://github.com/rust-lang/crates.io-index" 373 - checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" 374 - dependencies = [ 375 - "derive_builder_core", 376 - "syn", 377 - ] 412 + checksum = "abd57806937c9cc163efc8ea3910e00a62e2aeb0b8119f1793a978088f8f6b04" 378 413 379 414 [[package]] 380 415 name = "digest" ··· 387 422 ] 388 423 389 424 [[package]] 390 - name = "displaydoc" 391 - version = "0.2.5" 392 - source = "registry+https://github.com/rust-lang/crates.io-index" 393 - checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" 394 - dependencies = [ 395 - "proc-macro2", 396 - "quote", 397 - "syn", 398 - ] 399 - 400 - [[package]] 401 425 name = "emojis" 402 426 version = "0.8.0" 403 427 source = "registry+https://github.com/rust-lang/crates.io-index" 404 428 checksum = "50c1c1870b766fc398e5f0526498d09c94b6de15be5fd769a28bbc804fb1b05d" 405 429 dependencies = [ 406 - "phf", 430 + "phf 0.13.1", 407 431 ] 408 432 409 433 [[package]] ··· 472 496 version = "1.0.7" 473 497 source = "registry+https://github.com/rust-lang/crates.io-index" 474 498 checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 475 - 476 - [[package]] 477 - name = "form_urlencoded" 478 - version = "1.2.2" 479 - source = "registry+https://github.com/rust-lang/crates.io-index" 480 - checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" 481 - dependencies = [ 482 - "percent-encoding", 483 - ] 484 499 485 500 [[package]] 486 501 name = "generic-array" ··· 493 508 ] 494 509 495 510 [[package]] 496 - name = "handlebars" 497 - version = "6.4.0" 511 + name = "getrandom" 512 + version = "0.2.17" 498 513 source = "registry+https://github.com/rust-lang/crates.io-index" 499 - checksum = "9b3f9296c208515b87bd915a2f5d1163d4b3f863ba83337d7713cf478055948e" 514 + checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" 500 515 dependencies = [ 501 - "derive_builder", 502 - "log", 503 - "num-order", 504 - "pest", 505 - "pest_derive", 506 - "serde", 507 - "serde_json", 508 - "thiserror", 516 + "cfg-if", 517 + "libc", 518 + "wasi", 509 519 ] 510 520 511 521 [[package]] 512 - name = "hashbrown" 513 - version = "0.16.1" 514 - source = "registry+https://github.com/rust-lang/crates.io-index" 515 - checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" 516 - 517 - [[package]] 518 - name = "heck" 519 - version = "0.5.0" 520 - source = "registry+https://github.com/rust-lang/crates.io-index" 521 - checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 522 - 523 - [[package]] 524 - name = "icu_collections" 525 - version = "2.1.1" 522 + name = "globset" 523 + version = "0.4.18" 526 524 source = "registry+https://github.com/rust-lang/crates.io-index" 527 - checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" 525 + checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3" 528 526 dependencies = [ 529 - "displaydoc", 530 - "potential_utf", 531 - "yoke", 532 - "zerofrom", 533 - "zerovec", 527 + "aho-corasick", 528 + "bstr", 529 + "log", 530 + "regex-automata", 531 + "regex-syntax", 534 532 ] 535 533 536 534 [[package]] 537 - name = "icu_locale_core" 538 - version = "2.1.1" 535 + name = "globwalk" 536 + version = "0.9.1" 539 537 source = "registry+https://github.com/rust-lang/crates.io-index" 540 - checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" 538 + checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" 541 539 dependencies = [ 542 - "displaydoc", 543 - "litemap", 544 - "tinystr", 545 - "writeable", 546 - "zerovec", 540 + "bitflags", 541 + "ignore", 542 + "walkdir", 547 543 ] 548 544 549 545 [[package]] 550 - name = "icu_normalizer" 551 - version = "2.1.1" 546 + name = "hashbrown" 547 + version = "0.16.1" 552 548 source = "registry+https://github.com/rust-lang/crates.io-index" 553 - checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" 554 - dependencies = [ 555 - "icu_collections", 556 - "icu_normalizer_data", 557 - "icu_properties", 558 - "icu_provider", 559 - "smallvec", 560 - "zerovec", 561 - ] 549 + checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" 562 550 563 551 [[package]] 564 - name = "icu_normalizer_data" 565 - version = "2.1.1" 552 + name = "heck" 553 + version = "0.5.0" 566 554 source = "registry+https://github.com/rust-lang/crates.io-index" 567 - checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" 555 + checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 568 556 569 557 [[package]] 570 - name = "icu_properties" 571 - version = "2.1.2" 558 + name = "humansize" 559 + version = "2.1.3" 572 560 source = "registry+https://github.com/rust-lang/crates.io-index" 573 - checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" 561 + checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7" 574 562 dependencies = [ 575 - "icu_collections", 576 - "icu_locale_core", 577 - "icu_properties_data", 578 - "icu_provider", 579 - "zerotrie", 580 - "zerovec", 563 + "libm", 581 564 ] 582 565 583 566 [[package]] 584 - name = "icu_properties_data" 585 - version = "2.1.2" 567 + name = "iana-time-zone" 568 + version = "0.1.65" 586 569 source = "registry+https://github.com/rust-lang/crates.io-index" 587 - checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" 570 + checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" 571 + dependencies = [ 572 + "android_system_properties", 573 + "core-foundation-sys", 574 + "iana-time-zone-haiku", 575 + "js-sys", 576 + "log", 577 + "wasm-bindgen", 578 + "windows-core", 579 + ] 588 580 589 581 [[package]] 590 - name = "icu_provider" 591 - version = "2.1.1" 582 + name = "iana-time-zone-haiku" 583 + version = "0.1.2" 592 584 source = "registry+https://github.com/rust-lang/crates.io-index" 593 - checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" 585 + checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" 594 586 dependencies = [ 595 - "displaydoc", 596 - "icu_locale_core", 597 - "writeable", 598 - "yoke", 599 - "zerofrom", 600 - "zerotrie", 601 - "zerovec", 587 + "cc", 602 588 ] 603 589 604 590 [[package]] ··· 608 594 checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 609 595 610 596 [[package]] 611 - name = "idna" 612 - version = "1.1.0" 597 + name = "ignore" 598 + version = "0.4.25" 613 599 source = "registry+https://github.com/rust-lang/crates.io-index" 614 - checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" 600 + checksum = "d3d782a365a015e0f5c04902246139249abf769125006fbe7649e2ee88169b4a" 615 601 dependencies = [ 616 - "idna_adapter", 617 - "smallvec", 618 - "utf8_iter", 619 - ] 620 - 621 - [[package]] 622 - name = "idna_adapter" 623 - version = "1.2.1" 624 - source = "registry+https://github.com/rust-lang/crates.io-index" 625 - checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" 626 - dependencies = [ 627 - "icu_normalizer", 628 - "icu_properties", 602 + "crossbeam-deque", 603 + "globset", 604 + "log", 605 + "memchr", 606 + "regex-automata", 607 + "same-file", 608 + "walkdir", 609 + "winapi-util", 629 610 ] 630 611 631 612 [[package]] ··· 657 638 checksum = "47f142fe24a9c9944451e8349de0a56af5f3e7226dc46f3ed4d4ecc0b85af75e" 658 639 659 640 [[package]] 641 + name = "js-sys" 642 + version = "0.3.85" 643 + source = "registry+https://github.com/rust-lang/crates.io-index" 644 + checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" 645 + dependencies = [ 646 + "once_cell", 647 + "wasm-bindgen", 648 + ] 649 + 650 + [[package]] 651 + name = "lazy_static" 652 + version = "1.5.0" 653 + source = "registry+https://github.com/rust-lang/crates.io-index" 654 + checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" 655 + 656 + [[package]] 660 657 name = "libc" 661 658 version = "0.2.180" 662 659 source = "registry+https://github.com/rust-lang/crates.io-index" 663 660 checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" 664 661 665 662 [[package]] 663 + name = "libm" 664 + version = "0.2.16" 665 + source = "registry+https://github.com/rust-lang/crates.io-index" 666 + checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" 667 + 668 + [[package]] 666 669 name = "linked-hash-map" 667 670 version = "0.5.6" 668 671 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 673 676 version = "0.11.0" 674 677 source = "registry+https://github.com/rust-lang/crates.io-index" 675 678 checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" 676 - 677 - [[package]] 678 - name = "litemap" 679 - version = "0.8.1" 680 - source = "registry+https://github.com/rust-lang/crates.io-index" 681 - checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" 682 679 683 680 [[package]] 684 681 name = "log" ··· 731 728 checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" 732 729 733 730 [[package]] 734 - name = "num-modular" 735 - version = "0.6.1" 731 + name = "num-traits" 732 + version = "0.2.19" 736 733 source = "registry+https://github.com/rust-lang/crates.io-index" 737 - checksum = "17bb261bf36fa7d83f4c294f834e91256769097b3cb505d44831e0a179ac647f" 738 - 739 - [[package]] 740 - name = "num-order" 741 - version = "1.2.0" 742 - source = "registry+https://github.com/rust-lang/crates.io-index" 743 - checksum = "537b596b97c40fcf8056d153049eb22f481c17ebce72a513ec9286e4986d1bb6" 734 + checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 744 735 dependencies = [ 745 - "num-modular", 736 + "autocfg", 746 737 ] 747 738 748 739 [[package]] ··· 786 777 "anyhow", 787 778 "clap", 788 779 "comrak", 789 - "handlebars", 790 780 "maud", 791 781 "serde", 792 782 "serde_json", 793 - "url", 783 + "tera", 784 + ] 785 + 786 + [[package]] 787 + name = "parse-zoneinfo" 788 + version = "0.3.1" 789 + source = "registry+https://github.com/rust-lang/crates.io-index" 790 + checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24" 791 + dependencies = [ 792 + "regex", 794 793 ] 795 794 796 795 [[package]] ··· 844 843 845 844 [[package]] 846 845 name = "phf" 846 + version = "0.11.3" 847 + source = "registry+https://github.com/rust-lang/crates.io-index" 848 + checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" 849 + dependencies = [ 850 + "phf_shared 0.11.3", 851 + ] 852 + 853 + [[package]] 854 + name = "phf" 847 855 version = "0.13.1" 848 856 source = "registry+https://github.com/rust-lang/crates.io-index" 849 857 checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" 850 858 dependencies = [ 851 - "phf_shared", 859 + "phf_shared 0.13.1", 852 860 "serde", 853 861 ] 854 862 855 863 [[package]] 856 864 name = "phf_codegen" 865 + version = "0.11.3" 866 + source = "registry+https://github.com/rust-lang/crates.io-index" 867 + checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" 868 + dependencies = [ 869 + "phf_generator 0.11.3", 870 + "phf_shared 0.11.3", 871 + ] 872 + 873 + [[package]] 874 + name = "phf_codegen" 857 875 version = "0.13.1" 858 876 source = "registry+https://github.com/rust-lang/crates.io-index" 859 877 checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1" 860 878 dependencies = [ 861 - "phf_generator", 862 - "phf_shared", 879 + "phf_generator 0.13.1", 880 + "phf_shared 0.13.1", 881 + ] 882 + 883 + [[package]] 884 + name = "phf_generator" 885 + version = "0.11.3" 886 + source = "registry+https://github.com/rust-lang/crates.io-index" 887 + checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" 888 + dependencies = [ 889 + "phf_shared 0.11.3", 890 + "rand", 863 891 ] 864 892 865 893 [[package]] ··· 869 897 checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" 870 898 dependencies = [ 871 899 "fastrand", 872 - "phf_shared", 900 + "phf_shared 0.13.1", 901 + ] 902 + 903 + [[package]] 904 + name = "phf_shared" 905 + version = "0.11.3" 906 + source = "registry+https://github.com/rust-lang/crates.io-index" 907 + checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" 908 + dependencies = [ 909 + "siphasher", 873 910 ] 874 911 875 912 [[package]] ··· 901 938 ] 902 939 903 940 [[package]] 904 - name = "potential_utf" 905 - version = "0.1.4" 906 - source = "registry+https://github.com/rust-lang/crates.io-index" 907 - checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" 908 - dependencies = [ 909 - "zerovec", 910 - ] 911 - 912 - [[package]] 913 941 name = "powerfmt" 914 942 version = "0.2.0" 915 943 source = "registry+https://github.com/rust-lang/crates.io-index" 916 944 checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" 917 945 918 946 [[package]] 947 + name = "ppv-lite86" 948 + version = "0.2.21" 949 + source = "registry+https://github.com/rust-lang/crates.io-index" 950 + checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" 951 + dependencies = [ 952 + "zerocopy", 953 + ] 954 + 955 + [[package]] 919 956 name = "prettyplease" 920 957 version = "0.2.37" 921 958 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 965 1002 ] 966 1003 967 1004 [[package]] 1005 + name = "rand" 1006 + version = "0.8.5" 1007 + source = "registry+https://github.com/rust-lang/crates.io-index" 1008 + checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 1009 + dependencies = [ 1010 + "libc", 1011 + "rand_chacha", 1012 + "rand_core", 1013 + ] 1014 + 1015 + [[package]] 1016 + name = "rand_chacha" 1017 + version = "0.3.1" 1018 + source = "registry+https://github.com/rust-lang/crates.io-index" 1019 + checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 1020 + dependencies = [ 1021 + "ppv-lite86", 1022 + "rand_core", 1023 + ] 1024 + 1025 + [[package]] 1026 + name = "rand_core" 1027 + version = "0.6.4" 1028 + source = "registry+https://github.com/rust-lang/crates.io-index" 1029 + checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 1030 + dependencies = [ 1031 + "getrandom", 1032 + ] 1033 + 1034 + [[package]] 1035 + name = "regex" 1036 + version = "1.12.3" 1037 + source = "registry+https://github.com/rust-lang/crates.io-index" 1038 + checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" 1039 + dependencies = [ 1040 + "aho-corasick", 1041 + "memchr", 1042 + "regex-automata", 1043 + "regex-syntax", 1044 + ] 1045 + 1046 + [[package]] 968 1047 name = "regex-automata" 969 1048 version = "0.4.14" 970 1049 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1094 1173 checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" 1095 1174 1096 1175 [[package]] 1176 + name = "slug" 1177 + version = "0.1.6" 1178 + source = "registry+https://github.com/rust-lang/crates.io-index" 1179 + checksum = "882a80f72ee45de3cc9a5afeb2da0331d58df69e4e7d8eeb5d3c7784ae67e724" 1180 + dependencies = [ 1181 + "deunicode", 1182 + "wasm-bindgen", 1183 + ] 1184 + 1185 + [[package]] 1097 1186 name = "smallvec" 1098 1187 version = "1.15.1" 1099 1188 source = "registry+https://github.com/rust-lang/crates.io-index" 1100 1189 checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" 1101 1190 1102 1191 [[package]] 1103 - name = "stable_deref_trait" 1104 - version = "1.2.1" 1105 - source = "registry+https://github.com/rust-lang/crates.io-index" 1106 - checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" 1107 - 1108 - [[package]] 1109 1192 name = "strsim" 1110 1193 version = "0.11.1" 1111 1194 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1120 1203 "proc-macro2", 1121 1204 "quote", 1122 1205 "unicode-ident", 1123 - ] 1124 - 1125 - [[package]] 1126 - name = "synstructure" 1127 - version = "0.13.2" 1128 - source = "registry+https://github.com/rust-lang/crates.io-index" 1129 - checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" 1130 - dependencies = [ 1131 - "proc-macro2", 1132 - "quote", 1133 - "syn", 1134 1206 ] 1135 1207 1136 1208 [[package]] ··· 1156 1228 ] 1157 1229 1158 1230 [[package]] 1231 + name = "tera" 1232 + version = "1.20.1" 1233 + source = "registry+https://github.com/rust-lang/crates.io-index" 1234 + checksum = "e8004bca281f2d32df3bacd59bc67b312cb4c70cea46cbd79dbe8ac5ed206722" 1235 + dependencies = [ 1236 + "chrono", 1237 + "chrono-tz", 1238 + "globwalk", 1239 + "humansize", 1240 + "lazy_static", 1241 + "percent-encoding", 1242 + "pest", 1243 + "pest_derive", 1244 + "rand", 1245 + "regex", 1246 + "serde", 1247 + "serde_json", 1248 + "slug", 1249 + "unicode-segmentation", 1250 + ] 1251 + 1252 + [[package]] 1159 1253 name = "terminal_size" 1160 1254 version = "0.4.3" 1161 1255 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1217 1311 ] 1218 1312 1219 1313 [[package]] 1220 - name = "tinystr" 1221 - version = "0.8.2" 1222 - source = "registry+https://github.com/rust-lang/crates.io-index" 1223 - checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" 1224 - dependencies = [ 1225 - "displaydoc", 1226 - "zerovec", 1227 - ] 1228 - 1229 - [[package]] 1230 1314 name = "tinyvec" 1231 1315 version = "1.10.0" 1232 1316 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1275 1359 ] 1276 1360 1277 1361 [[package]] 1362 + name = "unicode-segmentation" 1363 + version = "1.12.0" 1364 + source = "registry+https://github.com/rust-lang/crates.io-index" 1365 + checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" 1366 + 1367 + [[package]] 1278 1368 name = "unicode_categories" 1279 1369 version = "0.1.1" 1280 1370 source = "registry+https://github.com/rust-lang/crates.io-index" 1281 1371 checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" 1282 1372 1283 1373 [[package]] 1284 - name = "url" 1285 - version = "2.5.8" 1286 - source = "registry+https://github.com/rust-lang/crates.io-index" 1287 - checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" 1288 - dependencies = [ 1289 - "form_urlencoded", 1290 - "idna", 1291 - "percent-encoding", 1292 - "serde", 1293 - ] 1294 - 1295 - [[package]] 1296 - name = "utf8_iter" 1297 - version = "1.0.4" 1298 - source = "registry+https://github.com/rust-lang/crates.io-index" 1299 - checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" 1300 - 1301 - [[package]] 1302 1374 name = "utf8parse" 1303 1375 version = "0.2.2" 1304 1376 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1321 1393 ] 1322 1394 1323 1395 [[package]] 1396 + name = "wasi" 1397 + version = "0.11.1+wasi-snapshot-preview1" 1398 + source = "registry+https://github.com/rust-lang/crates.io-index" 1399 + checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" 1400 + 1401 + [[package]] 1402 + name = "wasm-bindgen" 1403 + version = "0.2.108" 1404 + source = "registry+https://github.com/rust-lang/crates.io-index" 1405 + checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" 1406 + dependencies = [ 1407 + "cfg-if", 1408 + "once_cell", 1409 + "rustversion", 1410 + "wasm-bindgen-macro", 1411 + "wasm-bindgen-shared", 1412 + ] 1413 + 1414 + [[package]] 1415 + name = "wasm-bindgen-macro" 1416 + version = "0.2.108" 1417 + source = "registry+https://github.com/rust-lang/crates.io-index" 1418 + checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" 1419 + dependencies = [ 1420 + "quote", 1421 + "wasm-bindgen-macro-support", 1422 + ] 1423 + 1424 + [[package]] 1425 + name = "wasm-bindgen-macro-support" 1426 + version = "0.2.108" 1427 + source = "registry+https://github.com/rust-lang/crates.io-index" 1428 + checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" 1429 + dependencies = [ 1430 + "bumpalo", 1431 + "proc-macro2", 1432 + "quote", 1433 + "syn", 1434 + "wasm-bindgen-shared", 1435 + ] 1436 + 1437 + [[package]] 1438 + name = "wasm-bindgen-shared" 1439 + version = "0.2.108" 1440 + source = "registry+https://github.com/rust-lang/crates.io-index" 1441 + checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" 1442 + dependencies = [ 1443 + "unicode-ident", 1444 + ] 1445 + 1446 + [[package]] 1324 1447 name = "winapi-util" 1325 1448 version = "0.1.11" 1326 1449 source = "registry+https://github.com/rust-lang/crates.io-index" 1327 1450 checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" 1328 1451 dependencies = [ 1329 1452 "windows-sys 0.61.2", 1453 + ] 1454 + 1455 + [[package]] 1456 + name = "windows-core" 1457 + version = "0.62.2" 1458 + source = "registry+https://github.com/rust-lang/crates.io-index" 1459 + checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" 1460 + dependencies = [ 1461 + "windows-implement", 1462 + "windows-interface", 1463 + "windows-link", 1464 + "windows-result", 1465 + "windows-strings", 1466 + ] 1467 + 1468 + [[package]] 1469 + name = "windows-implement" 1470 + version = "0.60.2" 1471 + source = "registry+https://github.com/rust-lang/crates.io-index" 1472 + checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" 1473 + dependencies = [ 1474 + "proc-macro2", 1475 + "quote", 1476 + "syn", 1477 + ] 1478 + 1479 + [[package]] 1480 + name = "windows-interface" 1481 + version = "0.59.3" 1482 + source = "registry+https://github.com/rust-lang/crates.io-index" 1483 + checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" 1484 + dependencies = [ 1485 + "proc-macro2", 1486 + "quote", 1487 + "syn", 1330 1488 ] 1331 1489 1332 1490 [[package]] ··· 1336 1494 checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" 1337 1495 1338 1496 [[package]] 1497 + name = "windows-result" 1498 + version = "0.4.1" 1499 + source = "registry+https://github.com/rust-lang/crates.io-index" 1500 + checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" 1501 + dependencies = [ 1502 + "windows-link", 1503 + ] 1504 + 1505 + [[package]] 1506 + name = "windows-strings" 1507 + version = "0.5.1" 1508 + source = "registry+https://github.com/rust-lang/crates.io-index" 1509 + checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" 1510 + dependencies = [ 1511 + "windows-link", 1512 + ] 1513 + 1514 + [[package]] 1339 1515 name = "windows-sys" 1340 1516 version = "0.60.2" 1341 1517 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1419 1595 checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" 1420 1596 1421 1597 [[package]] 1422 - name = "writeable" 1423 - version = "0.6.2" 1424 - source = "registry+https://github.com/rust-lang/crates.io-index" 1425 - checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" 1426 - 1427 - [[package]] 1428 1598 name = "xdg" 1429 1599 version = "3.0.0" 1430 1600 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1440 1610 ] 1441 1611 1442 1612 [[package]] 1443 - name = "yoke" 1444 - version = "0.8.1" 1613 + name = "zerocopy" 1614 + version = "0.8.39" 1445 1615 source = "registry+https://github.com/rust-lang/crates.io-index" 1446 - checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" 1616 + checksum = "db6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4a" 1447 1617 dependencies = [ 1448 - "stable_deref_trait", 1449 - "yoke-derive", 1450 - "zerofrom", 1618 + "zerocopy-derive", 1451 1619 ] 1452 1620 1453 1621 [[package]] 1454 - name = "yoke-derive" 1455 - version = "0.8.1" 1622 + name = "zerocopy-derive" 1623 + version = "0.8.39" 1456 1624 source = "registry+https://github.com/rust-lang/crates.io-index" 1457 - checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" 1458 - dependencies = [ 1459 - "proc-macro2", 1460 - "quote", 1461 - "syn", 1462 - "synstructure", 1463 - ] 1464 - 1465 - [[package]] 1466 - name = "zerofrom" 1467 - version = "0.1.6" 1468 - source = "registry+https://github.com/rust-lang/crates.io-index" 1469 - checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" 1470 - dependencies = [ 1471 - "zerofrom-derive", 1472 - ] 1473 - 1474 - [[package]] 1475 - name = "zerofrom-derive" 1476 - version = "0.1.6" 1477 - source = "registry+https://github.com/rust-lang/crates.io-index" 1478 - checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" 1479 - dependencies = [ 1480 - "proc-macro2", 1481 - "quote", 1482 - "syn", 1483 - "synstructure", 1484 - ] 1485 - 1486 - [[package]] 1487 - name = "zerotrie" 1488 - version = "0.2.3" 1489 - source = "registry+https://github.com/rust-lang/crates.io-index" 1490 - checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" 1491 - dependencies = [ 1492 - "displaydoc", 1493 - "yoke", 1494 - "zerofrom", 1495 - ] 1496 - 1497 - [[package]] 1498 - name = "zerovec" 1499 - version = "0.11.5" 1500 - source = "registry+https://github.com/rust-lang/crates.io-index" 1501 - checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" 1502 - dependencies = [ 1503 - "yoke", 1504 - "zerofrom", 1505 - "zerovec-derive", 1506 - ] 1507 - 1508 - [[package]] 1509 - name = "zerovec-derive" 1510 - version = "0.11.2" 1511 - source = "registry+https://github.com/rust-lang/crates.io-index" 1512 - checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" 1625 + checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517" 1513 1626 dependencies = [ 1514 1627 "proc-macro2", 1515 1628 "quote",
+1 -2
Cargo.toml
··· 5 5 edition = "2024" 6 6 7 7 [dependencies] 8 - url = "2.5.8" 9 8 comrak = "0.50.0" 10 9 maud = "0.27.0" 11 10 serde = { version = "1.0.228", features = ["derive"] } 12 11 serde_json = "1.0.149" 13 12 anyhow = "1.0.101" 14 - handlebars = "6.4.0" 15 13 clap = { version = "4.5.57", features = ["derive"] } 14 + tera = "1.20.1"
-12
example/index.md
··· 1 - # Web page 2 - 3 - Hello World! 4 - 5 - [Repository](https://codeberg.org/IamPyu/pagegen) 6 - 7 - Rust code: 8 - ```rs 9 - fn main() { 10 - println!("Hello World"); 11 - } 12 - ```
+7 -9
example/pagegen.json
··· 1 1 { 2 - "title": "My Website", 3 - "css": "style.css", 4 - "pages": [ 5 - "index.md" 6 - ], 7 - "templates": [ 8 - { "name": "footer", "path": "footer.html" } 9 - ] 10 - } 2 + "title": "My Awesome Website", 3 + "static": "static", 4 + "templates": { 5 + "style": "style.css", 6 + "footer": "footer.html" 7 + } 8 + }
+5
example/static/HELLO.md
··· 1 + {{style}} 2 + # math 3 + $x+3^6$ 4 + 5 + <p>cool guys</p>
+21
example/static/index.html
··· 1 + <html> 2 + 3 + <head> 4 + <title>site</title> 5 + <style> 6 + /* {{style}}*/ 7 + </style> 8 + </head> 9 + 10 + <body> 11 + <p>hello</p> 12 + 13 + {{ footer }} 14 + 15 + cool 16 + {{ link(href="https://google.com", text="cool") }} 17 + </body> 18 + 19 + 20 + 21 + </html>
+1 -1
example/style.css
··· 23 23 font-size: 1.3em; 24 24 font-weight: 500; 25 25 color: var(--text); 26 - } 26 + }
+191
src/impl.rs
··· 1 + use anyhow::Result; 2 + use serde_json::Value; 3 + use std::{ 4 + collections::HashMap, 5 + env::current_dir, 6 + fs::{File, ReadDir, create_dir_all, read_dir, read_to_string, write}, 7 + io::ErrorKind, 8 + path::{Path, PathBuf}, 9 + sync::LazyLock, 10 + }; 11 + 12 + const PAGEGEN_FILE: &str = "pagegen.json"; 13 + 14 + #[derive(serde::Deserialize)] 15 + 16 + pub struct Config { 17 + /// Title of website 18 + pub title: String, 19 + 20 + /// Template variables 21 + #[serde(alias = "variables", default = "Default::default")] 22 + pub vars: HashMap<String, Value>, 23 + 24 + /// Non-content files to copy 25 + #[serde(alias = "templates", default = "Default::default")] 26 + pub templates: HashMap<String, PathBuf>, 27 + 28 + /// Director for static files with templating 29 + #[serde(rename = "static")] 30 + pub static_dir: PathBuf, 31 + } 32 + 33 + pub struct State { 34 + pub(crate) config: Config, 35 + #[allow(unused)] 36 + root: PathBuf, 37 + output_dir: PathBuf, 38 + } 39 + 40 + impl State { 41 + pub fn new<P: AsRef<Path>>(root: Option<PathBuf>, output: P) -> Result<Self> { 42 + let output = output.as_ref(); 43 + let root = root.unwrap_or(current_dir()?); 44 + 45 + let file = match File::open(root.join(PAGEGEN_FILE)) { 46 + Ok(f) => f, 47 + Err(e) => match e.kind() { 48 + ErrorKind::NotFound => anyhow::bail!("{PAGEGEN_FILE} not found"), 49 + ErrorKind::PermissionDenied => { 50 + anyhow::bail!("permission denied opening {PAGEGEN_FILE}") 51 + } 52 + _ => anyhow::bail!("{e}"), 53 + }, 54 + }; 55 + 56 + let mut config: Config = match serde_json::from_reader(&file) { 57 + Ok(c) => c, 58 + Err(e) => anyhow::bail!("Failed to load configuration file ({PAGEGEN_FILE}): {e}"), 59 + }; 60 + 61 + config 62 + .vars 63 + .insert("PAGE_TITLE".to_owned(), config.title.clone().into()); 64 + 65 + for (k, v) in &config.templates { 66 + let p = read_to_string(v)?; 67 + config.vars.insert(k.to_owned(), p.into()); 68 + } 69 + 70 + let state = State { 71 + config, 72 + root, 73 + output_dir: output.to_path_buf(), 74 + }; 75 + 76 + Ok(state) 77 + } 78 + 79 + pub fn apply(&self) -> Result<()> { 80 + let output = self.output_dir.as_path(); 81 + create_dir_all(&output)?; 82 + 83 + let static_dir_path = self.root.join(&self.config.static_dir); 84 + let static_dir = match read_dir(&static_dir_path) { 85 + Ok(r) => r, 86 + Err(e) => match e.kind() { 87 + ErrorKind::NotFound => { 88 + anyhow::bail!("page directory `{}` not found", static_dir_path.display()) 89 + } 90 + _ => anyhow::bail!("{e}"), 91 + }, 92 + }; 93 + 94 + let mut engine = tera::Tera::default(); 95 + impl_tera(&mut engine)?; 96 + 97 + let ctx = tera::Context::from_serialize(&self.config.vars)?; 98 + self.recurse(static_dir, &mut engine, &ctx)?; 99 + 100 + Ok(()) 101 + } 102 + 103 + pub const MARKDOWN_OPTIONS: LazyLock<comrak::Options<'static>> = 104 + LazyLock::new(|| comrak::Options { 105 + render: comrak::options::Render { 106 + r#unsafe: true, 107 + ..Default::default() 108 + }, 109 + extension: comrak::options::Extension { 110 + math_code: true, 111 + math_dollars: true, 112 + ..Default::default() 113 + }, 114 + ..Default::default() 115 + }); 116 + 117 + pub fn recurse( 118 + &self, 119 + dir: ReadDir, 120 + engine: &mut tera::Tera, 121 + ctx: &tera::Context, 122 + ) -> Result<()> { 123 + let output = self.output_dir.as_path(); 124 + let static_dir_path = self.root.join(&self.config.static_dir); 125 + 126 + for entry in dir { 127 + let entry = entry?; 128 + 129 + let ft = entry.file_type()?; 130 + 131 + if ft.is_file() { 132 + let out = output.join(&entry.path().strip_prefix(&static_dir_path)?); 133 + if let Some(p) = out.parent() { 134 + create_dir_all(&p)?; 135 + } 136 + 137 + let template = read_to_string(entry.path())?; 138 + let rendered = engine.render_str(&template, &ctx)?; 139 + 140 + match out.extension().map(|s| s.as_encoded_bytes()) { 141 + Some(b"md") | Some(b"markdown") => { 142 + let rendered = comrak::markdown_to_html(&rendered, &Self::MARKDOWN_OPTIONS); 143 + 144 + let html = maud::html! { 145 + (maud::DOCTYPE) 146 + head { 147 + title {( self.config.title )}; 148 + meta charset="utf-8"; 149 + } 150 + (maud::PreEscaped(rendered)) 151 + }; 152 + 153 + write(out.with_extension("html"), html.into_string())?; 154 + } 155 + Some(b"html") => { 156 + let html = maud::html! { 157 + (maud::DOCTYPE) 158 + (maud::PreEscaped(rendered)) 159 + }; 160 + 161 + write(out, html.into_string())?; 162 + } 163 + _ => write(out, rendered)?, 164 + }; 165 + } else if ft.is_dir() { 166 + self.recurse(read_dir(entry.path())?, engine, ctx)?; 167 + } 168 + } 169 + 170 + Ok(()) 171 + } 172 + } 173 + 174 + pub fn impl_tera(tera: &mut tera::Tera) -> Result<()> { 175 + type Args = HashMap<String, Value>; 176 + use tera::Error; 177 + 178 + // TOOD: fix quotes 179 + tera.register_function("link", |args: &Args| { 180 + let href = args.get("href").ok_or(Error::msg("expected `href` argument"))?.to_string(); 181 + let text = args.get("text").ok_or(Error::msg("expected `text` argument"))?.to_string(); 182 + 183 + let t = maud::html! { 184 + a herf=(maud::PreEscaped(href)) {(maud::PreEscaped(text))} 185 + }; 186 + 187 + Ok(t.0.into()) 188 + }); 189 + 190 + Ok(()) 191 + }
-182
src/lib.rs
··· 1 - use anyhow::Result; 2 - use serde_json::Value; 3 - use std::{ 4 - env::current_dir, 5 - fs::{File, canonicalize, copy, create_dir_all, read_to_string, write}, 6 - io::ErrorKind, 7 - path::{Path, PathBuf}, 8 - }; 9 - 10 - const PAGEGEN_FILE: &str = "pagegen.json"; 11 - 12 - #[derive(serde::Deserialize)] 13 - pub struct Template { 14 - pub name: String, 15 - pub path: PathBuf, 16 - } 17 - 18 - #[derive(serde::Deserialize)] 19 - #[serde(default)] 20 - pub struct Config { 21 - /// Page title 22 - pub title: String, 23 - 24 - /// Optional path to CSS file 25 - pub css: Option<PathBuf>, 26 - 27 - /// Template variables 28 - #[serde(alias = "variables")] 29 - pub vars: serde_json::Map<String, Value>, 30 - 31 - /// Path to pages, can be either HTML or Markdown 32 - pub pages: Vec<PathBuf>, 33 - 34 - /// Non-content files to copy 35 - pub files: Vec<PathBuf>, 36 - 37 - /// Files to include as string templates 38 - pub templates: Vec<Template>, 39 - } 40 - 41 - impl Config {} 42 - 43 - impl Default for Config { 44 - fn default() -> Self { 45 - Self { 46 - title: "Unnamed site".to_owned(), 47 - css: None, 48 - vars: serde_json::Map::new(), 49 - pages: Vec::new(), 50 - files: Vec::new(), 51 - templates: Vec::new(), 52 - } 53 - } 54 - } 55 - 56 - pub struct StatePage { 57 - pub path: PathBuf, 58 - pub template: String, 59 - } 60 - 61 - pub struct State { 62 - config: Config, 63 - #[allow(unused)] 64 - root: PathBuf, 65 - pages: Vec<StatePage>, 66 - output_dir: PathBuf, 67 - } 68 - 69 - impl State { 70 - pub fn new<P: AsRef<Path>>(root: Option<PathBuf>, output: P) -> Result<Self> { 71 - let output = output.as_ref(); 72 - let root = root.unwrap_or(current_dir()?); 73 - 74 - let file = match File::open(root.join(PAGEGEN_FILE)) { 75 - Ok(f) => f, 76 - Err(e) => match e.kind() { 77 - ErrorKind::NotFound => anyhow::bail!("{PAGEGEN_FILE} not found"), 78 - ErrorKind::PermissionDenied => { 79 - anyhow::bail!("permission denied opening {PAGEGEN_FILE}") 80 - } 81 - _ => anyhow::bail!("{e}"), 82 - }, 83 - }; 84 - 85 - let mut config: Config = serde_json::from_reader(&file).unwrap_or_default(); 86 - 87 - let pages = config 88 - .pages 89 - .iter() 90 - .filter(|x| { 91 - let b = x.join(&root).starts_with(&root); 92 - if !b { 93 - eprintln!("page at `{}` is not in root directory", x.display()); 94 - } 95 - b 96 - }) 97 - .filter_map(|x| { 98 - let path = root.join(&x); 99 - let template = read_to_string(&path).ok()?; 100 - let path = path.strip_prefix(&root).map(Path::to_path_buf).ok()?; 101 - 102 - let page = StatePage { path, template }; 103 - Some(page) 104 - }) 105 - .collect::<Vec<_>>(); 106 - 107 - for Template {name, path} in &config.templates { 108 - let fp = root.join(&path); 109 - if !fp.exists() { 110 - continue; 111 - } 112 - 113 - config.vars.insert(name.to_owned(), serde_json::json!(read_to_string(&fp)?)); 114 - } 115 - 116 - let state = State { 117 - config, 118 - root, 119 - output_dir: output.to_path_buf(), 120 - pages, 121 - }; 122 - 123 - Ok(state) 124 - } 125 - 126 - pub fn apply(&self) -> Result<()> { 127 - let output = self.output_dir.as_path(); 128 - let config = &self.config; 129 - let engine = handlebars::Handlebars::new(); 130 - let ctx = handlebars::Context::wraps(&config.vars)?; 131 - let css_path = output.join("style.css"); 132 - create_dir_all(&output)?; 133 - 134 - if let Some(css) = &config.css { 135 - let css = read_to_string(&css)?; 136 - let out = engine.render_template_with_context(&css, &ctx)?; 137 - 138 - write(&css_path, out)?; 139 - } 140 - 141 - for page in &self.pages { 142 - let mut rendered = engine.render_template_with_context(&page.template, &ctx)?; 143 - let mut out = output.join(&page.path); 144 - if let Some(p) = out.parent() { 145 - create_dir_all(&p)?; 146 - } 147 - 148 - let is_markdown = page.path.extension().is_some_and(|c| c == "md"); 149 - 150 - 151 - if is_markdown { 152 - out.set_extension("html"); 153 - rendered = comrak::markdown_to_html(&rendered, &comrak::Options::default()); 154 - } 155 - 156 - let css: maud::Markup = maud::html! { 157 - link rel="stylesheet" type="text/css" href=(css_path.strip_prefix(&output)?.display()); 158 - }; 159 - 160 - let html: maud::Markup = maud::html! { 161 - (maud::DOCTYPE); 162 - head { 163 - title {(config.title)}; 164 - meta charset="utf-8"; 165 - (css); 166 - }; 167 - (maud::PreEscaped(rendered)); 168 - }; 169 - 170 - write(&out, html.into_string())?; 171 - } 172 - 173 - for file in &config.files { 174 - let fp = canonicalize(&file)?; 175 - if fp.starts_with(&self.root) { 176 - copy(&fp, output.join(&file))?; 177 - } 178 - } 179 - 180 - Ok(()) 181 - } 182 - }
+11 -2
src/main.rs
··· 1 + use anyhow::Result; 1 2 use clap::{Parser, Subcommand}; 2 - use pagegen::State; 3 + 4 + mod r#impl; 5 + use r#impl::State; 3 6 4 7 fn p() -> String { 5 8 "site".to_owned() ··· 18 21 enum Action { 19 22 #[command(about = "Generate the static site")] 20 23 Gen, 24 + #[command(about = "Dump template variables")] 25 + Dump, 21 26 } 22 27 23 - fn main() -> anyhow::Result<()> { 28 + fn main() -> Result<()> { 24 29 let args = Cmd::parse(); 25 30 let state = State::new(None, args.output)?; 26 31 27 32 match args.action { 28 33 Action::Gen => { 29 34 state.apply()?; 35 + } 36 + Action::Dump => { 37 + let json = serde_json::to_string_pretty(&state.config.vars)?; 38 + println!("{json}"); 30 39 } 31 40 } 32 41