aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris Guyonvarch2026-01-01 18:29:11 +0100
committerJoris Guyonvarch2026-01-01 18:29:11 +0100
commit12aba49b256d11a34c1472288e8a585be74928e1 (patch)
treeee6a2c7849adb30202d852d8906884cb1497d554 /src
parentbe94934ccd7d144cd30f6029941d5d835e29746d (diff)
Add page icon
https://uxwing.com/blank-file-icon/
Diffstat (limited to 'src')
-rw-r--r--src/routes.rs22
-rw-r--r--src/static/icon.pngbin0 -> 351 bytes
-rw-r--r--src/templates.rs1
3 files changed, 12 insertions, 11 deletions
diff --git a/src/routes.rs b/src/routes.rs
index ae97b7a..509f1b2 100644
--- a/src/routes.rs
+++ b/src/routes.rs
@@ -17,6 +17,10 @@ use crate::model;
use crate::templates;
use crate::util;
+static MAIN_JS: &[u8] = include_bytes!("static/main.js");
+static MAIN_CSS: &[u8] = include_bytes!("static/main.css");
+static ICON_PNG: &[u8] = include_bytes!("static/icon.png");
+
pub async fn routes(
request: Request<Incoming>,
db_conn: Connection,
@@ -29,12 +33,12 @@ pub async fn routes(
match (request.method(), path_parts) {
(&Method::GET, []) => Ok(html(templates::INDEX)),
- (&Method::GET, ["static", "main.js"]) => Ok(static_file(
- include_str!("static/main.js"),
- "application/javascript",
- )),
+ (&Method::GET, ["static", "main.js"]) =>
+ Ok(static_file(MAIN_JS, "application/javascript")),
+ (&Method::GET, ["static", "icon.png"]) =>
+ Ok(static_file(ICON_PNG, "image/png")),
(&Method::GET, ["static", "main.css"]) => {
- Ok(static_file(include_str!("static/main.css"), "text/css"))
+ Ok(static_file(MAIN_CSS, "text/css"))
}
(&Method::POST, ["upload"]) => {
upload_file(request, db_conn, authorized_key, files_dir).await
@@ -146,15 +150,11 @@ async fn get(
}
fn static_file(
- text: impl Into<String>,
+ content: &'static[u8],
content_type: &str,
) -> Response<BoxBody<Bytes, std::io::Error>> {
let response = Response::builder()
- .body(
- Full::new(text.into().into())
- .map_err(|e| match e {})
- .boxed(),
- )
+ .body(Full::new(content.into()).map_err(|e| match e {}).boxed())
.unwrap();
with_headers(response, vec![(CONTENT_TYPE, content_type)])
}
diff --git a/src/static/icon.png b/src/static/icon.png
new file mode 100644
index 0000000..bde49fb
--- /dev/null
+++ b/src/static/icon.png
Binary files differ
diff --git a/src/templates.rs b/src/templates.rs
index 0dc6230..3432789 100644
--- a/src/templates.rs
+++ b/src/templates.rs
@@ -11,6 +11,7 @@ const PAGE: &str = r#"
<title>Files</title>
<link rel="stylesheet" href="/static/main.css">
+<link rel="icon" href="/static/icon.png">
<script src="/static/main.js"></script>
<a href="/">