From c0c3096e488eb88e8d6b1b8469cb9992b5d47f8b Mon Sep 17 00:00:00 2001 From: gilesb Date: Thu, 8 Jan 2026 18:09:51 +0000 Subject: [PATCH] Add configurable IPFS gateway URL with local gateway as primary - IPFS_GATEWAY_URL env var for local gateway (e.g., https://ipfs.celery-artdag.rose-ash.com) - Local gateway shown first with green button when configured - Removed Pinata from public gateways list Co-Authored-By: Claude Opus 4.5 --- docker-compose.yml | 2 +- server.py | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3ed63c9..d42d671 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,7 +49,7 @@ services: - DATABASE_URL=postgresql://artdag:artdag@postgres:5432/artdag - IPFS_API=/dns/ipfs/tcp/5001 - CACHE_DIR=/data/cache - # L2_SERVER and L2_DOMAIN from .env file + # L2_SERVER, L2_DOMAIN, IPFS_GATEWAY_URL from .env file volumes: - l1_cache:/data/cache depends_on: diff --git a/server.py b/server.py index 4a3d41d..2f8792b 100644 --- a/server.py +++ b/server.py @@ -40,6 +40,9 @@ L1_PUBLIC_URL = os.environ.get("L1_PUBLIC_URL", "http://localhost:8100") # Default L2 for login redirect when not logged in (user can login to any L2) DEFAULT_L2_SERVER = os.environ.get("DEFAULT_L2_SERVER", "http://localhost:8200") +# IPFS gateway URL for public access to IPFS content +IPFS_GATEWAY_URL = os.environ.get("IPFS_GATEWAY_URL", "") + # Cache directory (use /data/cache in Docker, ~/.artdag/cache locally) CACHE_DIR = Path(os.environ.get("CACHE_DIR", str(Path.home() / ".artdag" / "cache"))) CACHE_DIR.mkdir(parents=True, exist_ok=True) @@ -1778,6 +1781,30 @@ async def cache_detail(content_hash: str, request: Request): # Add IPFS section if we have a CID if ipfs_cid: + # Build gateway links - local gateway first if configured + gateway_links = [] + if IPFS_GATEWAY_URL: + gateway_links.append(f''' + + Local Gateway + ''') + gateway_links.extend([ + f''' + ipfs.io + ''', + f''' + dweb.link + ''', + f''' + Cloudflare + ''', + ]) + gateways_html = '\n'.join(gateway_links) + content += f'''

IPFS

@@ -1785,24 +1812,9 @@ async def cache_detail(content_hash: str, request: Request):
Content Identifier (CID)
{ipfs_cid}
-
Public Gateways:
+
Gateways:
'''