Compare commits

..

No commits in common. "main" and "v0.2.0" have entirely different histories.
main ... v0.2.0

6 changed files with 48 additions and 40 deletions

28
Cargo.lock generated
View file

@ -744,6 +744,16 @@ dependencies = [
"cc",
]
[[package]]
name = "libyml"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3302702afa434ffa30847a83305f0a69d6abd74293b6554c18ec85c7ef30c980"
dependencies = [
"anyhow",
"version_check",
]
[[package]]
name = "log"
version = "0.4.27"
@ -963,7 +973,7 @@ dependencies = [
"pulldown-cmark",
"rayon",
"serde",
"serde_yaml_ng",
"serde_yml",
"tera",
"thiserror 2.0.12",
"time",
@ -1293,16 +1303,18 @@ dependencies = [
]
[[package]]
name = "serde_yaml_ng"
version = "0.10.0"
name = "serde_yml"
version = "0.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4db627b98b36d4203a7b458cf3573730f2bb591b28871d916dfa9efabfd41f"
checksum = "59e2dd588bf1597a252c3b920e0143eb99b0f76e4e082f4c92ce34fbc9e71ddd"
dependencies = [
"indexmap",
"itoa",
"libyml",
"memchr",
"ryu",
"serde",
"unsafe-libyaml",
"version_check",
]
[[package]]
@ -1597,12 +1609,6 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]]
name = "utf8parse"
version = "0.2.2"

View file

@ -19,7 +19,7 @@ log = "0.4.27"
pulldown-cmark = "0.13.0"
rayon = "1.10"
serde = { version = "1.0", features = ["derive"] }
serde_yaml_ng = "0.10.0"
serde_yml = "0.0.12"
tera = { version = "1.20", default-features = false }
thiserror = "2.0"
time = { version = "0.3.41", features = ["formatting", "macros", "parsing"] }

View file

@ -23,7 +23,7 @@ impl Config {
config_path.display(),
)
})?;
let cfg = serde_yaml_ng::from_slice(&content)
let cfg = serde_yml::from_slice(&content)
.with_context(|| format!("Failed to parse config from {}", config_path.display()))?;
Ok(cfg)
}
@ -56,11 +56,11 @@ mod test {
fn from_yaml() {
// Empty YAML gives full default values
let default_cfg = Config::default();
let cfg: Config = serde_yaml_ng::from_str("").unwrap();
let cfg: Config = serde_yml::from_str("").unwrap();
assert_eq!(cfg, default_cfg);
// Default values for any unspecified fields
let cfg: Config = serde_yaml_ng::from_str("thumbnail_size: [1, 1]").unwrap();
let cfg: Config = serde_yml::from_str("thumbnail_size: [1, 1]").unwrap();
assert_ne!(cfg, default_cfg);
assert_eq!(cfg.thumbnail_size, (1, 1));
assert_eq!(cfg.view_size, default_cfg.view_size);

View file

@ -19,7 +19,7 @@ pub struct AlbumDir {
impl AlbumDir {
/// Returns an iterator over all images in the album and subalbums
pub fn iter_all_images(&self) -> AlbumImageIter<'_> {
pub fn iter_all_images(&self) -> AlbumImageIter {
AlbumImageIter::new(self)
}
@ -79,20 +79,20 @@ impl AlbumDir {
}
}
}
} else if entry_path.is_dir()
&& let Some(dirname) = entry_path.file_name().and_then(|n| n.to_str())
{
if dirname.starts_with("_") {
// Likely a templates or static dir
continue;
} else if dirname == "site" {
// Is a generated site dir, don't descend into it
continue;
} else if dirname == "slides" {
continue;
}
} else if entry_path.is_dir() {
if let Some(dirname) = entry_path.file_name().and_then(|n| n.to_str()) {
if dirname.starts_with("_") {
// Likely a templates or static dir
continue;
} else if dirname == "site" {
// Is a generated site dir, don't descend into it
continue;
} else if dirname == "slides" {
continue;
}
children.push(AlbumDir::from_path(&entry_path, root)?);
children.push(AlbumDir::from_path(&entry_path, root)?);
}
}
}

View file

@ -55,15 +55,17 @@ impl Image {
/// return "blah.thumb"
fn slide_filename(path: &Path, ext: &str, keep_ext: bool) -> anyhow::Result<String> {
let mut new_ext: OsString = ext.into();
if keep_ext && let Some(e) = path.extension() {
new_ext = OsString::from(
ext.to_string()
+ "."
+ e.to_str().ok_or(anyhow!(
"Image {} extension is not valid UTF-8",
path.display()
))?,
)
if keep_ext {
if let Some(e) = path.extension() {
new_ext = OsString::from(
ext.to_string()
+ "."
+ e.to_str().ok_or(anyhow!(
"Image {} extension is not valid UTF-8",
path.display()
))?,
)
}
}
let new_path = path.with_extension(new_ext);

View file

@ -1,7 +1,7 @@
use anyhow::{Context, anyhow};
use anyhow::{anyhow, Context};
use image::ImageReader;
use std::ffi::OsStr;
use std::fs::{File, rename};
use std::fs::{rename, File};
use std::io::BufReader;
use std::path::{Path, PathBuf};
use std::str::from_utf8;