clippy pass
This commit is contained in:
parent
2bacda9de5
commit
ac23e53614
3 changed files with 17 additions and 18 deletions
|
@ -71,7 +71,7 @@ impl TryFrom<&AlbumDir> for AlbumContext {
|
||||||
log::debug!("Crumbs for {}: {breadcrumbs:?}", album.path.display());
|
log::debug!("Crumbs for {}: {breadcrumbs:?}", album.path.display());
|
||||||
|
|
||||||
// The first breadcrumb path is the relative path to the root album
|
// The first breadcrumb path is the relative path to the root album
|
||||||
let root_path = if breadcrumbs.len() > 0 {
|
let root_path = if !breadcrumbs.is_empty() {
|
||||||
breadcrumbs[0].path.clone()
|
breadcrumbs[0].path.clone()
|
||||||
} else {
|
} else {
|
||||||
PathBuf::new()
|
PathBuf::new()
|
||||||
|
@ -86,7 +86,7 @@ impl TryFrom<&AlbumDir> for AlbumContext {
|
||||||
let children: Vec<AlbumContext> = album
|
let children: Vec<AlbumContext> = album
|
||||||
.children
|
.children
|
||||||
.iter()
|
.iter()
|
||||||
.map(|a| AlbumContext::try_from(a))
|
.map(AlbumContext::try_from)
|
||||||
.collect::<anyhow::Result<Vec<AlbumContext>>>()?;
|
.collect::<anyhow::Result<Vec<AlbumContext>>>()?;
|
||||||
let images: Vec<Image> = album.images.clone();
|
let images: Vec<Image> = album.images.clone();
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ fn generate_html(config: &Config, album: &AlbumDir) -> anyhow::Result<()> {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
for child in album.children.iter() {
|
for child in album.children.iter() {
|
||||||
dir_queue.push_back(&child);
|
dir_queue.push_back(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (pos, img) in album.images.iter().enumerate() {
|
for (pos, img) in album.images.iter().enumerate() {
|
||||||
|
|
|
@ -48,7 +48,7 @@ impl AlbumDir {
|
||||||
} else {
|
} else {
|
||||||
if filename.to_string_lossy().starts_with("cover") {
|
if filename.to_string_lossy().starts_with("cover") {
|
||||||
cover = Some(Image::new(
|
cover = Some(Image::new(
|
||||||
entry_path.strip_prefix(&root)?.to_path_buf(),
|
entry_path.strip_prefix(root)?.to_path_buf(),
|
||||||
String::new(),
|
String::new(),
|
||||||
)?);
|
)?);
|
||||||
}
|
}
|
||||||
|
@ -60,16 +60,15 @@ impl AlbumDir {
|
||||||
|
|
||||||
// Read in any associated description file
|
// Read in any associated description file
|
||||||
if entry_path.with_extension("txt").exists() {
|
if entry_path.with_extension("txt").exists() {
|
||||||
description =
|
description = fs::read_to_string(entry_path.with_extension("txt"))?;
|
||||||
fs::read_to_string(&entry_path.with_extension("txt"))?;
|
|
||||||
} else if entry_path.with_extension("md").exists() {
|
} else if entry_path.with_extension("md").exists() {
|
||||||
let _contents = fs::read(&entry_path.with_extension("md"))?;
|
let _contents = fs::read(entry_path.with_extension("md"))?;
|
||||||
// TODO: render markdown
|
// TODO: render markdown
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
|
|
||||||
images.push(Image::new(
|
images.push(Image::new(
|
||||||
entry_path.strip_prefix(&root)?.to_path_buf(),
|
entry_path.strip_prefix(root)?.to_path_buf(),
|
||||||
description,
|
description,
|
||||||
)?);
|
)?);
|
||||||
}
|
}
|
||||||
|
@ -85,12 +84,12 @@ impl AlbumDir {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
children.push(AlbumDir::from_path(&entry_path, &root)?);
|
children.push(AlbumDir::from_path(&entry_path, root)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cover.is_none() && images.len() > 0 {
|
if cover.is_none() && !images.is_empty() {
|
||||||
cover = Some(images[0].clone());
|
cover = Some(images[0].clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +200,7 @@ impl Image {
|
||||||
/// Returns the filename for a given slide type. For example if ext = "thumb" and the current
|
/// Returns the filename for a given slide type. For example if ext = "thumb" and the current
|
||||||
/// filename is "blah.jpg" this will return "blah.thumb.jpg". If keep_ext if false, it would
|
/// filename is "blah.jpg" this will return "blah.thumb.jpg". If keep_ext if false, it would
|
||||||
/// return "blah.thumb"
|
/// return "blah.thumb"
|
||||||
fn slide_filename(path: &PathBuf, 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 {
|
if keep_ext {
|
||||||
if let Some(e) = path.extension() {
|
if let Some(e) = path.extension() {
|
||||||
|
@ -228,11 +227,11 @@ impl Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the path to the file in the slides dir given the path to the original image
|
/// Returns the path to the file in the slides dir given the path to the original image
|
||||||
fn slide_path(path: &PathBuf, file_name: &str) -> PathBuf {
|
fn slide_path(path: &Path, file_name: &str) -> PathBuf {
|
||||||
let mut new_path = path.clone();
|
let mut new_path = path.to_path_buf();
|
||||||
new_path.pop();
|
new_path.pop();
|
||||||
new_path.push("slides");
|
new_path.push("slides");
|
||||||
new_path.push(&file_name);
|
new_path.push(file_name);
|
||||||
new_path
|
new_path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
make_skeleton(album_path)?;
|
make_skeleton(album_path)?;
|
||||||
println!("Album created in {}", album_path.display());
|
println!("Album created in {}", album_path.display());
|
||||||
}
|
}
|
||||||
Commands::Generate { quick } => {
|
Commands::Generate {} => {
|
||||||
let path = generate(&album_path.to_path_buf())?;
|
let path = generate(&album_path.to_path_buf())?;
|
||||||
println!("Album site generated in {}", path.display());
|
println!("Album site generated in {}", path.display());
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ enum Commands {
|
||||||
Init {},
|
Init {},
|
||||||
/// Generates a photo album
|
/// Generates a photo album
|
||||||
Generate {
|
Generate {
|
||||||
/// Don't re-generate things that already exist (thumbnails, etc.)
|
// /// Don't re-generate things that already exist (thumbnails, etc.)
|
||||||
#[arg(long)]
|
// #[arg(long)]
|
||||||
quick: bool,
|
// _quick: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue