Browse Source

Cleanup of slotmap impl

Fix #205
index-subcmd
Vincent Prouillet 5 years ago
parent
commit
cdcebaea26
20 changed files with 101 additions and 304 deletions
  1. +13
    -126
      Cargo.lock
  2. +1
    -1
      components/errors/Cargo.toml
  3. +1
    -1
      components/front_matter/Cargo.toml
  4. +1
    -1
      components/imageproc/Cargo.toml
  5. +1
    -1
      components/library/Cargo.toml
  6. +5
    -6
      components/library/src/content/page.rs
  7. +10
    -10
      components/library/src/content/section.rs
  8. +33
    -126
      components/library/src/library.rs
  9. +1
    -4
      components/library/src/pagination/mod.rs
  10. +10
    -3
      components/library/src/sorting.rs
  11. +2
    -2
      components/library/src/taxonomies/mod.rs
  12. +2
    -2
      components/rebuild/src/lib.rs
  13. +1
    -1
      components/rendering/Cargo.toml
  14. +1
    -1
      components/site/Cargo.toml
  15. +9
    -9
      components/site/src/lib.rs
  16. +2
    -2
      components/site/tests/site.rs
  17. +1
    -1
      components/templates/Cargo.toml
  18. +2
    -2
      components/templates/src/global_fns.rs
  19. +1
    -1
      components/utils/Cargo.toml
  20. +4
    -4
      components/utils/src/templates.rs

+ 13
- 126
Cargo.lock View File

