Don't allow back when on top
This commit is contained in:
parent
1870defa2b
commit
27fa8be23e
16
src/main.rs
16
src/main.rs
@ -577,19 +577,23 @@ fn handle_relative_connection(
|
|||||||
.map(|(path, _)| path)
|
.map(|(path, _)| path)
|
||||||
.unwrap_or_default();
|
.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 section = |stream: &mut TcpStream| {
|
||||||
let _ = writeln!(stream, "<hr>");
|
let _ = writeln!(stream, "<hr>");
|
||||||
let _ = writeln!(stream, "<a href=\"/{parent_path}\"><< Back</a>");
|
if back {
|
||||||
|
let _ = writeln!(stream, "<a href=\"/{parent_path}\"><< Back</a>");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = writeln!(stream, "<p>👁️{visits} 💖️{up} 💔️{down}</p>");
|
let _ = writeln!(stream, "<p>👁️{visits} 💖️{up} 💔️{down}</p>");
|
||||||
|
|
||||||
section(&mut stream);
|
section(&mut stream);
|
||||||
|
|
||||||
let title = relative_path
|
|
||||||
.rsplit_once('/')
|
|
||||||
.map_or(relative_path, |(_, title)| title);
|
|
||||||
|
|
||||||
fn entry_handler<W: Write>(
|
fn entry_handler<W: Write>(
|
||||||
path: &Path,
|
path: &Path,
|
||||||
relative_path: &str,
|
relative_path: &str,
|
||||||
@ -635,7 +639,7 @@ fn handle_relative_connection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !title.is_empty() {
|
if back {
|
||||||
let _ = writeln!(stream, "<h1>{title}</h1>");
|
let _ = writeln!(stream, "<h1>{title}</h1>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user