license and some functions
This commit is contained in:
1 parent
0655cfe48c
commit
ef8dfc67c1
56 files changed
+2586
-547
No files matched your search
+18
-4
@@ -1,6 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Mateusz Gruszczyński @linuxiarz.pl
|
||||
* Source-Available Code / Dual-Licensed.
|
||||
*
|
||||
* Free for non-commercial and evaluation use under terms of BSL/GPLv3.
|
||||
* Commercial or production use requires a valid paid license.
|
||||
* See LICENSE file in repository root for details.
|
||||
*/
|
||||
|
||||
mod pages;
|
||||
|
||||
use pages::*;
|
||||
use axum::{
|
||||
Router,
|
||||
extract::{DefaultBodyLimit, Request},
|
||||
@@ -9,6 +17,7 @@ use axum::{
|
||||
response::Response,
|
||||
routing::{get, post},
|
||||
};
|
||||
use pages::*;
|
||||
use tower::{ServiceBuilder, service_fn};
|
||||
use tower_http::{services::ServeDir, set_header::SetResponseHeaderLayer, trace::TraceLayer};
|
||||
|
||||
@@ -118,7 +127,10 @@ pub fn router(
|
||||
"/api/pads/{slug}/editor-color",
|
||||
get(api::pad_editor_color).post(api::set_pad_editor_color),
|
||||
)
|
||||
.route("/api/pads/{slug}/editor-settings", post(api::set_pad_editor_settings))
|
||||
.route(
|
||||
"/api/pads/{slug}/editor-settings",
|
||||
post(api::set_pad_editor_settings),
|
||||
)
|
||||
.route("/api/pads/{slug}/publish", post(api::publish_pad_page))
|
||||
.route("/api/pads/{slug}/restore", post(api::pad_restore))
|
||||
.route(
|
||||
@@ -147,7 +159,10 @@ pub fn router(
|
||||
"/api/workspaces/{workspace_slug}/notes/{note_slug}/editor-color",
|
||||
get(api::note_editor_color).post(api::set_note_editor_color),
|
||||
)
|
||||
.route("/api/workspaces/{workspace_slug}/notes/{note_slug}/editor-settings", post(api::set_note_editor_settings))
|
||||
.route(
|
||||
"/api/workspaces/{workspace_slug}/notes/{note_slug}/editor-settings",
|
||||
post(api::set_note_editor_settings),
|
||||
)
|
||||
.route(
|
||||
"/api/workspaces/{workspace_slug}/notes/{note_slug}/publish",
|
||||
post(api::publish_note_page),
|
||||
@@ -233,4 +248,3 @@ async fn add_non_asset_security_headers(request: Request, next: Next) -> Respons
|
||||
|
||||
response
|
||||
}
|
||||
|
||||
+37
-5
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Mateusz Gruszczyński @linuxiarz.pl
|
||||
* Source-Available Code / Dual-Licensed.
|
||||
*
|
||||
* Free for non-commercial and evaluation use under terms of BSL/GPLv3.
|
||||
* Commercial or production use requires a valid paid license.
|
||||
* See LICENSE file in repository root for details.
|
||||
*/
|
||||
|
||||
use axum::{
|
||||
extract::{Path, State},
|
||||
http::{HeaderValue, StatusCode, header},
|
||||
@@ -66,7 +75,10 @@ pub(super) async fn pad(State(state): State<SharedState>, Path(slug): Path<Strin
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn public_page(State(state): State<SharedState>, Path(token): Path<String>) -> Response {
|
||||
pub(super) async fn public_page(
|
||||
State(state): State<SharedState>,
|
||||
Path(token): Path<String>,
|
||||
) -> Response {
|
||||
match db::find_published_page(&state.db, &token).await {
|
||||
Ok(Some(_)) => assets::render_html(
|
||||
include_str!("../../static/public.html"),
|
||||
@@ -99,8 +111,14 @@ pub(super) async fn workspace(
|
||||
) -> Response {
|
||||
match db::find_workspace(&state.db, &workspace_slug).await {
|
||||
Ok(Some(workspace)) => {
|
||||
let html = include_str!("../../static/workspace.html")
|
||||
.replace("__WORKSPACE_TITLE__", &escape_html(if workspace.is_private != 0 { "Workspace" } else { &workspace.title }));
|
||||
let html = include_str!("../../static/workspace.html").replace(
|
||||
"__WORKSPACE_TITLE__",
|
||||
&escape_html(if workspace.is_private != 0 {
|
||||
"Workspace"
|
||||
} else {
|
||||
&workspace.title
|
||||
}),
|
||||
);
|
||||
assets::render_html(
|
||||
&html,
|
||||
&state.asset_version,
|
||||
@@ -153,8 +171,22 @@ pub(super) async fn note(
|
||||
match db::find_note(&state.db, workspace.id, ¬e_slug).await {
|
||||
Ok(Some(note)) => {
|
||||
let html = include_str!("../../static/note.html")
|
||||
.replace("__NOTE_TITLE__", &escape_html(if workspace.is_private != 0 { "Note" } else { ¬e.title }))
|
||||
.replace("__WORKSPACE_TITLE__", &escape_html(if workspace.is_private != 0 { "Workspace" } else { &workspace.title }))
|
||||
.replace(
|
||||
"__NOTE_TITLE__",
|
||||
&escape_html(if workspace.is_private != 0 {
|
||||
"Note"
|
||||
} else {
|
||||
¬e.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,
|
||||
|
||||
Reference in new issue
Block a user