Add libs subcrate (#1747)

* Add libs subcrate

* Remove last direct lazy_static usage

* Update pinned ci version

* Update deps
This commit is contained in:
Vincent Prouillet 2022-02-01 23:02:03 +01:00
parent fd0bcfabe6
commit ae3a8b802e
84 changed files with 627 additions and 580 deletions

347
Cargo.lock generated
View file

@ -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"
@ -299,9 +305,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 +326,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 +363,9 @@ dependencies = [
name = "config"
version = "0.1.0"
dependencies = [
"chrono",
"errors",
"globset",
"lazy_static",
"libs",
"serde",
"serde_derive",
"syntect",
"toml",
"unic-langid",
"utils",
]
@ -490,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]]
@ -638,10 +646,23 @@ dependencies = [
name = "errors"
version = "0.1.0"
dependencies = [
"image",
"syntect",
"tera",
"toml",
"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]]
@ -680,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]]
@ -718,16 +752,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",
]
@ -870,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]]
@ -943,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"
@ -1108,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",
@ -1131,17 +1168,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]]
@ -1154,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"
@ -1239,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",
]
@ -1274,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"
@ -1298,39 +1349,72 @@ 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"
version = "0.1.0"
dependencies = [
"chrono",
"config",
"errors",
"front_matter",
"globset",
"lazy_static",
"lexical-sort",
"rayon",
"regex",
"libs",
"rendering",
"serde",
"serde_derive",
"slotmap",
"tempfile",
"utils",
]
[[package]]
name = "libs"
version = "0.1.0"
dependencies = [
"ammonia",
"base64",
"chrono",
"csv",
"elasticlunr-rs",
"filetime",
"gh-emoji",
"glob",
"globset",
"image",
"lexical-sort",
"minify-html",
"mockito",
"nom-bibtex",
"num-format",
"once_cell",
"percent-encoding",
"pulldown-cmark",
"rayon",
"regex",
"relative-path",
"reqwest",
"sass-rs",
"serde_json",
"serde_yaml",
"sha2",
"slotmap",
"slug",
"svg_metadata",
"syntect",
"tera",
"toml",
"utils",
"unic-langid",
"unicode-segmentation",
"url",
"walkdir",
"webp",
]
[[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",
]
@ -1429,9 +1513,8 @@ version = "0.1.0"
dependencies = [
"config",
"errors",
"lazy_static",
"libs",
"mockito",
"reqwest",
"utils",
]
@ -1443,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",
]
@ -1545,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"
@ -1647,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"
@ -1828,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",
@ -2123,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"
@ -2157,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]]
@ -2408,18 +2512,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",
]
@ -2473,7 +2571,7 @@ dependencies = [
"cc",
"libc",
"once_cell",
"spin",
"spin 0.5.2",
"untrusted",
"web-sys",
"winapi 0.3.9",
@ -2598,19 +2696,17 @@ dependencies = [
name = "search"
version = "0.1.0"
dependencies = [
"ammonia",
"config",
"elasticlunr-rs",
"errors",
"lazy_static",
"library",
"libs",
]
[[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",
@ -2621,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",
@ -2730,25 +2826,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]]
@ -2783,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",
@ -2797,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"
@ -2933,26 +3029,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",
]
@ -3056,13 +3141,22 @@ dependencies = [
]
[[package]]
name = "tiff"
version = "0.6.1"
name = "threadpool"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a53f4706d65497df0c4349241deddf35f84cee19c87ed86ea8ca590f4464437"
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
dependencies = [
"jpeg-decoder",
"miniz_oxide 0.4.4",
"num_cpus",
]
[[package]]
name = "tiff"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0247608e998cb6ce39dfc8f4a16c50361ce71e5b52e6d24ea1227ea8ea8ee0b2"
dependencies = [
"flate2",
"jpeg-decoder 0.1.22",
"weezl",
]
@ -3110,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",
@ -3374,17 +3468,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]]
@ -3516,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",
@ -3682,28 +3768,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",
]

View file

@ -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

View file

@ -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:

View file

