diff --git a/CHANGELOG.md b/CHANGELOG.md index 959d16d..cb64d5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed - markdown preview in search (Issue [#74](https://github.com/out-of-cheese-error/gooseberry/issues/74)) +### Added +- handlebars_misc_helpers (Issue [#81](https://github.com/out-of-cheese-error/gooseberry/issues/66)) + ## [0.8.0] - 2021-03-14 ### Fixed * All w3 selectors (partially) supported (Issue [#66](https://github.com/out-of-cheese-error/gooseberry/issues/66)) diff --git a/Cargo.lock b/Cargo.lock index 6b57a1e..f8cef6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,17 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "addr2line" version = "0.14.1" @@ -77,6 +89,20 @@ dependencies = [ "wait-timeout", ] +[[package]] +name = "attohttpc" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe174d1b67f7b2bafed829c09db039301eb5841f66e43be2cf60b326e7f8e2cc" +dependencies = [ + "flate2", + "http", + "log", + "native-tls", + "openssl", + "url", +] + [[package]] name = "atty" version = "0.2.14" @@ -400,6 +426,22 @@ dependencies = [ "memchr", ] +[[package]] +name = "core-foundation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" + [[package]] name = "crc32fast" version = "1.2.1" @@ -757,6 +799,12 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "enquote" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ec878a5d2f3b6e9eaee72373dd23414cfc7d353104741471bec712ef241a66e" + [[package]] name = "env_logger" version = "0.8.3" @@ -832,6 +880,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.0.1" @@ -962,6 +1025,12 @@ dependencies = [ "byteorder", ] +[[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" + [[package]] name = "generic-array" version = "0.12.4" @@ -1029,6 +1098,7 @@ dependencies = [ "eyre", "futures", "handlebars", + "handlebars_misc_helpers", "hypothesis", "indicatif", "predicates", @@ -1078,6 +1148,26 @@ dependencies = [ "serde_json", ] +[[package]] +name = "handlebars_misc_helpers" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffabb036ccea7ad1a3240f304d2e1b7827f3006d380aa4590edb1111b41d5c00" +dependencies = [ + "Inflector", + "attohttpc", + "enquote", + "handlebars", + "jsonnet-rs", + "lazy_static", + "log", + "serde", + "serde_json", + "serde_yaml", + "thiserror", + "toml", +] + [[package]] name = "hashbrown" version = "0.9.1" @@ -1273,6 +1363,26 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonnet-rs" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea3859e42541d9ecee82613c105234d2af74e1794c255af2d155d1e7ad57558" +dependencies = [ + "jsonnet-sys", + "libc", +] + +[[package]] +name = "jsonnet-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2948bf138e186428476eaea072b4b07ef3cd8e6bcaeab941a65ec783a927e6ef" +dependencies = [ + "gcc", + "libc", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -1395,6 +1505,24 @@ dependencies = [ "winapi", ] +[[package]] +name = "native-tls" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nix" version = "0.14.1" @@ -1488,6 +1616,39 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "openssl" +version = "0.10.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "openssl-sys" +version = "0.9.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "owo-colors" version = "1.3.0" @@ -1609,6 +1770,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + [[package]] name = "plist" version = "1.1.0" @@ -1982,6 +2149,16 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "088c5d71572124929ea7549a8ce98e1a6fd33d0a38367b09027b382e67c033db" +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -1998,6 +2175,29 @@ dependencies = [ "untrusted", ] +[[package]] +name = "security-framework" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3670b1d2fdf6084d192bc71ead7aabe6c06aa2ea3fbd9cc3ac111fa5c2b1bd84" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3676258fd3cfe2c9a0ec99ce3038798d847ce3e4bb17746373eb9f0f1ac16339" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "0.9.0" @@ -2557,6 +2757,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ + "indexmap", "serde", ] @@ -2723,6 +2924,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" +[[package]] +name = "vcpkg" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" + [[package]] name = "vec_map" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index ed78eb4..2d25c85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ handlebars = "3.5.4" # Sanitizing filenames sanitize-filename = "0.3.0" +handlebars_misc_helpers = "0.11.2" [dev-dependencies] assert_cmd = "1.0.3" diff --git a/src/gooseberry/knowledge_base.rs b/src/gooseberry/knowledge_base.rs index 3a3d79f..846a65c 100644 --- a/src/gooseberry/knowledge_base.rs +++ b/src/gooseberry/knowledge_base.rs @@ -107,6 +107,7 @@ impl<'a> Default for Templates<'a> { pub(crate) fn get_handlebars(templates: Templates) -> color_eyre::Result { let mut hbs = Handlebars::new(); + handlebars_misc_helpers::register(&mut hbs); hbs.register_escape_fn(handlebars::no_escape); hbs.register_helper("date_format", Box::new(date_format)); hbs.register_template_string("annotation", templates.annotation_template)?;