From c6e9a3dd43d7cf3f91f08173b210e83ea587d676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Fri, 31 Jul 2026 14:15:44 +0200 Subject: [PATCH] icons and logos --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/app/mod.rs | 14 +++-- src/app/pages.rs | 80 +++++++++++++++++++++++++-- src/assets.rs | 7 ++- static/css/styles.css | 54 +++++++++++++++++- static/editor.html | 8 ++- static/icons/apple-touch-icon.png | Bin 0 -> 1412 bytes static/icons/favicon-32.png | Bin 0 -> 321 bytes static/icons/favicon.ico | Bin 0 -> 3995 bytes static/icons/favicon.svg | 12 ++++ static/js/icons/apple-touch-icon.png | Bin 0 -> 1412 bytes static/js/icons/favicon-32.png | Bin 0 -> 321 bytes static/js/icons/favicon.ico | Bin 0 -> 3995 bytes static/js/icons/favicon.svg | 12 ++++ static/workspace.html | 8 ++- 16 files changed, 182 insertions(+), 17 deletions(-) create mode 100644 static/icons/apple-touch-icon.png create mode 100644 static/icons/favicon-32.png create mode 100644 static/icons/favicon.ico create mode 100644 static/icons/favicon.svg create mode 100644 static/js/icons/apple-touch-icon.png create mode 100644 static/js/icons/favicon-32.png create mode 100644 static/js/icons/favicon.ico create mode 100644 static/js/icons/favicon.svg diff --git a/Cargo.lock b/Cargo.lock index 8f53364..de95d92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2581,7 +2581,7 @@ dependencies = [ [[package]] name = "rustpad" -version = "0.2.10" +version = "0.2.11" dependencies = [ "argon2", "aws-config", diff --git a/Cargo.toml b/Cargo.toml index dad6b37..afddb1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustpad" -version = "0.2.10" +version = "0.2.11" edition = "2024" rust-version = "1.94" description = "Collaborative Markdown notepad built with Axum, WebSockets and SQLite, PostgreSQL and MySQL" diff --git a/src/app/mod.rs b/src/app/mod.rs index 8d03fcd..d44ef41 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -46,10 +46,9 @@ pub fn router( } }); - let asset_cache_control = HeaderValue::from_str(&crate::cache::cache_control( - asset_cache_max_age_seconds, - )) - .expect("valid asset cache-control header"); + let asset_cache_control = + HeaderValue::from_str(&crate::cache::cache_control(asset_cache_max_age_seconds)) + .expect("valid asset cache-control header"); Router::new() .route("/", get(home)) @@ -63,6 +62,13 @@ pub fn router( .route("/health", get(health)) .route("/robots.txt", get(robots_txt)) .route("/favicon.ico", get(favicon)) + .route("/favicon.svg", get(favicon_svg)) + .route("/favicon-32.png", get(favicon_png)) + .route("/apple-touch-icon.png", get(apple_touch_icon)) + .route("/icons/favicon.ico", get(favicon)) + .route("/icons/favicon.svg", get(favicon_svg)) + .route("/icons/favicon-32.png", get(favicon_png)) + .route("/icons/apple-touch-icon.png", get(apple_touch_icon)) .route("/f/{token}/{filename}", get(api::download_file)) .route( "/files/{directory}/{filename}", diff --git a/src/app/pages.rs b/src/app/pages.rs index 39bf29f..b28e7a1 100644 --- a/src/app/pages.rs +++ b/src/app/pages.rs @@ -28,6 +28,7 @@ fn render_editor_page( ) -> Response { let html = include_str!("../../static/editor.html") .replace("__RESOURCE_KIND__", resource_kind) + .replace("__RESOURCE_LABEL__", "Note") .replace("__DOCUMENT_TITLE__", &escape_html(document_title)) .replace("__PARENT_TITLE__", &escape_html(parent_title)) .replace("__PARENT_URL__", &escape_html(parent_url)) @@ -49,8 +50,71 @@ pub(super) async fn health() -> &'static str { "ok" } -pub(super) async fn favicon() -> StatusCode { - StatusCode::NO_CONTENT +pub(super) async fn favicon() -> Response { + static FAVICON: &[u8] = include_bytes!("../../static/icons/favicon.ico"); + ( + [ + ( + header::CONTENT_TYPE, + HeaderValue::from_static("image/x-icon"), + ), + ( + header::CACHE_CONTROL, + HeaderValue::from_static("public, max-age=604800"), + ), + ], + FAVICON, + ) + .into_response() +} + +pub(super) async fn favicon_svg() -> Response { + static FAVICON: &str = include_str!("../../static/icons/favicon.svg"); + ( + [ + ( + header::CONTENT_TYPE, + HeaderValue::from_static("image/svg+xml; charset=utf-8"), + ), + ( + header::CACHE_CONTROL, + HeaderValue::from_static("public, max-age=604800"), + ), + ], + FAVICON, + ) + .into_response() +} + + +pub(super) async fn favicon_png() -> Response { + static FAVICON: &[u8] = include_bytes!("../../static/icons/favicon-32.png"); + ( + [ + (header::CONTENT_TYPE, HeaderValue::from_static("image/png")), + ( + header::CACHE_CONTROL, + HeaderValue::from_static("public, max-age=604800"), + ), + ], + FAVICON, + ) + .into_response() +} + +pub(super) async fn apple_touch_icon() -> Response { + static ICON: &[u8] = include_bytes!("../../static/icons/apple-touch-icon.png"); + ( + [ + (header::CONTENT_TYPE, HeaderValue::from_static("image/png")), + ( + header::CACHE_CONTROL, + HeaderValue::from_static("public, max-age=604800"), + ), + ], + ICON, + ) + .into_response() } pub(super) async fn robots_txt() -> Response { @@ -201,8 +265,16 @@ pub(super) async fn note( &state, "note", "note", - if workspace.is_private != 0 { "Note" } else { ¬e.title }, - if workspace.is_private != 0 { "Workspace" } else { &workspace.title }, + if workspace.is_private != 0 { + "Note" + } else { + ¬e.title + }, + if workspace.is_private != 0 { + "Workspace" + } else { + &workspace.title + }, &format!("/w/{workspace_slug}"), "", "workspace", diff --git a/src/assets.rs b/src/assets.rs index e0610e6..47a46b7 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -60,7 +60,12 @@ pub fn render_html( "false" }, ) - .replace("", &format!("{frontend_config}")); + .replace( + "", + &format!( + r#"{frontend_config}"# + ), + ); let mut response = Html(html).into_response(); response.headers_mut().insert( diff --git a/static/css/styles.css b/static/css/styles.css index b5a73c7..694ed55 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -2586,7 +2586,7 @@ dialog::backdrop { } .hide-preview-line-numbers .preview { - padding-left: 24px; + padding-left: 0; } .hide-preview-line-numbers .preview-source-line::before { @@ -6148,4 +6148,54 @@ dialog::backdrop { .pad-page .participant-badges:empty { display: none; -} \ No newline at end of file +} +/* Unified RustPad resource identity used by notes and workspaces. */ +.resource-brand { + display: grid; + flex: 0 0 auto; + gap: 2px; + min-width: 82px; + line-height: 1; +} + +.resource-brand__logo { + display: inline-block; + width: fit-content; + font-size: .78rem; + font-weight: 800; + letter-spacing: -.02em; + text-decoration: none; +} + + +.resource-brand__kind { + width: fit-content; + padding-left: 0; + color: var(--text-heading); + font-size: .72rem; + font-weight: 650; + letter-spacing: .01em; + text-decoration: none; +} + +.resource-brand__kind:hover, +.resource-brand__kind:focus-visible, +.resource-brand__logo:hover, +.resource-brand__logo:focus-visible { + color: var(--link-hover); +} + +@media (max-width: 520px) { + .resource-brand { + min-width: 70px; + } + + .resource-brand__logo { + font-size: .72rem; + } + + .resource-brand__kind { + padding-left: 0; + font-size: .68rem; + } +} diff --git a/static/editor.html b/static/editor.html index 4406001..3411a9b 100644 --- a/static/editor.html +++ b/static/editor.html @@ -14,8 +14,12 @@
-
__PARENT_TITLE__ +
+ +