@ -1,19 +1,12 @@
[package]
name = "config"
version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
edition = "2018"
edition = "2021"
include = ["src/**/*"]
[dependencies]
toml = "0.5"
serde = "1"
serde_derive = "1"
chrono = "0.4"
globset = "0.4"
lazy_static = "1"
syntect = "4"
unic-langid = "0.9"
serde = {version = "1.0", features = ["derive"] }
errors = { path = "../errors" }
utils = { path = "../utils" }
libs = { path = "../libs" }

View file

@ -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

View file

@ -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;

View file

@ -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<String>,
}

View file

@ -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};

View file

@ -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<Config> {
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),
};

View file

@ -1,4 +1,4 @@
use serde_derive::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]

View file

@ -1,4 +1,4 @@
use serde_derive::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
use utils::slugs::SlugifyStrategy;

View file

@ -1,4 +1,4 @@
use serde_derive::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]

View file

@ -1,22 +1,18 @@
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 libs::once_cell::sync::Lazy;
use crate::config::Config;
pub const CLASS_STYLE: ClassStyle = ClassStyle::SpacedPrefixed { prefix: "z-" };
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<SyntaxSet> =
Lazy::new(|| from_binary(include_bytes!("../../../sublime/syntaxes/newlines.packdump")));
pub static THEME_SET: Lazy<ThemeSet> =
Lazy::new(|| from_binary(include_bytes!("../../../sublime/themes/all.themedump")));
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum HighlightSource {

View file

@ -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<Config> {

View file

@ -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;

View file

@ -1,11 +1,7 @@
[package]
name = "errors"
version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
edition = "2018"
edition = "2021"
[dependencies]
tera = "1"
toml = "0.5"
image = "0.23"
syntect = "4"
libs = { path = "../libs" }

View file

@ -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),

View file

@ -1,21 +1,14 @@
[package]
name = "front_matter"
version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
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

View file

@ -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<Regex> = 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<Regex> = Lazy::new(|| {
Regex::new(r"^[[:space:]]*---(\r?\n(?s).*?(?-s))---[[:space:]]*(?:$|(?:\r?\n((?s).*(?-s))$))")
.unwrap()
});
pub enum RawFrontMatter<'a> {
Toml(&'a str),

View file

@ -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")]

View file

@ -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;

View file

@ -1,24 +1,15 @@
[package]
name = "imageproc"
version = "0.1.0"
authors = ["Vojtěch Král <vojtech@kral.hk>"]
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"

View file

@ -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<Regex> =
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)]

View file

@ -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<PathBuf> =
Lazy::new(|| [env!("CARGO_MANIFEST_DIR"), "tests", "test_imgs"].iter().collect());
static PROCESSED_PREFIX: Lazy<String> =
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));

View file

@ -1,28 +1,17 @@
[package]
name = "library"
version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
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"

View file

@ -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);
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"] {
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

View file

@ -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<Regex> = Lazy::new(|| {
Regex::new(
r"^(?P<datetime>(\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<slug>.+$)"
).unwrap();
).unwrap()
});
static ref FOOTNOTES_RE: Regex = Regex::new(r"<sup\s*.*?>\s*.*?</sup>").unwrap();
}
static FOOTNOTES_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"<sup\s*.*?>\s*.*?</sup>").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};

View file

@ -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;

View file

@ -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;

View file

@ -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};

View file

@ -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::{

View file

@ -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;

View file

@ -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};

View file

@ -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};

View file

@ -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.24"
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"]

View file

@ -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;

View file

@ -1,24 +1,13 @@
[package]
name = "link_checker"
version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
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"]

View file

@ -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<StatusCode, String>;
@ -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<RwLock<HashMap<String, Result>>> = Arc::new(RwLock::new(HashMap::new()));
}
// Keep history of link checks so a rebuild doesn't have to check again
static LINKS: Lazy<Arc<RwLock<HashMap<String, Result>>>> =
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

View file

@ -1,27 +1,20 @@
[package]
name = "rendering"
version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
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" }

View file

@ -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() {

View file

@ -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};

View file

@ -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

View file

