mirror of
https://github.com/svenstaro/miniserve
synced 2024-07-08 20:05:56 +00:00
Add --readme
info and reformat
This commit is contained in:
parent
f56840a4c0
commit
19ab9c632e
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1930,7 +1930,7 @@ dependencies = [
|
|||
"indexmap",
|
||||
"line-wrap",
|
||||
"serde",
|
||||
"time 0.3.11",
|
||||
"time 0.3.13",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ tar = "0.4"
|
|||
thiserror = "1"
|
||||
yansi = "0.5"
|
||||
zip = { version = "0.6.2", default-features = false }
|
||||
get_if_addrs = "0.5"
|
||||
comrak = "0.14.0"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -101,6 +101,7 @@ Some mobile browsers like Firefox on Android will offer to open the camera app w
|
|||
- Shell completions
|
||||
- Sane and secure defaults
|
||||
- TLS (for supported architectures)
|
||||
- Supports README.md rendering like on GitHub
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -204,6 +205,9 @@ Some mobile browsers like Firefox on Android will offer to open the camera app w
|
|||
--random-route
|
||||
Generate a random 6-hexdigit route
|
||||
|
||||
--readme
|
||||
Enable README.md redering in directories
|
||||
|
||||
--route-prefix <ROUTE_PREFIX>
|
||||
Use a specific route prefix
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue
Block a user