icons and logos
This commit is contained in:
+10
-4
@@ -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}",
|
||||
|
||||
+76
-4
@@ -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",
|
||||
|
||||
+6
-1
@@ -60,7 +60,12 @@ pub fn render_html(
|
||||
"false"
|
||||
},
|
||||
)
|
||||
.replace("</head>", &format!("{frontend_config}</head>"));
|
||||
.replace(
|
||||
"</head>",
|
||||
&format!(
|
||||
r#"<link rel="icon" href="/favicon.svg" type="image/svg+xml"><link rel="icon" href="/favicon.ico" sizes="any"><link rel="icon" href="/favicon-32.png" type="image/png" sizes="32x32"><link rel="apple-touch-icon" href="/apple-touch-icon.png">{frontend_config}</head>"#
|
||||
),
|
||||
);
|
||||
|
||||
let mut response = Html(html).into_response();
|
||||
response.headers_mut().insert(
|
||||
|
||||
Reference in New Issue
Block a user