diff options
author | Gaurav <allmanpride@gmail.com> | 2022-08-12 01:46:56 +0000 |
---|---|---|
committer | Gaurav <allmanpride@gmail.com> | 2022-08-14 00:27:54 +0000 |
commit | 19ab9c632e4a12dd7c7c30f56317bf26cb0e3f2f (patch) | |
tree | 12a81872cf36c1d3382e319cdd6406f64507b093 /src | |
parent | Satisfy cargo fmt (diff) | |
download | miniserve-19ab9c632e4a12dd7c7c30f56317bf26cb0e3f2f.tar.gz miniserve-19ab9c632e4a12dd7c7c30f56317bf26cb0e3f2f.zip |
Add `--readme` info and reformat
Diffstat (limited to 'src')
-rw-r--r-- | src/args.rs | 4 | ||||
-rw-r--r-- | src/listing.rs | 1 | ||||
-rw-r--r-- | src/renderer.rs | 19 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/args.rs b/src/args.rs index 9674651..dd96f05 100644 --- a/src/args.rs +++ b/src/args.rs @@ -198,8 +198,8 @@ pub struct CliArgs { #[clap(long = "tls-key", requires = "tls-cert", value_hint = ValueHint::FilePath)] pub tls_key: Option<PathBuf>, - /// Enable readme redering in directories - #[clap(long = "readme")] + /// Enable README.md redering in directories + #[clap(long)] pub readme: bool, } diff --git a/src/listing.rs b/src/listing.rs index 42054ca..1c017b0 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -283,7 +283,6 @@ pub fn directory_listing( last_modification_date, symlink_dest, )); - // TODO: Pattern match? if conf.readme && file_name.to_lowercase() == "readme.md" { let file_path = conf .path diff --git a/src/renderer.rs b/src/renderer.rs index 3ce985b..abf6053 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -12,6 +12,7 @@ use crate::auth::CurrentUser; use crate::listing::{Breadcrumb, Entry, QueryParameters, SortingMethod, SortingOrder}; use crate::{archive::ArchiveMethod, MiniserveConfig}; +#[allow(clippy::too_many_arguments)] /// Renders the file listing pub fn page( entries: Vec<Entry>, @@ -169,15 +170,15 @@ pub fn page( } } @if readme.is_some() { - div { - h3 { (readme.as_ref().unwrap().file_name().unwrap() - .to_string_lossy().to_string()) } - (PreEscaped - (markdown_to_html( - &std::fs::read_to_string(readme.unwrap()) - .unwrap_or_else(|_| "Cannot read File.".to_string()), - &ComrakOptions::default()))); - } + div { + h3 { (readme.as_ref().unwrap().file_name().unwrap() + .to_string_lossy().to_string()) } + (PreEscaped + (markdown_to_html( + &std::fs::read_to_string(readme.unwrap()) + .unwrap_or_else(|_| "Cannot read File.".to_string()), + &ComrakOptions::default()))); + } } a.back href="#top" { (arrow_up()) |