@ -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 = "<span id=\"continue-reading\"></span>";
const ANCHOR_LINK_TEMPLATE: &str = "anchor-link.html";
static EMOJI_REPLACER: Lazy<EmojiReplacer> = Lazy::new(|| EmojiReplacer::new());
#[derive(Debug)]
pub struct Rendered {
@ -146,10 +149,6 @@ pub fn markdown_to_html(
context: &RenderContext,
html_shortcodes: Vec<Shortcode>,
) -> Result<Rendered> {
lazy_static! {
static ref EMOJI_REPLACER: gh_emoji::Replacer = gh_emoji::Replacer::new();
}
let path = context
.tera_context
.get("page")

View file

@ -1,6 +1,7 @@
use std::collections::HashMap;
use errors::{Error, Result};
use libs::tera;
use utils::templates::{ShortcodeDefinition, ShortcodeFileType};
mod parser;

View file

@ -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@@";

View file

@ -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)]

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use tera::Tera;
use libs::tera::Tera;
use config::Config;
use front_matter::InsertAnchor;

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use tera::Tera;
use libs::tera::Tera;
use config::Config;
use front_matter::InsertAnchor;

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use tera::Tera;
use libs::tera::Tera;
use config::Config;
use front_matter::InsertAnchor;

View file

@ -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
</span></td></tr></tbody></table></code></pre>
"#
);
}
}

View file

@ -1,6 +1,7 @@
mod common;
use common::ShortCode;
use libs::tera;
const COMPLETE_PAGE: &str = r#"
<!-- Adapted from https://markdown-it.github.io/ -->

View file

@ -4,6 +4,7 @@ use errors::Result;
use rendering::Rendered;
mod common;
use libs::tera;
fn render_content(content: &str, permalinks: HashMap<String, String>) -> Result<Rendered> {
let config = config::Config::default_for_test();

View file

@ -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;

View file

@ -1,6 +1,7 @@
mod common;
use common::ShortCode;
use libs::tera;
use std::path::PathBuf;
use templates::ZOLA_TERA;

View file

@ -1,6 +1,7 @@
mod common;
use common::ShortCode;
use libs::tera;
macro_rules! test_scenario_summary {
($in_str:literal, $summary:literal, [$($shortcodes:ident),*]) => {

View file

@ -1,6 +1,7 @@
mod common;
use common::ShortCode;
use libs::tera;
use rendering::Heading;
#[derive(PartialEq, Debug)]

View file

@ -1,19 +1,10 @@
[package]
name = "search"
version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
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" }

View file

@ -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<ammonia::Builder<'static>> = 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<String> {
let mut fields = vec![];

View file

@ -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"]

View file

@ -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;

View file

@ -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<RwLock<HashMap<RelativePathBuf, String>>> = Arc::new(RwLock::new(HashMap::new()));
}
pub static SITE_CONTENT: Lazy<Arc<RwLock<HashMap<RelativePathBuf, String>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
/// Where are we building the site
#[derive(Debug, Clone, Copy, Eq, PartialEq)]

View file

@ -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))
}
});

View file

@ -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};

View file

@ -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

View file

@ -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<()> {

View file

@ -1,22 +1,10 @@
[package]
name = "templates"
version = "0.1.0"
authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"]
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"]

View file

@ -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<String, String>,
) -> TeraResult<Self> {
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<String, Value>) -> TeraResult<Value> {
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);

View file

@ -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)]

View file

@ -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<D: digest::Digest>(
@ -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;

View file

@ -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;

View file

@ -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();

View file

@ -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<Value> {
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

View file

@ -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<Tera> = 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

View file

@ -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"

View file

@ -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

View file

@ -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;

View file

@ -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#"<a name="fred">"#));

View file

@ -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<String> {
let mut cfg = Cfg::spec_compliant();

View file

@ -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;

View file

@ -1,3 +1,4 @@
use libs::slug;
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]

View file

@ -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() {

View file

@ -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;

View file

@ -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<ColorChoice> =
Lazy::new(|| if has_color() { ColorChoice::Always } else { ColorChoice::Never });
pub fn info(message: &str) {
colorize(message, ColorSpec::new().set_bold(true));

View file

@ -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;