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());
|
||||
|
||||
// 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()
|
||||
} else {
|
||||
PathBuf::new()
|
||||
|
@ -86,7 +86,7 @@ impl TryFrom<&AlbumDir> for AlbumContext {
|
|||
let children: Vec<AlbumContext> = album
|
||||
.children
|
||||
.iter()
|
||||
.map(|a| AlbumContext::try_from(a))
|
||||
.map(AlbumContext::try_from)
|
||||
.collect::<anyhow::Result<Vec<AlbumContext>>>()?;
|
||||
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() {
|
||||
dir_queue.push_back(&child);
|
||||
dir_queue.push_back(child);
|
||||
}
|
||||
|
||||
for (pos, img) in album.images.iter().enumerate() {
|
||||
|
|
|
@ -48,7 +48,7 @@ impl AlbumDir {
|
|||
} else {
|
||||
if filename.to_string_lossy().starts_with("cover") {
|
||||
cover = Some(Image::new(
|
||||
entry_path.strip_prefix(&root)?.to_path_buf(),
|
||||
entry_path.strip_prefix(root)?.to_path_buf(),
|
||||
String::new(),
|
||||
)?);
|
||||
}
|
||||
|
@ -60,16 +60,15 @@ impl AlbumDir {
|
|||
|
||||
// Read in any associated description file
|
||||
if entry_path.with_extension("txt").exists() {
|
||||
description =
|
||||
fs::read_to_string(&entry_path.with_extension("txt"))?;
|
||||
description = fs::read_to_string(entry_path.with_extension("txt"))?;
|
||||
} 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!();
|
||||
}
|
||||
|
||||
images.push(Image::new(
|
||||
entry_path.strip_prefix(&root)?.to_path_buf(),
|
||||
entry_path.strip_prefix(root)?.to_path_buf(),
|
||||
description,
|
||||
)?);
|
||||
}
|
||||
|
@ -85,12 +84,12 @@ impl AlbumDir {
|
|||
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());
|
||||
}
|
||||
|
||||
|
@ -201,7 +200,7 @@ impl Image {
|
|||
/// 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
|
||||
/// 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();
|
||||
if keep_ext {
|
||||
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
|
||||
fn slide_path(path: &PathBuf, file_name: &str) -> PathBuf {
|
||||
let mut new_path = path.clone();
|
||||
fn slide_path(path: &Path, file_name: &str) -> PathBuf {
|
||||
let mut new_path = path.to_path_buf();
|
||||
new_path.pop();
|
||||
new_path.push("slides");
|
||||
new_path.push(&file_name);
|
||||
new_path.push(file_name);
|
||||
new_path
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ fn main() -> anyhow::Result<()> {
|
|||
make_skeleton(album_path)?;
|
||||
println!("Album created in {}", album_path.display());
|
||||
}
|
||||
Commands::Generate { quick } => {
|
||||
Commands::Generate {} => {
|
||||
let path = generate(&album_path.to_path_buf())?;
|
||||
println!("Album site generated in {}", path.display());
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ enum Commands {
|
|||
Init {},
|
||||
/// Generates a photo album
|
||||
Generate {
|
||||
/// Don't re-generate things that already exist (thumbnails, etc.)
|
||||
#[arg(long)]
|
||||
quick: bool,
|
||||
// /// Don't re-generate things that already exist (thumbnails, etc.)
|
||||
// #[arg(long)]
|
||||
// _quick: bool,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue