stapix

Yet another static page generator for photo galleries

Commit
5b3da5c4fc8ba1e81f80ad9c56b65b93855406ee
Parent
b28c1d98ab6470e40dda761dc7c3ad8eab165a47
Author
Pablo <pablo-escobar@riseup.net>
Date

Added some documentation and formated the code

Followed Clippy's recommendations

Diffstat

2 files changed, 14 insertions, 11 deletions

Status File Name N° Changes Insertions Deletions
Modified src/main.rs 24 13 11
Modified src/picture.rs 1 1 0
diff --git a/src/main.rs b/src/main.rs
@@ -1,13 +1,15 @@
 use crossterm::style::Stylize;
 use image::io::Reader as ImageReader;
 use image::DynamicImage;
-use std::env;
-use std::fmt::{self, Display};
-use std::fs::{self, File};
-use std::io::{self, Write};
-use std::path::PathBuf;
-use std::process::ExitCode;
-use std::sync::mpsc;
+use std::{
+    env,
+    fmt::{self, Display},
+    fs::{self, File},
+    io::{self, Write},
+    path::PathBuf,
+    process::ExitCode,
+    sync::mpsc,
+};
 use picture::Picture;
 use threadpool::ThreadPool;
 
@@ -129,14 +131,14 @@ fn main() -> ExitCode {
         Err(err) => {
             error!("Couldn't open {config:?}: {err}",
                    config = config, err = err; newline = false);
-            return ExitCode::FAILURE;
+           ExitCode::FAILURE
         }
         // Error parsing the config file
         Ok(Err(err)) => {
             error!("Couldn't parse {config:?}: {err}",
                    config = config, err = err; newline = false);
             usage_config!();
-            return ExitCode::FAILURE;
+            ExitCode::FAILURE
         }
         Ok(Ok(pics)) => render_gallery(pics),
     }
@@ -201,14 +203,14 @@ fn render_gallery(pics: Vec<Picture>) -> ExitCode {
 
     // ========================================================================
     log!("Rendering index.html...");
-    if let Err(_) = render_index(&pics) {
+    if render_index(&pics).is_err() {
         return ExitCode::FAILURE;
     }
     log_done!();
 
     for pic in pics {
         log!("Rendering HTML page for {name:?}...", name = pic.file_name);
-        if let Err(_) = render_pic_page(&pic) {
+        if render_pic_page(&pic).is_err() {
             return ExitCode::FAILURE;
         }
         log_done!();
diff --git a/src/picture.rs b/src/picture.rs
@@ -4,6 +4,7 @@ use serde::{
 };
 use std::path::PathBuf;
 
+/// Info on a individual entry on the gallery
 #[derive(Debug, Clone, PartialEq, Eq)]
 pub struct Picture {
     pub path: PathBuf,