Spaces:
Sleeping
Sleeping
Commit ·
c1e4742
1
Parent(s): 28ae1ac
Move SVG icons from Python constants into HTML template directly
Browse filesStatic SVG markup has no reason to live as Python variables — inline
them in templates/app.html and drop the five constants and their
.format() kwargs from app.py.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- app.py +1 -20
- templates/app.html +5 -5
app.py
CHANGED
|
@@ -434,29 +434,10 @@ with open("static/wire_outputs.js") as _f:
|
|
| 434 |
with open("static/run_preprocess.js") as _f:
|
| 435 |
run_preprocess_js = _f.read()
|
| 436 |
|
| 437 |
-
# ── SVG icon constants (inlined into the HTML template) ───────────────────────
|
| 438 |
-
|
| 439 |
-
DOWNLOAD_SVG = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 16l-5-5h3V4h4v7h3l-5 5z"/><path d="M20 18H4v2h16v-2z"/></svg>'
|
| 440 |
-
|
| 441 |
-
UPLOAD_SVG = '<svg class="tb-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>'
|
| 442 |
-
|
| 443 |
-
REMOVE_SVG = '<svg class="tb-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>'
|
| 444 |
-
|
| 445 |
-
CLEAR_SVG = '<svg class="tb-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>'
|
| 446 |
-
|
| 447 |
-
FIRE_LOGO_SVG = '<svg viewBox="0 0 24 24" fill="white" xmlns="http://www.w3.org/2000/svg"><path d="M12 23c-3.6 0-8-2.69-8-7.5 0-3.5 3-6.5 4.5-8 .27-.27.75-.08.75.28v2.44c0 .42.5.63.72.28C12.28 7.5 13 3 13 1c0-.42.48-.64.8-.35C18 4.5 20 9 20 12c0 5.5-3.5 11-8 11z"/></svg>'
|
| 448 |
-
|
| 449 |
# ── HTML template ──────────────────────────────────────────────────────────────
|
| 450 |
|
| 451 |
with open("templates/app.html") as _f:
|
| 452 |
-
app_html = _f.read().format(
|
| 453 |
-
fire_logo_svg=FIRE_LOGO_SVG,
|
| 454 |
-
upload_svg=UPLOAD_SVG,
|
| 455 |
-
remove_svg=REMOVE_SVG,
|
| 456 |
-
clear_svg=CLEAR_SVG,
|
| 457 |
-
download_svg=DOWNLOAD_SVG,
|
| 458 |
-
example_cards_html=EXAMPLE_CARDS_HTML,
|
| 459 |
-
)
|
| 460 |
|
| 461 |
# ── Gradio blocks ──────────────────────────────────────────────────────────────
|
| 462 |
|
|
|
|
| 434 |
with open("static/run_preprocess.js") as _f:
|
| 435 |
run_preprocess_js = _f.read()
|
| 436 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
# ── HTML template ──────────────────────────────────────────────────────────────
|
| 438 |
|
| 439 |
with open("templates/app.html") as _f:
|
| 440 |
+
app_html = _f.read().format(example_cards_html=EXAMPLE_CARDS_HTML)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
|
| 442 |
# ── Gradio blocks ──────────────────────────────────────────────────────────────
|
| 443 |
|
templates/app.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
<div class="app-header">
|
| 4 |
<div class="app-header-left">
|
| 5 |
-
<div class="app-logo">
|
| 6 |
<span class="app-title">FireRed-Image-Edit</span>
|
| 7 |
<span class="app-badge">v1.1</span>
|
| 8 |
<span class="app-badge fast">4-Step Fast</span>
|
|
@@ -20,13 +20,13 @@
|
|
| 20 |
|
| 21 |
<div class="app-toolbar">
|
| 22 |
<button id="tb-upload" class="modern-tb-btn" title="Upload images">
|
| 23 |
-
|
| 24 |
</button>
|
| 25 |
<button id="tb-remove" class="modern-tb-btn" title="Remove selected image">
|
| 26 |
-
|
| 27 |
</button>
|
| 28 |
<button id="tb-clear" class="modern-tb-btn" title="Clear all images">
|
| 29 |
-
|
| 30 |
</button>
|
| 31 |
<div class="tb-sep"></div>
|
| 32 |
<span id="tb-image-count" class="tb-info">No images</span>
|
|
@@ -107,7 +107,7 @@
|
|
| 107 |
<div class="out-title">
|
| 108 |
<span>Output</span>
|
| 109 |
<span id="dl-btn-output" class="out-download-btn" title="Download">
|
| 110 |
-
|
| 111 |
</span>
|
| 112 |
</div>
|
| 113 |
<div class="out-body" id="output-image-container">
|
|
|
|
| 2 |
|
| 3 |
<div class="app-header">
|
| 4 |
<div class="app-header-left">
|
| 5 |
+
<div class="app-logo"><svg viewBox="0 0 24 24" fill="white" xmlns="http://www.w3.org/2000/svg"><path d="M12 23c-3.6 0-8-2.69-8-7.5 0-3.5 3-6.5 4.5-8 .27-.27.75-.08.75.28v2.44c0 .42.5.63.72.28C12.28 7.5 13 3 13 1c0-.42.48-.64.8-.35C18 4.5 20 9 20 12c0 5.5-3.5 11-8 11z"/></svg></div>
|
| 6 |
<span class="app-title">FireRed-Image-Edit</span>
|
| 7 |
<span class="app-badge">v1.1</span>
|
| 8 |
<span class="app-badge fast">4-Step Fast</span>
|
|
|
|
| 20 |
|
| 21 |
<div class="app-toolbar">
|
| 22 |
<button id="tb-upload" class="modern-tb-btn" title="Upload images">
|
| 23 |
+
<svg class="tb-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg><span class="tb-label">Upload</span>
|
| 24 |
</button>
|
| 25 |
<button id="tb-remove" class="modern-tb-btn" title="Remove selected image">
|
| 26 |
+
<svg class="tb-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg><span class="tb-label">Remove</span>
|
| 27 |
</button>
|
| 28 |
<button id="tb-clear" class="modern-tb-btn" title="Clear all images">
|
| 29 |
+
<svg class="tb-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg><span class="tb-label">Clear All</span>
|
| 30 |
</button>
|
| 31 |
<div class="tb-sep"></div>
|
| 32 |
<span id="tb-image-count" class="tb-info">No images</span>
|
|
|
|
| 107 |
<div class="out-title">
|
| 108 |
<span>Output</span>
|
| 109 |
<span id="dl-btn-output" class="out-download-btn" title="Download">
|
| 110 |
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 16l-5-5h3V4h4v7h3l-5 5z"/><path d="M20 18H4v2h16v-2z"/></svg> Save
|
| 111 |
</span>
|
| 112 |
</div>
|
| 113 |
<div class="out-body" id="output-image-container">
|