Improve recipe display - show YAML source and L2 link
- Recipe detail page now shows the full YAML source - Shows "View on L2" link if recipe is shared to L2 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
30
server.py
30
server.py
@@ -1762,6 +1762,28 @@ async def recipe_detail_page(recipe_id: str, request: Request):
|
||||
if pinned:
|
||||
pinned_badge = f'<span class="px-2 py-1 bg-yellow-600 text-white text-xs rounded-full ml-2">Pinned: {pin_reason}</span>'
|
||||
|
||||
# Check if shared to L2
|
||||
l2_shares = await database.get_l2_shares(recipe_id, ctx.actor_id if ctx else None)
|
||||
l2_link_html = ""
|
||||
if l2_shares:
|
||||
share = l2_shares[0]
|
||||
l2_server = share.get("l2_server", "").replace("http://", "https://")
|
||||
asset_name = share.get("asset_name", "")
|
||||
l2_link_html = f'<a href="{l2_server}/ui/asset/{asset_name}" target="_blank" class="px-2 py-1 bg-blue-600 text-white text-xs rounded-full ml-2 hover:bg-blue-700">View on L2</a>'
|
||||
|
||||
# Load recipe source YAML
|
||||
recipe_path = cache_manager.get_by_content_hash(recipe_id)
|
||||
recipe_source = ""
|
||||
if recipe_path and recipe_path.exists():
|
||||
try:
|
||||
recipe_source = recipe_path.read_text()
|
||||
except Exception:
|
||||
recipe_source = "(Could not load recipe source)"
|
||||
|
||||
# Escape HTML in source for display
|
||||
import html
|
||||
recipe_source_escaped = html.escape(recipe_source)
|
||||
|
||||
content = f'''
|
||||
<div class="mb-6">
|
||||
<a href="/recipes" class="text-blue-400 hover:text-blue-300 text-sm">← Back to recipes</a>
|
||||
@@ -1772,12 +1794,18 @@ async def recipe_detail_page(recipe_id: str, request: Request):
|
||||
<h2 class="text-2xl font-bold text-white">{recipe.name}</h2>
|
||||
<span class="px-2 py-1 bg-gray-600 text-white text-xs rounded-full">v{recipe.version}</span>
|
||||
{pinned_badge}
|
||||
{l2_link_html}
|
||||
</div>
|
||||
<p class="text-gray-400 mb-4">{recipe.description or 'No description'}</p>
|
||||
<div class="text-xs text-gray-500 font-mono">{recipe.recipe_id}</div>
|
||||
<div class="text-xs text-gray-500 font-mono mb-4">{recipe.recipe_id}</div>
|
||||
{fixed_inputs_html}
|
||||
</div>
|
||||
|
||||
<div class="bg-dark-700 rounded-lg p-6 mb-6">
|
||||
<h3 class="text-lg font-semibold text-white mb-4">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>
|
||||
|
||||
<div class="bg-dark-700 rounded-lg p-6">
|
||||
<h3 class="text-lg font-semibold text-white mb-4">Run this Recipe</h3>
|
||||
<form hx-post="/ui/recipes/{recipe_id}/run" hx-target="#run-result" hx-swap="innerHTML">
|
||||
|
||||
Reference in New Issue
Block a user