Don't allow back when on top

This commit is contained in:
p11 2025-05-29 23:43:31 +02:00
parent 1870defa2b
commit 27fa8be23e

View File

@ -577,19 +577,23 @@ fn handle_relative_connection(
.map(|(path, _)| path)
.unwrap_or_default();
let title = relative_path
.rsplit_once('/')
.map_or(relative_path, |(_, title)| title);
let back = !title.is_empty();
let section = |stream: &mut TcpStream| {
let _ = writeln!(stream, "<hr>");
let _ = writeln!(stream, "<a href=\"/{parent_path}\">&lt;&lt; Back</a>");
if back {
let _ = writeln!(stream, "<a href=\"/{parent_path}\">&lt;&lt; Back</a>");
}
};
let _ = writeln!(stream, "<p>👁️{visits} 💖️{up} 💔️{down}</p>");
section(&mut stream);
let title = relative_path
.rsplit_once('/')
.map_or(relative_path, |(_, title)| title);
fn entry_handler<W: Write>(
path: &Path,
relative_path: &str,
@ -635,7 +639,7 @@ fn handle_relative_connection(
}
}
if !title.is_empty() {
if back {
let _ = writeln!(stream, "<h1>{title}</h1>");
}