feat: add public share page with download support (#253)
Share links now point to /s/{token} (was /api/s/{token}) and render a
proper HTML page instead of raw JSON.
Changes:
- static/share.html: standalone public share page
- static/css/views/share-public.css: share page styles
- static/js/views/public/publicShare.js: client-side logic that fetches
share metadata via /api/s/{token}, handles password-protected shares,
and renders file download / folder info
- build.rs: include share.html in the HTML embed pipeline
- web/mod.rs: serve /s/{token} route (unauthenticated)
- share_dto.rs: generate URLs as /s/{token} instead of /api/s/{token}
- share_handler.rs: new download_shared_file() handler that validates the
share token and streams file content without requiring authentication
- routes.rs: mount GET /api/s/{token}/download (public, uses AppState)
This commit is contained in:
@@ -59,6 +59,7 @@ pub fn create_web_routes() -> Router<Arc<AppState>> {
|
||||
.route("/profile", get(serve_profile_page))
|
||||
.route("/admin", get(serve_admin_page))
|
||||
.route("/device", get(serve_device_verify_page))
|
||||
.route("/s/{token}", get(serve_share_page))
|
||||
// Serve static files with compression + cache headers
|
||||
.fallback_service(static_service)
|
||||
.layer(CompressionLayer::new().br(true).gzip(true))
|
||||
@@ -90,3 +91,8 @@ async fn serve_device_verify_page() -> Html<&'static str> {
|
||||
"/device-verify.html"
|
||||
)))
|
||||
}
|
||||
|
||||
/// Serve the public share page (unauthenticated)
|
||||
async fn serve_share_page() -> Html<&'static str> {
|
||||
Html(include_str!(concat!(env!("OUT_DIR"), "/share.html")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user