parent
da5c4c496a
commit
405dda6722
@ -42,6 +42,8 @@ stages:
|
|||||||
displayName: Cargo build (Rust TLS)
|
displayName: Cargo build (Rust TLS)
|
||||||
- script: cargo test --all
|
- script: cargo test --all
|
||||||
displayName: Cargo test
|
displayName: Cargo test
|
||||||
|
- script: cargo fmt --check
|
||||||
|
displayName: Cargo fmt
|
||||||
|
|
||||||
|
|
||||||
- stage: Release
|
- stage: Release
|
||||||
|
|||||||
@ -222,8 +222,11 @@ impl Taxonomy {
|
|||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
context.insert("config", &config.serialize(&self.lang));
|
context.insert("config", &config.serialize(&self.lang));
|
||||||
let terms: Vec<SerializedTaxonomyTerm> =
|
let terms: Vec<SerializedTaxonomyTerm> = self
|
||||||
self.items.iter().map(|i| SerializedTaxonomyTerm::from_item(i, library, true)).collect();
|
.items
|
||||||
|
.iter()
|
||||||
|
.map(|i| SerializedTaxonomyTerm::from_item(i, library, true))
|
||||||
|
.collect();
|
||||||
context.insert("terms", &terms);
|
context.insert("terms", &terms);
|
||||||
context.insert("lang", &self.lang);
|
context.insert("lang", &self.lang);
|
||||||
context.insert("taxonomy", &self.kind);
|
context.insert("taxonomy", &self.kind);
|
||||||
|
|||||||
@ -4,7 +4,10 @@ use std::ffi::OsStr;
|
|||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::{collections::hash_map::DefaultHasher, io::{Write, BufWriter}};
|
use std::{
|
||||||
|
collections::hash_map::DefaultHasher,
|
||||||
|
io::{BufWriter, Write},
|
||||||
|
};
|
||||||
|
|
||||||
use image::error::ImageResult;
|
use image::error::ImageResult;
|
||||||
use image::io::Reader as ImgReader;
|
use image::io::Reader as ImgReader;
|
||||||
|
|||||||
@ -142,4 +142,3 @@ mod tests {
|
|||||||
assert_eq!(res, expected);
|
assert_eq!(res, expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
use std::fs::create_dir_all;
|
use std::fs::create_dir_all;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use libs::walkdir::{WalkDir, DirEntry};
|
use libs::globset::Glob;
|
||||||
use libs::globset::{Glob};
|
|
||||||
use libs::sass_rs::{compile_file, Options, OutputStyle};
|
use libs::sass_rs::{compile_file, Options, OutputStyle};
|
||||||
|
use libs::walkdir::{DirEntry, WalkDir};
|
||||||
|
|
||||||
use crate::anyhow;
|
use crate::anyhow;
|
||||||
use errors::{bail, Result};
|
use errors::{bail, Result};
|
||||||
@ -67,10 +67,7 @@ fn compile_sass_glob(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_partial_scss(entry: &DirEntry) -> bool {
|
fn is_partial_scss(entry: &DirEntry) -> bool {
|
||||||
entry.file_name()
|
entry.file_name().to_str().map(|s| s.starts_with("_")).unwrap_or(false)
|
||||||
.to_str()
|
|
||||||
.map(|s| s.starts_with("_"))
|
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_non_partial_scss(sass_path: &Path, extension: &str) -> Vec<PathBuf> {
|
fn get_non_partial_scss(sass_path: &Path, extension: &str) -> Vec<PathBuf> {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::global_fns::helpers::search_for_file;
|
use crate::global_fns::helpers::search_for_file;
|
||||||
use config::Config;
|
use config::Config;
|
||||||
@ -11,10 +11,7 @@ use libs::tera::{from_value, to_value, Function as TeraFn, Result, Value};
|
|||||||
use libs::url;
|
use libs::url;
|
||||||
use utils::site::resolve_internal_link;
|
use utils::site::resolve_internal_link;
|
||||||
|
|
||||||
fn compute_hash<D: digest::Digest>(
|
fn compute_hash<D: digest::Digest>(literal: String, as_base64: bool) -> String
|
||||||
literal: String,
|
|
||||||
as_base64: bool,
|
|
||||||
) -> String
|
|
||||||
where
|
where
|
||||||
digest::Output<D>: core::fmt::LowerHex,
|
digest::Output<D>: core::fmt::LowerHex,
|
||||||
D: std::io::Write,
|
D: std::io::Write,
|
||||||
@ -135,8 +132,7 @@ impl TeraFn for GetUrl {
|
|||||||
f.read_to_string(&mut contents).ok()?;
|
f.read_to_string(&mut contents).ok()?;
|
||||||
|
|
||||||
Some(compute_hash::<Sha256>(contents, false))
|
Some(compute_hash::<Sha256>(contents, false))
|
||||||
})
|
}) {
|
||||||
{
|
|
||||||
Some(hash) => {
|
Some(hash) => {
|
||||||
permalink = format!("{}?h={}", permalink, hash);
|
permalink = format!("{}?h={}", permalink, hash);
|
||||||
}
|
}
|
||||||
@ -201,10 +197,12 @@ impl TeraFn for GetHash {
|
|||||||
let contents = match (path, literal) {
|
let contents = match (path, literal) {
|
||||||
(Some(_), Some(_)) => {
|
(Some(_), Some(_)) => {
|
||||||
return Err("`get_hash`: must have only one of `path` or `literal` argument".into());
|
return Err("`get_hash`: must have only one of `path` or `literal` argument".into());
|
||||||
},
|
}
|
||||||
(None, None) => {
|
(None, None) => {
|
||||||
return Err("`get_hash`: must have at least one of `path` or `literal` argument".into());
|
return Err(
|
||||||
},
|
"`get_hash`: must have at least one of `path` or `literal` argument".into()
|
||||||
|
);
|
||||||
|
}
|
||||||
(Some(path_v), None) => {
|
(Some(path_v), None) => {
|
||||||
let file_path =
|
let file_path =
|
||||||
match search_for_file(&self.base_path, &path_v, &self.theme, &self.output_path)
|
match search_for_file(&self.base_path, &path_v, &self.theme, &self.output_path)
|
||||||
@ -234,10 +232,9 @@ impl TeraFn for GetHash {
|
|||||||
|
|
||||||
contents
|
contents
|
||||||
}
|
}
|
||||||
(None, Some(literal_v)) => { literal_v }
|
(None, Some(literal_v)) => literal_v,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let sha_type = optional_arg!(
|
let sha_type = optional_arg!(
|
||||||
u16,
|
u16,
|
||||||
args.get("sha_type"),
|
args.get("sha_type"),
|
||||||
@ -245,11 +242,8 @@ impl TeraFn for GetHash {
|
|||||||
)
|
)
|
||||||
.unwrap_or(384);
|
.unwrap_or(384);
|
||||||
|
|
||||||
let base64 = optional_arg!(
|
let base64 =
|
||||||
bool,
|
optional_arg!(bool, args.get("base64"), "`get_hash`: `base64` must be true or false")
|
||||||
args.get("base64"),
|
|
||||||
"`get_hash`: `base64` must be true or false"
|
|
||||||
)
|
|
||||||
.unwrap_or(true);
|
.unwrap_or(true);
|
||||||
|
|
||||||
let hash = match sha_type {
|
let hash = match sha_type {
|
||||||
@ -587,9 +581,7 @@ title = "A title"
|
|||||||
args.insert("literal".to_string(), to_value("Hello World").unwrap());
|
args.insert("literal".to_string(), to_value("Hello World").unwrap());
|
||||||
args.insert("sha_type".to_string(), to_value(256).unwrap());
|
args.insert("sha_type".to_string(), to_value(256).unwrap());
|
||||||
args.insert("base64".to_string(), to_value(true).unwrap());
|
args.insert("base64".to_string(), to_value(true).unwrap());
|
||||||
assert_eq!(
|
assert_eq!(static_fn.call(&args).unwrap(), "pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=");
|
||||||
static_fn.call(&args).unwrap(),
|
|
||||||
"pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user