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 <noreply@anthropic.com>
This commit is contained in:
35
server.py
35
server.py
@@ -840,6 +840,41 @@ async def ui_asset_detail(name: str, request: Request):
|
||||
</div>
|
||||
</div>
|
||||
'''
|
||||
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'''
|
||||
<div class="bg-dark-600 rounded-lg p-4 mb-6">
|
||||
<h3 class="text-lg font-semibold text-white mb-3">Recipe Source</h3>
|
||||
<pre class="bg-dark-900 p-4 rounded-lg overflow-x-auto text-sm text-gray-300 font-mono whitespace-pre-wrap"><code>{recipe_source_escaped}</code></pre>
|
||||
<div class="mt-3 text-center">
|
||||
<a href="{l1_server}/cache/{content_hash}" download
|
||||
class="inline-block px-4 py-2 bg-green-600 hover:bg-green-700 text-white font-medium rounded-lg transition-colors">
|
||||
Download YAML
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
'''
|
||||
else:
|
||||
content_html = f'''
|
||||
<div class="bg-dark-600 rounded-lg p-4 mb-6 text-center">
|
||||
|
||||
Reference in New Issue
Block a user