This commit is contained in:
Mateusz Gruszczyński committed 2026-07-28 23:53:37 +02:00
1 parent bc25e49bd6
commit 09669ff330
28 files changed
+412 -89

No files matched your search

-1
View File
@@ -50,7 +50,6 @@ pub fn router(
.route("/s/{token}", get(public_page))
.route("/w/{workspace_slug}", get(workspace))
.route("/w/{workspace_slug}/n/{note_slug}", get(note))
.route("/errors/private-workspace", get(private_workspace_error))
.route("/health", get(health))
.route("/robots.txt", get(robots_txt))
.route("/favicon.ico", get(favicon))
+11 -23
View File
@@ -6,18 +6,6 @@ use axum::{
use crate::{assets, db, state::SharedState};
pub(super) async fn private_workspace_error(State(state): State<SharedState>) -> Response {
error_response(
StatusCode::FORBIDDEN,
"403",
"Private workspace",
"You do not have permission to access this private workspace. Ask the owner to share it with your account or use a valid share link.",
"/",
"Home page",
&state.asset_version,
)
}
pub(super) async fn health() -> &'static str {
"ok"
}
@@ -112,7 +100,7 @@ pub(super) async fn workspace(
match db::find_workspace(&state.db, &workspace_slug).await {
Ok(Some(workspace)) => {
let html = include_str!("../../static/workspace.html")
.replace("__WORKSPACE_TITLE__", &escape_html(&workspace.title));
.replace("__WORKSPACE_TITLE__", &escape_html(if workspace.is_private != 0 { "Workspace" } else { &workspace.title }));
assets::render_html(
&html,
&state.asset_version,
@@ -126,8 +114,8 @@ pub(super) async fn workspace(
Ok(None) => error_response(
StatusCode::NOT_FOUND,
"404",
"Workspace not found",
"This workspace does not exist or has been deleted.",
"Page not found",
"Check the address or return to the home page.",
"/",
"Home page",
&state.asset_version,
@@ -149,8 +137,8 @@ pub(super) async fn note(
return error_response(
StatusCode::NOT_FOUND,
"404",
"Workspace not found",
"The workspace for this note does not exist or has been deleted.",
"Page not found",
"Check the address or return to the home page.",
"/",
"Home page",
&state.asset_version,
@@ -165,8 +153,8 @@ pub(super) async fn note(
match db::find_note(&state.db, workspace.id, &note_slug).await {
Ok(Some(note)) => {
let html = include_str!("../../static/note.html")
.replace("__NOTE_TITLE__", &escape_html(&note.title))
.replace("__WORKSPACE_TITLE__", &escape_html(&workspace.title))
.replace("__NOTE_TITLE__", &escape_html(if workspace.is_private != 0 { "Note" } else { &note.title }))
.replace("__WORKSPACE_TITLE__", &escape_html(if workspace.is_private != 0 { "Workspace" } else { &workspace.title }))
.replace("__WORKSPACE_SLUG__", &escape_html(&workspace_slug));
assets::render_html(
&html,
@@ -181,10 +169,10 @@ pub(super) async fn note(
Ok(None) => error_response(
StatusCode::NOT_FOUND,
"404",
"Note not found",
"This note does not exist or has been deleted.",
&format!("/w/{workspace_slug}"),
"Back do workspace",
"Page not found",
"Check the address or return to the home page.",
"/",
"Home page",
&state.asset_version,
),
Err(error) => {