Compare commits
No commits in common. "main" and "v0.2.0" have entirely different histories.
6 changed files with 48 additions and 40 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
|
@ -744,6 +744,16 @@ dependencies = [
|
||||||
"cc",
|
"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]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.27"
|
version = "0.4.27"
|
||||||
|
|
@ -963,7 +973,7 @@ dependencies = [
|
||||||
"pulldown-cmark",
|
"pulldown-cmark",
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_yaml_ng",
|
"serde_yml",
|
||||||
"tera",
|
"tera",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
"time",
|
"time",
|
||||||
|
|
@ -1293,16 +1303,18 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_yaml_ng"
|
name = "serde_yml"
|
||||||
version = "0.10.0"
|
version = "0.0.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7b4db627b98b36d4203a7b458cf3573730f2bb591b28871d916dfa9efabfd41f"
|
checksum = "59e2dd588bf1597a252c3b920e0143eb99b0f76e4e082f4c92ce34fbc9e71ddd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itoa",
|
"itoa",
|
||||||
|
"libyml",
|
||||||
|
"memchr",
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
"unsafe-libyaml",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1597,12 +1609,6 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unsafe-libyaml"
|
|
||||||
version = "0.2.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8parse"
|
name = "utf8parse"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ log = "0.4.27"
|
||||||
pulldown-cmark = "0.13.0"
|
pulldown-cmark = "0.13.0"
|
||||||
rayon = "1.10"
|
rayon = "1.10"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_yaml_ng = "0.10.0"
|
serde_yml = "0.0.12"
|
||||||
tera = { version = "1.20", default-features = false }
|
tera = { version = "1.20", default-features = false }
|
||||||
thiserror = "2.0"
|
thiserror = "2.0"
|
||||||
time = { version = "0.3.41", features = ["formatting", "macros", "parsing"] }
|
time = { version = "0.3.41", features = ["formatting", "macros", "parsing"] }
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ impl Config {
|
||||||
config_path.display(),
|
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()))?;
|
.with_context(|| format!("Failed to parse config from {}", config_path.display()))?;
|
||||||
Ok(cfg)
|
Ok(cfg)
|
||||||
}
|
}
|
||||||
|
|
@ -56,11 +56,11 @@ mod test {
|
||||||
fn from_yaml() {
|
fn from_yaml() {
|
||||||
// Empty YAML gives full default values
|
// Empty YAML gives full default values
|
||||||
let default_cfg = Config::default();
|
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);
|
assert_eq!(cfg, default_cfg);
|
||||||
|
|
||||||
// Default values for any unspecified fields
|
// 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_ne!(cfg, default_cfg);
|
||||||
assert_eq!(cfg.thumbnail_size, (1, 1));
|
assert_eq!(cfg.thumbnail_size, (1, 1));
|
||||||
assert_eq!(cfg.view_size, default_cfg.view_size);
|
assert_eq!(cfg.view_size, default_cfg.view_size);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ pub struct AlbumDir {
|
||||||
|
|
||||||
impl AlbumDir {
|
impl AlbumDir {
|
||||||
/// Returns an iterator over all images in the album and subalbums
|
/// 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)
|
AlbumImageIter::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,20 +79,20 @@ impl AlbumDir {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if entry_path.is_dir()
|
} else if entry_path.is_dir() {
|
||||||
&& let Some(dirname) = entry_path.file_name().and_then(|n| n.to_str())
|
if let Some(dirname) = entry_path.file_name().and_then(|n| n.to_str()) {
|
||||||
{
|
if dirname.starts_with("_") {
|
||||||
if dirname.starts_with("_") {
|
// Likely a templates or static dir
|
||||||
// Likely a templates or static dir
|
continue;
|
||||||
continue;
|
} else if dirname == "site" {
|
||||||
} else if dirname == "site" {
|
// Is a generated site dir, don't descend into it
|
||||||
// Is a generated site dir, don't descend into it
|
continue;
|
||||||
continue;
|
} else if dirname == "slides" {
|
||||||
} else if dirname == "slides" {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
children.push(AlbumDir::from_path(&entry_path, root)?);
|
children.push(AlbumDir::from_path(&entry_path, root)?);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,15 +55,17 @@ impl Image {
|
||||||
/// return "blah.thumb"
|
/// return "blah.thumb"
|
||||||
fn slide_filename(path: &Path, ext: &str, keep_ext: bool) -> anyhow::Result<String> {
|
fn slide_filename(path: &Path, ext: &str, keep_ext: bool) -> anyhow::Result<String> {
|
||||||
let mut new_ext: OsString = ext.into();
|
let mut new_ext: OsString = ext.into();
|
||||||
if keep_ext && let Some(e) = path.extension() {
|
if keep_ext {
|
||||||
new_ext = OsString::from(
|
if let Some(e) = path.extension() {
|
||||||
ext.to_string()
|
new_ext = OsString::from(
|
||||||
+ "."
|
ext.to_string()
|
||||||
+ e.to_str().ok_or(anyhow!(
|
+ "."
|
||||||
"Image {} extension is not valid UTF-8",
|
+ e.to_str().ok_or(anyhow!(
|
||||||
path.display()
|
"Image {} extension is not valid UTF-8",
|
||||||
))?,
|
path.display()
|
||||||
)
|
))?,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_path = path.with_extension(new_ext);
|
let new_path = path.with_extension(new_ext);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::{Context, anyhow};
|
use anyhow::{anyhow, Context};
|
||||||
use image::ImageReader;
|
use image::ImageReader;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs::{File, rename};
|
use std::fs::{rename, File};
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue