diff --git a/README.md b/README.md index 015f78b..fcf234b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # TypstDrive [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/your-username/typstdrive) +[![Typst Version](https://img.shields.io/badge/Typst-0.14.2-239dad?logo=typst&logoColor=white)](https://typst.app/) [![Rust](https://img.shields.io/badge/Rust-1.82+-orange?logo=rust&logoColor=white)](https://www.rust-lang.org/) [![SvelteKit](https://img.shields.io/badge/SvelteKit-5-ff3e00?logo=svelte)](https://kit.svelte.dev/) [![Tailwind CSS](https://img.shields.io/badge/Tailwind_CSS-06B6D4?logo=tailwindcss&logoColor=white)](https://tailwindcss.com/) @@ -8,7 +9,7 @@ [![SQLite](https://img.shields.io/badge/SQLite-003B57?logo=sqlite&logoColor=white)](https://www.sqlite.org/) [![Docker](https://img.shields.io/badge/Docker-2496ED?logo=docker&logoColor=white)](https://www.docker.com/) -TypstDrive is a real-time collaborative web editor for Typst. With built-in dark mode, multiple themes, and a clean Google Docs-like interface, it makes creating and sharing documents effortless. +TypstDrive is a collaborative web editor for Typst. With built-in dark mode, multiple themes, and a clean Google Docs-like interface, it makes creating and sharing documents effortless. ## Features @@ -89,3 +90,13 @@ If you'd like to contribute or run TypstDrive without Docker: 2. Build and run: `cargo run` Note: The frontend expects the backend to be running on port 3000. During local development via Vite, API calls are proxied automatically. + +## Screenshots + +

+ Editor view +

+

+ Dashboard view + Authentication view +

\ No newline at end of file diff --git a/preview/dashboard.png b/preview/dashboard.png new file mode 100644 index 0000000..2f8b571 Binary files /dev/null and b/preview/dashboard.png differ diff --git a/preview/editor.png b/preview/editor.png new file mode 100644 index 0000000..159c4dd Binary files /dev/null and b/preview/editor.png differ diff --git a/preview/register.png b/preview/register.png new file mode 100644 index 0000000..09db7a4 Binary files /dev/null and b/preview/register.png differ diff --git a/server/src/auth.rs b/server/src/auth.rs index 08f1575..a4643ee 100644 --- a/server/src/auth.rs +++ b/server/src/auth.rs @@ -7,7 +7,7 @@ use axum_extra::extract::cookie::{Cookie, SameSite, SignedCookieJar}; use uuid::Uuid; use crate::{ - models::{User, RegisterRequest, LoginRequest, ChangePasswordRequest, UpdateProfileRequest}, + models::{User, RegisterRequest, LoginRequest, ChangePasswordRequest, UpdateProfileRequest, StorageStats}, AppState, }; @@ -188,3 +188,35 @@ pub async fn change_password( Ok(StatusCode::OK) } + +pub async fn storage_stats( + State(state): State, + jar: SignedCookieJar, +) -> Result, (StatusCode, String)> { + let user_id = jar.get("session_user_id").map(|c| c.value().to_string()) + .ok_or((StatusCode::UNAUTHORIZED, "Not logged in".to_string()))?; + + let docs_size: (i64,) = sqlx::query_as( + "SELECT COALESCE(SUM(LENGTH(content)), 0) FROM documents WHERE owner_id = ?" + ) + .bind(&user_id) + .fetch_one(&state.db) + .await + .unwrap_or((0,)); + + let files_size: (i64,) = sqlx::query_as( + "SELECT COALESCE(SUM(LENGTH(data)), 0) FROM files WHERE owner_id = ?" + ) + .bind(&user_id) + .fetch_one(&state.db) + .await + .unwrap_or((0,)); + + let stats = StorageStats { + documents_size_bytes: docs_size.0, + files_size_bytes: files_size.0, + total_size_bytes: docs_size.0 + files_size.0, + }; + + Ok(Json(stats)) +} diff --git a/server/src/main.rs b/server/src/main.rs index 8024f59..7615612 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -70,6 +70,7 @@ async fn main() { .route("/auth/login", post(auth::login)) .route("/auth/logout", post(auth::logout)) .route("/auth/me", get(auth::me).put(auth::update_profile)) + .route("/auth/storage", get(auth::storage_stats)) .route("/auth/change-password", put(auth::change_password)) .route("/folders", get(folders::list_folders).post(folders::create_folder)) .route("/folders/{id}", delete(folders::delete_folder).patch(folders::update_folder)) diff --git a/server/src/models.rs b/server/src/models.rs index a0e1bf6..4eab573 100644 --- a/server/src/models.rs +++ b/server/src/models.rs @@ -83,3 +83,10 @@ pub struct UpdateDocumentRequest { pub title: Option, pub folder_id: Option, } + +#[derive(Debug, Serialize, Deserialize)] +pub struct StorageStats { + pub documents_size_bytes: i64, + pub files_size_bytes: i64, + pub total_size_bytes: i64, +} diff --git a/src/lib/components/Footer.svelte b/src/lib/components/Footer.svelte index 49d33d2..8a36820 100644 --- a/src/lib/components/Footer.svelte +++ b/src/lib/components/Footer.svelte @@ -1,8 +1,9 @@ -