diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c428ee..ae72273a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.14.1 (2021-08-24) + +- HTML minification now respects HTML spec (it still worked before because browsers can handle invalid HTML well and minifiers take advantage of it) +- Show all errors on `zola serve` +- `zola serve` now properly returns a 404 +- Fix `zola serve` having issues with config files in separate dir +- Fix code blocks content not being escaped when not using syntax highlighting +- Add missing `draft` attribute to the `section` variable in templates + ## 0.14.0 (2021-07-19) ### Breaking diff --git a/Cargo.lock b/Cargo.lock index 17496d28..30af561f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" @@ -190,9 +190,9 @@ checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e" [[package]] name = "bytemuck" -version = "1.7.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9966d2ab714d0f785dbac0a0396251a35280aeb42413281617d0209ab4898435" +checksum = "72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b" [[package]] name = "byteorder" @@ -318,6 +318,22 @@ dependencies = [ "utils", ] +[[package]] +name = "core-foundation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" + [[package]] name = "cpufeatures" version = "0.1.5" @@ -348,9 +364,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", @@ -404,9 +420,9 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.1.9" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "232295399409a8b7ae41276757b5a1cc21032848d42bff2352261f958b3ca29a" +checksum = "377c9b002a72a0b2c1a18c62e2f3864bdfea4a015e3683a96e24aa45dd6c02d1" dependencies = [ "nix", "winapi 0.3.9", @@ -579,9 +595,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "filetime" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" +checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98" dependencies = [ "cfg-if 1.0.0", "libc", @@ -607,6 +623,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.0.1" @@ -681,30 +712,30 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2" +checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" +checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" [[package]] name = "futures-io" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1" +checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" [[package]] name = "futures-macro" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121" +checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57" dependencies = [ "autocfg", "proc-macro-hack", @@ -715,21 +746,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282" +checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" [[package]] name = "futures-task" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae" +checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" [[package]] name = "futures-util" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" +checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" dependencies = [ "autocfg", "futures-core", @@ -787,11 +818,11 @@ dependencies = [ [[package]] name = "gh-emoji" -version = "1.0.3" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17a050b7eb420553344e1cf1db648e8b584c79e98b74e6e6d119eeedd9ddcbc" +checksum = "d6af39cf9a679d7195b3370f5454381ba49c4791bc7ce3ae2a7bf1a2a89c7adf" dependencies = [ - "phf", + "phf 0.10.0", "regex", ] @@ -837,9 +868,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" +checksum = "d7f3675cfef6a30c8031cf9e6493ebdc3bb3272a3fea3923c4210d1830e6a472" dependencies = [ "bytes 1.0.1", "fnv", @@ -915,9 +946,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" +checksum = "399c583b2979440c60be0821a6199eca73bc3c8dcd9d070d75ac726e2c6186e5" dependencies = [ "bytes 1.0.1", "http", @@ -926,9 +957,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" +checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" [[package]] name = "httpdate" @@ -944,9 +975,9 @@ checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" [[package]] name = "hyper" -version = "0.14.10" +version = "0.14.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7728a72c4c7d72665fde02204bcbd93b247721025b222ef78606f14513e0fd03" +checksum = "0b61cf2d1aebcf6e6352c97b81dc2244ca29194be1b276f5d8ad5c6330fffb11" dependencies = [ "bytes 1.0.1", "futures-channel", @@ -981,6 +1012,19 @@ dependencies = [ "webpki", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes 1.0.1", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "idna" version = "0.2.3" @@ -1095,9 +1139,9 @@ checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "jieba-rs" @@ -1108,16 +1152,16 @@ dependencies = [ "cedarwood", "hashbrown 0.8.2", "lazy_static", - "phf", + "phf 0.8.0", "phf_codegen", "regex", ] [[package]] name = "jobserver" -version = "0.1.22" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" dependencies = [ "libc", ] @@ -1133,9 +1177,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.51" +version = "0.3.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" +checksum = "e4bf49d50e2961077d9c99f4b7997d770a1114f087c3c2e0069b36c13fc2979d" dependencies = [ "wasm-bindgen", ] @@ -1192,9 +1236,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.98" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "a1fa8cddc8fbbee11227ef194b5317ed014b8acbf15139bd716a18ad3fe99ec5" [[package]] name = "library" @@ -1346,7 +1390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" dependencies = [ "log", - "phf", + "phf 0.8.0", "phf_codegen", "string_cache", "string_cache_codegen", @@ -1367,15 +1411,15 @@ dependencies = [ [[package]] name = "matches" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "memchr" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" @@ -1404,9 +1448,9 @@ dependencies = [ [[package]] name = "minify-html" -version = "0.4.11" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee59033f9253bab9ec605e58b6a9f9ac22548346cbc88927194a7f56527b541b" +checksum = "af97b0ff1a328e6877ad03266f51d0ee9d8b8b31aa05da6566dc1ca4ed921f0f" dependencies = [ "aho-corasick", "lazy_static", @@ -1515,6 +1559,24 @@ dependencies = [ "serde_urlencoded", ] +[[package]] +name = "native-tls" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "net2" version = "0.2.37" @@ -1534,14 +1596,15 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] name = "nix" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a" +checksum = "cf1e25ee6b412c2a1e3fcb6a4499a5c1bfe7f43e014bdce9a6b6666e5aa2d187" dependencies = [ "bitflags", "cc", "cfg-if 1.0.0", "libc", + "memoffset", ] [[package]] @@ -1747,14 +1810,47 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "open" -version = "1.7.1" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcea7a30d6b81a2423cc59c43554880feff7b57d12916f231a79f8d6d9470201" +checksum = "b46b233de7d83bc167fe43ae2dda3b5b84e80e09cceba581e4decb958a4896bf" dependencies = [ "pathdiff", "winapi 0.3.9", ] +[[package]] +name = "openssl" +version = "0.10.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" + +[[package]] +name = "openssl-sys" +version = "0.9.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1996d2d305e561b70d1ee0c53f1542833f4e1ac6ce9a6708b6ff2738ca67dc82" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "parse-zoneinfo" version = "0.3.0" @@ -1831,7 +1927,16 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" dependencies = [ - "phf_shared", + "phf_shared 0.8.0", +] + +[[package]] +name = "phf" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9fc3db1018c4b59d7d582a739436478b6035138b6aecbce989fc91c3e98409f" +dependencies = [ + "phf_shared 0.10.0", ] [[package]] @@ -1841,7 +1946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" dependencies = [ "phf_generator", - "phf_shared", + "phf_shared 0.8.0", ] [[package]] @@ -1850,7 +1955,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ - "phf_shared", + "phf_shared 0.8.0", "rand 0.7.3", ] @@ -1863,6 +1968,15 @@ dependencies = [ "siphasher", ] +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project-lite" version = "0.2.7" @@ -1883,9 +1997,9 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "plist" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "679104537029ed2287c216bfb942bbf723f48ee98f0aef15611634173a74ef21" +checksum = "a38d026d73eeaf2ade76309d0c65db5a35ecf649e3cec428db316243ea9d6711" dependencies = [ "base64", "chrono", @@ -1933,9 +2047,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" dependencies = [ "unicode-xid", ] @@ -2084,9 +2198,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ "bitflags", ] @@ -2122,9 +2236,9 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "relative-path" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a479d53d7eed831f3c92ca79c61002d5987e21417d528296832f802bca532380" +checksum = "f9629de8974fd69c97684736786b807edd3da456d3e3f95341dd9d4cbd8f5ad6" [[package]] name = "remove_dir_all" @@ -2172,17 +2286,20 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", + "hyper-tls", "ipnet", "js-sys", "lazy_static", "log", "mime", + "native-tls", "percent-encoding", "pin-project-lite", "rustls", "serde", "serde_urlencoded", "tokio", + "tokio-native-tls", "tokio-rustls", "url", "wasm-bindgen", @@ -2282,6 +2399,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi 0.3.9", +] + [[package]] name = "scoped_threadpool" version = "0.1.9" @@ -2317,19 +2444,42 @@ dependencies = [ ] [[package]] -name = "serde" -version = "1.0.126" +name = "security-framework" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e4effb91b4b8b6fb7732e670b6cee160278ff8e6bf485c7805d9e319d76e284" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1f72836d2aa753853178eda473a3b9d8e4eefdaf20523b919677e6de489f8f1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "e57ae87ad533d9a56427558b516d0adac283614e347abf85b0dc0cbbf0a249f3" dependencies = [ "proc-macro2", "quote", @@ -2338,9 +2488,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" dependencies = [ "indexmap", "itoa", @@ -2362,12 +2512,12 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23" +checksum = "6375dbd828ed6964c3748e4ef6d18e7a175d408ffe184bca01698d0c73f915a9" dependencies = [ "dtoa", - "linked-hash-map", + "indexmap", "serde", "yaml-rust", ] @@ -2399,9 +2549,9 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbce6d4507c7e4a3962091436e56e95290cb71fa302d0d270e32130b75fbff27" +checksum = "729a25c17d72b06c68cb47955d44fda88ad2d3e7d77e025663fdd69b93dd71a1" [[package]] name = "site" @@ -2433,9 +2583,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" +checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" [[package]] name = "slotmap" @@ -2463,9 +2613,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad" dependencies = [ "libc", "winapi 0.3.9", @@ -2491,7 +2641,7 @@ checksum = "8ddb1139b5353f96e429e1a5e19fbaf663bddedaa06d1dbd49f82e352601209a" dependencies = [ "lazy_static", "new_debug_unreachable", - "phf_shared", + "phf_shared 0.8.0", "precomputed-hash", "serde", ] @@ -2503,7 +2653,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f24c8e5e19d22a726626f1a5e16fe15b132dcf21d10177fa5a45ce7962996b97" dependencies = [ "phf_generator", - "phf_shared", + "phf_shared 0.8.0", "proc-macro2", "quote", ] @@ -2546,9 +2696,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.73" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" +checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7" dependencies = [ "proc-macro2", "quote", @@ -2557,8 +2707,9 @@ dependencies = [ [[package]] name = "syntect" -version = "5.0.0" -source = "git+https://github.com/Keats/syntect.git?branch=scopestack#6b36f5eb406d57e57ddb6eb51df3a5e36e52c955" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b20815bbe80ee0be06e6957450a841185fcf690fe0178f14d77a05ce2caa031" dependencies = [ "bincode", "bitflags", @@ -2719,9 +2870,9 @@ checksum = "29738eedb4388d9ea620eeab9384884fc3f06f586a2eddb56bedc5885126c7c1" [[package]] name = "tinyvec" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" +checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338" dependencies = [ "tinyvec_macros", ] @@ -2734,9 +2885,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c8b05dc14c75ea83d63dd391100353789f5f24b8b3866542a5e85c8be8e985" +checksum = "01cf844b23c6131f624accf65ce0e4e9956a8bb329400ea5bcc26ae3a5c20b0b" dependencies = [ "autocfg", "bytes 1.0.1", @@ -2748,6 +2899,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.22.0" @@ -2801,9 +2962,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +checksum = "2ca517f43f0fb96e0c3072ed5c275fe5eece87e8cb52f4a77b69226d3b1c9df8" dependencies = [ "lazy_static", ] @@ -2905,12 +3066,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" -dependencies = [ - "matches", -] +checksum = "246f4c42e67e7a4e3c6106ff716a5d067d4132a642840b242e357e468a2a0085" [[package]] name = "unicode-normalization" @@ -2986,6 +3144,12 @@ dependencies = [ "walkdir", ] +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "vec_map" version = "0.8.2" @@ -3033,9 +3197,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.74" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" +checksum = "8ce9b1b516211d33767048e5d47fa2a381ed8b76fc48d2ce4aa39877f9f183e0" dependencies = [ "cfg-if 1.0.0", "serde", @@ -3045,9 +3209,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.74" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" +checksum = "cfe8dc78e2326ba5f845f4b5bf548401604fa20b1dd1d365fb73b6c1d6364041" dependencies = [ "bumpalo", "lazy_static", @@ -3060,9 +3224,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.24" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fba7978c679d53ce2d0ac80c8c175840feb849a161664365d1287b41f2e67f1" +checksum = "95fded345a6559c2cfee778d562300c581f7d4ff3edb9b0d230d69800d213972" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3072,9 +3236,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.74" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" +checksum = "44468aa53335841d9d6b6c023eaab07c0cd4bddbcfdee3e2bb1e8d2cb8069fef" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3082,9 +3246,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.74" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" +checksum = "0195807922713af1e67dc66132c7328206ed9766af3858164fb583eedc25fbad" dependencies = [ "proc-macro2", "quote", @@ -3095,15 +3259,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.74" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" +checksum = "acdb075a845574a1fa5f09fd77e43f7747599301ea3417a9fbffdeedfc1f4a29" [[package]] name = "web-sys" -version = "0.3.51" +version = "0.3.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" +checksum = "224b2f6b67919060055ef1a67807367c2066ed520c3862cc013d26cf893a783c" dependencies = [ "js-sys", "wasm-bindgen", @@ -3226,9 +3390,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" +checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" [[package]] name = "xml5ever" @@ -3259,7 +3423,7 @@ dependencies = [ [[package]] name = "zola" -version = "0.14.0" +version = "0.14.1" dependencies = [ "atty", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 068948ff..33837707 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zola" -version = "0.14.0" +version = "0.14.1" authors = ["Vincent Prouillet "] edition = "2018" license = "MIT" @@ -33,7 +33,7 @@ percent-encoding = "2" notify = "4" ws = "0.9" ctrlc = "3" -open = "1.2" +open = "2" globset = "0.4" relative-path = "1" serde_json = "1.0" @@ -49,6 +49,11 @@ search = { path = "components/search" } [dev-dependencies] same-file = "1" +[features] +default = ["rust-tls"] +rust-tls = ["site/rust-tls"] +native-tls = ["site/native-tls"] + [workspace] members = [ "components/config", diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9c61e0d1..87e7dec3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -36,8 +36,10 @@ stages: echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin" displayName: Windows install rust condition: eq( variables['Agent.OS'], 'Windows_NT' ) + - script: cargo build --all --no-default-features --features=native-tls && cargo clean + displayName: Cargo build (Native TLS) - script: cargo build --all - displayName: Cargo build + displayName: Cargo build (Rust TLS) - script: cargo test --all displayName: Cargo test diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index d55ef73f..dbf08912 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -12,8 +12,7 @@ serde_derive = "1" chrono = "0.4" globset = "0.4" lazy_static = "1" -# TODO: go back to version 4/5 once https://github.com/trishume/syntect/pull/337 is merged -syntect = { git = "https://github.com/Keats/syntect.git", branch = "scopestack" } +syntect = "4" unic-langid = "0.9" errors = { path = "../errors" } diff --git a/components/config/examples/generate_sublime.rs b/components/config/examples/generate_sublime.rs index fb859349..a1946a15 100644 --- a/components/config/examples/generate_sublime.rs +++ b/components/config/examples/generate_sublime.rs @@ -38,7 +38,7 @@ fn main() { }; // and then the ones we add - let mut extra = base_path.clone(); + let mut extra = base_path; extra.push("extra"); match builder.add_from_folder(&extra, true) { Ok(_) => (), @@ -60,7 +60,7 @@ fn main() { .or_insert_with(|| HashSet::from_iter(s.file_extensions.iter().cloned())); } let mut keys = syntaxes.keys().collect::>(); - keys.sort_by(|a, b| a.to_lowercase().cmp(&b.to_lowercase())); + keys.sort_by_key(|&a| a.to_lowercase()); for k in keys { if !syntaxes[k].is_empty() { let mut extensions_sorted = syntaxes[k].iter().cloned().collect::>(); diff --git a/components/config/src/config/mod.rs b/components/config/src/config/mod.rs index 19faa036..cc6b858c 100644 --- a/components/config/src/config/mod.rs +++ b/components/config/src/config/mod.rs @@ -117,18 +117,18 @@ impl Config { bail!("A base URL is required in config.toml with key `base_url`"); } - if config.markdown.highlight_theme != "css" { - if !THEME_SET.themes.contains_key(&config.markdown.highlight_theme) { - bail!( - "Highlight theme {} defined in config does not exist.", - config.markdown.highlight_theme - ); - } + if config.markdown.highlight_theme != "css" + && !THEME_SET.themes.contains_key(&config.markdown.highlight_theme) + { + bail!( + "Highlight theme {} defined in config does not exist.", + config.markdown.highlight_theme + ); } languages::validate_code(&config.default_language)?; for code in config.languages.keys() { - languages::validate_code(&code)?; + languages::validate_code(code)?; } config.add_default_language(); @@ -229,8 +229,8 @@ impl Config { /// Parse the theme.toml file and merges the extra data from the theme /// with the config extra data - pub fn merge_with_theme(&mut self, path: &PathBuf, theme_name: &str) -> Result<()> { - let theme = Theme::from_file(path, theme_name)?; + pub fn merge_with_theme(&mut self, path: PathBuf, theme_name: &str) -> Result<()> { + let theme = Theme::from_file(&path, theme_name)?; self.add_theme_extra(&theme) } @@ -414,44 +414,38 @@ hello = "world" #[test] fn can_make_url_index_page_with_non_trailing_slash_url() { - let mut config = Config::default(); - config.base_url = "http://vincent.is".to_string(); + let config = Config { base_url: "http://vincent.is".to_string(), ..Default::default() }; assert_eq!(config.make_permalink(""), "http://vincent.is/"); } #[test] fn can_make_url_index_page_with_railing_slash_url() { - let mut config = Config::default(); - config.base_url = "http://vincent.is/".to_string(); + let config = Config { base_url: "http://vincent.is".to_string(), ..Default::default() }; assert_eq!(config.make_permalink(""), "http://vincent.is/"); } #[test] fn can_make_url_with_non_trailing_slash_base_url() { - let mut config = Config::default(); - config.base_url = "http://vincent.is".to_string(); + let config = Config { base_url: "http://vincent.is".to_string(), ..Default::default() }; assert_eq!(config.make_permalink("hello"), "http://vincent.is/hello/"); } #[test] fn can_make_url_with_trailing_slash_path() { - let mut config = Config::default(); - config.base_url = "http://vincent.is/".to_string(); + let config = Config { base_url: "http://vincent.is".to_string(), ..Default::default() }; assert_eq!(config.make_permalink("/hello"), "http://vincent.is/hello/"); } #[test] fn can_make_url_with_localhost() { - let mut config = Config::default(); - config.base_url = "http://127.0.0.1:1111".to_string(); + let config = Config { base_url: "http://127.0.0.1:1111".to_string(), ..Default::default() }; assert_eq!(config.make_permalink("/tags/rust"), "http://127.0.0.1:1111/tags/rust/"); } // https://github.com/Keats/gutenberg/issues/486 #[test] fn doesnt_add_trailing_slash_to_feed() { - let mut config = Config::default(); - config.base_url = "http://vincent.is/".to_string(); + let config = Config { base_url: "http://vincent.is".to_string(), ..Default::default() }; assert_eq!(config.make_permalink("atom.xml"), "http://vincent.is/atom.xml"); } @@ -656,7 +650,7 @@ bar = "baz" "#; let theme = Theme::parse(theme_str).unwrap(); // We expect an error here - assert_eq!(false, config.add_theme_extra(&theme).is_ok()); + assert!(!config.add_theme_extra(&theme).is_ok()); } #[test] diff --git a/components/config/src/theme.rs b/components/config/src/theme.rs index 5022319b..7daa2486 100644 --- a/components/config/src/theme.rs +++ b/components/config/src/theme.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; -use std::path::PathBuf; +use std::path::Path; use serde_derive::{Deserialize, Serialize}; use toml::Value as Toml; @@ -39,7 +39,7 @@ impl Theme { } /// Parses a theme file from the given path - pub fn from_file(path: &PathBuf, theme_name: &str) -> Result { + pub fn from_file(path: &Path, theme_name: &str) -> Result { let content = read_file(path) .map_err(|e| errors::Error::chain(format!("Failed to load theme {}", theme_name), e))?; Theme::parse(&content) diff --git a/components/errors/Cargo.toml b/components/errors/Cargo.toml index 2786bd0a..48f746a7 100644 --- a/components/errors/Cargo.toml +++ b/components/errors/Cargo.toml @@ -8,5 +8,4 @@ edition = "2018" tera = "1" toml = "0.5" image = "0.23" -# TODO: go back to version 4/5 once https://github.com/trishume/syntect/pull/337 is merged -syntect = { git = "https://github.com/Keats/syntect.git", branch = "scopestack" } +syntect = "4" diff --git a/components/front_matter/src/page.rs b/components/front_matter/src/page.rs index d331521b..7d2b7351 100644 --- a/components/front_matter/src/page.rs +++ b/components/front_matter/src/page.rs @@ -81,7 +81,7 @@ impl PageFrontMatter { let mut f: PageFrontMatter = raw.deserialize()?; if let Some(ref slug) = f.slug { - if slug == "" { + if slug.is_empty() { bail!("`slug` can't be empty if present") } } diff --git a/components/imageproc/src/lib.rs b/components/imageproc/src/lib.rs index fedd98ac..e54e5424 100644 --- a/components/imageproc/src/lib.rs +++ b/components/imageproc/src/lib.rs @@ -140,7 +140,7 @@ impl ResizeOp { } Fit(w, h) => { if orig_w <= w && orig_h <= h { - return res; // ie. no-op + return res; // ie. no-op } let orig_w_h = orig_w as u64 * h as u64; @@ -338,7 +338,7 @@ impl ImageOp { Some(q) => encoder.encode(q as f32), None => encoder.encode_lossless(), }; - f.write_all(&memory.as_bytes())?; + f.write_all(memory.as_bytes())?; } } @@ -408,6 +408,7 @@ impl Processor { self.img_ops.len() + self.img_ops_collisions.len() } + #[allow(clippy::too_many_arguments)] pub fn enqueue( &mut self, input_src: String, diff --git a/components/imageproc/tests/resize_image.rs b/components/imageproc/tests/resize_image.rs index 7fbfe21f..e4e376b9 100644 --- a/components/imageproc/tests/resize_image.rs +++ b/components/imageproc/tests/resize_image.rs @@ -30,6 +30,7 @@ lazy_static! { static ref PROCESSED_PREFIX: String = format!("static{0}processed_images{0}", SLASH); } +#[allow(clippy::too_many_arguments)] fn image_op_test( source_img: &str, op: &str, @@ -44,7 +45,7 @@ fn image_op_test( ) { let source_path = TEST_IMGS.join(source_img); - let config = Config::parse(&CONFIG).unwrap(); + let config = Config::parse(CONFIG).unwrap(); let mut proc = Processor::new(TMPDIR.clone(), &config); let resp = diff --git a/components/library/src/content/file_info.rs b/components/library/src/content/file_info.rs index 2260e7f7..606d1d46 100644 --- a/components/library/src/content/file_info.rs +++ b/components/library/src/content/file_info.rs @@ -52,7 +52,7 @@ pub struct FileInfo { } impl FileInfo { - pub fn new_page(path: &Path, base_path: &PathBuf) -> FileInfo { + pub fn new_page(path: &Path, base_path: &Path) -> FileInfo { let file_path = path.to_path_buf(); let mut parent = file_path.parent().expect("Get parent of page").to_path_buf(); let name = path.file_stem().unwrap().to_string_lossy().to_string(); @@ -87,7 +87,7 @@ impl FileInfo { } } - pub fn new_section(path: &Path, base_path: &PathBuf) -> FileInfo { + pub fn new_section(path: &Path, base_path: &Path) -> FileInfo { let file_path = path.to_path_buf(); let parent = path.parent().expect("Get parent of section").to_path_buf(); let name = path.file_stem().unwrap().to_string_lossy().to_string(); @@ -166,7 +166,7 @@ mod tests { #[test] fn can_find_components_in_page_with_assets() { let file = FileInfo::new_page( - &Path::new("/home/vincent/code/site/content/posts/tutorials/python/index.md"), + Path::new("/home/vincent/code/site/content/posts/tutorials/python/index.md"), &PathBuf::new(), ); assert_eq!(file.components, ["posts".to_string(), "tutorials".to_string()]); @@ -175,7 +175,7 @@ mod tests { #[test] fn doesnt_fail_with_multiple_content_directories_in_path() { let file = FileInfo::new_page( - &Path::new("/home/vincent/code/content/site/content/posts/tutorials/python/index.md"), + Path::new("/home/vincent/code/content/site/content/posts/tutorials/python/index.md"), &PathBuf::from("/home/vincent/code/content/site"), ); assert_eq!(file.components, ["posts".to_string(), "tutorials".to_string()]); @@ -186,7 +186,7 @@ mod tests { let mut config = Config::default(); config.languages.insert("fr".to_owned(), LanguageOptions::default()); let mut file = FileInfo::new_page( - &Path::new("/home/vincent/code/site/content/posts/tutorials/python.fr.md"), + Path::new("/home/vincent/code/site/content/posts/tutorials/python.fr.md"), &PathBuf::new(), ); let res = file.find_language(&config); @@ -199,7 +199,7 @@ mod tests { let mut config = Config::default(); config.languages.insert("fr".to_owned(), LanguageOptions::default()); let mut file = FileInfo::new_page( - &Path::new("/home/vincent/code/site/content/posts/tutorials/python.en.md"), + Path::new("/home/vincent/code/site/content/posts/tutorials/python.en.md"), &PathBuf::new(), ); let res = file.find_language(&config); @@ -212,7 +212,7 @@ mod tests { let mut config = Config::default(); config.languages.insert("fr".to_owned(), LanguageOptions::default()); let mut file = FileInfo::new_page( - &Path::new("/home/vincent/code/site/content/posts/tutorials/python/index.fr.md"), + Path::new("/home/vincent/code/site/content/posts/tutorials/python/index.fr.md"), &PathBuf::new(), ); assert_eq!(file.components, ["posts".to_string(), "tutorials".to_string()]); @@ -225,7 +225,7 @@ mod tests { fn do_nothing_on_unknown_language_in_page_with_i18n_off() { let config = Config::default(); let mut file = FileInfo::new_page( - &Path::new("/home/vincent/code/site/content/posts/tutorials/python.fr.md"), + Path::new("/home/vincent/code/site/content/posts/tutorials/python.fr.md"), &PathBuf::new(), ); let res = file.find_language(&config); @@ -238,7 +238,7 @@ mod tests { let mut config = Config::default(); config.languages.insert("it".to_owned(), LanguageOptions::default()); let mut file = FileInfo::new_page( - &Path::new("/home/vincent/code/site/content/posts/tutorials/python.fr.md"), + Path::new("/home/vincent/code/site/content/posts/tutorials/python.fr.md"), &PathBuf::new(), ); let res = file.find_language(&config); @@ -250,7 +250,7 @@ mod tests { let mut config = Config::default(); config.languages.insert("fr".to_owned(), LanguageOptions::default()); let mut file = FileInfo::new_section( - &Path::new("/home/vincent/code/site/content/posts/tutorials/_index.fr.md"), + Path::new("/home/vincent/code/site/content/posts/tutorials/_index.fr.md"), &PathBuf::new(), ); let res = file.find_language(&config); @@ -262,7 +262,7 @@ mod tests { #[test] fn correct_canonical_for_index() { let file = FileInfo::new_page( - &Path::new("/home/vincent/code/site/content/posts/tutorials/python/index.md"), + Path::new("/home/vincent/code/site/content/posts/tutorials/python/index.md"), &PathBuf::new(), ); assert_eq!( @@ -277,7 +277,7 @@ mod tests { let mut config = Config::default(); config.languages.insert("fr".to_owned(), LanguageOptions::default()); let mut file = FileInfo::new_page( - &Path::new("/home/vincent/code/site/content/posts/tutorials/python/index.fr.md"), + Path::new("/home/vincent/code/site/content/posts/tutorials/python/index.fr.md"), &PathBuf::new(), ); let res = file.find_language(&config); diff --git a/components/library/src/content/page.rs b/components/library/src/content/page.rs index 7f04609f..c8bcd0aa 100644 --- a/components/library/src/content/page.rs +++ b/components/library/src/content/page.rs @@ -97,16 +97,12 @@ pub struct Page { } impl Page { - pub fn new>(file_path: P, meta: PageFrontMatter, base_path: &PathBuf) -> Page { + pub fn new>(file_path: P, meta: PageFrontMatter, base_path: &Path) -> Page { let file_path = file_path.as_ref(); Page { file: FileInfo::new_page(file_path, base_path), meta, ..Self::default() } } - pub fn is_draft(&self) -> bool { - self.meta.draft - } - /// Parse a page given the content of the .md file /// Files without front matter or with invalid front matter are considered /// erroneous @@ -114,7 +110,7 @@ impl Page { file_path: &Path, content: &str, config: &Config, - base_path: &PathBuf, + base_path: &Path, ) -> Result { let (meta, content) = split_page_content(file_path, content)?; let mut page = Page::new(file_path, meta, base_path); @@ -205,11 +201,7 @@ impl Page { } /// Read and parse a .md file into a Page struct - pub fn from_file>( - path: P, - config: &Config, - base_path: &PathBuf, - ) -> Result { + pub fn from_file>(path: P, config: &Config, base_path: &Path) -> Result { let path = path.as_ref(); let content = read_file(path)?; let mut page = Page::parse(path, &content, config, base_path)?; @@ -217,7 +209,7 @@ impl Page { if page.file.name == "index" { let parent_dir = path.parent().unwrap(); page.assets = find_related_assets(parent_dir, config); - page.serialized_assets = page.serialize_assets(&base_path); + page.serialized_assets = page.serialize_assets(base_path); } else { page.assets = vec![]; } @@ -249,11 +241,10 @@ impl Page { Error::chain(format!("Failed to render content of {}", self.file.path.display()), e) })?; - self.summary = if let Some(s) = res.summary_len.map(|l| &res.body[0..l]) { - Some(FOOTNOTES_RE.replace(s, "").into_owned()) - } else { - None - }; + self.summary = res + .summary_len + .map(|l| &res.body[0..l]) + .map(|s| FOOTNOTES_RE.replace(s, "").into_owned()); self.content = res.body; self.toc = res.toc; self.external_links = res.external_links; @@ -276,13 +267,13 @@ impl Page { context.insert("page", &self.to_serialized(library)); context.insert("lang", &self.lang); - render_template(&tpl_name, tera, context, &config.theme).map_err(|e| { + render_template(tpl_name, tera, context, &config.theme).map_err(|e| { Error::chain(format!("Failed to render page '{}'", self.file.path.display()), e) }) } /// Creates a vectors of asset URLs. - fn serialize_assets(&self, base_path: &PathBuf) -> Vec { + fn serialize_assets(&self, base_path: &Path) -> Vec { self.assets .iter() .filter_map(|asset| asset.file_name()) diff --git a/components/library/src/content/section.rs b/components/library/src/content/section.rs index b7bafa46..5f9e93bf 100644 --- a/components/library/src/content/section.rs +++ b/components/library/src/content/section.rs @@ -68,7 +68,7 @@ impl Section { pub fn new>( file_path: P, meta: SectionFrontMatter, - base_path: &PathBuf, + base_path: &Path, ) -> Section { let file_path = file_path.as_ref(); @@ -79,7 +79,7 @@ impl Section { file_path: &Path, content: &str, config: &Config, - base_path: &PathBuf, + base_path: &Path, ) -> Result
{ let (meta, content) = split_section_content(file_path, content)?; let mut section = Section::new(file_path, meta, base_path); @@ -115,7 +115,7 @@ impl Section { pub fn from_file>( path: P, config: &Config, - base_path: &PathBuf, + base_path: &Path, ) -> Result
{ let path = path.as_ref(); let content = read_file(path)?; diff --git a/components/library/src/content/ser.rs b/components/library/src/content/ser.rs index 83ab4964..b506a677 100644 --- a/components/library/src/content/ser.rs +++ b/components/library/src/content/ser.rs @@ -25,6 +25,7 @@ impl<'a> TranslatedContent<'a> { pub fn find_all_sections(section: &'a Section, library: &'a Library) -> Vec { let mut translations = vec![]; + #[allow(clippy::or_fun_call)] for key in library .translations .get(§ion.file.canonical) @@ -47,6 +48,7 @@ impl<'a> TranslatedContent<'a> { pub fn find_all_pages(page: &'a Page, library: &'a Library) -> Vec { let mut translations = vec![]; + #[allow(clippy::or_fun_call)] for key in library.translations.get(&page.file.canonical).or(Some(&HashSet::new())).unwrap().iter() { @@ -165,7 +167,7 @@ impl<'a> SerializingPage<'a> { word_count: page.word_count, reading_time: page.reading_time, assets: &page.serialized_assets, - draft: page.is_draft(), + draft: page.meta.draft, lang: &page.lang, lighter, heavier, @@ -181,7 +183,7 @@ impl<'a> SerializingPage<'a> { /// currently only used in testing pub fn get_title(&'a self) -> &'a Option { - &self.title + self.title } /// Same as from_page but does not fill sibling pages @@ -194,7 +196,7 @@ impl<'a> SerializingPage<'a> { month = Some(d.1); day = Some(d.2); } - let ancestors = if let Some(ref lib) = library { + let ancestors = if let Some(lib) = library { page.ancestors .iter() .map(|k| lib.get_section_by_key(*k).file.relative.as_str()) @@ -203,7 +205,7 @@ impl<'a> SerializingPage<'a> { vec![] }; - let translations = if let Some(ref lib) = library { + let translations = if let Some(lib) = library { TranslatedContent::find_all_pages(page, lib) } else { vec![] @@ -231,7 +233,7 @@ impl<'a> SerializingPage<'a> { word_count: page.word_count, reading_time: page.reading_time, assets: &page.serialized_assets, - draft: page.is_draft(), + draft: page.meta.draft, lang: &page.lang, lighter: None, heavier: None, @@ -251,6 +253,7 @@ pub struct SerializingSection<'a> { relative_path: &'a str, content: &'a str, permalink: &'a str, + draft: bool, ancestors: Vec<&'a str>, title: &'a Option, description: &'a Option, @@ -290,6 +293,7 @@ impl<'a> SerializingSection<'a> { SerializingSection { relative_path: §ion.file.relative, ancestors, + draft: section.meta.draft, content: §ion.content, permalink: §ion.permalink, title: §ion.meta.title, @@ -313,7 +317,7 @@ impl<'a> SerializingSection<'a> { let mut ancestors = vec![]; let mut translations = vec![]; let mut subsections = vec![]; - if let Some(ref lib) = library { + if let Some(lib) = library { ancestors = section .ancestors .iter() @@ -327,6 +331,7 @@ impl<'a> SerializingSection<'a> { SerializingSection { relative_path: §ion.file.relative, ancestors, + draft: section.meta.draft, content: §ion.content, permalink: §ion.permalink, title: §ion.meta.title, diff --git a/components/library/src/library.rs b/components/library/src/library.rs index 4b4cee61..baa9209a 100644 --- a/components/library/src/library.rs +++ b/components/library/src/library.rs @@ -84,7 +84,7 @@ impl Library { let rel_path = section.path.clone(); let mut entries = vec![rel_path]; - entries.extend(section.meta.aliases.iter().map(|a| a.clone()).collect::>()); + entries.extend(section.meta.aliases.to_vec()); self.insert_reverse_aliases(entries, §ion.file.relative); let key = self.sections.insert(section); @@ -98,7 +98,7 @@ impl Library { let rel_path = page.path.clone(); let mut entries = vec![rel_path]; - entries.extend(page.meta.aliases.iter().map(|a| a.clone()).collect::>()); + entries.extend(page.meta.aliases.to_vec()); self.insert_reverse_aliases(entries, &page.file.relative); let key = self.pages.insert(page); @@ -252,7 +252,7 @@ impl Library { } for section in self.sections.values_mut() { - if let Some(ref children) = subsections.get(§ion.file.path) { + if let Some(children) = subsections.get(§ion.file.path) { let mut children: Vec<_> = children.iter().map(|p| sections[p]).collect(); children.sort_by(|a, b| sections_weight[a].cmp(§ions_weight[b])); section.subsections = children; @@ -446,12 +446,9 @@ mod tests { #[test] fn can_find_no_collisions() { let mut library = Library::new(10, 10, false); - let mut page = Page::default(); - page.path = "hello".to_string(); - let mut page2 = Page::default(); - page2.path = "hello-world".to_string(); - let mut section = Section::default(); - section.path = "blog".to_string(); + let page = Page { path: "hello".to_string(), ..Default::default() }; + let page2 = Page { path: "hello-world".to_string(), ..Default::default() }; + let section = Section { path: "blog".to_string(), ..Default::default() }; library.insert_page(page); library.insert_page(page2); library.insert_section(section); @@ -463,14 +460,11 @@ mod tests { #[test] fn can_find_collisions_between_pages() { let mut library = Library::new(10, 10, false); - let mut page = Page::default(); - page.path = "hello".to_string(); + let mut page = Page { path: "hello".to_string(), ..Default::default() }; page.file.relative = "hello".to_string(); - let mut page2 = Page::default(); - page2.path = "hello".to_string(); + let mut page2 = Page { path: "hello".to_string(), ..Default::default() }; page2.file.relative = "hello-world".to_string(); - let mut section = Section::default(); - section.path = "blog".to_string(); + let mut section = Section { path: "blog".to_string(), ..Default::default() }; section.file.relative = "hello-world".to_string(); library.insert_page(page.clone()); library.insert_page(page2.clone()); @@ -486,15 +480,12 @@ mod tests { #[test] fn can_find_collisions_with_an_alias() { let mut library = Library::new(10, 10, false); - let mut page = Page::default(); - page.path = "hello".to_string(); + let mut page = Page { path: "hello".to_string(), ..Default::default() }; page.file.relative = "hello".to_string(); - let mut page2 = Page::default(); - page2.path = "hello-world".to_string(); + let mut page2 = Page { path: "hello".to_string(), ..Default::default() }; page2.file.relative = "hello-world".to_string(); page2.meta.aliases = vec!["hello".to_string()]; - let mut section = Section::default(); - section.path = "blog".to_string(); + let mut section = Section { path: "blog".to_string(), ..Default::default() }; section.file.relative = "hello-world".to_string(); library.insert_page(page.clone()); library.insert_page(page2.clone()); diff --git a/components/library/src/pagination/mod.rs b/components/library/src/pagination/mod.rs index 16f017a2..26bc8a3e 100644 --- a/components/library/src/pagination/mod.rs +++ b/components/library/src/pagination/mod.rs @@ -255,15 +255,17 @@ mod tests { use crate::library::Library; use crate::taxonomies::{Taxonomy, TaxonomyItem}; use config::Taxonomy as TaxonomyConfig; - use front_matter::SectionFrontMatter; use super::Paginator; fn create_section(is_index: bool, paginate_reversed: bool) -> Section { - let mut f = SectionFrontMatter::default(); - f.paginate_by = Some(2); - f.paginate_path = "page".to_string(); - f.paginate_reversed = paginate_reversed; + let f = front_matter::SectionFrontMatter { + paginate_by: Some(2), + paginate_path: "page".to_string(), + paginate_reversed, + ..Default::default() + }; + let mut s = Section::new("content/_index.md", f, &PathBuf::new()); if !is_index { s.path = "/posts/".to_string(); diff --git a/components/library/src/sorting.rs b/components/library/src/sorting.rs index 07dc4a61..f0b8f9b3 100644 --- a/components/library/src/sorting.rs +++ b/components/library/src/sorting.rs @@ -31,7 +31,7 @@ pub fn sort_pages_by_date( can_be_sorted.par_sort_unstable_by(|a, b| { let ord = b.1.unwrap().cmp(&a.1.unwrap()); if ord == Ordering::Equal { - a.2.cmp(&b.2) + a.2.cmp(b.2) } else { ord } @@ -53,7 +53,7 @@ pub fn sort_pages_by_title( can_be_sorted.par_sort_unstable_by(|a, b| { let ord = natural_lexical_cmp(a.1.unwrap(), b.1.unwrap()); if ord == Ordering::Equal { - a.2.cmp(&b.2) + a.2.cmp(b.2) } else { ord } @@ -74,7 +74,7 @@ pub fn sort_pages_by_weight( can_be_sorted.par_sort_unstable_by(|a, b| { let ord = a.1.unwrap().cmp(&b.1.unwrap()); if ord == Ordering::Equal { - a.2.cmp(&b.2) + a.2.cmp(b.2) } else { ord } @@ -119,21 +119,19 @@ mod tests { use front_matter::PageFrontMatter; fn create_page_with_date(date: &str) -> Page { - let mut front_matter = PageFrontMatter::default(); - front_matter.date = Some(date.to_string()); + let mut front_matter = + PageFrontMatter { date: Some(date.to_string()), ..Default::default() }; front_matter.date_to_datetime(); Page::new("content/hello.md", front_matter, &PathBuf::new()) } fn create_page_with_title(title: &str) -> Page { - let mut front_matter = PageFrontMatter::default(); - front_matter.title = Some(title.to_string()); + let front_matter = PageFrontMatter { title: Some(title.to_string()), ..Default::default() }; Page::new("content/hello.md", front_matter, &PathBuf::new()) } fn create_page_with_weight(weight: usize) -> Page { - let mut front_matter = PageFrontMatter::default(); - front_matter.weight = Some(weight); + let front_matter = PageFrontMatter { weight: Some(weight), ..Default::default() }; Page::new("content/hello.md", front_matter, &PathBuf::new()) } @@ -251,11 +249,11 @@ mod tests { fn can_find_siblings() { let mut dense = DenseSlotMap::new(); let page1 = create_page_with_weight(1); - let key1 = dense.insert(page1.clone()); + let key1 = dense.insert(page1); let page2 = create_page_with_weight(2); - let key2 = dense.insert(page2.clone()); + let key2 = dense.insert(page2); let page3 = create_page_with_weight(3); - let key3 = dense.insert(page3.clone()); + let key3 = dense.insert(page3); let input = vec![key1, key2, key3]; diff --git a/components/library/src/taxonomies/mod.rs b/components/library/src/taxonomies/mod.rs index c919bc3d..f2d96ad1 100644 --- a/components/library/src/taxonomies/mod.rs +++ b/components/library/src/taxonomies/mod.rs @@ -263,7 +263,7 @@ pub fn find_taxonomies(config: &Config, library: &Library) -> Result ClassHighlighter<'config> { /// *Note:* This function requires `line` to include a newline at the end and /// also use of the `load_defaults_newlines` version of the syntaxes. pub fn highlight_line(&mut self, line: &str) -> String { - debug_assert!(line.ends_with("\n")); - let parsed_line = self.parse_state.parse_line(line, &self.syntax_set); - let (formatted_line, delta) = tokens_to_classed_spans( + debug_assert!(line.ends_with('\n')); + let parsed_line = self.parse_state.parse_line(line, self.syntax_set); + let (formatted_line, delta) = line_tokens_to_classed_spans( line, parsed_line.as_slice(), CLASS_STYLE, @@ -80,9 +81,12 @@ impl<'config> InlineHighlighter<'config> { } pub fn highlight_line(&mut self, line: &str) -> String { - let regions = self.h.highlight(line, &self.syntax_set); + let regions = self.h.highlight(line, self.syntax_set); // TODO: add a param like `IncludeBackground` for `IncludeForeground` in syntect - let highlighted = styled_line_to_highlighted_html(®ions, IncludeBackground::IfDifferent(self.bg_color)); + let highlighted = styled_line_to_highlighted_html( + ®ions, + IncludeBackground::IfDifferent(self.bg_color), + ); highlighted.replace(&self.fg_color, "") } } @@ -113,7 +117,7 @@ impl<'config> SyntaxHighlighter<'config> { match self { Inlined(h) => h.highlight_line(line), Classed(h) => h.highlight_line(line), - NoHighlight => line.to_owned(), + NoHighlight => escape_html(line), } } @@ -171,7 +175,7 @@ impl<'config> SyntaxHighlighter<'config> { &mut styles, h.theme.settings.line_highlight.unwrap_or(Color { r: 255, g: 255, b: 0, a: 0 }), ); - styles.push_str(";"); + styles.push(';'); Some(styles) } } @@ -194,7 +198,7 @@ mod tests { let mut highlighter = ClassHighlighter::new(syntax_and_theme.syntax, syntax_and_theme.syntax_set); let mut out = String::new(); - for line in LinesWithEndings::from(&code) { + for line in LinesWithEndings::from(code) { out.push_str(&highlighter.highlight_line(line)); } out.push_str(&highlighter.finalize()); @@ -216,11 +220,25 @@ mod tests { syntax_and_theme.theme.unwrap(), ); let mut out = String::new(); - for line in LinesWithEndings::from(&code) { + for line in LinesWithEndings::from(code) { out.push_str(&highlighter.highlight_line(line)); } assert!(out.starts_with(r#"")); } + + #[test] + fn no_highlight_escapes_html() { + let mut config = Config::default(); + config.markdown.highlight_code = false; + let code = ""; + let syntax_and_theme = resolve_syntax_and_theme(Some("py"), &config); + let mut highlighter = SyntaxHighlighter::new(false, syntax_and_theme); + let mut out = String::new(); + for line in LinesWithEndings::from(&code) { + out.push_str(&highlighter.highlight_line(line)); + } + assert!(!out.contains("