aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/listing.rs8
-rw-r--r--src/renderer.rs9
2 files changed, 16 insertions, 1 deletions
diff --git a/src/listing.rs b/src/listing.rs
index 25f50fa..3c77c14 100644
--- a/src/listing.rs
+++ b/src/listing.rs
@@ -232,6 +232,7 @@ pub fn directory_listing(
}
let mut entries: Vec<Entry> = Vec::new();
+ let mut readme: Option<String> = None;
for entry in dir.path.read_dir()? {
if dir.is_visible(&entry) || conf.show_hidden {
@@ -275,13 +276,17 @@ pub fn directory_listing(
));
} else if metadata.is_file() {
entries.push(Entry::new(
- file_name,
+ file_name.clone(),
EntryType::File,
file_url,
Some(ByteSize::b(metadata.len())),
last_modification_date,
symlink_dest,
));
+ // TODO: Pattern match, or user arg for readme name?
+ if file_name.to_lowercase() == "readme.md"{
+ readme = Some(file_name);
+ }
}
} else {
continue;
@@ -372,6 +377,7 @@ pub fn directory_listing(
HttpResponse::Ok().content_type(mime::TEXT_HTML_UTF_8).body(
renderer::page(
entries,
+ readme,
is_root,
query_params,
breadcrumbs,
diff --git a/src/renderer.rs b/src/renderer.rs
index 75d2c71..775d7c8 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -5,6 +5,7 @@ use clap::{crate_name, crate_version};
use maud::{html, Markup, PreEscaped, DOCTYPE};
use std::time::SystemTime;
use strum::IntoEnumIterator;
+use std::path::Path;
use crate::auth::CurrentUser;
use crate::listing::{Breadcrumb, Entry, QueryParameters, SortingMethod, SortingOrder};
@@ -13,6 +14,7 @@ use crate::{archive::ArchiveMethod, MiniserveConfig};
/// Renders the file listing
pub fn page(
entries: Vec<Entry>,
+ readme: Option<String>,
is_root: bool,
query_params: QueryParameters,
breadcrumbs: Vec<Breadcrumb>,
@@ -165,6 +167,13 @@ pub fn page(
}
}
}
+ @if readme.is_some() {
+ div {
+ h3 { (readme.as_ref().unwrap()) }
+ (PreEscaped
+ (markdown::file_to_html(Path::new(&readme.unwrap())).unwrap()));
+ }
+ }
a.back href="#top" {
(arrow_up())
}