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:
@@ -46,7 +46,7 @@ pub struct UpdateShareDto {
|
||||
/// Extension methods to convert between DTOs and domain entities
|
||||
impl ShareDto {
|
||||
pub fn from_entity(share: &Share, base_url: &str) -> Self {
|
||||
let url = format!("{}/api/s/{}", base_url, share.token());
|
||||
let url = format!("{}/s/{}", base_url, share.token());
|
||||
|
||||
Self {
|
||||
id: share.id().to_string(),
|
||||
|
||||
@@ -1135,6 +1135,6 @@ mod tests {
|
||||
assert_eq!(share_dto.item_id, "test_file_id");
|
||||
assert_eq!(share_dto.item_type, "file");
|
||||
assert!(share_dto.has_password);
|
||||
assert!(share_dto.url.starts_with("http://127.0.0.1:8086/api/s/"));
|
||||
assert!(share_dto.url.starts_with("http://127.0.0.1:8086/s/"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user