From b3004c69ef68b83b7dd9e55eb3aaef2910493b9e Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Thu, 29 Nov 2018 20:24:45 +0100 Subject: [PATCH] Fix broken taxonomies pagination Closes #533 --- CHANGELOG.md | 1 + Cargo.lock | 88 +++++++++---------- components/library/src/pagination/mod.rs | 7 +- components/library/src/taxonomies/mod.rs | 6 +- components/rebuild/tests/rebuild.rs | 3 +- components/rendering/src/shortcode.rs | 2 +- components/site/src/lib.rs | 30 +++---- components/site/tests/site.rs | 75 ++++++++++++++++ .../documentation/templates/pagination.md | 19 +++- .../documentation/templates/taxonomies.md | 48 ++++++---- test_site/templates/tags/single.html | 26 ++++-- 11 files changed, 214 insertions(+), 91 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3908d8c2..5fe0d727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.5.1 (unreleased) - Fix deleting markdown file in `zola serve` +- Fix pagination for taxonomies being broken and add missing documentation for it ## 0.5.0 (2018-11-17) diff --git a/Cargo.lock b/Cargo.lock index 7cea6c50..5a1fb7ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,7 +109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -158,7 +158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "arrayvec" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -400,7 +400,7 @@ name = "crossbeam-epoch" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -414,7 +414,7 @@ name = "crossbeam-epoch" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -575,7 +575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "encoding_rs" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -624,7 +624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -640,7 +640,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -841,7 +841,7 @@ dependencies = [ "markup5ever 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -866,7 +866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "humantime" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -996,7 +996,7 @@ dependencies = [ [[package]] name = "ipconfig" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1076,7 +1076,7 @@ dependencies = [ "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "slotmap 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "utils 0.1.0", @@ -1286,7 +1286,7 @@ dependencies = [ "schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1350,7 +1350,7 @@ dependencies = [ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1562,7 +1562,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1637,7 +1637,7 @@ dependencies = [ [[package]] name = "rand" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1646,7 +1646,7 @@ dependencies = [ "rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_isaac 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1685,7 +1685,7 @@ dependencies = [ [[package]] name = "rand_isaac" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1738,12 +1738,12 @@ dependencies = [ "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "library 0.1.0", "site 0.1.0", - "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1751,7 +1751,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1811,7 +1811,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding_rs 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1973,7 +1973,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2043,7 +2043,7 @@ dependencies = [ "search 0.1.0", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "templates 0.1.0", "tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)", "utils 0.1.0", @@ -2082,7 +2082,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2145,7 +2145,7 @@ dependencies = [ "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2160,7 +2160,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.21" +version = "0.15.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2175,7 +2175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2202,13 +2202,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.0.4" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2278,7 +2278,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2315,7 +2315,7 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2444,7 +2444,7 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2537,7 +2537,7 @@ dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "ipconfig 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "ipconfig 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2690,7 +2690,7 @@ version = "0.1.0" dependencies = [ "errors 0.1.0", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2887,7 +2887,7 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arc-swap 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "5c5ed110e2537bdd3f5b9091707a8a5556a72ac49bbd7302ae0b28fdccb3246c" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" -"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" +"checksum arrayvec 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f405cc4c21cd8b784f6c8fc2adf9bc00f59558f0049b5ec21517f875963040cc" "checksum askama_escape 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "719b48039ffac1564f67d70162109ba9341125cee0096a540e478355b3c724a7" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" @@ -2936,7 +2936,7 @@ dependencies = [ "checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" "checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" "checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" -"checksum encoding_rs 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ca20350a7cb5aab5b9034731123d6d412caf3e92d4985e739e411ba0955fd0eb" +"checksum encoding_rs 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1a8fa54e6689eb2549c4efed8d00d7f3b2b994a064555b0e8df4ae3764bcc4be" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" "checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" @@ -2968,7 +2968,7 @@ dependencies = [ "checksum http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "02096a6d2c55e63f7fcb800690e4f889a25f6ec342e3adb4594e293b625215ab" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" -"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" +"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum hyper 0.12.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0aeedb8ca5f0f96be00f84073c6d0d5f962ecad020ef543dff99a7c12717a60e" "checksum hyper-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "32cd73f14ad370d3b4d4b7dce08f69b81536c82e39fcc89731930fe5788cd661" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" @@ -2978,7 +2978,7 @@ dependencies = [ "checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" "checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum ipconfig 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "fccb81dd962b29a25de46c4f46e497b75117aa816468b6fff7a63a598a192394" +"checksum ipconfig 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "08f7eadeaf4b52700de180d147c4805f199854600b36faa963d91114827b2ffc" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum jpeg-decoder 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c8b7d43206b34b3f94ea9445174bda196e772049b9bddbc620c9d29b2d20110d" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -3047,17 +3047,17 @@ dependencies = [ "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" "checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" -"checksum rand 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de3f08319b5395bd19b70e73c4c465329495db02dafeb8ca711a20f1c2bd058c" +"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a" "checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a" "checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_isaac 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6ecfe9ebf36acd47a49d150990b047a5f7db0a7236ee2414b7ff5cc1097c7b" +"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" "checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3" "checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473" "checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" -"checksum redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cf8fb82a4d1c9b28f1c26c574a5b541f5ffb4315f6c9a791fa47b6a04438fe93" +"checksum redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" "checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e" @@ -3101,10 +3101,10 @@ dependencies = [ "checksum strum 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c3a2071519ab6a48f465808c4c1ffdd00dfc8e93111d02b4fc5abab177676e" "checksum strum_macros 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8baacebd7b7c9b864d83a6ba7a246232983e277b86fa5cdec77f565715a4b136" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -"checksum syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)" = "816b7af21405b011a23554ea2dc3f6576dc86ca557047c34098c1d741f10f823" +"checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum syntect 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e02dd9df97a68a2d005ace28ff24c610abfc3ce17afcfdb22a077645dabb599a" -"checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" +"checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" "checksum tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9de21546595a0873061940d994bbbc5c35f024ae4fd61ec5c5b159115684f508" "checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" diff --git a/components/library/src/pagination/mod.rs b/components/library/src/pagination/mod.rs index ab2e8f09..b1648667 100644 --- a/components/library/src/pagination/mod.rs +++ b/components/library/src/pagination/mod.rs @@ -14,7 +14,7 @@ use taxonomies::{Taxonomy, TaxonomyItem}; #[derive(Clone, Debug, PartialEq)] enum PaginationRoot<'a> { Section(&'a Section), - Taxonomy(&'a Taxonomy), + Taxonomy(&'a Taxonomy, &'a TaxonomyItem), } /// A list of all the pages in the paginator with their index and links @@ -93,7 +93,7 @@ impl<'a> Paginator<'a> { all_pages: &item.pages, pagers: Vec::with_capacity(item.pages.len() / paginate_by), paginate_by, - root: PaginationRoot::Taxonomy(taxonomy), + root: PaginationRoot::Taxonomy(taxonomy, item), permalink: item.permalink.clone(), path: format!("{}/{}", taxonomy.kind.name, item.slug), paginate_path: taxonomy @@ -212,8 +212,9 @@ impl<'a> Paginator<'a> { context .insert("section", &SerializingSection::from_section_basic(s, Some(library))); } - PaginationRoot::Taxonomy(t) => { + PaginationRoot::Taxonomy(t, item) => { context.insert("taxonomy", &t.kind); + context.insert("term", &item.serialize(library)); } }; context.insert("current_url", &pager.permalink); diff --git a/components/library/src/taxonomies/mod.rs b/components/library/src/taxonomies/mod.rs index f245cd33..6bba13c2 100644 --- a/components/library/src/taxonomies/mod.rs +++ b/components/library/src/taxonomies/mod.rs @@ -13,7 +13,7 @@ use library::Library; use sorting::sort_pages_by_date; #[derive(Debug, Clone, PartialEq, Serialize)] -struct SerializedTaxonomyItem<'a> { +pub struct SerializedTaxonomyItem<'a> { name: &'a str, slug: &'a str, permalink: &'a str, @@ -71,6 +71,10 @@ impl TaxonomyItem { TaxonomyItem { name: name.to_string(), permalink, slug, pages } } + + pub fn serialize<'a>(&'a self, library: &'a Library) -> SerializedTaxonomyItem<'a> { + SerializedTaxonomyItem::from_item(self, library) + } } #[derive(Debug, Clone, PartialEq, Serialize)] diff --git a/components/rebuild/tests/rebuild.rs b/components/rebuild/tests/rebuild.rs index 10d16936..b5a96ea0 100644 --- a/components/rebuild/tests/rebuild.rs +++ b/components/rebuild/tests/rebuild.rs @@ -228,7 +228,8 @@ fn can_rebuild_after_renaming_section_folder() { fn can_rebuild_after_renaming_non_md_asset_in_colocated_folder() { let tmp_dir = tempdir().expect("create temp dir"); let (site_path, mut site) = load_and_build_site!(tmp_dir); - let (old_path, new_path) = rename!(site_path, "content/posts/with-assets/zola.png", "gutenberg.png"); + let (old_path, new_path) = + rename!(site_path, "content/posts/with-assets/zola.png", "gutenberg.png"); // Testing that we don't try to load some images as markdown or something let res = after_content_rename(&mut site, &old_path, &new_path); diff --git a/components/rendering/src/shortcode.rs b/components/rendering/src/shortcode.rs index d292e867..804b4876 100644 --- a/components/rendering/src/shortcode.rs +++ b/components/rendering/src/shortcode.rs @@ -1,7 +1,7 @@ use pest::iterators::Pair; use pest::Parser; -use tera::{to_value, Context, Map, Value}; use regex::Regex; +use tera::{to_value, Context, Map, Value}; use context::RenderContext; use errors::{Result, ResultExt}; diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 3df0686d..1b37a3e1 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -646,7 +646,6 @@ impl Site { /// Renders all taxonomies with at least one non-draft post pub fn render_taxonomies(&self) -> Result<()> { - // TODO: make parallel? for taxonomy in &self.taxonomies { self.render_taxonomy(taxonomy)?; } @@ -669,24 +668,26 @@ impl Site { .items .par_iter() .map(|item| { + let path = output_path.join(&item.slug); + if taxonomy.kind.is_paginated() { + self.render_paginated( + &path, + &Paginator::from_taxonomy(&taxonomy, item, &self.library), + )?; + } else { + let single_output = + taxonomy.render_term(item, &self.tera, &self.config, &self.library)?; + create_directory(&path)?; + create_file(&path.join("index.html"), &self.inject_livereload(single_output))?; + } + if taxonomy.kind.rss { self.render_rss_feed( item.pages.iter().map(|p| self.library.get_page_by_key(*p)).collect(), Some(&PathBuf::from(format!("{}/{}", taxonomy.kind.name, item.slug))), - )?; - } - - if taxonomy.kind.is_paginated() { - self.render_paginated( - &output_path, - &Paginator::from_taxonomy(&taxonomy, item, &self.library), ) } else { - let single_output = - taxonomy.render_term(item, &self.tera, &self.config, &self.library)?; - let path = output_path.join(&item.slug); - create_directory(&path)?; - create_file(&path.join("index.html"), &self.inject_livereload(single_output)) + Ok(()) } }) .collect::>() @@ -737,8 +738,8 @@ impl Site { terms.sort_by(|a, b| a.permalink.cmp(&b.permalink)); taxonomies.push(terms); } - context.insert("taxonomies", &taxonomies); + context.insert("taxonomies", &taxonomies); context.insert("config", &self.config); let sitemap = &render_template("sitemap.xml", &self.tera, &context, &self.config.theme)?; @@ -805,7 +806,6 @@ impl Site { } else { create_file(&self.output_path.join("rss.xml"), feed)?; } - Ok(()) } diff --git a/components/site/tests/site.rs b/components/site/tests/site.rs index 431bb50d..4031444c 100644 --- a/components/site/tests/site.rs +++ b/components/site/tests/site.rs @@ -1,3 +1,4 @@ +extern crate config; extern crate site; extern crate tempfile; @@ -7,6 +8,7 @@ use std::fs::File; use std::io::prelude::*; use std::path::Path; +use config::Taxonomy; use site::Site; use tempfile::tempdir; @@ -512,6 +514,79 @@ fn can_build_site_with_pagination_for_index() { assert_eq!(file_contains!(public, "index.html", "has_next"), false); } +#[test] +fn can_build_site_with_pagination_for_taxonomy() { + let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf(); + path.push("test_site"); + let mut site = Site::new(&path, "config.toml").unwrap(); + site.config.taxonomies.push(Taxonomy { + name: "tags".to_string(), + paginate_by: Some(2), + paginate_path: None, + rss: true, + }); + site.load().unwrap(); + + for (i, (_, page)) in site.library.pages_mut().iter_mut().enumerate() { + page.meta.taxonomies = { + let mut taxonomies = HashMap::new(); + taxonomies + .insert("tags".to_string(), vec![if i % 2 == 0 { "A" } else { "B" }.to_string()]); + taxonomies + }; + } + site.populate_taxonomies().unwrap(); + + let tmp_dir = tempdir().expect("create temp dir"); + let public = &tmp_dir.path().join("public"); + site.set_output_path(&public); + site.build().unwrap(); + + assert!(Path::new(&public).exists()); + + assert!(file_exists!(public, "index.html")); + assert!(file_exists!(public, "sitemap.xml")); + assert!(file_exists!(public, "robots.txt")); + assert!(file_exists!(public, "a-fixed-url/index.html")); + assert!(file_exists!(public, "posts/python/index.html")); + assert!(file_exists!(public, "posts/tutorials/devops/nix/index.html")); + assert!(file_exists!(public, "posts/with-assets/index.html")); + + // Tags + assert!(file_exists!(public, "tags/index.html")); + // With RSS + assert!(file_exists!(public, "tags/a/rss.xml")); + assert!(file_exists!(public, "tags/b/rss.xml")); + // And pagination! + assert!(file_exists!(public, "tags/a/pages/1/index.html")); + assert!(file_exists!(public, "tags/b/pages/1/index.html")); + assert!(file_exists!(public, "tags/a/pages/2/index.html")); + assert!(file_exists!(public, "tags/b/pages/2/index.html")); + + // should redirect to posts/ + assert!(file_contains!( + public, + "tags/a/pages/1/index.html", + "http-equiv=\"refresh\" content=\"0;url=https://replace-this-with-your-url.com/tags/a/\"" + )); + assert!(file_contains!(public, "tags/a/index.html", "Num pagers: 6")); + assert!(file_contains!(public, "tags/a/index.html", "Page size: 2")); + assert!(file_contains!(public, "tags/a/index.html", "Current index: 1")); + assert!(!file_contains!(public, "tags/a/index.html", "has_prev")); + assert!(file_contains!(public, "tags/a/index.html", "has_next")); + assert!(file_contains!( + public, + "tags/a/index.html", + "First: https://replace-this-with-your-url.com/tags/a/" + )); + assert!(file_contains!( + public, + "tags/a/index.html", + "Last: https://replace-this-with-your-url.com/tags/a/pages/6/" + )); + assert_eq!(file_contains!(public, "tags/a/index.html", "has_prev"), false); +} + #[test] fn can_build_rss_feed() { let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf(); diff --git a/docs/content/documentation/templates/pagination.md b/docs/content/documentation/templates/pagination.md index b4fcddd4..53e15ab4 100644 --- a/docs/content/documentation/templates/pagination.md +++ b/docs/content/documentation/templates/pagination.md @@ -7,10 +7,9 @@ Two things can get paginated: a section or a taxonomy term. A paginated section gets the same `section` variable as a normal [section page](./documentation/templates/pages-sections.md#section-variables) minus its pages -while a paginated taxonomy gets the a `taxonomy` variable of type `TaxonomyConfig`, equivalent -to the taxonomy definition in the `config.toml`. +while -In addition, a paginated page gets a `paginator` variable of the `Pager` type: +Both get a paginated page gets a `paginator` variable of the `Pager` type: ```ts // How many items per page @@ -33,3 +32,17 @@ pages: Array; // Which page are we on current_index: Number; ``` + +## Section + +A paginated section gets the same `section` variable as a normal +[section page](./documentation/templates/pages-sections.md#section-variables) minus its pages. + +## Taxonomy term + +A paginated taxonomy gets two variables: + +- a `taxonomy` variable of type `TaxonomyConfig` +- a `term` variable of type `TaxonomyTerm`. + +See the [taxonomies page](./documentation/templates/taxonomies.md) for a detailed version of the types. diff --git a/docs/content/documentation/templates/taxonomies.md b/docs/content/documentation/templates/taxonomies.md index 1b5b6116..c17d53f9 100644 --- a/docs/content/documentation/templates/taxonomies.md +++ b/docs/content/documentation/templates/taxonomies.md @@ -17,8 +17,35 @@ permalink: String; pages: Array; ``` -## Non-paginated taxonomies -If a taxonomy is not paginated, the templates get the following variables: +and a `TaxonomyConfig`: + +```ts +name: String, +slug: String, +paginate_by: Number?; +paginate_path: String?; +rss: Bool; +``` + +``` + +### Taxonomy list (`list.html`) + +This template is never paginated and therefore get the following variables in all cases. + +```ts +// The site config +config: Config; +// The data of the taxonomy, from the config +taxonomy: TaxonomyConfig; +// The current full permalink for that page +current_url: String; +// The current path for that page +current_path: String; +// All terms for that taxonomy +terms: Array; +``` + ### Single term (`single.html`) ```ts @@ -34,18 +61,5 @@ current_path: String; term: TaxonomyTerm; ``` -### Taxonomy list (`list.html`) -```ts -// The site config -config: Config; -// The data of the taxonomy, from the config -taxonomy: TaxonomyConfig; -// The current full permalink for that page -current_url: String; -// The current path for that page -current_path: String; -// All terms for that taxonomy -terms: Array; -``` - -## Paginated taxonomies +A paginated taxonomy term will also get a `paginator` variable, see the [pagination page](./documentation/templates/pagination.md) +for more details on that. diff --git a/test_site/templates/tags/single.html b/test_site/templates/tags/single.html index 0813ae8f..0c3f8fb8 100644 --- a/test_site/templates/tags/single.html +++ b/test_site/templates/tags/single.html @@ -1,7 +1,21 @@ -Tag: {{ term.name }} +{% if not paginator %} + Tag: {{ term.name }} -{% for page in term.pages %} - -{% endfor %} + {% for page in term.pages %} + + {% endfor %} +{% else %} + Tag: {{ term.name }} + {% for page in paginator.pages %} + {{page.title|safe}} + {% endfor %} + Num pagers: {{ paginator.number_pagers }} + Page size: {{ paginator.paginate_by }} + Current index: {{ paginator.current_index }} + First: {{ paginator.first | safe }} + Last: {{ paginator.last | safe }} + {% if paginator.previous %}has_prev{% endif%} + {% if paginator.next %}has_next{% endif%} +{% endif %}