From d113e798eab0f902f38af19f9163535aa2d61244 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 26 Jan 2022 22:44:53 +0100 Subject: [PATCH 1/4] Add libs subcrate --- Cargo.lock | 142 +++++++----------- Cargo.toml | 29 +--- components/config/Cargo.toml | 13 +- .../config/examples/generate_sublime.rs | 6 +- components/config/src/config/languages.rs | 4 +- components/config/src/config/link_checker.rs | 3 +- components/config/src/config/markup.rs | 4 +- components/config/src/config/mod.rs | 8 +- components/config/src/config/search.rs | 2 +- components/config/src/config/slugify.rs | 2 +- components/config/src/config/taxonomies.rs | 2 +- components/config/src/highlighting.rs | 9 +- components/config/src/lib.rs | 4 +- components/config/src/theme.rs | 4 +- components/errors/Cargo.toml | 8 +- components/errors/src/lib.rs | 2 + components/front_matter/Cargo.toml | 15 +- components/front_matter/src/lib.rs | 29 ++-- components/front_matter/src/page.rs | 8 +- components/front_matter/src/section.rs | 4 +- components/imageproc/Cargo.toml | 15 +- components/imageproc/src/lib.rs | 9 +- components/imageproc/tests/resize_image.rs | 26 +--- components/library/Cargo.toml | 15 +- components/library/src/content/mod.rs | 24 ++- components/library/src/content/page.rs | 26 ++-- components/library/src/content/section.rs | 6 +- components/library/src/content/ser.rs | 7 +- components/library/src/lib.rs | 2 +- components/library/src/library.rs | 2 +- components/library/src/pagination/mod.rs | 11 +- components/library/src/sorting.rs | 10 +- components/library/src/taxonomies/mod.rs | 6 +- components/libs/Cargo.toml | 54 +++++++ components/libs/src/lib.rs | 42 ++++++ components/link_checker/Cargo.toml | 15 +- components/link_checker/src/lib.rs | 25 ++- components/rendering/Cargo.toml | 13 +- .../rendering/src/codeblock/highlight.rs | 12 +- components/rendering/src/codeblock/mod.rs | 2 +- components/rendering/src/context.rs | 2 +- components/rendering/src/markdown.rs | 11 +- components/rendering/src/shortcode/mod.rs | 1 + components/rendering/src/shortcode/parser.rs | 2 +- components/rendering/src/table_of_contents.rs | 2 +- .../rendering/tests/codeblock_hide_lines.rs | 2 +- .../rendering/tests/codeblock_hl_lines.rs | 2 +- .../rendering/tests/codeblock_linenos.rs | 2 +- .../tests/codeblock_shortcode_mix.rs | 4 +- components/rendering/tests/integration.rs | 1 + components/rendering/tests/links.rs | 1 + components/rendering/tests/markdown.rs | 1 + components/rendering/tests/spec.rs | 1 + components/rendering/tests/summary.rs | 1 + components/rendering/tests/toc.rs | 1 + components/search/Cargo.toml | 13 +- components/search/src/lib.rs | 39 +++-- components/site/Cargo.toml | 18 +-- components/site/src/feed.rs | 6 +- components/site/src/lib.rs | 17 +-- components/site/src/link_checking.rs | 7 +- components/site/src/sass.rs | 4 +- components/site/src/sitemap.rs | 4 +- components/site/src/tpls.rs | 2 +- components/templates/Cargo.toml | 25 +-- components/templates/src/filters.rs | 15 +- .../templates/src/global_fns/content.rs | 2 +- components/templates/src/global_fns/files.rs | 9 +- components/templates/src/global_fns/i18n.rs | 2 +- components/templates/src/global_fns/images.rs | 4 +- .../templates/src/global_fns/load_data.rs | 19 ++- components/templates/src/lib.rs | 69 ++++----- components/utils/Cargo.toml | 10 +- components/utils/src/de.rs | 3 +- components/utils/src/fs.rs | 5 +- components/utils/src/links.rs | 18 +-- components/utils/src/minify.rs | 2 +- components/utils/src/site.rs | 4 +- components/utils/src/slugs.rs | 1 + components/utils/src/templates.rs | 4 +- src/cmd/serve.rs | 8 +- src/console.rs | 21 +-- src/prompt.rs | 2 +- 83 files changed, 465 insertions(+), 522 deletions(-) create mode 100644 components/libs/Cargo.toml create mode 100644 components/libs/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 634b8fdbc8..f6a58522b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -299,9 +299,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.0.12" +version = "3.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2afefa54b5c7dd40918dc1e09f213a171ab5937aadccab45e804780b238f9f43" +checksum = "08799f92c961c7a1cf0cc398a9073da99e21ce388b46372c37f3191f2f3eed3e" dependencies = [ "atty", "bitflags", @@ -320,7 +320,7 @@ version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4dabb7e2f006497e1da045feaa512acf0686f76b68d94925da2d9422dcb521" dependencies = [ - "clap 3.0.12", + "clap 3.0.13", ] [[package]] @@ -357,15 +357,10 @@ dependencies = [ name = "config" version = "0.1.0" dependencies = [ - "chrono", "errors", - "globset", "lazy_static", + "libs", "serde", - "serde_derive", - "syntect", - "toml", - "unic-langid", "utils", ] @@ -638,10 +633,7 @@ dependencies = [ name = "errors" version = "0.1.0" dependencies = [ - "image", - "syntect", - "tera", - "toml", + "libs", ] [[package]] @@ -718,16 +710,10 @@ dependencies = [ name = "front_matter" version = "0.1.0" dependencies = [ - "chrono", "errors", - "lazy_static", - "regex", + "libs", "serde", - "serde_derive", - "serde_yaml", - "tera", "test-case", - "toml", "utils", ] @@ -1131,17 +1117,10 @@ version = "0.1.0" dependencies = [ "config", "errors", - "image", - "lazy_static", - "rayon", - "regex", + "libs", "serde", - "serde_json", - "site", - "svg_metadata", - "tera", + "tempfile", "utils", - "webp", ] [[package]] @@ -1306,24 +1285,57 @@ checksum = "b0005d08a8f7b65fb8073cb697aa0b12b631ed251ce73d862ce50eeb52ce3b50" name = "library" version = "0.1.0" dependencies = [ - "chrono", "config", "errors", "front_matter", + "libs", + "rendering", + "serde", + "tempfile", + "utils", +] + +[[package]] +name = "libs" +version = "0.1.0" +dependencies = [ + "ammonia", + "base64", + "chrono", + "csv", + "elasticlunr-rs", + "filetime", + "gh-emoji", + "glob", "globset", - "lazy_static", + "image", "lexical-sort", + "minify-html", + "mockito", + "nom-bibtex", + "num-format", + "once_cell", + "percent-encoding", + "pulldown-cmark", "rayon", "regex", - "rendering", - "serde", - "serde_derive", + "relative-path", + "reqwest", + "sass-rs", + "serde_json", + "serde_yaml", + "sha2", "slotmap", - "tempfile", + "slug", + "svg_metadata", + "syntect", "tera", "toml", - "utils", + "unic-langid", + "unicode-segmentation", + "url", "walkdir", + "webp", ] [[package]] @@ -1429,9 +1441,8 @@ version = "0.1.0" dependencies = [ "config", "errors", - "lazy_static", + "libs", "mockito", - "reqwest", "utils", ] @@ -2408,18 +2419,12 @@ dependencies = [ "config", "errors", "front_matter", - "gh-emoji", - "lazy_static", + "libs", "link_checker", "pest", "pest_derive", - "pulldown-cmark", - "regex", "serde", - "serde_derive", - "syntect", "templates", - "tera", "utils", ] @@ -2598,12 +2603,10 @@ dependencies = [ name = "search" version = "0.1.0" dependencies = [ - "ammonia", "config", - "elasticlunr-rs", "errors", - "lazy_static", "library", + "libs", ] [[package]] @@ -2730,25 +2733,16 @@ dependencies = [ "config", "errors", "front_matter", - "glob", "imageproc", - "lazy_static", "library", + "libs", "link_checker", "path-slash", - "rayon", - "relative-path", - "sass-rs", "search", "serde", - "serde_derive", - "slotmap", "tempfile", "templates", - "tera", - "url", "utils", - "walkdir", ] [[package]] @@ -2933,26 +2927,15 @@ dependencies = [ name = "templates" version = "0.1.0" dependencies = [ - "base64", "config", - "csv", "errors", "imageproc", - "lazy_static", "library", + "libs", "mockito", - "nom-bibtex", - "num-format", "rendering", - "reqwest", "serde", - "serde_derive", - "serde_json", - "sha2", "tempfile", - "tera", - "toml", - "url", "utils", ] @@ -3374,17 +3357,9 @@ name = "utils" version = "0.1.0" dependencies = [ "errors", - "filetime", - "minify-html", - "percent-encoding", - "regex", + "libs", "serde", - "slug", "tempfile", - "tera", - "toml", - "unicode-segmentation", - "walkdir", ] [[package]] @@ -3682,28 +3657,23 @@ name = "zola" version = "0.16.0" dependencies = [ "atty", - "chrono", - "clap 3.0.12", + "clap 3.0.13", "clap_complete", "ctrlc", "errors", "front_matter", - "globset", "hyper", "lazy_static", + "libs", "mime_guess", "notify", "open", "pathdiff", - "percent-encoding", - "relative-path", "same-file", "search", - "serde_json", "site", "termcolor", "tokio", - "url", "utils", "ws", ] diff --git a/Cargo.toml b/Cargo.toml index 4809e42d85..7e14095b23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,23 +22,16 @@ name = "zola" [dependencies] atty = "0.2.11" clap = { version = "3", features = ["derive"] } -chrono = "0.4" lazy_static = "1.1" termcolor = "1.0.4" -# Used in init to ensure the url given as base_url is a valid one -url = "2" # Below is for the serve cmd hyper = { version = "0.14.1", default-features = false, features = ["runtime", "server", "http2", "http1"] } tokio = { version = "1.0.1", default-features = false, features = ["rt", "fs", "time"] } -percent-encoding = "2" notify = "4" ws = "0.9" ctrlc = "3" open = "2" -globset = "0.4" -relative-path = "1" pathdiff = "0.2" -serde_json = "1.0" # For mimetype detection in serve mode mime_guess = "2.0" @@ -47,29 +40,21 @@ errors = { path = "components/errors" } front_matter = { path = "components/front_matter" } utils = { path = "components/utils" } search = { path = "components/search" } +libs = { path = "components/libs" } + [dev-dependencies] same-file = "1" [features] default = ["rust-tls"] -rust-tls = ["site/rust-tls"] -native-tls = ["site/native-tls"] +rust-tls = ["libs/rust-tls"] +native-tls = ["libs/native-tls"] +indexing-zh = ["libs/indexing-zh"] +indexing-ja = ["libs/indexing-ja"] [workspace] -members = [ - "components/config", - "components/errors", - "components/front_matter", - "components/rendering", - "components/site", - "components/templates", - "components/utils", - "components/search", - "components/imageproc", - "components/link_checker", - "components/library", -] +members = ["components/*"] [profile.release] lto = true diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index dbf089128d..00f82e94d7 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -1,19 +1,14 @@ [package] name = "config" version = "0.1.0" -authors = ["Vincent Prouillet "] -edition = "2018" +edition = "2021" include = ["src/**/*"] [dependencies] -toml = "0.5" -serde = "1" -serde_derive = "1" -chrono = "0.4" -globset = "0.4" +serde = {version = "1.0", features = ["derive"] } +# TODO: remove me if we can get highlight to work with once_cell lazy_static = "1" -syntect = "4" -unic-langid = "0.9" errors = { path = "../errors" } utils = { path = "../utils" } +libs = { path = "../libs" } diff --git a/components/config/examples/generate_sublime.rs b/components/config/examples/generate_sublime.rs index a1946a1532..06a0ba0fbc 100644 --- a/components/config/examples/generate_sublime.rs +++ b/components/config/examples/generate_sublime.rs @@ -3,14 +3,14 @@ //! Although it is a valid example for serializing syntaxes, you probably won't need //! to do this yourself unless you want to cache your own compiled grammars. +use libs::syntect::dumps::*; +use libs::syntect::highlighting::ThemeSet; +use libs::syntect::parsing::SyntaxSetBuilder; use std::collections::HashMap; use std::collections::HashSet; use std::env; use std::iter::FromIterator; use std::path::Path; -use syntect::dumps::*; -use syntect::highlighting::ThemeSet; -use syntect::parsing::SyntaxSetBuilder; fn usage_and_exit() -> ! { println!("USAGE: cargo run --example generate_sublime synpack source-dir newlines.packdump nonewlines.packdump\n diff --git a/components/config/src/config/languages.rs b/components/config/src/config/languages.rs index 9c532b4f98..064b680399 100644 --- a/components/config/src/config/languages.rs +++ b/components/config/src/config/languages.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use errors::{bail, Result}; -use serde_derive::{Deserialize, Serialize}; -use unic_langid::LanguageIdentifier; +use libs::unic_langid::LanguageIdentifier; +use serde::{Deserialize, Serialize}; use crate::config::search; use crate::config::taxonomies; diff --git a/components/config/src/config/link_checker.rs b/components/config/src/config/link_checker.rs index 2e81083bbd..53d353c919 100644 --- a/components/config/src/config/link_checker.rs +++ b/components/config/src/config/link_checker.rs @@ -1,4 +1,4 @@ -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(default)] @@ -8,4 +8,3 @@ pub struct LinkChecker { /// Skip anchor checking for these URL prefixes pub skip_anchor_prefixes: Vec, } - diff --git a/components/config/src/config/markup.rs b/components/config/src/config/markup.rs index 2b250cdab6..fcfc4f8a91 100644 --- a/components/config/src/config/markup.rs +++ b/components/config/src/config/markup.rs @@ -1,11 +1,11 @@ use std::{path::Path, sync::Arc}; -use serde_derive::{Deserialize, Serialize}; -use syntect::{ +use libs::syntect::{ highlighting::{Theme, ThemeSet}, html::css_for_theme_with_class_style, parsing::{SyntaxSet, SyntaxSetBuilder}, }; +use serde::{Deserialize, Serialize}; use errors::{bail, Result}; diff --git a/components/config/src/config/mod.rs b/components/config/src/config/mod.rs index 2e291e3434..47d33c3853 100644 --- a/components/config/src/config/mod.rs +++ b/components/config/src/config/mod.rs @@ -8,9 +8,9 @@ pub mod taxonomies; use std::collections::HashMap; use std::path::{Path, PathBuf}; -use globset::{Glob, GlobSet, GlobSetBuilder}; -use serde_derive::{Deserialize, Serialize}; -use toml::Value as Toml; +use libs::globset::{Glob, GlobSet, GlobSetBuilder}; +use libs::toml::Value as Toml; +use serde::{Deserialize, Serialize}; use crate::theme::Theme; use errors::{bail, Error, Result}; @@ -109,7 +109,7 @@ impl Config { /// Parses a string containing TOML to our Config struct /// Any extra parameter will end up in the extra field pub fn parse(content: &str) -> Result { - let mut config: Config = match toml::from_str(content) { + let mut config: Config = match libs::toml::from_str(content) { Ok(c) => c, Err(e) => bail!(e), }; diff --git a/components/config/src/config/search.rs b/components/config/src/config/search.rs index 71ff325d74..aa36c46e76 100644 --- a/components/config/src/config/search.rs +++ b/components/config/src/config/search.rs @@ -1,4 +1,4 @@ -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(default)] diff --git a/components/config/src/config/slugify.rs b/components/config/src/config/slugify.rs index dae4be61ef..c22065b34d 100644 --- a/components/config/src/config/slugify.rs +++ b/components/config/src/config/slugify.rs @@ -1,4 +1,4 @@ -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; use utils::slugs::SlugifyStrategy; diff --git a/components/config/src/config/taxonomies.rs b/components/config/src/config/taxonomies.rs index ac93a7f4b7..468e5015d3 100644 --- a/components/config/src/config/taxonomies.rs +++ b/components/config/src/config/taxonomies.rs @@ -1,4 +1,4 @@ -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(default)] diff --git a/components/config/src/highlighting.rs b/components/config/src/highlighting.rs index 40e778a30b..ece852942d 100644 --- a/components/config/src/highlighting.rs +++ b/components/config/src/highlighting.rs @@ -1,13 +1,14 @@ use lazy_static::lazy_static; -use syntect::dumps::from_binary; -use syntect::highlighting::{Theme, ThemeSet}; -use syntect::html::ClassStyle; -use syntect::parsing::{SyntaxReference, SyntaxSet}; +use libs::syntect::dumps::from_binary; +use libs::syntect::highlighting::{Theme, ThemeSet}; +use libs::syntect::html::ClassStyle; +use libs::syntect::parsing::{SyntaxReference, SyntaxSet}; use crate::config::Config; pub const CLASS_STYLE: ClassStyle = ClassStyle::SpacedPrefixed { prefix: "z-" }; +// TODO: replace with once_cell. I was getting malloc error with sync::Lazy lazy_static! { pub static ref SYNTAX_SET: SyntaxSet = { let ss: SyntaxSet = diff --git a/components/config/src/lib.rs b/components/config/src/lib.rs index 4f85fde224..a915cbfc5c 100644 --- a/components/config/src/lib.rs +++ b/components/config/src/lib.rs @@ -2,14 +2,14 @@ mod config; pub mod highlighting; mod theme; +use std::path::Path; + pub use crate::config::{ languages::LanguageOptions, link_checker::LinkChecker, search::Search, slugify::Slugify, taxonomies::Taxonomy, Config, }; use errors::Result; -use std::path::Path; - /// Get and parse the config. /// If it doesn't succeed, exit pub fn get_config(filename: &Path) -> Result { diff --git a/components/config/src/theme.rs b/components/config/src/theme.rs index 7daa24864e..ed239af6f4 100644 --- a/components/config/src/theme.rs +++ b/components/config/src/theme.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use std::path::Path; -use serde_derive::{Deserialize, Serialize}; -use toml::Value as Toml; +use libs::toml::Value as Toml; +use serde::{Deserialize, Serialize}; use errors::{bail, Result}; use utils::fs::read_file; diff --git a/components/errors/Cargo.toml b/components/errors/Cargo.toml index 48f746a7e1..da39c131cb 100644 --- a/components/errors/Cargo.toml +++ b/components/errors/Cargo.toml @@ -1,11 +1,7 @@ [package] name = "errors" version = "0.1.0" -authors = ["Vincent Prouillet "] -edition = "2018" +edition = "2021" [dependencies] -tera = "1" -toml = "0.5" -image = "0.23" -syntect = "4" +libs = { path = "../libs" } diff --git a/components/errors/src/lib.rs b/components/errors/src/lib.rs index dcaee80f42..f2a6c9e3b4 100644 --- a/components/errors/src/lib.rs +++ b/components/errors/src/lib.rs @@ -2,6 +2,8 @@ use std::convert::Into; use std::error::Error as StdError; use std::fmt; +use libs::{image, syntect, tera, toml}; + #[derive(Debug)] pub enum ErrorKind { Msg(String), diff --git a/components/front_matter/Cargo.toml b/components/front_matter/Cargo.toml index 15b8e65043..ad7dbe76c1 100644 --- a/components/front_matter/Cargo.toml +++ b/components/front_matter/Cargo.toml @@ -1,21 +1,14 @@ [package] name = "front_matter" version = "0.1.0" -authors = ["Vincent Prouillet "] -edition = "2018" +edition = "2021" [dependencies] -tera = "1" -chrono = "0.4" -serde = "1" -serde_derive = "1" -serde_yaml = "0.8" -toml = "0.5" -regex = "1" -lazy_static = "1" +serde = {version = "1.0", features = ["derive"] } errors = { path = "../errors" } utils = { path = "../utils" } +libs = { path = "../libs" } [dev-dependencies] -test-case = "1" +test-case = "1" # TODO: can we solve that usecase in src/page.rs in a simpler way? A custom macro_rules! maybe diff --git a/components/front_matter/src/lib.rs b/components/front_matter/src/lib.rs index ddfcd2b68b..121f70ff75 100644 --- a/components/front_matter/src/lib.rs +++ b/components/front_matter/src/lib.rs @@ -1,9 +1,11 @@ -use lazy_static::lazy_static; -use serde_derive::{Deserialize, Serialize}; +use std::path::Path; + +use libs::once_cell::sync::Lazy; +use serde::{Deserialize, Serialize}; use errors::{bail, Error, Result}; -use regex::Regex; -use std::path::Path; +use libs::regex::Regex; +use libs::{serde_yaml, toml}; mod page; mod section; @@ -11,16 +13,17 @@ mod section; pub use page::PageFrontMatter; pub use section::SectionFrontMatter; -lazy_static! { - static ref TOML_RE: Regex = Regex::new( - r"^[[:space:]]*\+\+\+(\r?\n(?s).*?(?-s))\+\+\+[[:space:]]*(?:$|(?:\r?\n((?s).*(?-s))$))" +static TOML_RE: Lazy = Lazy::new(|| { + Regex::new( + r"^[[:space:]]*\+\+\+(\r?\n(?s).*?(?-s))\+\+\+[[:space:]]*(?:$|(?:\r?\n((?s).*(?-s))$))", ) - .unwrap(); - static ref YAML_RE: Regex = Regex::new( - r"^[[:space:]]*---(\r?\n(?s).*?(?-s))---[[:space:]]*(?:$|(?:\r?\n((?s).*(?-s))$))" - ) - .unwrap(); -} + .unwrap() +}); + +static YAML_RE: Lazy = Lazy::new(|| { + Regex::new(r"^[[:space:]]*---(\r?\n(?s).*?(?-s))---[[:space:]]*(?:$|(?:\r?\n((?s).*(?-s))$))") + .unwrap() +}); pub enum RawFrontMatter<'a> { Toml(&'a str), diff --git a/components/front_matter/src/page.rs b/components/front_matter/src/page.rs index 7d2b7351f2..7c2c14e2c7 100644 --- a/components/front_matter/src/page.rs +++ b/components/front_matter/src/page.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; -use chrono::prelude::*; -use serde_derive::Deserialize; -use tera::{Map, Value}; +use libs::chrono::prelude::*; +use libs::tera::{Map, Value}; +use serde::Deserialize; use errors::{bail, Result}; use utils::de::{fix_toml_dates, from_toml_datetime}; @@ -152,7 +152,7 @@ impl Default for PageFrontMatter { mod tests { use super::PageFrontMatter; use super::RawFrontMatter; - use tera::to_value; + use libs::tera::to_value; use test_case::test_case; #[test_case(&RawFrontMatter::Toml(r#" "#); "toml")] diff --git a/components/front_matter/src/section.rs b/components/front_matter/src/section.rs index 063ba01451..9424fb7acf 100644 --- a/components/front_matter/src/section.rs +++ b/components/front_matter/src/section.rs @@ -1,5 +1,5 @@ -use serde_derive::{Deserialize, Serialize}; -use tera::{Map, Value}; +use libs::tera::{Map, Value}; +use serde::{Deserialize, Serialize}; use super::{InsertAnchor, SortBy}; use errors::Result; diff --git a/components/imageproc/Cargo.toml b/components/imageproc/Cargo.toml index dc5ec5939f..29c810d801 100644 --- a/components/imageproc/Cargo.toml +++ b/components/imageproc/Cargo.toml @@ -1,24 +1,15 @@ [package] name = "imageproc" version = "0.1.0" -authors = ["Vojtěch Král "] -edition = "2018" +edition = "2021" [dependencies] -lazy_static = "1" -regex = "1.0" -tera = "1" -image = "0.23" -rayon = "1" -webp = "0.2" serde = { version = "1", features = ["derive"] } -svg_metadata = "0.4.1" errors = { path = "../errors" } utils = { path = "../utils" } config = { path = "../config" } +libs = { path = "../libs" } [dev-dependencies] -# TODO: prune -serde_json = "1" -site = { path = "../site" } +tempfile = "3" diff --git a/components/imageproc/src/lib.rs b/components/imageproc/src/lib.rs index 58f92608b6..de46c46cb8 100644 --- a/components/imageproc/src/lib.rs +++ b/components/imageproc/src/lib.rs @@ -11,7 +11,8 @@ use image::error::ImageResult; use image::io::Reader as ImgReader; use image::{imageops::FilterType, EncodableLayout}; use image::{ImageFormat, ImageOutputFormat}; -use lazy_static::lazy_static; +use libs::{image, once_cell, rayon, regex, svg_metadata, webp}; +use once_cell::sync::Lazy; use rayon::prelude::*; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -24,10 +25,8 @@ use utils::fs as ufs; static RESIZED_SUBDIR: &str = "processed_images"; const DEFAULT_Q_JPG: u8 = 75; -lazy_static! { - pub static ref RESIZED_FILENAME: Regex = - Regex::new(r#"([0-9a-f]{16})([0-9a-f]{2})[.](jpg|png|webp)"#).unwrap(); -} +static RESIZED_FILENAME: Lazy = + Lazy::new(|| Regex::new(r#"([0-9a-f]{16})([0-9a-f]{2})[.](jpg|png|webp)"#).unwrap()); /// Size and format read cheaply with `image`'s `Reader`. #[derive(Debug)] diff --git a/components/imageproc/tests/resize_image.rs b/components/imageproc/tests/resize_image.rs index e4e376b9f6..3f5b7f8551 100644 --- a/components/imageproc/tests/resize_image.rs +++ b/components/imageproc/tests/resize_image.rs @@ -1,11 +1,9 @@ use std::env; use std::path::{PathBuf, MAIN_SEPARATOR as SLASH}; -use lazy_static::lazy_static; - use config::Config; use imageproc::{assert_processed_path_matches, ImageMetaResponse, Processor}; -use utils::fs as ufs; +use libs::once_cell::sync::Lazy; static CONFIG: &str = r#" title = "imageproc integration tests" @@ -17,18 +15,10 @@ build_search_index = false highlight_code = false "#; -lazy_static! { - static ref TEST_IMGS: PathBuf = - [env!("CARGO_MANIFEST_DIR"), "tests", "test_imgs"].iter().collect(); - static ref TMPDIR: PathBuf = { - let tmpdir = option_env!("CARGO_TARGET_TMPDIR").map(PathBuf::from).unwrap_or_else(|| { - env::current_exe().unwrap().parent().unwrap().parent().unwrap().join("tmpdir") - }); - ufs::ensure_directory_exists(&tmpdir).unwrap(); - tmpdir - }; - static ref PROCESSED_PREFIX: String = format!("static{0}processed_images{0}", SLASH); -} +static TEST_IMGS: Lazy = + Lazy::new(|| [env!("CARGO_MANIFEST_DIR"), "tests", "test_imgs"].iter().collect()); +static PROCESSED_PREFIX: Lazy = + Lazy::new(|| format!("static{0}processed_images{0}", SLASH)); #[allow(clippy::too_many_arguments)] fn image_op_test( @@ -44,9 +34,9 @@ fn image_op_test( orig_height: u32, ) { let source_path = TEST_IMGS.join(source_img); - + let tmpdir = tempfile::tempdir().unwrap().into_path(); let config = Config::parse(CONFIG).unwrap(); - let mut proc = Processor::new(TMPDIR.clone(), &config); + let mut proc = Processor::new(tmpdir.clone(), &config); let resp = proc.enqueue(source_img.into(), source_path, op, width, height, format, None).unwrap(); @@ -60,7 +50,7 @@ fn image_op_test( proc.do_process().unwrap(); let processed_path = PathBuf::from(&resp.static_path); - let processed_size = imageproc::read_image_metadata(&TMPDIR.join(processed_path)) + let processed_size = imageproc::read_image_metadata(&tmpdir.join(processed_path)) .map(|meta| (meta.width, meta.height)) .unwrap(); assert_eq!(processed_size, (expect_width, expect_height)); diff --git a/components/library/Cargo.toml b/components/library/Cargo.toml index d7122e0e2d..3b1051509a 100644 --- a/components/library/Cargo.toml +++ b/components/library/Cargo.toml @@ -1,28 +1,17 @@ [package] name = "library" version = "0.1.0" -authors = ["Vincent Prouillet "] edition = "2018" [dependencies] -slotmap = "1" -rayon = "1" -chrono = { version = "0.4", features = ["serde"] } -tera = "1" -serde = "1" -serde_derive = "1" -regex = "1" -lazy_static = "1" -lexical-sort = "0.3" -walkdir = "2" +serde = {version = "1.0", features = ["derive"] } front_matter = { path = "../front_matter" } config = { path = "../config" } utils = { path = "../utils" } rendering = { path = "../rendering" } errors = { path = "../errors" } +libs = { path = "../libs" } [dev-dependencies] tempfile = "3" -toml = "0.5" -globset = "0.4" diff --git a/components/library/src/content/mod.rs b/components/library/src/content/mod.rs index 73660cfe81..850961885f 100644 --- a/components/library/src/content/mod.rs +++ b/components/library/src/content/mod.rs @@ -1,12 +1,12 @@ +use std::path::{Path, PathBuf}; + +use libs::walkdir::WalkDir; + mod file_info; mod page; mod section; mod ser; -use std::path::{Path, PathBuf}; - -use walkdir::WalkDir; - pub use self::file_info::FileInfo; pub use self::page::Page; pub use self::section::Section; @@ -89,9 +89,14 @@ mod tests { let assets = find_related_assets(path, &Config::default(), true); assert_eq!(assets.len(), 5); - assert_eq!(assets.iter().filter(|p| p.extension().unwrap_or("".as_ref()) != "md").count(), 5); - - for asset in vec!["example.js", "graph.jpg", "fail.png", "subdir/example.js", "extensionless"] { + assert_eq!( + assets.iter().filter(|p| p.extension().unwrap_or("".as_ref()) != "md").count(), + 5 + ); + + for asset in + vec!["example.js", "graph.jpg", "fail.png", "subdir/example.js", "extensionless"] + { assert!(assets .iter() .find(|p| p.strip_prefix(path).unwrap() == Path::new(asset)) @@ -113,7 +118,10 @@ mod tests { File::create(path.join("subdir").join("example.js")).unwrap(); let assets = find_related_assets(path, &Config::default(), false); assert_eq!(assets.len(), 4); - assert_eq!(assets.iter().filter(|p| p.extension().unwrap_or("".as_ref()) != "md").count(), 4); + assert_eq!( + assets.iter().filter(|p| p.extension().unwrap_or("".as_ref()) != "md").count(), + 4 + ); for asset in vec!["example.js", "graph.jpg", "fail.png", "extensionless"] { assert!(assets diff --git a/components/library/src/content/page.rs b/components/library/src/content/page.rs index 26c5340846..cda0851dc4 100644 --- a/components/library/src/content/page.rs +++ b/components/library/src/content/page.rs @@ -2,10 +2,10 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; -use lazy_static::lazy_static; -use regex::Regex; -use slotmap::DefaultKey; -use tera::{Context as TeraContext, Tera}; +use libs::once_cell::sync::Lazy; +use libs::regex::Regex; +use libs::slotmap::DefaultKey; +use libs::tera::{Context as TeraContext, Tera}; use crate::library::Library; use config::Config; @@ -22,15 +22,15 @@ use crate::content::{find_related_assets, has_anchor}; use utils::fs::read_file; use utils::links::has_anchor_id; -lazy_static! { - // Based on https://regex101.com/r/H2n38Z/1/tests - // A regex parsing RFC3339 date followed by {_,-}, some characters and ended by .md - static ref RFC3339_DATE: Regex = Regex::new( +// Based on https://regex101.com/r/H2n38Z/1/tests +// A regex parsing RFC3339 date followed by {_,-}, some characters and ended by .md +static RFC3339_DATE: Lazy = Lazy::new(|| { + Regex::new( r"^(?P(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9])))?)\s?(_|-)(?P.+$)" - ).unwrap(); + ).unwrap() +}); - static ref FOOTNOTES_RE: Regex = Regex::new(r"\s*.*?").unwrap(); -} +static FOOTNOTES_RE: Lazy = Lazy::new(|| Regex::new(r"\s*.*?").unwrap()); #[derive(Clone, Debug, Default, PartialEq)] pub struct Page { @@ -321,9 +321,9 @@ mod tests { use std::io::Write; use std::path::{Path, PathBuf}; - use globset::{Glob, GlobSetBuilder}; + use libs::globset::{Glob, GlobSetBuilder}; + use libs::tera::Tera; use tempfile::tempdir; - use tera::Tera; use super::Page; use config::{Config, LanguageOptions}; diff --git a/components/library/src/content/section.rs b/components/library/src/content/section.rs index d2fb636d80..e1926b7d53 100644 --- a/components/library/src/content/section.rs +++ b/components/library/src/content/section.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; -use slotmap::DefaultKey; -use tera::{Context as TeraContext, Tera}; +use libs::slotmap::DefaultKey; +use libs::tera::{Context as TeraContext, Tera}; use config::Config; use errors::{Error, Result}; @@ -232,7 +232,7 @@ mod tests { use std::io::Write; use std::path::{Path, PathBuf}; - use globset::{Glob, GlobSetBuilder}; + use libs::globset::{Glob, GlobSetBuilder}; use tempfile::tempdir; use super::Section; diff --git a/components/library/src/content/ser.rs b/components/library/src/content/ser.rs index b506a6776f..252aed7258 100644 --- a/components/library/src/content/ser.rs +++ b/components/library/src/content/ser.rs @@ -1,10 +1,9 @@ //! What we are sending to the templates when rendering them -use std::collections::HashMap; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; use std::path::Path; -use serde_derive::Serialize; -use tera::{Map, Value}; +use libs::tera::{Map, Value}; +use serde::Serialize; use crate::content::{Page, Section}; use crate::library::Library; diff --git a/components/library/src/lib.rs b/components/library/src/lib.rs index 71c4b41ec1..6e2f0abb4b 100644 --- a/components/library/src/lib.rs +++ b/components/library/src/lib.rs @@ -4,7 +4,7 @@ mod pagination; mod sorting; mod taxonomies; -pub use slotmap::{DenseSlotMap, Key}; +pub use libs::slotmap::{DenseSlotMap, Key}; pub use crate::library::Library; pub use content::{Page, Section, SerializingPage, SerializingSection}; diff --git a/components/library/src/library.rs b/components/library/src/library.rs index baa9209a31..1a10a9a2f0 100644 --- a/components/library/src/library.rs +++ b/components/library/src/library.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; use std::path::{Path, PathBuf}; -use slotmap::{DefaultKey, DenseSlotMap}; +use libs::slotmap::{DefaultKey, DenseSlotMap}; use crate::content::{Page, Section}; use crate::sorting::{ diff --git a/components/library/src/pagination/mod.rs b/components/library/src/pagination/mod.rs index 899b20bbcf..99b059a912 100644 --- a/components/library/src/pagination/mod.rs +++ b/components/library/src/pagination/mod.rs @@ -1,8 +1,9 @@ +use std::borrow::Cow; use std::collections::HashMap; -use serde_derive::Serialize; -use slotmap::DefaultKey; -use tera::{to_value, Context, Tera, Value}; +use libs::slotmap::DefaultKey; +use libs::tera::{to_value, Context, Tera, Value}; +use serde::Serialize; use config::Config; use errors::{Error, Result}; @@ -12,8 +13,6 @@ use crate::content::{Section, SerializingPage, SerializingSection}; use crate::library::Library; use crate::taxonomies::{Taxonomy, TaxonomyItem}; -use std::borrow::Cow; - #[derive(Clone, Debug, PartialEq)] enum PaginationRoot<'a> { Section(&'a Section), @@ -256,8 +255,8 @@ impl<'a> Paginator<'a> { #[cfg(test)] mod tests { + use libs::tera::{to_value, Tera}; use std::path::PathBuf; - use tera::{to_value, Tera}; use crate::content::{Page, Section}; use crate::library::Library; diff --git a/components/library/src/sorting.rs b/components/library/src/sorting.rs index f0b8f9b3f4..69b5ec2f73 100644 --- a/components/library/src/sorting.rs +++ b/components/library/src/sorting.rs @@ -1,9 +1,9 @@ use std::cmp::Ordering; -use chrono::NaiveDateTime; -use lexical_sort::natural_lexical_cmp; -use rayon::prelude::*; -use slotmap::DefaultKey; +use libs::chrono::NaiveDateTime; +use libs::lexical_sort::natural_lexical_cmp; +use libs::rayon::prelude::*; +use libs::slotmap::DefaultKey; use crate::content::Page; @@ -111,7 +111,7 @@ pub fn find_siblings( #[cfg(test)] mod tests { - use slotmap::DenseSlotMap; + use libs::slotmap::DenseSlotMap; use std::path::PathBuf; use super::{find_siblings, sort_pages_by_date, sort_pages_by_title, sort_pages_by_weight}; diff --git a/components/library/src/taxonomies/mod.rs b/components/library/src/taxonomies/mod.rs index 99ed14c57b..241f7b9847 100644 --- a/components/library/src/taxonomies/mod.rs +++ b/components/library/src/taxonomies/mod.rs @@ -1,9 +1,9 @@ use std::cmp::Ordering; use std::collections::HashMap; -use serde_derive::Serialize; -use slotmap::DefaultKey; -use tera::{Context, Tera}; +use libs::slotmap::DefaultKey; +use libs::tera::{Context, Tera}; +use serde::Serialize; use config::{Config, Taxonomy as TaxonomyConfig}; use errors::{bail, Error, Result}; diff --git a/components/libs/Cargo.toml b/components/libs/Cargo.toml new file mode 100644 index 0000000000..4396176296 --- /dev/null +++ b/components/libs/Cargo.toml @@ -0,0 +1,54 @@ +[package] +name = "libs" +version = "0.1.0" +edition = "2021" + +[dependencies] +tera = { version = "1", features = ["preserve_order"] } +toml = "0.5" +csv = "1" +base64 = "0.13" +serde_json = "1" +serde_yaml = "0.8" +url = "2" +syntect = "4" +once_cell = "1" +globset = "0.4" +unic-langid = "0.9" +image = "0.23" +regex = "1" +# TODO: replace chrono with time +chrono = { version = "0.4", features = ["serde"] } +rayon = "1" +webp = "0.2" +svg_metadata = "0.4" +slotmap = "1" +lexical-sort = "0.3" +walkdir = "2" +pulldown-cmark = { version = "0.8", default-features = false } +gh-emoji = "1" +elasticlunr-rs = {version = "2", default-features = false, features = ["da", "no", "de", "du", "es", "fi", "fr", "it", "pt", "ro", "ru", "sv", "tr"] } +ammonia = "3" +nom-bibtex = "0.3" +num-format = "0.4" +sha2 = "0.10" +unicode-segmentation = "1.2" +slug = "0.1" +percent-encoding = "2" +filetime = "0.2" +minify-html = "0.8" +reqwest = {version = "0.11", default-features = false, features = ["blocking"]} +sass-rs = "0.2" +relative-path = "1" +glob = "0.3" + + +[dev-dependencies] +mockito = "0.30" + + +[features] +rust-tls = ["reqwest/rustls-tls"] +native-tls = ["reqwest/default-tls"] +indexing-zh = ["elasticlunr-rs/zh"] +indexing-ja = ["elasticlunr-rs/ja"] diff --git a/components/libs/src/lib.rs b/components/libs/src/lib.rs new file mode 100644 index 0000000000..4d12f2d700 --- /dev/null +++ b/components/libs/src/lib.rs @@ -0,0 +1,42 @@ +//! This component is only there to re-export libraries used in the rest of the sub-crates +//! without having to add them to each `Cargo.toml`. This way, updating a library version only requires +//! modifying one crate instead of eg updating Tera in 5 sub crates using it. It also means if you want +//! to define features, it is done in a single place. +//! It doesn't work for crates exporting macros like `serde` or dev deps but that's ok for most. + +pub use ammonia; +pub use base64; +pub use chrono; +pub use csv; +pub use elasticlunr; +pub use filetime; +pub use gh_emoji; +pub use glob; +pub use globset; +pub use image; +pub use lexical_sort; +pub use minify_html; +pub use nom_bibtex; +pub use num_format; +pub use once_cell; +pub use percent_encoding; +pub use pulldown_cmark; +pub use rayon; +pub use regex; +pub use relative_path; +pub use reqwest; +pub use sass_rs; +pub use serde_json; +pub use serde_yaml; +pub use sha2; +pub use slotmap; +pub use slug; +pub use svg_metadata; +pub use syntect; +pub use tera; +pub use toml; +pub use unic_langid; +pub use unicode_segmentation; +pub use url; +pub use walkdir; +pub use webp; diff --git a/components/link_checker/Cargo.toml b/components/link_checker/Cargo.toml index 4b4bca42d4..d0d6a2c649 100644 --- a/components/link_checker/Cargo.toml +++ b/components/link_checker/Cargo.toml @@ -1,24 +1,13 @@ [package] name = "link_checker" version = "0.1.0" -authors = ["Vincent Prouillet "] -edition = "2018" +edition = "2021" [dependencies] -lazy_static = "1" - config = { path = "../config" } errors = { path = "../errors" } utils = { path = "../utils" } - -[dependencies.reqwest] -version = "0.11" -default-features = false -features = ["blocking"] +libs = { path = "../libs" } [dev-dependencies] mockito = "0.30" - -[features] -rust-tls = ["reqwest/rustls-tls"] -native-tls = ["reqwest/default-tls"] diff --git a/components/link_checker/src/lib.rs b/components/link_checker/src/lib.rs index 48502d7b3a..8baadce519 100644 --- a/components/link_checker/src/lib.rs +++ b/components/link_checker/src/lib.rs @@ -1,12 +1,13 @@ -use lazy_static::lazy_static; -use reqwest::header::{HeaderMap, ACCEPT}; -use reqwest::{blocking::Client, StatusCode}; - -use config::LinkChecker; - use std::collections::HashMap; use std::result; use std::sync::{Arc, RwLock}; + +use libs::once_cell::sync::Lazy; +use libs::reqwest::header::{HeaderMap, ACCEPT}; +use libs::reqwest::{blocking::Client, StatusCode}; + +use config::LinkChecker; + use utils::links::has_anchor_id; pub type Result = result::Result; @@ -25,10 +26,9 @@ pub fn message(res: &Result) -> String { } } -lazy_static! { - // Keep history of link checks so a rebuild doesn't have to check again - static ref LINKS: Arc>> = Arc::new(RwLock::new(HashMap::new())); -} +// Keep history of link checks so a rebuild doesn't have to check again +static LINKS: Lazy>>> = + Lazy::new(|| Arc::new(RwLock::new(HashMap::new()))); pub fn check_url(url: &str, config: &LinkChecker) -> Result { { @@ -106,8 +106,7 @@ fn check_page_for_anchor(url: &str, body: String) -> errors::Result<()> { let index = url.find('#').unwrap(); let anchor = url.get(index + 1..).unwrap(); - - if has_anchor_id(&body, &anchor){ + if has_anchor_id(&body, &anchor) { Ok(()) } else { Err(errors::Error::from(format!("Anchor `#{}` not found on page", anchor))) @@ -119,8 +118,8 @@ mod tests { use super::{ check_page_for_anchor, check_url, has_anchor, is_valid, message, LinkChecker, LINKS, }; + use libs::reqwest::StatusCode; use mockito::mock; - use reqwest::StatusCode; // NOTE: HTTP mock paths below are randomly generated to avoid name // collisions. Mocks with the same path can sometimes bleed between tests diff --git a/components/rendering/Cargo.toml b/components/rendering/Cargo.toml index 74b6475c29..58c6c49e45 100644 --- a/components/rendering/Cargo.toml +++ b/components/rendering/Cargo.toml @@ -1,27 +1,20 @@ [package] name = "rendering" version = "0.1.0" -authors = ["Vincent Prouillet "] -edition = "2018" +edition = "2021" include = ["src/**/*"] [dependencies] -tera = { version = "1", features = ["preserve_order"] } -syntect = "4" -pulldown-cmark = { version = "0.8", default-features = false } -serde = "1" -serde_derive = "1" +serde = {version = "1.0", features = ["derive"] } pest = "2" pest_derive = "2" -regex = "1" -lazy_static = "1" -gh-emoji = "1.0" errors = { path = "../errors" } front_matter = { path = "../front_matter" } utils = { path = "../utils" } config = { path = "../config" } link_checker = { path = "../link_checker" } +libs = { path = "../libs" } [dev-dependencies] templates = { path = "../templates" } diff --git a/components/rendering/src/codeblock/highlight.rs b/components/rendering/src/codeblock/highlight.rs index d14aec29e0..1870e0f04f 100644 --- a/components/rendering/src/codeblock/highlight.rs +++ b/components/rendering/src/codeblock/highlight.rs @@ -1,13 +1,13 @@ use std::fmt::Write; use config::highlighting::{SyntaxAndTheme, CLASS_STYLE}; -use syntect::easy::HighlightLines; -use syntect::highlighting::{Color, Theme}; -use syntect::html::{ +use libs::syntect::easy::HighlightLines; +use libs::syntect::highlighting::{Color, Theme}; +use libs::syntect::html::{ line_tokens_to_classed_spans, styled_line_to_highlighted_html, ClassStyle, IncludeBackground, }; -use syntect::parsing::{ParseState, ScopeStack, SyntaxReference, SyntaxSet}; -use tera::escape_html; +use libs::syntect::parsing::{ParseState, ScopeStack, SyntaxReference, SyntaxSet}; +use libs::tera::escape_html; /// Not public, but from syntect::html fn write_css_color(s: &mut String, c: Color) { @@ -192,7 +192,7 @@ mod tests { use super::*; use config::highlighting::resolve_syntax_and_theme; use config::Config; - use syntect::util::LinesWithEndings; + use libs::syntect::util::LinesWithEndings; #[test] fn can_highlight_with_classes() { diff --git a/components/rendering/src/codeblock/mod.rs b/components/rendering/src/codeblock/mod.rs index df1c60492e..5c9a463143 100644 --- a/components/rendering/src/codeblock/mod.rs +++ b/components/rendering/src/codeblock/mod.rs @@ -3,7 +3,7 @@ mod highlight; use std::ops::RangeInclusive; -use syntect::util::LinesWithEndings; +use libs::syntect::util::LinesWithEndings; use crate::codeblock::highlight::SyntaxHighlighter; use config::highlighting::{resolve_syntax_and_theme, HighlightSource}; diff --git a/components/rendering/src/context.rs b/components/rendering/src/context.rs index 1bc23c6388..179dd31965 100644 --- a/components/rendering/src/context.rs +++ b/components/rendering/src/context.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use config::Config; use front_matter::InsertAnchor; -use tera::{Context, Tera}; +use libs::tera::{Context, Tera}; use utils::templates::ShortcodeDefinition; /// All the information from the zola site that is needed to render HTML from markdown diff --git a/components/rendering/src/markdown.rs b/components/rendering/src/markdown.rs index 4181c2dcb3..65ceba621b 100644 --- a/components/rendering/src/markdown.rs +++ b/components/rendering/src/markdown.rs @@ -1,5 +1,7 @@ -use lazy_static::lazy_static; -use pulldown_cmark as cmark; +use libs::gh_emoji::Replacer as EmojiReplacer; +use libs::once_cell::sync::Lazy; +use libs::pulldown_cmark as cmark; +use libs::tera; use crate::context::RenderContext; use crate::table_of_contents::{make_table_of_contents, Heading}; @@ -15,6 +17,7 @@ use crate::shortcode::{Shortcode, SHORTCODE_PLACEHOLDER}; const CONTINUE_READING: &str = ""; const ANCHOR_LINK_TEMPLATE: &str = "anchor-link.html"; +static EMOJI_REPLACER: Lazy = Lazy::new(|| EmojiReplacer::new()); #[derive(Debug)] pub struct Rendered { @@ -146,10 +149,6 @@ pub fn markdown_to_html( context: &RenderContext, html_shortcodes: Vec, ) -> Result { - lazy_static! { - static ref EMOJI_REPLACER: gh_emoji::Replacer = gh_emoji::Replacer::new(); - } - let path = context .tera_context .get("page") diff --git a/components/rendering/src/shortcode/mod.rs b/components/rendering/src/shortcode/mod.rs index 7c142f8927..4239ed4d37 100644 --- a/components/rendering/src/shortcode/mod.rs +++ b/components/rendering/src/shortcode/mod.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use errors::{Error, Result}; +use libs::tera; use utils::templates::{ShortcodeDefinition, ShortcodeFileType}; mod parser; diff --git a/components/rendering/src/shortcode/parser.rs b/components/rendering/src/shortcode/parser.rs index bcb14116bc..fefecd7291 100644 --- a/components/rendering/src/shortcode/parser.rs +++ b/components/rendering/src/shortcode/parser.rs @@ -1,11 +1,11 @@ use std::ops::Range; use errors::{bail, Result}; +use libs::tera::{to_value, Context, Map, Tera, Value}; use pest::iterators::Pair; use pest::Parser; use pest_derive::Parser; use std::collections::HashMap; -use tera::{to_value, Context, Map, Tera, Value}; use utils::templates::ShortcodeFileType; pub const SHORTCODE_PLACEHOLDER: &str = "@@ZOLA_SC_PLACEHOLDER@@"; diff --git a/components/rendering/src/table_of_contents.rs b/components/rendering/src/table_of_contents.rs index 8e7773d012..75bbf21487 100644 --- a/components/rendering/src/table_of_contents.rs +++ b/components/rendering/src/table_of_contents.rs @@ -1,4 +1,4 @@ -use serde_derive::Serialize; +use serde::Serialize; /// Populated while receiving events from the markdown parser #[derive(Debug, Default, PartialEq, Clone, Serialize)] diff --git a/components/rendering/tests/codeblock_hide_lines.rs b/components/rendering/tests/codeblock_hide_lines.rs index 72a2f8dc66..37ee279a29 100644 --- a/components/rendering/tests/codeblock_hide_lines.rs +++ b/components/rendering/tests/codeblock_hide_lines.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use tera::Tera; +use libs::tera::Tera; use config::Config; use front_matter::InsertAnchor; diff --git a/components/rendering/tests/codeblock_hl_lines.rs b/components/rendering/tests/codeblock_hl_lines.rs index e002a06529..700818082d 100644 --- a/components/rendering/tests/codeblock_hl_lines.rs +++ b/components/rendering/tests/codeblock_hl_lines.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use tera::Tera; +use libs::tera::Tera; use config::Config; use front_matter::InsertAnchor; diff --git a/components/rendering/tests/codeblock_linenos.rs b/components/rendering/tests/codeblock_linenos.rs index 94e367dbde..d974c32c6c 100644 --- a/components/rendering/tests/codeblock_linenos.rs +++ b/components/rendering/tests/codeblock_linenos.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use tera::Tera; +use libs::tera::Tera; use config::Config; use front_matter::InsertAnchor; diff --git a/components/rendering/tests/codeblock_shortcode_mix.rs b/components/rendering/tests/codeblock_shortcode_mix.rs index 53a7da4fac..59bb615827 100644 --- a/components/rendering/tests/codeblock_shortcode_mix.rs +++ b/components/rendering/tests/codeblock_shortcode_mix.rs @@ -2,8 +2,8 @@ use std::collections::HashMap; use config::Config; use front_matter::InsertAnchor; -use templates::ZOLA_TERA; use rendering::{render_content, RenderContext}; +use templates::ZOLA_TERA; #[test] fn can_render_shortcode_in_codeblock() { @@ -268,4 +268,4 @@ A quote "# ); -} \ No newline at end of file +} diff --git a/components/rendering/tests/integration.rs b/components/rendering/tests/integration.rs index 29606c8e2d..61f9aebe53 100644 --- a/components/rendering/tests/integration.rs +++ b/components/rendering/tests/integration.rs @@ -1,6 +1,7 @@ mod common; use common::ShortCode; +use libs::tera; const COMPLETE_PAGE: &str = r#" diff --git a/components/rendering/tests/links.rs b/components/rendering/tests/links.rs index bc735cf768..bfa97014c8 100644 --- a/components/rendering/tests/links.rs +++ b/components/rendering/tests/links.rs @@ -4,6 +4,7 @@ use errors::Result; use rendering::Rendered; mod common; +use libs::tera; fn render_content(content: &str, permalinks: HashMap) -> Result { let config = config::Config::default_for_test(); diff --git a/components/rendering/tests/markdown.rs b/components/rendering/tests/markdown.rs index bcd0eda297..07b0a67ecc 100644 --- a/components/rendering/tests/markdown.rs +++ b/components/rendering/tests/markdown.rs @@ -4,6 +4,7 @@ use tera::Tera; use config::Config; use front_matter::InsertAnchor; +use libs::tera; use rendering::{render_content, RenderContext}; use templates::ZOLA_TERA; use utils::slugs::SlugifyStrategy; diff --git a/components/rendering/tests/spec.rs b/components/rendering/tests/spec.rs index 7e255f9227..751860fc1a 100644 --- a/components/rendering/tests/spec.rs +++ b/components/rendering/tests/spec.rs @@ -1,6 +1,7 @@ mod common; use common::ShortCode; +use libs::tera; use std::path::PathBuf; use templates::ZOLA_TERA; diff --git a/components/rendering/tests/summary.rs b/components/rendering/tests/summary.rs index c5d9de5a95..b5df18a309 100644 --- a/components/rendering/tests/summary.rs +++ b/components/rendering/tests/summary.rs @@ -1,6 +1,7 @@ mod common; use common::ShortCode; +use libs::tera; macro_rules! test_scenario_summary { ($in_str:literal, $summary:literal, [$($shortcodes:ident),*]) => { diff --git a/components/rendering/tests/toc.rs b/components/rendering/tests/toc.rs index d1b0f947c3..ecf05e3fe0 100644 --- a/components/rendering/tests/toc.rs +++ b/components/rendering/tests/toc.rs @@ -1,6 +1,7 @@ mod common; use common::ShortCode; +use libs::tera; use rendering::Heading; #[derive(PartialEq, Debug)] diff --git a/components/search/Cargo.toml b/components/search/Cargo.toml index bb01dcc9e6..f80fcfe58d 100644 --- a/components/search/Cargo.toml +++ b/components/search/Cargo.toml @@ -1,19 +1,10 @@ [package] name = "search" version = "0.1.0" -authors = ["Vincent Prouillet "] -edition = "2018" +edition = "2021" [dependencies] -elasticlunr-rs = {version = "2", default-features = false, features = ["da", "no", "de", "du", "es", "fi", "fr", "it", "pt", "ro", "ru", "sv", "tr"] } -ammonia = "3" -lazy_static = "1" - errors = { path = "../errors" } library = { path = "../library" } config = { path = "../config" } - -[features] -default = [] -indexing-zh = ["elasticlunr-rs/zh"] -indexing-ja = ["elasticlunr-rs/ja"] +libs = { path = "../libs" } diff --git a/components/search/src/lib.rs b/components/search/src/lib.rs index d53e59e855..2a7d1eba22 100644 --- a/components/search/src/lib.rs +++ b/components/search/src/lib.rs @@ -1,9 +1,10 @@ use std::collections::{HashMap, HashSet}; -use elasticlunr::pipeline; -use elasticlunr::pipeline::TokenizerFn; -use elasticlunr::{Index, Language}; -use lazy_static::lazy_static; +use libs::ammonia; +use libs::elasticlunr::pipeline; +use libs::elasticlunr::pipeline::TokenizerFn; +use libs::elasticlunr::{Index, Language}; +use libs::once_cell::sync::Lazy; use config::{Config, Search}; use errors::{bail, Result}; @@ -11,22 +12,20 @@ use library::{Library, Section}; pub const ELASTICLUNR_JS: &str = include_str!("elasticlunr.min.js"); -lazy_static! { - static ref AMMONIA: ammonia::Builder<'static> = { - let mut clean_content = HashSet::new(); - clean_content.insert("script"); - clean_content.insert("style"); - let mut builder = ammonia::Builder::new(); - builder - .tags(HashSet::new()) - .tag_attributes(HashMap::new()) - .generic_attributes(HashSet::new()) - .link_rel(None) - .allowed_classes(HashMap::new()) - .clean_content_tags(clean_content); - builder - }; -} +static AMMONIA: Lazy> = Lazy::new(|| { + let mut clean_content = HashSet::new(); + clean_content.insert("script"); + clean_content.insert("style"); + let mut builder = ammonia::Builder::new(); + builder + .tags(HashSet::new()) + .tag_attributes(HashMap::new()) + .generic_attributes(HashSet::new()) + .link_rel(None) + .allowed_classes(HashMap::new()) + .clean_content_tags(clean_content); + builder +}); fn build_fields(search_config: &Search) -> Vec { let mut fields = vec![]; diff --git a/components/site/Cargo.toml b/components/site/Cargo.toml index d8589dac63..9ad630e676 100644 --- a/components/site/Cargo.toml +++ b/components/site/Cargo.toml @@ -6,17 +6,7 @@ edition = "2018" include = ["src/**/*"] [dependencies] -tera = "1" -glob = "0.3" -walkdir = "2" -rayon = "1" -serde = "1" -serde_derive = "1" -sass-rs = "0.2" -lazy_static = "1.1" -relative-path = "1" -slotmap = "1" -url = "2" +serde = { version = "1.0", features = ["derive"] } errors = { path = "../errors" } config = { path = "../config" } @@ -27,12 +17,8 @@ search = { path = "../search" } imageproc = { path = "../imageproc" } library = { path = "../library" } link_checker = { path = "../link_checker" } +libs = { path = "../libs" } [dev-dependencies] tempfile = "3" path-slash = "0.1.4" - -[features] -default = [] -rust-tls = ["templates/rust-tls", "link_checker/rust-tls"] -native-tls = ["templates/native-tls", "link_checker/native-tls"] diff --git a/components/site/src/feed.rs b/components/site/src/feed.rs index b64ea79550..1413acecb1 100644 --- a/components/site/src/feed.rs +++ b/components/site/src/feed.rs @@ -1,8 +1,8 @@ use std::path::PathBuf; -use rayon::prelude::*; -use serde_derive::Serialize; -use tera::Context; +use libs::rayon::prelude::*; +use libs::tera::Context; +use serde::Serialize; use crate::Site; use errors::Result; diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 2d80a09df5..548f6a41e7 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -9,16 +9,17 @@ use std::fs::remove_dir_all; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex, RwLock}; -use lazy_static::lazy_static; -use rayon::prelude::*; -use tera::{Context, Tera}; -use walkdir::{DirEntry, WalkDir}; +// use lazy_static::lazy_static; +use libs::once_cell::sync::Lazy; +use libs::rayon::prelude::*; +use libs::tera::{Context, Tera}; +use libs::walkdir::{DirEntry, WalkDir}; use config::{get_config, Config}; use errors::{bail, Error, Result}; use front_matter::InsertAnchor; use library::{find_taxonomies, Library, Page, Paginator, Section, Taxonomy}; -use relative_path::RelativePathBuf; +use libs::relative_path::RelativePathBuf; use std::time::Instant; use templates::{load_tera, render_redirect_template}; use utils::fs::{ @@ -28,10 +29,8 @@ use utils::minify; use utils::net::get_available_port; use utils::templates::{render_template, ShortcodeDefinition}; -lazy_static! { - /// The in-memory rendered map content - pub static ref SITE_CONTENT: Arc>> = Arc::new(RwLock::new(HashMap::new())); -} +pub static SITE_CONTENT: Lazy>>> = + Lazy::new(|| Arc::new(RwLock::new(HashMap::new()))); /// Where are we building the site #[derive(Debug, Clone, Copy, Eq, PartialEq)] diff --git a/components/site/src/link_checking.rs b/components/site/src/link_checking.rs index b42b2d1a62..33dbe519a8 100644 --- a/components/site/src/link_checking.rs +++ b/components/site/src/link_checking.rs @@ -1,11 +1,12 @@ -use rayon::prelude::*; +use libs::rayon::prelude::*; use crate::Site; use core::time; use errors::{bail, Result}; use errors::{Error, ErrorKind}; +use libs::rayon; +use libs::url::Url; use std::{collections::HashMap, path::PathBuf, thread}; -use url::Url; /// Check whether all internal links pointing to explicit anchor fragments are valid. /// @@ -64,7 +65,7 @@ pub fn check_internal_links_with_anchors(site: &Site) -> Result<()> { .get_page(&full_path) .expect("Couldn't find section in check_internal_links_with_anchors"); - !(page.has_anchor(anchor)||page.has_anchor_id(anchor)) + !(page.has_anchor(anchor) || page.has_anchor_id(anchor)) } }); diff --git a/components/site/src/sass.rs b/components/site/src/sass.rs index df0d373ac6..42c2440afe 100644 --- a/components/site/src/sass.rs +++ b/components/site/src/sass.rs @@ -1,8 +1,8 @@ use std::fs::create_dir_all; use std::path::{Path, PathBuf}; -use glob::glob; -use sass_rs::{compile_file, Options, OutputStyle}; +use libs::glob::glob; +use libs::sass_rs::{compile_file, Options, OutputStyle}; use errors::{bail, Result}; use utils::fs::{create_file, ensure_directory_exists}; diff --git a/components/site/src/sitemap.rs b/components/site/src/sitemap.rs index c58c749907..c637db66bf 100644 --- a/components/site/src/sitemap.rs +++ b/components/site/src/sitemap.rs @@ -2,12 +2,12 @@ use std::borrow::Cow; use std::collections::HashSet; use std::hash::{Hash, Hasher}; -use serde_derive::Serialize; +use serde::Serialize; use config::Config; use library::{Library, Taxonomy}; +use libs::tera::{Map, Value}; use std::cmp::Ordering; -use tera::{Map, Value}; /// The sitemap only needs links, potentially date and extra for pages in case of updates /// for examples so we trim down all entries to only that diff --git a/components/site/src/tpls.rs b/components/site/src/tpls.rs index 1abee3b2d8..8a91cb90c1 100644 --- a/components/site/src/tpls.rs +++ b/components/site/src/tpls.rs @@ -1,6 +1,6 @@ use crate::Site; +use libs::tera::Result as TeraResult; use templates::{filters, global_fns}; -use tera::Result as TeraResult; /// Adds global fns that are to be available to shortcodes while rendering markdown pub fn register_early_global_fns(site: &mut Site) -> TeraResult<()> { diff --git a/components/templates/Cargo.toml b/components/templates/Cargo.toml index a4e73374b4..81c236757d 100644 --- a/components/templates/Cargo.toml +++ b/components/templates/Cargo.toml @@ -1,22 +1,10 @@ [package] name = "templates" version = "0.1.0" -authors = ["Vincent Prouillet "] -edition = "2018" +edition = "2021" [dependencies] -tera = "1" -base64 = "0.13" -lazy_static = "1" -toml = "0.5" -csv = "1" -serde = "1" -serde_json = "1" -serde_derive = "1" -sha2 = "0.10" -url = "2" -nom-bibtex = "0.3" -num-format = "0.4" +serde = {version = "1.0", features = ["derive"] } errors = { path = "../errors" } utils = { path = "../utils" } @@ -24,16 +12,9 @@ library = { path = "../library" } config = { path = "../config" } imageproc = { path = "../imageproc" } rendering = { path = "../rendering" } +libs = { path = "../libs" } -[dependencies.reqwest] -version = "0.11" -default-features = false -features = ["blocking"] [dev-dependencies] mockito = "0.30" tempfile = "3" - -[features] -rust-tls = ["reqwest/rustls-tls"] -native-tls = ["reqwest/default-tls"] diff --git a/components/templates/src/filters.rs b/components/templates/src/filters.rs index 9acb03b50a..eaab13cf1c 100644 --- a/components/templates/src/filters.rs +++ b/components/templates/src/filters.rs @@ -3,13 +3,13 @@ use std::collections::HashMap; use std::hash::BuildHasher; use std::path::PathBuf; -use base64::{decode, encode}; use config::Config; -use rendering::{render_content, RenderContext}; -use tera::{ +use libs::base64::{decode, encode}; +use libs::tera::{ to_value, try_get_value, Error as TeraError, Filter as TeraFilter, Result as TeraResult, Tera, Value, }; +use rendering::{render_content, RenderContext}; use crate::load_tera; @@ -26,7 +26,7 @@ impl MarkdownFilter { config: Config, permalinks: HashMap, ) -> TeraResult { - let tera = load_tera(&path, &config).map_err(tera::Error::msg)?; + let tera = load_tera(&path, &config).map_err(TeraError::msg)?; Ok(Self { config, permalinks, tera }) } } @@ -94,7 +94,7 @@ impl NumFormatFilter { impl TeraFilter for NumFormatFilter { fn filter(&self, value: &Value, args: &HashMap) -> TeraResult { - use num_format::{Locale, ToFormattedString}; + use libs::num_format::{Locale, ToFormattedString}; let num = try_get_value!("num_format", "value", i64, value); let locale = match args.get("locale") { @@ -115,7 +115,7 @@ impl TeraFilter for NumFormatFilter { mod tests { use std::{collections::HashMap, path::PathBuf}; - use tera::{to_value, Filter}; + use libs::tera::{to_value, Error as TeraError, Filter}; use super::{base64_decode, base64_encode, MarkdownFilter, NumFormatFilter}; use config::Config; @@ -137,8 +137,7 @@ mod tests { let args = HashMap::new(); let config = Config::default(); let permalinks = HashMap::new(); - let mut tera = - super::load_tera(&PathBuf::new(), &config).map_err(tera::Error::msg).unwrap(); + let mut tera = super::load_tera(&PathBuf::new(), &config).map_err(TeraError::msg).unwrap(); tera.add_raw_template("shortcodes/explicitlang.html", "a{{ lang }}a").unwrap(); let filter = MarkdownFilter { config, permalinks, tera }; let result = filter.filter(&to_value(&"{{ explicitlang(lang='jp') }}").unwrap(), &args); diff --git a/components/templates/src/global_fns/content.rs b/components/templates/src/global_fns/content.rs index fafb226278..dfe0035a9a 100644 --- a/components/templates/src/global_fns/content.rs +++ b/components/templates/src/global_fns/content.rs @@ -1,8 +1,8 @@ use library::{Library, Taxonomy}; +use libs::tera::{from_value, to_value, Function as TeraFn, Result, Value}; use std::collections::HashMap; use std::path::PathBuf; use std::sync::{Arc, RwLock}; -use tera::{from_value, to_value, Function as TeraFn, Result, Value}; use utils::slugs::{slugify_paths, SlugifyStrategy}; #[derive(Debug)] diff --git a/components/templates/src/global_fns/files.rs b/components/templates/src/global_fns/files.rs index 13e95117bd..cd9bb99d87 100644 --- a/components/templates/src/global_fns/files.rs +++ b/components/templates/src/global_fns/files.rs @@ -3,10 +3,11 @@ use std::path::PathBuf; use std::{fs, io, result}; use crate::global_fns::helpers::search_for_file; -use base64::encode as encode_b64; use config::Config; -use sha2::{digest, Sha256, Sha384, Sha512}; -use tera::{from_value, to_value, Function as TeraFn, Result, Value}; +use libs::base64::encode as encode_b64; +use libs::sha2::{digest, Sha256, Sha384, Sha512}; +use libs::tera::{from_value, to_value, Function as TeraFn, Result, Value}; +use libs::url; use utils::site::resolve_internal_link; fn compute_file_hash( @@ -233,8 +234,8 @@ mod tests { use std::fs::create_dir; use std::path::PathBuf; + use libs::tera::{to_value, Function}; use tempfile::{tempdir, TempDir}; - use tera::{to_value, Function}; use config::Config; use utils::fs::create_file; diff --git a/components/templates/src/global_fns/i18n.rs b/components/templates/src/global_fns/i18n.rs index b1bf76d144..e859e0f802 100644 --- a/components/templates/src/global_fns/i18n.rs +++ b/components/templates/src/global_fns/i18n.rs @@ -1,4 +1,4 @@ -use tera::{from_value, to_value, Error, Function as TeraFn, Result, Value}; +use libs::tera::{from_value, to_value, Error, Function as TeraFn, Result, Value}; use config::Config; use std::collections::HashMap; diff --git a/components/templates/src/global_fns/images.rs b/components/templates/src/global_fns/images.rs index 6e0c06fecf..e9aad501cb 100644 --- a/components/templates/src/global_fns/images.rs +++ b/components/templates/src/global_fns/images.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::path::PathBuf; use std::sync::{Arc, Mutex}; -use tera::{from_value, to_value, Function as TeraFn, Result, Value}; +use libs::tera::{from_value, to_value, Function as TeraFn, Result, Value}; use crate::global_fns::helpers::search_for_file; @@ -144,10 +144,10 @@ mod tests { use std::fs::{copy, create_dir_all}; use config::Config; + use libs::tera::{to_value, Function}; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use tempfile::{tempdir, TempDir}; - use tera::{to_value, Function}; fn create_dir_with_image() -> TempDir { let dir = tempdir().unwrap(); diff --git a/components/templates/src/global_fns/load_data.rs b/components/templates/src/global_fns/load_data.rs index 366b3be9f7..1b31a2ab60 100644 --- a/components/templates/src/global_fns/load_data.rs +++ b/components/templates/src/global_fns/load_data.rs @@ -5,11 +5,14 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::{Arc, Mutex}; -use csv::Reader; -use reqwest::header::{HeaderMap, HeaderName, HeaderValue, CONTENT_TYPE}; -use reqwest::{blocking::Client, header}; -use tera::{from_value, to_value, Error, Function as TeraFn, Map, Result, Value}; -use url::Url; +use libs::csv::Reader; +use libs::reqwest::header::{HeaderMap, HeaderName, HeaderValue, CONTENT_TYPE}; +use libs::reqwest::{blocking::Client, header}; +use libs::tera::{ + from_value, to_value, Error, Error as TeraError, Function as TeraFn, Map, Result, Value, +}; +use libs::url::Url; +use libs::{nom_bibtex, serde_json, toml}; use utils::de::fix_toml_dates; use utils::fs::{get_file_time, read_file}; @@ -476,7 +479,7 @@ fn load_csv(csv_data: String) -> Result { let record = match result { Ok(r) => r, Err(e) => { - return Err(tera::Error::chain( + return Err(TeraError::chain( String::from("Error encountered when parsing csv records"), e, )); @@ -507,11 +510,11 @@ mod tests { use std::path::PathBuf; use crate::global_fns::load_data::Method; + use libs::serde_json::json; + use libs::tera::{self, to_value, Function}; use mockito::mock; - use serde_json::json; use std::fs::{copy, create_dir_all}; use tempfile::tempdir; - use tera::{to_value, Function}; // NOTE: HTTP mock paths below are randomly generated to avoid name // collisions. Mocks with the same path can sometimes bleed between tests diff --git a/components/templates/src/lib.rs b/components/templates/src/lib.rs index 7104e543aa..735fee3928 100644 --- a/components/templates/src/lib.rs +++ b/components/templates/src/lib.rs @@ -4,47 +4,42 @@ pub mod global_fns; use std::path::Path; use config::Config; -use lazy_static::lazy_static; -use tera::{Context, Tera}; +use libs::once_cell::sync::Lazy; +use libs::tera::{Context, Tera}; use errors::{bail, Error, Result}; use utils::templates::rewrite_theme_paths; -lazy_static! { - pub static ref ZOLA_TERA: Tera = { - let mut tera = Tera::default(); - tera.add_raw_templates(vec![ - ("__zola_builtins/404.html", include_str!("builtins/404.html")), - ("__zola_builtins/atom.xml", include_str!("builtins/atom.xml")), - ("__zola_builtins/rss.xml", include_str!("builtins/rss.xml")), - ("__zola_builtins/sitemap.xml", include_str!("builtins/sitemap.xml")), - ("__zola_builtins/robots.txt", include_str!("builtins/robots.txt")), - ( - "__zola_builtins/split_sitemap_index.xml", - include_str!("builtins/split_sitemap_index.xml"), - ), - ("__zola_builtins/anchor-link.html", include_str!("builtins/anchor-link.html")), - ( - "__zola_builtins/shortcodes/youtube.html", - include_str!("builtins/shortcodes/youtube.html"), - ), - ( - "__zola_builtins/shortcodes/vimeo.html", - include_str!("builtins/shortcodes/vimeo.html"), - ), - ("__zola_builtins/shortcodes/gist.html", include_str!("builtins/shortcodes/gist.html")), - ( - "__zola_builtins/shortcodes/streamable.html", - include_str!("builtins/shortcodes/streamable.html"), - ), - ("internal/alias.html", include_str!("builtins/internal/alias.html")), - ]) - .unwrap(); - tera.register_filter("base64_encode", filters::base64_encode); - tera.register_filter("base64_decode", filters::base64_decode); - tera - }; -} +pub static ZOLA_TERA: Lazy = Lazy::new(|| { + let mut tera = Tera::default(); + tera.add_raw_templates(vec![ + ("__zola_builtins/404.html", include_str!("builtins/404.html")), + ("__zola_builtins/atom.xml", include_str!("builtins/atom.xml")), + ("__zola_builtins/rss.xml", include_str!("builtins/rss.xml")), + ("__zola_builtins/sitemap.xml", include_str!("builtins/sitemap.xml")), + ("__zola_builtins/robots.txt", include_str!("builtins/robots.txt")), + ( + "__zola_builtins/split_sitemap_index.xml", + include_str!("builtins/split_sitemap_index.xml"), + ), + ("__zola_builtins/anchor-link.html", include_str!("builtins/anchor-link.html")), + ( + "__zola_builtins/shortcodes/youtube.html", + include_str!("builtins/shortcodes/youtube.html"), + ), + ("__zola_builtins/shortcodes/vimeo.html", include_str!("builtins/shortcodes/vimeo.html")), + ("__zola_builtins/shortcodes/gist.html", include_str!("builtins/shortcodes/gist.html")), + ( + "__zola_builtins/shortcodes/streamable.html", + include_str!("builtins/shortcodes/streamable.html"), + ), + ("internal/alias.html", include_str!("builtins/internal/alias.html")), + ]) + .unwrap(); + tera.register_filter("base64_encode", filters::base64_encode); + tera.register_filter("base64_decode", filters::base64_decode); + tera +}); /// Renders the `internal/alias.html` template that will redirect /// via refresh to the url given diff --git a/components/utils/Cargo.toml b/components/utils/Cargo.toml index 07f0399dd4..65c4513381 100644 --- a/components/utils/Cargo.toml +++ b/components/utils/Cargo.toml @@ -6,18 +6,10 @@ edition = "2018" include = ["src/**/*"] [dependencies] -tera = "1" -unicode-segmentation = "1.2" -walkdir = "2" -regex="1" -toml = "0.5" serde = { version = "1.0", features = ["derive"] } -slug = "0.1" -percent-encoding = "2" -filetime = "0.2.12" -minify-html = "0.8" errors = { path = "../errors" } +libs = { path = "../libs" } [dev-dependencies] tempfile = "3" diff --git a/components/utils/src/de.rs b/components/utils/src/de.rs index 20a91d592a..983b31d9da 100644 --- a/components/utils/src/de.rs +++ b/components/utils/src/de.rs @@ -1,5 +1,6 @@ +use libs::tera::{Map, Value}; +use libs::toml; use serde::{Deserialize, Deserializer}; -use tera::{Map, Value}; /// Used as an attribute when we want to convert from TOML to a string date /// If a TOML datetime isn't present, it will accept a string and push it through diff --git a/components/utils/src/fs.rs b/components/utils/src/fs.rs index 7b2a3aeb6d..24301521a6 100644 --- a/components/utils/src/fs.rs +++ b/components/utils/src/fs.rs @@ -1,9 +1,9 @@ -use filetime::{set_file_mtime, FileTime}; +use libs::filetime::{set_file_mtime, FileTime}; +use libs::walkdir::WalkDir; use std::fs::{copy, create_dir_all, metadata, File}; use std::io::prelude::*; use std::path::Path; use std::time::SystemTime; -use walkdir::WalkDir; use errors::{Error, Result}; @@ -183,6 +183,7 @@ mod tests { use std::path::PathBuf; use std::str::FromStr; + use libs::filetime; use tempfile::tempdir_in; use super::copy_file; diff --git a/components/utils/src/links.rs b/components/utils/src/links.rs index 3e18b2ada0..642e58937f 100644 --- a/components/utils/src/links.rs +++ b/components/utils/src/links.rs @@ -1,29 +1,25 @@ -use regex::Regex; - +use libs::regex::Regex; pub fn has_anchor_id(content: &str, anchor: &str) -> bool { let checks = anchor_id_checks(anchor); checks.is_match(content) } -fn anchor_id_checks(anchor:&str) -> Regex { - Regex::new( - &format!(r#" (?i)(id|name) *= *("|')*{}("|'| |>)+"#, anchor) - ).unwrap() +fn anchor_id_checks(anchor: &str) -> Regex { + Regex::new(&format!(r#" (?i)(id|name) *= *("|')*{}("|'| |>)+"#, anchor)).unwrap() } - #[cfg(test)] -mod tests{ +mod tests { use super::anchor_id_checks; - fn check(anchor:&str, content:&str) -> bool { + fn check(anchor: &str, content: &str) -> bool { anchor_id_checks(anchor).is_match(content) } #[test] - fn matchers () { - let m = |content| {check("fred", content)}; + fn matchers() { + let m = |content| check("fred", content); // Canonical match/non match assert!(m(r#""#)); diff --git a/components/utils/src/minify.rs b/components/utils/src/minify.rs index 75160d530b..5cfde316c2 100644 --- a/components/utils/src/minify.rs +++ b/components/utils/src/minify.rs @@ -1,5 +1,5 @@ use errors::{bail, Result}; -use minify_html::{minify, Cfg}; +use libs::minify_html::{minify, Cfg}; pub fn html(html: String) -> Result { let mut cfg = Cfg::spec_compliant(); diff --git a/components/utils/src/site.rs b/components/utils/src/site.rs index d49e559afb..ef57755569 100644 --- a/components/utils/src/site.rs +++ b/components/utils/src/site.rs @@ -1,7 +1,7 @@ -use percent_encoding::percent_decode; +use libs::percent_encoding::percent_decode; +use libs::unicode_segmentation::UnicodeSegmentation; use std::collections::HashMap; use std::hash::BuildHasher; -use unicode_segmentation::UnicodeSegmentation; use errors::Result; diff --git a/components/utils/src/slugs.rs b/components/utils/src/slugs.rs index 8f209254d5..acacd1ee20 100644 --- a/components/utils/src/slugs.rs +++ b/components/utils/src/slugs.rs @@ -1,3 +1,4 @@ +use libs::slug; use serde::{Deserialize, Serialize}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] diff --git a/components/utils/src/templates.rs b/components/utils/src/templates.rs index 814e59bca7..10a2242918 100644 --- a/components/utils/src/templates.rs +++ b/components/utils/src/templates.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use tera::{Context, Tera}; +use libs::tera::{Context, Tera}; use errors::{bail, Result}; @@ -150,7 +150,7 @@ mod tests { use crate::templates::check_template_fallbacks; use super::rewrite_theme_paths; - use tera::Tera; + use libs::tera::Tera; #[test] fn can_rewrite_all_paths_of_theme() { diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index b84655e1f9..fe191f610b 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -34,14 +34,16 @@ use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Method, Request, Response, StatusCode}; use mime_guess::from_path as mimetype_from_path; -use chrono::prelude::*; +use libs::chrono::prelude::*; +use libs::percent_encoding; +use libs::serde_json; use notify::{watcher, RecursiveMode, Watcher}; use ws::{Message, Sender, WebSocket}; use errors::{Error as ZolaError, Result}; -use globset::GlobSet; +use libs::globset::GlobSet; +use libs::relative_path::{RelativePath, RelativePathBuf}; use pathdiff::diff_paths; -use relative_path::{RelativePath, RelativePathBuf}; use site::sass::compile_sass; use site::{Site, SITE_CONTENT}; use utils::fs::copy_file; diff --git a/src/console.rs b/src/console.rs index 84fcde0f9a..14312ce00f 100644 --- a/src/console.rs +++ b/src/console.rs @@ -1,27 +1,20 @@ -use lazy_static::lazy_static; - use std::env; use std::error::Error as StdError; use std::io::Write; use std::time::Instant; -use chrono::Duration; +use libs::chrono::Duration; +use libs::once_cell::sync::Lazy; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use errors::Error; use site::Site; -lazy_static! { - /// Termcolor color choice. - /// We do not rely on ColorChoice::Auto behavior - /// as the check is already performed by has_color. - static ref COLOR_CHOICE: ColorChoice = - if has_color() { - ColorChoice::Always - } else { - ColorChoice::Never - }; -} +/// Termcolor color choice. +/// We do not rely on ColorChoice::Auto behavior +/// as the check is already performed by has_color. +static COLOR_CHOICE: Lazy = + Lazy::new(|| if has_color() { ColorChoice::Always } else { ColorChoice::Never }); pub fn info(message: &str) { colorize(message, ColorSpec::new().set_bold(true)); diff --git a/src/prompt.rs b/src/prompt.rs index 23a993ecd1..343664b750 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -1,7 +1,7 @@ use std::io::{self, BufRead, Write}; use std::time::Duration; -use url::Url; +use libs::url::Url; use crate::console; use errors::Result; From 4cebdc400760c38fa77a562180c7254f77c40949 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Fri, 28 Jan 2022 22:08:02 +0100 Subject: [PATCH 2/4] Remove last direct lazy_static usage --- Cargo.lock | 1 - components/config/Cargo.toml | 2 -- components/config/src/highlighting.rs | 17 ++++++----------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6a58522b7..c9f6617c0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -358,7 +358,6 @@ name = "config" version = "0.1.0" dependencies = [ "errors", - "lazy_static", "libs", "serde", "utils", diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index 00f82e94d7..d7ef4029b6 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -6,8 +6,6 @@ include = ["src/**/*"] [dependencies] serde = {version = "1.0", features = ["derive"] } -# TODO: remove me if we can get highlight to work with once_cell -lazy_static = "1" errors = { path = "../errors" } utils = { path = "../utils" } diff --git a/components/config/src/highlighting.rs b/components/config/src/highlighting.rs index ece852942d..c51a74982e 100644 --- a/components/config/src/highlighting.rs +++ b/components/config/src/highlighting.rs @@ -1,23 +1,18 @@ -use lazy_static::lazy_static; use libs::syntect::dumps::from_binary; use libs::syntect::highlighting::{Theme, ThemeSet}; use libs::syntect::html::ClassStyle; use libs::syntect::parsing::{SyntaxReference, SyntaxSet}; +use libs::once_cell::sync::Lazy; use crate::config::Config; pub const CLASS_STYLE: ClassStyle = ClassStyle::SpacedPrefixed { prefix: "z-" }; -// TODO: replace with once_cell. I was getting malloc error with sync::Lazy -lazy_static! { - pub static ref SYNTAX_SET: SyntaxSet = { - let ss: SyntaxSet = - from_binary(include_bytes!("../../../sublime/syntaxes/newlines.packdump")); - ss - }; - pub static ref THEME_SET: ThemeSet = - from_binary(include_bytes!("../../../sublime/themes/all.themedump")); -} +pub static SYNTAX_SET: Lazy = + Lazy::new(|| from_binary(include_bytes!("../../../sublime/syntaxes/newlines.packdump"))); + +pub static THEME_SET: Lazy = + Lazy::new(|| from_binary(include_bytes!("../../../sublime/themes/all.themedump"))); #[derive(Clone, Debug, PartialEq, Eq)] pub enum HighlightSource { From 79d3f41294c5375fb26ef48a37abf653e2caf989 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Fri, 28 Jan 2022 22:09:12 +0100 Subject: [PATCH 3/4] Update pinned ci version --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ba81d671f0..26c2213a08 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,7 +21,7 @@ stages: rustup_toolchain: stable linux-pinned: imageName: 'ubuntu-20.04' - rustup_toolchain: 1.54.0 + rustup_toolchain: 1.56.0 pool: vmImage: $(imageName) steps: From 6233bdd5fd4c0d93b9f140a852d61105d0725cc6 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 1 Feb 2022 22:36:53 +0100 Subject: [PATCH 4/4] Update deps --- Cargo.lock | 198 +++++++++++++++++++++++++++++-------- components/libs/Cargo.toml | 2 +- 2 files changed, 156 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9f6617c0a..381bcedb15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,6 +116,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bit_field" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" + [[package]] name = "bitflags" version = "1.3.2" @@ -484,12 +490,20 @@ dependencies = [ [[package]] name = "deflate" -version = "0.8.6" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" +checksum = "5f95bf05dffba6e6cce8dfbb30def788154949ccd9aed761b472119c21e01c70" +dependencies = [ + "adler32", +] + +[[package]] +name = "deflate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f" dependencies = [ "adler32", - "byteorder", ] [[package]] @@ -635,6 +649,22 @@ dependencies = [ "libs", ] +[[package]] +name = "exr" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4badb9489a465cb2c555af1f00f0bfd8cecd6fc12ac11da9d5b40c5dd5f0200" +dependencies = [ + "bit_field", + "deflate 1.0.0", + "flume", + "half", + "inflate", + "lebe", + "smallvec", + "threadpool", +] + [[package]] name = "fake-simd" version = "0.1.2" @@ -671,7 +701,20 @@ dependencies = [ "cfg-if 1.0.0", "crc32fast", "libc", - "miniz_oxide 0.4.4", + "miniz_oxide", +] + +[[package]] +name = "flume" +version = "0.10.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d04dafd11240188e146b6f6476a898004cace3be31d4ec5e08e216bf4947ac0" +dependencies = [ + "futures-core", + "futures-sink", + "nanorand", + "pin-project", + "spin 0.9.2", ] [[package]] @@ -855,8 +898,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ "cfg-if 1.0.0", + "js-sys", "libc", "wasi 0.10.2+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -928,6 +973,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "hashbrown" version = "0.11.2" @@ -1093,15 +1144,16 @@ dependencies = [ [[package]] name = "image" -version = "0.23.14" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1" +checksum = "e94ac3d41f882c624a82d7945952032388488681f45f9d4077999a6c85688d61" dependencies = [ "bytemuck", "byteorder", "color_quant", + "exr", "gif", - "jpeg-decoder", + "jpeg-decoder 0.2.1", "num-iter", "num-rational", "num-traits", @@ -1132,6 +1184,15 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "inflate" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" +dependencies = [ + "adler32", +] + [[package]] name = "inotify" version = "0.7.1" @@ -1217,6 +1278,12 @@ name = "jpeg-decoder" version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" + +[[package]] +name = "jpeg-decoder" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbcf0244f6597be39ab8d9203f574cafb529ae8c698afa2182f7b3c3205a4a9c" dependencies = [ "rayon", ] @@ -1252,6 +1319,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "lebe" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7efd1d698db0759e6ef11a7cd44407407399a910c774dd804c64c032da7826ff" + [[package]] name = "lexical-core" version = "0.7.6" @@ -1276,9 +1349,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.114" +version = "0.2.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0005d08a8f7b65fb8073cb697aa0b12b631ed251ce73d862ce50eeb52ce3b50" +checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74" [[package]] name = "library" @@ -1339,9 +1412,9 @@ dependencies = [ [[package]] name = "libwebp-sys" -version = "0.2.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e70c064738b35a28fd6f991d27c0d9680353641d167ae3702a8228dd8272ef6" +checksum = "439fd1885aa28937e7edcd68d2e793cb4a22f8733460d2519fbafd2b215672bf" dependencies = [ "cc", ] @@ -1453,9 +1526,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ "scopeguard", ] @@ -1555,15 +1628,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "miniz_oxide" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" -dependencies = [ - "adler32", -] - [[package]] name = "miniz_oxide" version = "0.4.4" @@ -1657,6 +1721,15 @@ dependencies = [ "serde_urlencoded", ] +[[package]] +name = "nanorand" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "729eb334247daa1803e0a094d0a5c55711b85571179f5ec6e53eccfdf7008958" +dependencies = [ + "getrandom 0.2.4", +] + [[package]] name = "native-tls" version = "0.2.8" @@ -1838,9 +1911,9 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" dependencies = [ "autocfg", "num-integer", @@ -2133,6 +2206,26 @@ dependencies = [ "uncased", ] +[[package]] +name = "pin-project" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.8" @@ -2167,14 +2260,15 @@ dependencies = [ [[package]] name = "png" -version = "0.16.8" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" +checksum = "c845088517daa61e8a57eee40309347cea13f273694d1385c553e7a57127763b" dependencies = [ "bitflags", "crc32fast", - "deflate", - "miniz_oxide 0.3.7", + "deflate 0.9.1", + "encoding", + "miniz_oxide", ] [[package]] @@ -2477,7 +2571,7 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", + "spin 0.5.2", "untrusted", "web-sys", "winapi 0.3.9", @@ -2610,9 +2704,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d09d3c15d814eda1d6a836f2f2b56a6abc1446c8a34351cb3180d3db92ffe4ce" +checksum = "3fed7948b6c68acbb6e20c334f55ad635dc0f75506963de4464289fbd3b051ac" dependencies = [ "bitflags", "core-foundation", @@ -2623,9 +2717,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90dd10c41c6bfc633da6e0c659bd25d31e0791e5974ac42970267d59eba87f7" +checksum = "a57321bf8bc2362081b2599912d2961fe899c0efadf1b4b2f8d48b3e253bb96c" dependencies = [ "core-foundation-sys", "libc", @@ -2776,9 +2870,9 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "socket2" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f82496b90c36d70af5fcd482edaa2e0bd16fade569de1330405fecbbdac736b" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi 0.3.9", @@ -2790,6 +2884,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5" +dependencies = [ + "lock_api", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -3037,14 +3140,23 @@ dependencies = [ "once_cell", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "tiff" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a53f4706d65497df0c4349241deddf35f84cee19c87ed86ea8ca590f4464437" +checksum = "0247608e998cb6ce39dfc8f4a16c50361ce71e5b52e6d24ea1227ea8ea8ee0b2" dependencies = [ - "jpeg-decoder", - "miniz_oxide 0.4.4", + "flate2", + "jpeg-decoder 0.1.22", "weezl", ] @@ -3092,9 +3204,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.15.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" +checksum = "0c27a64b625de6d309e8c57716ba93021dccf1b3b5c97edd6d3dd2d2135afc0a" dependencies = [ "bytes 1.1.0", "libc", @@ -3490,9 +3602,9 @@ dependencies = [ [[package]] name = "webp" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0041a9fcbdbf6402c3cb0ec7c2c1a1c240efd523519a0763ae07753bc95f7713" +checksum = "3f80f6a431ea17cbe9d6958628e553c17d22df62b301b39940a9dfd60f3dd7c6" dependencies = [ "image", "libwebp-sys", diff --git a/components/libs/Cargo.toml b/components/libs/Cargo.toml index 4396176296..12ede7abfe 100644 --- a/components/libs/Cargo.toml +++ b/components/libs/Cargo.toml @@ -15,7 +15,7 @@ syntect = "4" once_cell = "1" globset = "0.4" unic-langid = "0.9" -image = "0.23" +image = "0.24" regex = "1" # TODO: replace chrono with time chrono = { version = "0.4", features = ["serde"] }