@@ -119,11 +119,6 @@ dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "arrayref"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "arrayvec"
version = "0.4.7"
@@ -219,25 +214,11 @@ name = "bitflags"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "block-buffer"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "build_const"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "byte-tools"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "byteorder"
version = "1.2.6"
@@ -462,14 +443,6 @@ name = "deunicode"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "digest"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "dtoa"
version = "0.4.3"
@@ -590,7 +563,7 @@ version = "0.1.0"
dependencies = [
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.17 (git+https://github.com/Keats/tera/?branch=next)",
"tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

@@ -614,11 +587,6 @@ dependencies = [
"synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "fake-simd"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "filetime"
version = "0.2.1"
@@ -666,7 +634,7 @@ dependencies = [
"regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.17 (git+https://github.com/Keats/tera/?branch=next)",
"tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

@@ -730,14 +698,6 @@ dependencies = [
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "generic-array"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "getopts"
version = "0.2.18"
@@ -939,7 +899,7 @@ dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.17 (git+https://github.com/Keats/tera/?branch=next)",
"tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0",
]

@@ -1071,7 +1031,7 @@ dependencies = [
"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)",
"tera 0.11.17 (git+https://github.com/Keats/tera/?branch=next)",
"tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0",
]
@@ -1455,14 +1415,6 @@ name = "pest"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "pest"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "pest_derive"
version = "1.0.8"
@@ -1473,37 +1425,6 @@ dependencies = [
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "pest_derive"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"pest 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pest_generator 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "pest_generator"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"pest 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pest_meta 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "pest_meta"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pest 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "phf"
version = "0.7.23"
@@ -1755,7 +1676,7 @@ dependencies = [
"slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"syntect 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"templates 0.1.0",
"tera 0.11.17 (git+https://github.com/Keats/tera/?branch=next)",
"tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0",
]

@@ -1958,17 +1879,6 @@ dependencies = [
"url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "sha-1"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
"fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "sha1"
version = "0.6.0"
@@ -1996,7 +1906,7 @@ dependencies = [
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"templates 0.1.0",
"tera 0.11.17 (git+https://github.com/Keats/tera/?branch=next)",
"tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0",
]

@@ -2201,7 +2111,7 @@ dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"library 0.1.0",
"pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.17 (git+https://github.com/Keats/tera/?branch=next)",
"tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)",
"utils 0.1.0",
]

@@ -2217,16 +2127,16 @@ dependencies = [

[[package]]
name = "tera"
version = "0.11.17"
source = "git+https://github.com/Keats/tera/?branch=next#efb8af88e4768d119f06579f2b66d75025470030"
version = "0.11.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pest 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pest_derive 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pest_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2512,16 +2422,6 @@ name = "try-lock"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "typenum"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "ucd-trie"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "ucd-util"
version = "0.1.1"
@@ -2655,7 +2555,7 @@ version = "0.1.0"
dependencies = [
"errors 0.1.0",
"tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.17 (git+https://github.com/Keats/tera/?branch=next)",
"tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2834,7 +2734,6 @@ dependencies = [
"checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a"
"checksum ammonia 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8b93ecb80665873703bf3b0a77f369c96b183d8e0afaf30a3ff5ff07dfc6409"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"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 atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "346d7644f0b5f9bc73082d3b2236b69a05fd35cce0cfa3724e184e6a5c9e2a2f"
@@ -2846,9 +2745,7 @@ dependencies = [
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab"
"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39"
"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
"checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781"
"checksum bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0ce55bd354b095246fc34caf4e9e242f5297a7fd938b090cadfea6eee614aa62"
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
@@ -2873,7 +2770,6 @@ dependencies = [
"checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850"
"checksum deflate 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)" = "8a6abb26e16e8d419b5c78662aa9f82857c2386a073da266840e474d5055ec86"
"checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690"
"checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90"
"checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum elasticlunr-rs 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4837d77a1e157489a3933b743fd774ae75074e0e390b2b7f071530048a0d87ee"
@@ -2890,7 +2786,6 @@ dependencies = [
"checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46"
"checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9"
"checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
"checksum filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da4b9849e77b13195302c174324b5ba73eec9b236b24c221a61000daefb95c5f"
"checksum flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4af030962d89d62aa52cd9492083b1cd9b2d1a77764878102a6c0f86b4d5444d"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
@@ -2904,7 +2799,6 @@ dependencies = [
"checksum futf 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7c9c1ce3fa9336301af935ab852c437817d14cd33690446569392e65170aac3b"
"checksum futures 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "0c84b40c7e2de99ffd70602db314a7a8c26b2b3d830e6f7f7a142a8860ab3ca4"
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
"checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797"
"checksum gif 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4bca55ac1f213920ce3527ccd62386f1f15fa3f1714aeee1cf93f2c416903f"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
@@ -2975,11 +2869,7 @@ dependencies = [
"checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0fce5d8b5cc33983fc74f78ad552b5522ab41442c4ca91606e4236eb4b5ceefc"
"checksum pest 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c3abb0d36ede865dcc689fd3bee2ff39094eff6e57a814f4a53c3c6108088353"
"checksum pest_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3294f437119209b084c797604295f40227cffa35c57220b1e99a6ff3bf8ee4"
"checksum pest_derive 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b76f477146419bc539a63f4ef40e902166cb43b3e51cecc71d9136fd12c567e7"
"checksum pest_generator 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ebee4e9680be4fd162e6f3394ae4192a6b60b1e4d17d845e631f0c68d1a3386"
"checksum pest_meta 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1f6d5f6f0e6082578c86af197d780dc38328e3f768cec06aac9bc46d714e8221"
"checksum phf 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "cec29da322b242f4c3098852c77a0ca261c9c01b806cae85a5572a1eb94db9a6"
"checksum phf_codegen 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "7d187f00cd98d5afbcd8898f6cf181743a449162aeb329dcd2f3849009e605ad"
"checksum phf_generator 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "03dc191feb9b08b0dc1330d6549b795b9d81aec19efe6b4a45aec8d4caee0c4b"
@@ -3029,7 +2919,6 @@ dependencies = [
"checksum serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "31569d901045afbff7a9479f793177fe9259819aff10ab4f89ef69bbc5f567fe"
"checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce"
"checksum serde_urlencoded 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aaed41d9fb1e2f587201b863356590c90c1157495d811430a0c0325fe8169650"
"checksum sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9d1f3b5de8a167ab06834a7c883bd197f2191e1dda1a22d9ccfeedbf9aded"
"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
"checksum slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5f9776d6b986f77b35c6cf846c11ad986ff128fe0b2b63a3628e3755e8d3102d"
@@ -3054,7 +2943,7 @@ dependencies = [
"checksum syntect 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc8a6f0db88d4afc340522c20d260411e746b2225b257c6b238a75de9d7cec78"
"checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b"
"checksum tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9de21546595a0873061940d994bbbc5c35f024ae4fd61ec5c5b159115684f508"
"checksum tera 0.11.17 (git+https://github.com/Keats/tera/?branch=next)" = "<none>"
"checksum tera 0.11.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4f79f17fe555fffe4838a082a63636883ee13022888dc7bdc99edad8e0a411cd"
"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
@@ -3078,8 +2967,6 @@ dependencies = [
"checksum trust-dns-proto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32d7c204ee231f802aa821f9dc2195aa0d0269ef7e9f8c844208565c9e3981e4"
"checksum trust-dns-resolver 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4a821ad51a29816420b8cac4b026756b81c023630b97eaa4c8090637ee3508bd"
"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
"checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77"
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
"checksum unic-char-property 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce36d3f7ce754afdbccccf8ff0dd0134e50fb44aaae579f96218856e9e5dbd1e"
"checksum unic-char-range 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9ab85fab42ad1b26cafc03bf891f69cb4d6e15f491030e89a0122197baa8ae8"


+ 1
- 1
components/errors/Cargo.toml View File

@@ -5,6 +5,6 @@ authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]

[dependencies]
error-chain = "0.12"
tera = { git = "https://github.com/Keats/tera/", branch = "next" }
tera = "0.11"
toml = "0.4"
image = "0.20"

+ 1
- 1
components/front_matter/Cargo.toml View File

@@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]

[dependencies]
tera = { git = "https://github.com/Keats/tera/", branch = "next" }
tera = "0.11"
chrono = "0.4"
serde = "1"
serde_derive = "1"


+ 1
- 1
components/imageproc/Cargo.toml View File

@@ -6,7 +6,7 @@ authors = ["Vojtěch Král <vojtech@kral.hk>"]
[dependencies]
lazy_static = "1"
regex = "1.0"
tera = { git = "https://github.com/Keats/tera/", branch = "next" }
tera = "0.11"
image = "0.20"
rayon = "1"



+ 1
- 1
components/library/Cargo.toml View File

@@ -7,7 +7,7 @@ authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
slotmap = "0.2"
rayon = "1"
chrono = { version = "0.4", features = ["serde"] }
tera = { git = "https://github.com/Keats/tera/", branch = "next" }
tera = "0.11"
serde = "1"
serde_derive = "1"
slug = "0.1"


+ 5
- 6
components/library/src/content/page.rs View File

@@ -17,6 +17,7 @@ use library::Library;

use content::file_info::FileInfo;

/// What we are sending to the templates when rendering them
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct SerializingPage<'a> {
content: &'a str,
@@ -45,8 +46,7 @@ pub struct SerializingPage<'a> {
}

impl<'a> SerializingPage<'a> {
// We only want to fill one level of prev/next, otherwise it is going to overflow.
// `stop` is there for that
/// Grabs all the data from a page, including sibling pages
pub fn from_page(page: &'a Page, pages: &'a DenseSlotMap<Page>) -> Self {
let mut year = None;
let mut month = None;
@@ -322,10 +322,9 @@ impl Page {
context.insert("config", config);
context.insert("current_url", &self.permalink);
context.insert("current_path", &self.path);
let mut borrowed = HashMap::new();
borrowed.insert("page", library.get_cached_page_value(&self.file.path));
context.insert("page", &self.to_serialized(library.pages()));

render_template(&tpl_name, tera, &context, &config.theme, borrowed)
render_template(&tpl_name, tera, &context, &config.theme)
.chain_err(|| format!("Failed to render page '{}'", self.file.path.display()))
}

@@ -342,7 +341,7 @@ impl Page {
SerializingPage::from_page(self, pages)
}

pub fn to_serialized_basic<'a>(&'a self) -> SerializingPage<'a> {
pub fn to_serialized_basic(&self) -> SerializingPage {
SerializingPage::from_page_basic(self)
}
}


+ 10
- 10
components/library/src/content/section.rs View File

@@ -13,6 +13,7 @@ use utils::site::get_reading_analytics;
use rendering::{RenderContext, Header, render_content};

use content::file_info::FileInfo;
use content::SerializingPage;
use library::Library;


@@ -29,21 +30,21 @@ pub struct SerializingSection<'a> {
reading_time: Option<usize>,
toc: &'a [Header],
assets: Vec<String>,
pages: Vec<&'a Value>,
subsections: Vec<&'a Value>,
pages: Vec<SerializingPage<'a>>,
subsections: Vec<SerializingSection<'a>>,
}

impl<'a> SerializingSection<'a> {
pub fn from_section(section: &'a Section, library: &'a Library) -> Self {
let mut section_pages = vec![];
let mut subsections = vec![];
let mut pages = Vec::with_capacity(section.pages.len());
let mut subsections = Vec::with_capacity(section.subsections.len());

for k in &section.pages {
section_pages.push(library.get_cached_page_value_by_key(k));
pages.push(library.get_page_by_key(*k).to_serialized(library.pages()));
}

for k in &section.subsections {
subsections.push(library.get_cached_section_value_by_key(k));
subsections.push(library.get_section_by_key(*k).to_serialized(library));
}

SerializingSection {
@@ -58,7 +59,7 @@ impl<'a> SerializingSection<'a> {
reading_time: section.reading_time,
toc: &section.toc,
assets: section.serialize_assets(),
pages: section_pages,
pages,
subsections,
}
}
@@ -232,10 +233,9 @@ impl Section {
context.insert("config", config);
context.insert("current_url", &self.permalink);
context.insert("current_path", &self.path);
let mut borrowed = HashMap::new();
borrowed.insert("section", library.get_cached_section_value(&self.file.path));
context.insert("section", &self.to_serialized(library));

render_template(&tpl_name, tera, &context, &config.theme, borrowed)
render_template(&tpl_name, tera, &context, &config.theme)
.chain_err(|| format!("Failed to render section '{}'", self.file.path.display()))
}



+ 33
- 126
components/library/src/library.rs View File

@@ -2,61 +2,30 @@ use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};

use slotmap::{DenseSlotMap, Key};
use tera::{Value, to_value};

use front_matter::SortBy;

use sorting::{find_siblings, sort_pages_by_weight, sort_pages_by_date};
use content::{Page, Section};

#[derive(Debug)]
struct Values {
pages: HashMap<Key, Value>,
sections: HashMap<Key, Value>,
}

impl Values {
pub fn new(cap_pages: usize, cap_sections: usize) -> Values {
Values {
pages: HashMap::with_capacity(cap_pages),
sections: HashMap::with_capacity(cap_sections),
}
}

pub fn get_page(&self, key: &Key) -> &Value {
return self.pages.get(key).unwrap()
}

pub fn insert_page(&mut self, key: Key, value: Value) {
self.pages.insert(key, value);
}

pub fn remove_page(&mut self, key: &Key) {
self.pages.remove(key);
}

pub fn get_section(&self, key: &Key) -> &Value {
return self.sections.get(key).unwrap()
}

pub fn insert_section(&mut self, key: Key, value: Value) {
self.sections.insert(key, value);
}

pub fn remove_section(&mut self, key: &Key) {
self.sections.remove(key);
}
}

// Houses everything about pages/sections/taxonomies
/// Houses everything about pages and sections
/// Think of it as a database where each page and section has an id (Key here)
/// that can be used to find the actual value
/// Sections and pages can then refer to other elements by those keys, which are very cheap to
/// copy.
/// We can assume the keys are always existing as removing a page/section deletes all references
/// to that key.
#[derive(Debug)]
pub struct Library {
/// All the pages of the site
pages: DenseSlotMap<Page>,
/// All the sections of the site
sections: DenseSlotMap<Section>,
/// A mapping path -> key for pages so we can easily get their key
paths_to_pages: HashMap<PathBuf, Key>,
/// A mapping path -> key for sections so we can easily get their key
paths_to_sections: HashMap<PathBuf, Key>,

values: Values,
}

impl Library {
@@ -66,10 +35,10 @@ impl Library {
sections: DenseSlotMap::with_capacity(cap_sections),
paths_to_pages: HashMap::with_capacity(cap_pages),
paths_to_sections: HashMap::with_capacity(cap_sections),
values: Values::new(cap_pages, cap_sections),
}
}

/// Add a section and return its Key
pub fn insert_section(&mut self, section: Section) -> Key {
let path = section.file.path.clone();
let key = self.sections.insert(section);
@@ -77,6 +46,7 @@ impl Library {
key
}

/// Add a page and return its Key
pub fn insert_page(&mut self, page: Page) -> Key {
let path = page.file.path.clone();
let key = self.pages.insert(page);
@@ -96,10 +66,6 @@ impl Library {
self.pages.values().collect::<Vec<_>>()
}

pub fn pages_values_mut(&mut self) -> Vec<&mut Page> {
self.pages.values_mut().collect::<Vec<_>>()
}

pub fn sections(&self) -> &DenseSlotMap<Section> {
&self.sections
}
@@ -112,10 +78,6 @@ impl Library {
self.sections.values().collect::<Vec<_>>()
}

pub fn sections_values_mut(&mut self) -> Vec<&mut Section> {
self.sections.values_mut().collect::<Vec<_>>()
}

/// 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) {
@@ -158,6 +120,8 @@ impl Library {
}
}

/// Sort all sections pages unless `only` is set.
/// If `only` is set, only the pages of the section at that specific Path will be rendered.
pub fn sort_sections_pages(&mut self, only: Option<&Path>) {
let mut updates = HashMap::new();
for (key, section) in &self.sections {
@@ -167,7 +131,6 @@ impl Library {
}
}

// TODO: use an enum to avoid duplication there and in sorting.rs?
let (sorted_pages, cannot_be_sorted_pages) = match section.meta.sort_by {
SortBy::None => continue,
SortBy::Date => {
@@ -237,49 +200,7 @@ impl Library {
}
}

pub fn cache_all_pages(&mut self) {
let mut cache = HashMap::with_capacity(self.pages.capacity());
for (key, page) in &self.pages {
cache.insert(key, to_value(page.to_serialized(self.pages())).unwrap());
}

for (key, value) in cache {
self.values.insert_page(key, value);
}
}

// We need to do it from the bottom up to ensure all subsections of a section have been
// cached before doing it
pub fn cache_all_sections(&mut self) {
// we get the Key in order we want to process them first
let mut deps = HashMap::new();
for (key, section) in &self.sections {
deps.insert(key, section.subsections.clone());
}

loop {
if deps.is_empty() {
break;
}

let mut processed_keys = vec![];
for (key, _) in deps.iter().filter(|(_, v)| v.is_empty()) {
let section = self.sections.get(*key).unwrap();
let value = to_value(section.to_serialized(self)).unwrap();
self.values.insert_section(*key, value);
processed_keys.push(*key);
}

// remove the processed keys from the action
for key in processed_keys {
deps.remove(&key);
for (_, subs) in &mut deps {
subs.retain(|k| k != &key);
}
}
}
}

/// Find all the orphan pages: pages that are in a folder without an `_index.md`
pub fn get_all_orphan_pages(&self) -> Vec<&Page> {
let pages_in_sections = self.sections
.values()
@@ -305,52 +226,38 @@ impl Library {
self.sections.get(key).unwrap()
}

pub fn remove_section_by_path(&mut self, path: &PathBuf) -> Option<Section> {
if let Some(k) = self.paths_to_sections.remove(path) {
self.values.remove_section(&k);
self.sections.remove(k)
} else {
None
}
}

pub fn contains_section(&self, path: &PathBuf) -> bool {
self.paths_to_sections.contains_key(path)
}

pub fn get_cached_section_value(&self, path: &PathBuf) -> &Value {
self.values.get_section(self.paths_to_sections.get(path).unwrap())
}

pub fn get_cached_section_value_by_key(&self, key: &Key) -> &Value {
self.values.get_section(key)
}

pub fn get_page(&self, path: &PathBuf) -> Option<&Page> {
self.pages.get(self.paths_to_pages.get(path).cloned().unwrap_or_default())
}

pub fn get_cached_page_value(&self, path: &PathBuf) -> &Value {
self.values.get_page(self.paths_to_pages.get(path).unwrap())
}

pub fn get_cached_page_value_by_key(&self, key: &Key) -> &Value {
self.values.get_page(key)
}

pub fn get_page_by_key(&self, key: Key) -> &Page {
self.pages.get(key).unwrap()
}

pub fn remove_page_by_path(&mut self, path: &PathBuf) -> Option<Page> {
pub fn remove_section(&mut self, path: &PathBuf) -> Option<Section> {
if let Some(k) = self.paths_to_sections.remove(path) {
// TODO: delete section from parent subsection if there is one
self.sections.remove(k)
} else {
None
}
}

pub fn remove_page(&mut self, path: &PathBuf) -> Option<Page> {
if let Some(k) = self.paths_to_pages.remove(path) {
self.values.remove_page(&k);
// TODO: delete page from all parent sections
self.pages.remove(k)
} else {
None
}
}

/// Used in rebuild, to check if we know it already
pub fn contains_section(&self, path: &PathBuf) -> bool {
self.paths_to_sections.contains_key(path)
}

/// Used in rebuild, to check if we know it already
pub fn contains_page(&self, path: &PathBuf) -> bool {
self.paths_to_pages.contains_key(path)
}


+ 1
- 4
components/library/src/pagination/mod.rs View File

@@ -190,7 +190,6 @@ impl<'a> Paginator<'a> {

pub fn render_pager(&self, pager: &Pager, config: &Config, tera: &Tera) -> Result<String> {
let mut context = Context::new();
let borrowed = HashMap::new();
context.insert("config", &config);
let template_name = match self.root {
PaginationRoot::Section(s) => {
@@ -206,7 +205,7 @@ impl<'a> Paginator<'a> {
context.insert("current_path", &pager.path);
context.insert("paginator", &self.build_paginator_context(pager));

render_template(&template_name, tera, &context, &config.theme, borrowed)
render_template(&template_name, tera, &context, &config.theme)
.chain_err(|| format!("Failed to render pager {}", pager.index))
}
}
@@ -246,8 +245,6 @@ mod tests {
let mut section = create_section(is_index);
section.pages = library.pages().keys().collect();
library.insert_section(section.clone());
library.cache_all_pages();
library.cache_all_sections();

(section, library)
}


+ 10
- 3
components/library/src/sorting.rs View File

@@ -6,7 +6,8 @@ use chrono::NaiveDateTime;

use content::Page;

// Used by the RSS feed
/// Used by the RSS feed
/// There to not have to import sorting stuff in the site crate
pub fn sort_actual_pages_by_date(a: &&Page, b: &&Page) -> Ordering {
let ord = b.meta.datetime.unwrap().cmp(&a.meta.datetime.unwrap());
if ord == Ordering::Equal {
@@ -16,8 +17,9 @@ pub fn sort_actual_pages_by_date(a: &&Page, b: &&Page) -> Ordering {
}
}

// TODO: unify both sort_ functions
// TODO: add back sorting tests
/// Takes a list of (page key, date, permalink) and sort them by dates if possible
/// Pages without date will be put in the unsortable bucket
/// The permalink is used to break ties
pub fn sort_pages_by_date(pages: Vec<(&Key, Option<NaiveDateTime>, &str)>) -> (Vec<Key>, Vec<Key>) {
let (mut can_be_sorted, cannot_be_sorted): (Vec<_>, Vec<_>) = pages
.into_par_iter()
@@ -36,6 +38,9 @@ pub fn sort_pages_by_date(pages: Vec<(&Key, Option<NaiveDateTime>, &str)>) -> (V
(can_be_sorted.iter().map(|p| *p.0).collect(), cannot_be_sorted.iter().map(|p| *p.0).collect())
}

/// Takes a list of (page key, weight, permalink) and sort them by weight if possible
/// Pages without weight will be put in the unsortable bucket
/// The permalink is used to break ties
pub fn sort_pages_by_weight(pages: Vec<(&Key, Option<usize>, &str)>) -> (Vec<Key>, Vec<Key>) {
let (mut can_be_sorted, cannot_be_sorted): (Vec<_>, Vec<_>) = pages
.into_par_iter()
@@ -54,6 +59,8 @@ pub fn sort_pages_by_weight(pages: Vec<(&Key, Option<usize>, &str)>) -> (Vec<Key
(can_be_sorted.iter().map(|p| *p.0).collect(), cannot_be_sorted.iter().map(|p| *p.0).collect())
}

/// Find the lighter/heavier and earlier/later pages for all pages having a date/weight
/// and that are not drafts.
pub fn find_siblings(sorted: Vec<(&Key, bool)>) -> Vec<(Key, Option<Key>, Option<Key>)> {
let mut res = Vec::with_capacity(sorted.len());
let length = sorted.len();


+ 2
- 2
components/library/src/taxonomies/mod.rs View File

@@ -134,7 +134,7 @@ impl Taxonomy {
context.insert("current_url", &config.make_permalink(&format!("{}/{}", self.kind.name, item.slug)));
context.insert("current_path", &format!("/{}/{}", self.kind.name, item.slug));

render_template(&format!("{}/single.html", self.kind.name), tera, &context, &config.theme, HashMap::new())
render_template(&format!("{}/single.html", self.kind.name), tera, &context, &config.theme)
.chain_err(|| format!("Failed to render single term {} page.", self.kind.name))
}

@@ -147,7 +147,7 @@ impl Taxonomy {
context.insert("current_url", &config.make_permalink(&self.kind.name));
context.insert("current_path", &self.kind.name);

render_template(&format!("{}/list.html", self.kind.name), tera, &context, &config.theme, HashMap::new())
render_template(&format!("{}/list.html", self.kind.name), tera, &context, &config.theme)
.chain_err(|| format!("Failed to render a list of {} page.", self.kind.name))
}



+ 2
- 2
components/rebuild/src/lib.rs View File

@@ -104,11 +104,11 @@ fn delete_element(site: &mut Site, path: &Path, is_section: bool) -> Result<()>
}

if is_section {
if let Some(s) = site.library.remove_section_by_path(&path.to_path_buf()) {
if let Some(s) = site.library.remove_section(&path.to_path_buf()) {
site.permalinks.remove(&s.file.relative);
site.populate_sections();
}
} else if let Some(p) = site.library.remove_page_by_path(&path.to_path_buf()) {
} else if let Some(p) = site.library.remove_page(&path.to_path_buf()) {
site.permalinks.remove(&p.file.relative);

if !p.meta.taxonomies.is_empty() {


+ 1
- 1
components/rendering/Cargo.toml View File

@@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]

[dependencies]
tera = { git = "https://github.com/Keats/tera/", branch = "next", features = ["preserve_order"] }
tera = { version = "0.11", features = ["preserve_order"] }
syntect = "2"
pulldown-cmark = "0"
slug = "0.1"


+ 1
- 1
components/site/Cargo.toml View File

@@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]

[dependencies]
tera = { git = "https://github.com/Keats/tera/", branch = "next" }
tera = "0.11"
glob = "0.2"
rayon = "1"
serde = "1"


+ 9
- 9
components/site/src/lib.rs View File

@@ -241,8 +241,8 @@ impl Site {
self.register_early_global_fns();
self.render_markdown()?;
self.populate_sections();
self.library.cache_all_pages();
self.library.cache_all_sections();
// self.library.cache_all_pages();
// self.library.cache_all_sections();
self.populate_taxonomies()?;
self.register_tera_global_fns();

@@ -321,7 +321,7 @@ impl Site {
let insert_anchor = self.find_parent_section_insert_anchor(&page.file.parent);
page.render_markdown(&self.permalinks, &self.tera, &self.config, &self.base_path, insert_anchor)?;
}
let prev = self.library.remove_page_by_path(&page.file.path);
let prev = self.library.remove_page(&page.file.path);
self.library.insert_page(page);

Ok(prev)
@@ -336,7 +336,7 @@ impl Site {
if render {
section.render_markdown(&self.permalinks, &self.tera, &self.config, &self.base_path)?;
}
let prev = self.library.remove_section_by_path(&section.file.path);
let prev = self.library.remove_section(&section.file.path);
self.library.insert_section(section);

Ok(prev)
@@ -569,7 +569,7 @@ impl Site {
}

pub fn render_aliases(&self) -> Result<()> {
for page in self.library.pages_values() {
for (_, page) in self.library.pages() {
for alias in &page.meta.aliases {
let mut output_path = self.output_path.to_path_buf();
let mut split = alias.split('/').collect::<Vec<_>>();
@@ -605,7 +605,7 @@ impl Site {
context.insert("config", &self.config);
create_file(
&self.output_path.join("404.html"),
&render_template("404.html", &self.tera, &context, &self.config.theme, HashMap::new())?,
&render_template("404.html", &self.tera, &context, &self.config.theme)?,
)
}

@@ -614,7 +614,7 @@ impl Site {
ensure_directory_exists(&self.output_path)?;
create_file(
&self.output_path.join("robots.txt"),
&render_template("robots.txt", &self.tera, &Context::new(), &self.config.theme, HashMap::new())?,
&render_template("robots.txt", &self.tera, &Context::new(), &self.config.theme)?,
)
}

@@ -709,7 +709,7 @@ impl Site {

context.insert("config", &self.config);

let sitemap = &render_template("sitemap.xml", &self.tera, &context, &self.config.theme, HashMap::new())?;
let sitemap = &render_template("sitemap.xml", &self.tera, &context, &self.config.theme)?;

create_file(&self.output_path.join("sitemap.xml"), sitemap)?;

@@ -754,7 +754,7 @@ impl Site {

context.insert("feed_url", &rss_feed_url);

let feed = &render_template("rss.xml", &self.tera, &context, &self.config.theme, HashMap::new())?;
let feed = &render_template("rss.xml", &self.tera, &context, &self.config.theme)?;

if let Some(ref base) = base_path {
let mut output_path = self.output_path.clone().to_path_buf();


+ 2
- 2
components/site/tests/site.rs View File

@@ -221,7 +221,7 @@ fn can_build_site_with_taxonomies() {
let mut site = Site::new(&path, "config.toml").unwrap();
site.load().unwrap();

for (i, page) in site.library.pages_values_mut().iter_mut().enumerate() {
for (i, (_, page)) in site.library.pages_mut().iter_mut().enumerate() {
page.meta.taxonomies = {
let mut taxonomies = HashMap::new();
taxonomies.insert("categories".to_string(), vec![if i % 2 == 0 { "A" } else { "B" }.to_string()]);
@@ -291,7 +291,7 @@ fn can_build_site_with_pagination_for_section() {
path.push("test_site");
let mut site = Site::new(&path, "config.toml").unwrap();
site.load().unwrap();
for section in site.library.sections_values_mut() {
for (_, section) in site.library.sections_mut() {
if section.is_index() {
continue;
}


+ 1
- 1
components/templates/Cargo.toml View File

@@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]

[dependencies]
tera = { git = "https://github.com/Keats/tera/", branch = "next" }
tera = "0.11"
base64 = "0.9"
lazy_static = "1"
pulldown-cmark = "0"


+ 2
- 2
components/templates/src/global_fns.rs View File

@@ -56,7 +56,7 @@ pub fn make_get_page(library: &Library) -> GlobalFn {
for page in library.pages_values() {
pages.insert(
page.file.relative.clone(),
library.get_cached_page_value(&page.file.path).clone(),
to_value(library.get_page(&page.file.path).unwrap().to_serialized(library.pages())).unwrap(),
);
}

@@ -78,7 +78,7 @@ pub fn make_get_section(library: &Library) -> GlobalFn {
for section in library.sections_values() {
sections.insert(
section.file.relative.clone(),
library.get_cached_section_value(&section.file.path).clone(),
to_value(library.get_section(&section.file.path).unwrap().to_serialized(library)).unwrap(),
);
}



+ 1
- 1
components/utils/Cargo.toml View File

@@ -5,7 +5,7 @@ authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]

[dependencies]
errors = { path = "../errors" }
tera = { git = "https://github.com/Keats/tera/", branch = "next" }
tera = "0.11"
unicode-segmentation = "1.2"
walkdir = "2"



+ 4
- 4
components/utils/src/templates.rs View File

@@ -1,6 +1,6 @@
use std::collections::HashMap;

use tera::{Tera, Context, Value};
use tera::{Tera, Context};

use errors::Result;

@@ -22,16 +22,16 @@ macro_rules! render_default_tpl {
/// is not found, it will look up for the equivalent template for the current theme if there is one.
/// Lastly, if it's a default template (index, section or page), it will just return an empty string
/// to avoid an error if there isn't a template with that name
pub fn render_template(name: &str, tera: &Tera, context: &Context, theme: &Option<String>, borrowed: HashMap<&str, &Value>) -> Result<String> {
pub fn render_template(name: &str, tera: &Tera, context: &Context, theme: &Option<String>) -> Result<String> {
if tera.templates.contains_key(name) {
return tera
.render_with_borrowed(name, context, borrowed)
.render(name, context)
.map_err(|e| e.into());
}

if let Some(ref t) = *theme {
return tera
.render_with_borrowed(&format!("{}/templates/{}", t, name), context, borrowed)
.render(&format!("{}/templates/{}", t, name), context)
.map_err(|e| e.into());
}



Loading…
Cancel
Save