From 1c7729cac65e0b95eceb85f45b4a651624b64e42 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 29 Jan 2019 19:20:03 +0100 Subject: [PATCH] Default lang to config.default_language --- Cargo.lock | 100 ++++++++++-------- components/config/src/config.rs | 13 ++- components/library/src/content/file_info.rs | 16 +-- components/library/src/content/page.rs | 18 ++-- components/library/src/content/section.rs | 14 +-- components/library/src/content/ser.rs | 6 +- components/library/src/library.rs | 7 +- components/library/src/taxonomies/mod.rs | 28 +++-- components/site/src/lib.rs | 20 ++-- components/site/tests/site.rs | 2 +- components/site/tests/site_i18n.rs | 4 +- components/templates/src/global_fns/mod.rs | 10 +- .../documentation/templates/pages-sections.md | 8 +- 13 files changed, 137 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa0d547..61483e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ dependencies = [ "actix_derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -32,7 +32,7 @@ dependencies = [ "tokio-timer 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "trust-dns-proto 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "trust-dns-resolver 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -89,7 +89,7 @@ dependencies = [ "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -388,10 +388,10 @@ version = "0.6.0" 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)", - "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-epoch 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -399,12 +399,10 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -422,8 +420,8 @@ name = "crossbeam-deque" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-epoch 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -442,12 +440,12 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (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.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -463,10 +461,11 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.6.3" +version = "0.6.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)", + "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -948,7 +947,7 @@ name = "ignore" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.2 (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)", @@ -1366,10 +1365,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "nom" -version = "4.1.1" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1511,7 +1511,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1584,7 +1584,7 @@ version = "0.7.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1685,16 +1685,17 @@ dependencies = [ [[package]] name = "rand" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.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.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.2 (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.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1739,14 +1740,24 @@ dependencies = [ ] [[package]] -name = "rand_os" +name = "rand_jitter" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_os" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1898,7 +1909,7 @@ dependencies = [ "tokio-threadpool 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2274,7 +2285,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.48 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (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)", @@ -2432,7 +2443,7 @@ name = "tokio-executor" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2461,7 +2472,7 @@ name = "tokio-reactor" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (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)", @@ -2516,13 +2527,13 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "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.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2532,7 +2543,7 @@ name = "tokio-timer" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2804,10 +2815,10 @@ dependencies = [ [[package]] name = "uuid" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2833,7 +2844,7 @@ name = "v_escape_derive" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2844,7 +2855,7 @@ name = "v_escape_derive" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3080,13 +3091,13 @@ dependencies = [ "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e91d5240c6975ef33aeb5f148f35275c25eda8e8a5f95abe421978b05b8bf192" "checksum crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4c7ea749d9fb09e23c5cb17e3b70650860553a0e2744e38446b1803bf7db94" -"checksum crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "137bc235f622ffaa0428e3854e24acb53291fc0b3ff6fb2cb75a8be6fb02f06b" +"checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" -"checksum crossbeam-epoch 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f10a4f8f409aaac4b16a5474fb233624238fcdeefb9ba50d5ea059aab63ba31c" +"checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" -"checksum crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "41ee4864f4797060e52044376f7d107429ce1fb43460021b126424b7180ee21a" +"checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" "checksum csv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd1c44c58078cfbeaf11fbb3eac9ae5534c23004ed770cc4bfb48e658ae4f04" "checksum csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cdef62f37e6ffe7d1f07a381bc0db32b7a3ff1cac0de56cb0d81e71f53d65" "checksum ctrlc 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "630391922b1b893692c6334369ff528dcc3a9d8061ccf4c803aa8f83cb13db5e" @@ -3181,7 +3192,7 @@ dependencies = [ "checksum new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4" "checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" -"checksum nom 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c349f68f25f596b9f44cf0e7c69752a5c633b0550c3ff849518bfba0233774a" +"checksum nom 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b30adc557058ce00c9d0d7cb3c6e0b5bc6f36e2e2eabe74b0ba726d194abd588" "checksum notify 4.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c968cf37cf949114b00d51b0b23536d1c3a4a3963767cf4c969c65a6af78dc7d" "checksum num-derive 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d9fe8fcafd1b86a37ce8a1cfa15ae504817e0c8c2e7ad42767371461ac1d316d" "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" @@ -3216,13 +3227,14 @@ dependencies = [ "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -"checksum rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3906503e80ac6cbcacb2c2973fa8e473f24d7e2747c8c92bb230c2441cad96b5" +"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f46fbd5550acf75b0c2730f5dd1873751daf9beb8f11b44027778fae50d7feca" +"checksum rand_jitter 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fe7b8bc348249f3b1bbb9ab8baa6fa3419196ecfbf213408bca1b2494710de" +"checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d" "checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473" @@ -3324,7 +3336,7 @@ dependencies = [ "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf-8 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" -"checksum uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dab5c5526c5caa3d106653401a267fed923e7046f35895ffcb5ca42db64942e6" +"checksum uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0238db0c5b605dd1cf51de0f21766f97fba2645897024461d6a00c036819a768" "checksum v_escape 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c8b50688edb86f4c092a1a9fe8bda004b0faa3197100897653809e97e09a2814" "checksum v_escape 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6177565a30b7091835dd4a33a81fc4f064e671729a6b7cb964675b2a0bb295a1" "checksum v_escape_derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7cd994c63b487fef7aad31e5394ec04b9e24de7b32ea5251c9fb499cd2cbf44c" diff --git a/components/config/src/config.rs b/components/config/src/config.rs index 4c02086..1f37192 100644 --- a/components/config/src/config.rs +++ b/components/config/src/config.rs @@ -41,8 +41,9 @@ pub struct Taxonomy { pub paginate_path: Option, /// Whether to generate a RSS feed only for each taxonomy term, defaults to false pub rss: bool, - /// The language for that taxonomy, only used in multilingual sites - pub lang: Option, + /// The language for that taxonomy, only used in multilingual sites. + /// Defaults to the config `default_language` if not set + pub lang: String, } impl Taxonomy { @@ -70,7 +71,7 @@ impl Default for Taxonomy { paginate_by: None, paginate_path: None, rss: false, - lang: None, + lang: String::new(), } } } @@ -172,6 +173,12 @@ impl Config { Some(glob_set_builder.build().expect("Bad ignored_content in config file.")); } + for taxonomy in config.taxonomies.iter_mut() { + if taxonomy.lang.is_empty() { + taxonomy.lang = config.default_language.clone(); + } + } + Ok(config) } diff --git a/components/library/src/content/file_info.rs b/components/library/src/content/file_info.rs index 7111fa5..94311b5 100644 --- a/components/library/src/content/file_info.rs +++ b/components/library/src/content/file_info.rs @@ -112,14 +112,14 @@ impl FileInfo { /// Look for a language in the filename. /// If a language has been found, update the name of the file in this struct to /// remove it and return the language code - pub fn find_language(&mut self, config: &Config) -> Result> { + pub fn find_language(&mut self, config: &Config) -> Result { // No languages? Nothing to do if !config.is_multilingual() { - return Ok(None); + return Ok(config.default_language.clone()); } if !self.name.contains('.') { - return Ok(None); + return Ok(config.default_language.clone()); } // Go with the assumption that no one is using `.` in filenames when using i18n @@ -136,7 +136,7 @@ impl FileInfo { self.canonical = self.parent.join(&self.name); let lang = parts.swap_remove(0); - Ok(Some(lang)) + Ok(lang) } } @@ -187,7 +187,7 @@ mod tests { )); let res = file.find_language(&config); assert!(res.is_ok()); - assert_eq!(res.unwrap(), Some(String::from("fr"))); + assert_eq!(res.unwrap(), "fr"); } #[test] @@ -200,7 +200,7 @@ mod tests { assert_eq!(file.components, ["posts".to_string(), "tutorials".to_string()]); let res = file.find_language(&config); assert!(res.is_ok()); - assert_eq!(res.unwrap(), Some(String::from("fr"))); + assert_eq!(res.unwrap(), "fr"); } #[test] @@ -211,7 +211,7 @@ mod tests { )); let res = file.find_language(&config); assert!(res.is_ok()); - assert!(res.unwrap().is_none()); + assert_eq!(res.unwrap(), config.default_language); } #[test] @@ -234,6 +234,6 @@ mod tests { )); let res = file.find_language(&config); assert!(res.is_ok()); - assert_eq!(res.unwrap(), Some(String::from("fr"))); + assert_eq!(res.unwrap(), "fr"); } } diff --git a/components/library/src/content/page.rs b/components/library/src/content/page.rs index 89796d4..420e414 100644 --- a/components/library/src/content/page.rs +++ b/components/library/src/content/page.rs @@ -71,9 +71,9 @@ pub struct Page { /// How long would it take to read the raw content. /// See `get_reading_analytics` on how it is calculated pub reading_time: Option, - /// The language of that page. `None` if the user doesn't setup `languages` in config. + /// The language of that page. Equal to the default lang if the user doesn't setup `languages` in config. /// Corresponds to the lang in the {slug}.{lang}.md file scheme - pub lang: Option, + pub lang: String, /// Contains all the translated version of that page pub translations: Vec, } @@ -102,7 +102,7 @@ impl Page { toc: vec![], word_count: None, reading_time: None, - lang: None, + lang: String::new(), translations: Vec::new(), } } @@ -161,8 +161,8 @@ impl Page { format!("{}/{}", page.file.components.join("/"), page.slug) }; - if let Some(ref lang) = page.lang { - path = format!("{}/{}", lang, path); + if page.lang != config.default_language { + path = format!("{}/{}", page.lang, path); } page.path = path; @@ -302,7 +302,7 @@ impl Default for Page { toc: vec![], word_count: None, reading_time: None, - lang: None, + lang: String::new(), translations: Vec::new(), } } @@ -590,7 +590,7 @@ Bonjour le monde"# let res = Page::parse(Path::new("hello.fr.md"), &content, &config); assert!(res.is_ok()); let page = res.unwrap(); - assert_eq!(page.lang, Some("fr".to_string())); + assert_eq!(page.lang, "fr".to_string()); assert_eq!(page.slug, "hello"); assert_eq!(page.permalink, "http://a-website.com/fr/hello/"); } @@ -608,7 +608,7 @@ Bonjour le monde"# assert!(res.is_ok()); let page = res.unwrap(); assert_eq!(page.meta.date, Some("2018-10-08".to_string())); - assert_eq!(page.lang, Some("fr".to_string())); + assert_eq!(page.lang, "fr".to_string()); assert_eq!(page.slug, "hello"); assert_eq!(page.permalink, "http://a-website.com/fr/hello/"); } @@ -626,7 +626,7 @@ Bonjour le monde"# let res = Page::parse(Path::new("hello.fr.md"), &content, &config); assert!(res.is_ok()); let page = res.unwrap(); - assert_eq!(page.lang, Some("fr".to_string())); + assert_eq!(page.lang, "fr".to_string()); assert_eq!(page.slug, "hello"); assert_eq!(page.permalink, "http://a-website.com/bonjour/"); } diff --git a/components/library/src/content/section.rs b/components/library/src/content/section.rs index 5405689..2a7c4df 100644 --- a/components/library/src/content/section.rs +++ b/components/library/src/content/section.rs @@ -51,9 +51,9 @@ pub struct Section { /// How long would it take to read the raw content. /// See `get_reading_analytics` on how it is calculated pub reading_time: Option, - /// The language of that section. `None` if the user doesn't setup `languages` in config. + /// The language of that section. Equal to the default lang if the user doesn't setup `languages` in config. /// Corresponds to the lang in the _index.{lang}.md file scheme - pub lang: Option, + pub lang: String, /// Contains all the translated version of that section pub translations: Vec, } @@ -79,7 +79,7 @@ impl Section { toc: vec![], word_count: None, reading_time: None, - lang: None, + lang: String::new(), translations: Vec::new(), } } @@ -93,8 +93,8 @@ impl Section { section.word_count = Some(word_count); section.reading_time = Some(reading_time); let path = format!("{}/", section.file.components.join("/")); - if let Some(ref lang) = section.lang { - section.path = format!("{}/{}", lang, path); + if section.lang != config.default_language { + section.path = format!("{}/{}", section.lang, path); } else { section.path = path; } @@ -237,7 +237,7 @@ impl Default for Section { toc: vec![], reading_time: None, word_count: None, - lang: None, + lang: String::new(), translations: Vec::new(), } } @@ -315,7 +315,7 @@ Bonjour le monde"# let res = Section::parse(Path::new("content/hello/nested/_index.fr.md"), &content, &config); assert!(res.is_ok()); let section = res.unwrap(); - assert_eq!(section.lang, Some("fr".to_string())); + assert_eq!(section.lang, "fr".to_string()); assert_eq!(section.permalink, "http://a-website.com/fr/hello/nested/"); } } diff --git a/components/library/src/content/ser.rs b/components/library/src/content/ser.rs index 3404952..e8f311b 100644 --- a/components/library/src/content/ser.rs +++ b/components/library/src/content/ser.rs @@ -9,7 +9,7 @@ use rendering::Header; #[derive(Clone, Debug, PartialEq, Serialize)] pub struct TranslatedContent<'a> { - lang: &'a Option, + lang: &'a str, permalink: &'a str, title: &'a Option, } @@ -70,7 +70,7 @@ pub struct SerializingPage<'a> { toc: &'a [Header], assets: &'a [String], draft: bool, - lang: &'a Option, + lang: &'a str, lighter: Option>>, heavier: Option>>, earlier: Option>>, @@ -211,7 +211,7 @@ pub struct SerializingSection<'a> { components: &'a [String], word_count: Option, reading_time: Option, - lang: &'a Option, + lang: &'a str, toc: &'a [Header], assets: &'a [String], pages: Vec>, diff --git a/components/library/src/library.rs b/components/library/src/library.rs index 5552ee9..ad295e8 100644 --- a/components/library/src/library.rs +++ b/components/library/src/library.rs @@ -7,6 +7,7 @@ use front_matter::SortBy; use content::{Page, Section}; use sorting::{find_siblings, sort_pages_by_date, sort_pages_by_weight}; +use config::Config; /// Houses everything about pages and sections /// Think of it as a database where each page and section has an id (Key here) @@ -82,7 +83,7 @@ impl Library { /// Find out the direct subsections of each subsection if there are some /// as well as the pages for each section - pub fn populate_sections(&mut self) { + pub fn populate_sections(&mut self, config: &Config) { let root_path = self.sections.values().find(|s| s.is_index()).map(|s| s.file.parent.clone()).unwrap(); // We are going to get both the ancestors and grandparents for each section in one go @@ -128,8 +129,8 @@ impl Library { } for (key, page) in &mut self.pages { - let parent_filename = if let Some(ref lang) = page.lang { - format!("_index.{}.md", lang) + let parent_filename = if page.lang != config.default_language { + format!("_index.{}.md", page.lang) } else { "_index.md".to_string() }; diff --git a/components/library/src/taxonomies/mod.rs b/components/library/src/taxonomies/mod.rs index 6d949d3..0756b53 100644 --- a/components/library/src/taxonomies/mod.rs +++ b/components/library/src/taxonomies/mod.rs @@ -64,8 +64,8 @@ impl TaxonomyItem { .collect(); let (mut pages, ignored_pages) = sort_pages_by_date(data); let slug = slugify(name); - let permalink = if let Some(ref lang) = taxonomy.lang { - config.make_permalink(&format!("/{}/{}/{}", lang, taxonomy.name, slug)) + let permalink = if taxonomy.lang != config.default_language { + config.make_permalink(&format!("/{}/{}/{}", taxonomy.lang, taxonomy.name, slug)) } else { config.make_permalink(&format!("/{}/{}", taxonomy.name, slug)) }; @@ -242,9 +242,9 @@ mod tests { let mut library = Library::new(2, 0, false); config.taxonomies = vec![ - TaxonomyConfig { name: "categories".to_string(), ..TaxonomyConfig::default() }, - TaxonomyConfig { name: "tags".to_string(), ..TaxonomyConfig::default() }, - TaxonomyConfig { name: "authors".to_string(), ..TaxonomyConfig::default() }, + TaxonomyConfig { name: "categories".to_string(), lang: config.default_language.clone(), ..TaxonomyConfig::default() }, + TaxonomyConfig { name: "tags".to_string(), lang: config.default_language.clone(), ..TaxonomyConfig::default() }, + TaxonomyConfig { name: "authors".to_string(), lang: config.default_language.clone(), ..TaxonomyConfig::default() }, ]; let mut page1 = Page::default(); @@ -252,6 +252,7 @@ mod tests { taxo_page1.insert("tags".to_string(), vec!["rust".to_string(), "db".to_string()]); taxo_page1.insert("categories".to_string(), vec!["Programming tutorials".to_string()]); page1.meta.taxonomies = taxo_page1; + page1.lang = config.default_language.clone(); library.insert_page(page1); let mut page2 = Page::default(); @@ -259,6 +260,7 @@ mod tests { taxo_page2.insert("tags".to_string(), vec!["rust".to_string(), "js".to_string()]); taxo_page2.insert("categories".to_string(), vec!["Other".to_string()]); page2.meta.taxonomies = taxo_page2; + page2.lang = config.default_language.clone(); library.insert_page(page2); let mut page3 = Page::default(); @@ -266,6 +268,7 @@ mod tests { taxo_page3.insert("tags".to_string(), vec!["js".to_string()]); taxo_page3.insert("authors".to_string(), vec!["Vincent Prouillet".to_string()]); page3.meta.taxonomies = taxo_page3; + page3.lang = config.default_language.clone(); library.insert_page(page3); let taxonomies = find_taxonomies(&config, &library).unwrap(); @@ -322,11 +325,12 @@ mod tests { let mut library = Library::new(2, 0, false); config.taxonomies = - vec![TaxonomyConfig { name: "authors".to_string(), ..TaxonomyConfig::default() }]; + vec![TaxonomyConfig { name: "authors".to_string(), lang: config.default_language.clone(), ..TaxonomyConfig::default() }]; let mut page1 = Page::default(); let mut taxo_page1 = HashMap::new(); taxo_page1.insert("tags".to_string(), vec!["rust".to_string(), "db".to_string()]); page1.meta.taxonomies = taxo_page1; + page1.lang = config.default_language.clone(); library.insert_page(page1); let taxonomies = find_taxonomies(&config, &library); @@ -346,9 +350,9 @@ mod tests { let mut library = Library::new(2, 0, true); config.taxonomies = vec![ - TaxonomyConfig { name: "categories".to_string(), ..TaxonomyConfig::default() }, - TaxonomyConfig { name: "tags".to_string(), ..TaxonomyConfig::default() }, - TaxonomyConfig { name: "auteurs".to_string(), lang: Some("fr".to_string()), ..TaxonomyConfig::default() }, + TaxonomyConfig { name: "categories".to_string(), lang: config.default_language.clone(), ..TaxonomyConfig::default() }, + TaxonomyConfig { name: "tags".to_string(), lang: config.default_language.clone(), ..TaxonomyConfig::default() }, + TaxonomyConfig { name: "auteurs".to_string(), lang: "fr".to_string(), ..TaxonomyConfig::default() }, ]; let mut page1 = Page::default(); @@ -356,6 +360,7 @@ mod tests { taxo_page1.insert("tags".to_string(), vec!["rust".to_string(), "db".to_string()]); taxo_page1.insert("categories".to_string(), vec!["Programming tutorials".to_string()]); page1.meta.taxonomies = taxo_page1; + page1.lang = config.default_language.clone(); library.insert_page(page1); let mut page2 = Page::default(); @@ -363,10 +368,11 @@ mod tests { taxo_page2.insert("tags".to_string(), vec!["rust".to_string()]); taxo_page2.insert("categories".to_string(), vec!["Other".to_string()]); page2.meta.taxonomies = taxo_page2; + page2.lang = config.default_language.clone(); library.insert_page(page2); let mut page3 = Page::default(); - page3.lang = Some("fr".to_string()); + page3.lang = "fr".to_string(); let mut taxo_page3 = HashMap::new(); taxo_page3.insert("auteurs".to_string(), vec!["Vincent Prouillet".to_string()]); page3.meta.taxonomies = taxo_page3; @@ -431,7 +437,7 @@ mod tests { vec![TaxonomyConfig { name: "tags".to_string(), ..TaxonomyConfig::default() }]; let mut page1 = Page::default(); - page1.lang = Some("fr".to_string()); + page1.lang = "fr".to_string(); let mut taxo_page1 = HashMap::new(); taxo_page1.insert("tags".to_string(), vec!["rust".to_string(), "db".to_string()]); page1.meta.taxonomies = taxo_page1; diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index bc84def..8a8e0b7 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -396,10 +396,10 @@ impl Site { pub fn find_parent_section_insert_anchor( &self, parent_path: &PathBuf, - lang: &Option, + lang: &str, ) -> InsertAnchor { - let parent = if let Some(ref l) = lang { - parent_path.join(format!("_index.{}.md", l)) + let parent = if lang != self.config.default_language { + parent_path.join(format!("_index.{}.md", lang)) } else { parent_path.join("_index.md") }; @@ -413,7 +413,7 @@ impl Site { /// as well as the pages for each section pub fn populate_sections(&mut self) { let mut library = self.library.write().expect("Get lock for populate_sections"); - library.populate_sections(); + library.populate_sections(&self.config); } /// Find all the tags and categories if it's asked in the config @@ -531,7 +531,7 @@ impl Site { library .pages_values() .iter() - .filter(|p| p.lang.is_none()) + .filter(|p| p.lang == self.config.default_language) .map(|p| *p) .collect() } else { @@ -547,7 +547,7 @@ impl Site { let pages = library .pages_values() .iter() - .filter(|p| if let Some(ref l) = p.lang { l == &lang.code } else { false }) + .filter(|p| p.lang == lang.code) .map(|p| *p) .collect(); self.render_rss_feed(pages, Some(&PathBuf::from(lang.code.clone())))?; @@ -728,8 +728,8 @@ impl Site { } ensure_directory_exists(&self.output_path)?; - let output_path = if let Some(ref lang) = taxonomy.kind.lang { - let mid_path = self.output_path.join(lang); + let output_path = if taxonomy.kind.lang != self.config.default_language { + let mid_path = self.output_path.join(&taxonomy.kind.lang); create_directory(&mid_path)?; mid_path.join(&taxonomy.kind.name) } else { @@ -922,8 +922,8 @@ impl Site { ensure_directory_exists(&self.output_path)?; let mut output_path = self.output_path.clone(); - if let Some(ref lang) = section.lang { - output_path.push(lang); + if section.lang != self.config.default_language { + output_path.push(§ion.lang); if !output_path.exists() { create_directory(&output_path)?; } diff --git a/components/site/tests/site.rs b/components/site/tests/site.rs index 3a13fb9..7e025e7 100644 --- a/components/site/tests/site.rs +++ b/components/site/tests/site.rs @@ -486,7 +486,7 @@ fn can_build_site_with_pagination_for_taxonomy() { paginate_by: Some(2), paginate_path: None, rss: true, - lang: None, + lang: site.config.default_language.clone(), }); site.load().unwrap(); { diff --git a/components/site/tests/site_i18n.rs b/components/site/tests/site_i18n.rs index 6ccb790..f9b2a98 100644 --- a/components/site/tests/site_i18n.rs +++ b/components/site/tests/site_i18n.rs @@ -40,7 +40,7 @@ fn can_parse_multilingual_site() { ); for key in &default_blog.pages { let page = library.get_page_by_key(*key); - assert_eq!(page.lang, None); + assert_eq!(page.lang, "en"); } let fr_blog = library.get_section(&blog_path.join("_index.fr.md")).unwrap(); @@ -52,7 +52,7 @@ fn can_parse_multilingual_site() { ); for key in &fr_blog.pages { let page = library.get_page_by_key(*key); - assert_eq!(page.lang, Some("fr".to_string())); + assert_eq!(page.lang, "fr"); } } diff --git a/components/templates/src/global_fns/mod.rs b/components/templates/src/global_fns/mod.rs index bb7344b..2398386 100644 --- a/components/templates/src/global_fns/mod.rs +++ b/components/templates/src/global_fns/mod.rs @@ -347,9 +347,10 @@ mod tests { #[test] fn can_get_taxonomy() { - let taxo_config = TaxonomyConfig { name: "tags".to_string(), ..TaxonomyConfig::default() }; + let config = Config::default(); + let taxo_config = TaxonomyConfig { name: "tags".to_string(), lang: config.default_language.clone(), ..TaxonomyConfig::default() }; let library = Arc::new(RwLock::new(Library::new(0, 0, false))); - let tag = TaxonomyItem::new("Programming", &taxo_config, &Config::default(), vec![], &library.read().unwrap()); + let tag = TaxonomyItem::new("Programming", &taxo_config, &config, vec![], &library.read().unwrap()); let tags = Taxonomy { kind: taxo_config, items: vec![tag] }; let taxonomies = vec![tags.clone()]; @@ -386,9 +387,10 @@ mod tests { #[test] fn can_get_taxonomy_url() { - let taxo_config = TaxonomyConfig { name: "tags".to_string(), ..TaxonomyConfig::default() }; + let config = Config::default(); + let taxo_config = TaxonomyConfig { name: "tags".to_string(), lang: config.default_language.clone(), ..TaxonomyConfig::default() }; let library = Library::new(0, 0, false); - let tag = TaxonomyItem::new("Programming", &taxo_config, &Config::default(), vec![], &library); + let tag = TaxonomyItem::new("Programming", &taxo_config, &config, vec![], &library); let tags = Taxonomy { kind: taxo_config, items: vec![tag] }; let taxonomies = vec![tags.clone()]; diff --git a/docs/content/documentation/templates/pages-sections.md b/docs/content/documentation/templates/pages-sections.md index 0a3525c..c21ed77 100644 --- a/docs/content/documentation/templates/pages-sections.md +++ b/docs/content/documentation/templates/pages-sections.md @@ -53,8 +53,8 @@ assets: Array; ancestors: Array; // The relative path from the `content` directory to the markdown file relative_path: String; -// The language for the page if there is one -lang: String?; +// The language for the page if there is one. Default to the config `default_language` +lang: String; // Information about all the available languages for that content translations: Array; ``` @@ -99,8 +99,8 @@ assets: Array; ancestors: Array; // The relative path from the `content` directory to the markdown file relative_path: String; -// The language for the section if there is one -lang: String?; +// The language for the section if there is one. Default to the config `default_language` +lang: String; // Information about all the available languages for that content translations: Array; ```