0f91b8bb7c
- Add SharedLink model with token, expiry, view limit, password hash
- Add migration 025_add_shared_links
- Add API endpoints: create, list, revoke (auth) + public info/download
- Add management UI at /shared-links with revoke controls
- Add public share landing page at /share/{token}
- Add Share button on file_view.html
- Add Shared Links to user dropdown in common.js
- Write 35 unit tests covering all scenarios
- Update UserGuide.md with sharing documentation
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
29 lines
928 B
Python
29 lines
928 B
Python
"""Public view for accessing a shared document link.
|
|
|
|
This route does NOT require authentication — it is the landing page
|
|
that link recipients visit. The page fetches link metadata via the
|
|
public ``/api/share/{token}/info`` JSON endpoint and then renders the
|
|
appropriate download UI (password gate or direct download button).
|
|
"""
|
|
|
|
import logging
|
|
import pathlib
|
|
|
|
from fastapi import APIRouter, Request
|
|
from fastapi.templating import Jinja2Templates
|
|
|
|
logger = logging.getLogger(__name__)
|
|
router = APIRouter()
|
|
|
|
_templates_dir = pathlib.Path(__file__).parents[2] / "frontend" / "templates"
|
|
templates = Jinja2Templates(directory=str(_templates_dir))
|
|
|
|
|
|
@router.get("/share/{token}")
|
|
async def shared_link_view(request: Request, token: str):
|
|
"""Render the public share landing page for a given token."""
|
|
return templates.TemplateResponse(
|
|
"shared_link_view.html",
|
|
{"request": request, "token": token},
|
|
)
|