Don't allow back when on top
This commit is contained in:
parent
1870defa2b
commit
27fa8be23e
14
src/main.rs
14
src/main.rs
@ -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>");
|
||||
if back {
|
||||
let _ = writeln!(stream, "<a href=\"/{parent_path}\"><< 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>");
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user