diff --git a/server.py b/server.py index fb10313..4a3d41d 100644 --- a/server.py +++ b/server.py @@ -1714,6 +1714,10 @@ async def cache_detail(content_hash: str, request: Request): elif file_size > 1024: size_str = f"{file_size/1024:.1f} KB" + # Get IPFS CID from database + cache_item = await database.get_cache_item(content_hash) + ipfs_cid = cache_item.get("ipfs_cid") if cache_item else None + # Build media display HTML if media_type == "video": video_src = video_src_for_request(content_hash, request) @@ -1770,7 +1774,47 @@ async def cache_detail(content_hash: str, request: Request): + ''' + # Add IPFS section if we have a CID + if ipfs_cid: + content += f''' +
+

IPFS

+
+
Content Identifier (CID)
+
{ipfs_cid}
+
+
Public Gateways:
+
+ + ipfs.io + + + dweb.link + + + Cloudflare + + + Pinata + +
+
+ ''' + else: + content += ''' +
+

IPFS

+
Not yet uploaded to IPFS
+
+ ''' + + content += f'''
@@ -1783,12 +1827,15 @@ async def cache_detail(content_hash: str, request: Request): # JSON response - return metadata meta = await database.load_item_metadata(content_hash, ctx.actor_id if ctx else None) + cache_item = await database.get_cache_item(content_hash) + ipfs_cid = cache_item.get("ipfs_cid") if cache_item else None file_size = cache_path.stat().st_size media_type = detect_media_type(cache_path) return { "content_hash": content_hash, "size": file_size, "media_type": media_type, + "ipfs_cid": ipfs_cid, "meta": meta } @@ -3510,6 +3557,11 @@ async def ui_media_list( cache_path = get_cache_path(content_hash) media_type = detect_media_type(cache_path) if cache_path else "unknown" + # Check IPFS status + cache_item = await database.get_cache_item(content_hash) + ipfs_cid = cache_item.get("ipfs_cid") if cache_item else None + ipfs_badge = 'IPFS' if ipfs_cid else '' + # Format size size = item["size"] if size > 1024*1024: @@ -3523,7 +3575,10 @@ async def ui_media_list(
- {media_type} +
+ {media_type} + {ipfs_badge} +
{size_str}
{content_hash[:24]}...