From 4c177a64c2a53d310e2728ea0628f621635b69a9 Mon Sep 17 00:00:00 2001 From: gilesb Date: Fri, 9 Jan 2026 11:33:44 +0000 Subject: [PATCH] Show recipe source on L2 asset detail page Recipe assets now display their YAML source code in a formatted code block instead of just a download link. Co-Authored-By: Claude Opus 4.5 --- server.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/server.py b/server.py index 1d24567..5dad17d 100644 --- a/server.py +++ b/server.py @@ -840,6 +840,41 @@ async def ui_asset_detail(name: str, request: Request): ''' + elif asset_type == "recipe": + # Fetch recipe source from L1 or IPFS + recipe_source = "" + try: + resp = requests.get(f"{l1_server}/cache/{content_hash}", timeout=10, headers={"Accept": "text/plain"}) + if resp.status_code == 200: + recipe_source = resp.text + except Exception: + pass + + if not recipe_source and ipfs_cid: + # Try IPFS + try: + import ipfs_client + recipe_bytes = ipfs_client.get_bytes(ipfs_cid) + if recipe_bytes: + recipe_source = recipe_bytes.decode('utf-8') + except Exception: + pass + + import html as html_module + recipe_source_escaped = html_module.escape(recipe_source) if recipe_source else "(Could not load recipe source)" + + content_html = f''' +
+

Recipe Source

+
{recipe_source_escaped}
+ +
+ ''' else: content_html = f'''