From c0a98dd0fff1db2baf66cb3bb6fddf128c8a8259 Mon Sep 17 00:00:00 2001 From: gilesb Date: Thu, 8 Jan 2026 15:18:40 +0000 Subject: [PATCH] Rename Cache to Media in navigation, add login to home page - Change navigation tab from "Cache" to "Media" - Change /cache list route to /media - Add Recipes link to home page navigation - Add Login button to home page - Update all active_tab="cache" to active_tab="media" - Update "Back to cache" links to "Back to media" Co-Authored-By: Claude Opus 4.5 --- server.py | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/server.py b/server.py index 65bc4c1..7605e11 100644 --- a/server.py +++ b/server.py @@ -357,8 +357,10 @@ HOME_HTML = """

Art DAG L1 Server

@@ -386,7 +388,8 @@ HOME_HTML = """ POST/runsStart a rendering run GET/runsList all runs GET/runs/{run_id}Get run status - GET/cacheList cached content hashes + GET/mediaList media items + GET/recipesList recipes GET/cache/{hash}Download cached content POST/cache/uploadUpload file to cache GET/assetsList known assets @@ -1594,19 +1597,19 @@ async def cache_detail(content_hash: str, request: Request): if not cache_path: if wants_html(request): content = f'

Content not found: {content_hash}

' - return HTMLResponse(render_page("Not Found", content, current_user, active_tab="cache"), status_code=404) + return HTMLResponse(render_page("Not Found", content, current_user, active_tab="media"), status_code=404) raise HTTPException(404, f"Content {content_hash} not in cache") if wants_html(request): if not current_user: content = '

Login to view cached content.

' - return HTMLResponse(render_page("Login Required", content, current_user, active_tab="cache"), status_code=401) + return HTMLResponse(render_page("Login Required", content, current_user, active_tab="media"), status_code=401) # Check user has access user_hashes = get_user_cache_hashes(current_user) if content_hash not in user_hashes: content = '

Access denied.

' - return HTMLResponse(render_page("Access Denied", content, current_user, active_tab="cache"), status_code=403) + return HTMLResponse(render_page("Access Denied", content, current_user, active_tab="media"), status_code=403) media_type = detect_media_type(cache_path) file_size = cache_path.stat().st_size @@ -1626,11 +1629,11 @@ async def cache_detail(content_hash: str, request: Request): media_html = f'

Unknown file type. Download file

' content = f''' - + - Back to cache + Back to media
@@ -1681,7 +1684,7 @@ async def cache_detail(content_hash: str, request: Request):
''' - return HTMLResponse(render_page(f"Cache: {content_hash[:16]}...", content, current_user, active_tab="cache")) + return HTMLResponse(render_page(f"Cache: {content_hash[:16]}...", content, current_user, active_tab="media")) # JSON response - return metadata meta = load_cache_meta(content_hash) @@ -2091,8 +2094,8 @@ async def ui_republish_cache(content_hash: str, request: Request): return '
Updated on L2!
' -@app.get("/cache") -async def list_cache( +@app.get("/media") +async def list_media( request: Request, page: int = 1, limit: int = 20, @@ -2100,14 +2103,14 @@ async def list_cache( collection: Optional[str] = None, tag: Optional[str] = None ): - """List cached content. HTML for browsers (with infinite scroll), JSON for APIs (with pagination).""" + """List media items. HTML for browsers (with infinite scroll), JSON for APIs (with pagination).""" current_user = get_user_from_cookie(request) if wants_html(request): - # Require login for HTML cache view + # Require login for HTML media view if not current_user: - content = '

Login to see cached content.

' - return HTMLResponse(render_page("Cache", content, current_user, active_tab="cache")) + content = '

Login to see media.

' + return HTMLResponse(render_page("Media", content, current_user, active_tab="media")) # Get hashes owned by/associated with this user user_hashes = get_user_cache_hashes(current_user) @@ -2165,7 +2168,7 @@ async def list_cache( filter_msg = f" in collection '{collection}'" elif tag: filter_msg = f" with tag '{tag}'" - content = f'

No cached files{filter_msg}. Upload files or run effects to see them here.

' + content = f'

No media{filter_msg}. Upload files or run effects to see them here.

' else: return HTMLResponse("") # Empty for infinite scroll else: @@ -2216,7 +2219,7 @@ async def list_cache( if tag: query_params += f"&tag={tag}" html_parts.append(f''' -
+

Loading more...

''') @@ -2233,20 +2236,20 @@ async def list_cache( if tag: query_params += f"&tag={tag}" infinite_scroll_trigger = f''' -
+

Loading more...

''' content = f''' -

Cache ({total} items)

+

Media ({total} items)

{''.join(html_parts)} {infinite_scroll_trigger}
''' - return HTMLResponse(render_page("Cache", content, current_user, active_tab="cache")) + return HTMLResponse(render_page("Media", content, current_user, active_tab="media")) # JSON response for APIs - list all hashes with optional pagination all_hashes = [cf.content_hash for cf in cache_manager.list_all()] @@ -2373,7 +2376,7 @@ async def ui_discard_cache(content_hash: str, request: Request): return '''
- Item discarded. Back to cache + Item discarded. Back to media
''' @@ -2952,7 +2955,7 @@ def render_page(title: str, content: str, username: Optional[str] = None, active runs_active = "border-b-2 border-blue-500 text-white" if active_tab == "runs" else "text-gray-400 hover:text-white" recipes_active = "border-b-2 border-blue-500 text-white" if active_tab == "recipes" else "text-gray-400 hover:text-white" - cache_active = "border-b-2 border-blue-500 text-white" if active_tab == "cache" else "text-gray-400 hover:text-white" + media_active = "border-b-2 border-blue-500 text-white" if active_tab == "media" else "text-gray-400 hover:text-white" return f""" @@ -2975,7 +2978,7 @@ def render_page(title: str, content: str, username: Optional[str] = None, active