🔒 Repository is read-only – file editing is disabled.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
# -*- coding: utf-8 -*-
"""Wstawia ikony SVG do pustych kontroli po usunięciu emoji + konwersja flag na .flg."""
import glob, re
TRASH = '<svg class="i16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M10 11v6M14 11v6"/></svg>'
GEAR = '<svg class="i16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3"/><path d="M1 14h6M9 8h6M17 16h6"/></svg>'
WRENCH = '<svg class="i16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>'
LINK = '<svg class="i16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>'
PEN = '<svg class="i16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>'
def pick_icon(tag, attrs):
a = (attrs or "").lower()
if "nav-admin" in a or "settings" in (attrs or "") or a.count("ustawienia") or "/settings" in a:
return GEAR
if "usun" in a or "delete" in a or "remove" in a or "przywroc" in a:
return TRASH
if "rename" in a or "przemianuj" in a:
return PEN
if 'data-act="deps"' in attrs or "łańcuch" in a or "chain" in a:
return LINK
if 'data-act="build"' in attrs or "zbuduj" in a:
return WRENCH
if "background:#da" in a or "btn-danger" in a:
return TRASH
return ""
pat_btn = re.compile(r"<button([^>]*)>\s*</button>")
pat_a = re.compile(r"<a([^>]*)>\s*</a>")
def fix(text):
def rb(m):
ic = pick_icon("button", m.group(1))
return f"<button{m.group(1)}>{ic}</button>" if ic else m.group(0)
def ra(m):
ic = pick_icon("a", m.group(1))
return f"<a{m.group(1)}>{ic}</a>" if ic else m.group(0)
return pat_btn.sub(rb, text)
changed = []
for f in sorted(glob.glob("templates/**/*.html", recursive=True)):
t = open(f, encoding="utf-8").read()
n = fix(t)
if n != t:
open(f, "w", encoding="utf-8").write(n)
changed.append(f)
print("zmieniono:", len(changed))
for f in changed:
print(" -", f)