From e04beb31d2e7ebb8fe74cb6c0fd5163992d2dc5f Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Sun, 1 Feb 2026 18:03:32 +0100 Subject: [PATCH] updated widgets --- glance-system/glance-helper.yaml | 256 +++++++++++++++++------------ glance-system/glance-kisfenyo.yaml | 6 +- 2 files changed, 158 insertions(+), 104 deletions(-) diff --git a/glance-system/glance-helper.yaml b/glance-system/glance-helper.yaml index 1178ada..5b89edb 100644 --- a/glance-system/glance-helper.yaml +++ b/glance-system/glance-helper.yaml @@ -309,15 +309,20 @@ data: # Todo Widget # -------------------------------- @APP.get("/userdata/todo") - def todo_widget(key: str = "", user: str = "default", accent: str = "4ade80", bgcolor: str = "0d1117"): + def todo_widget(key: str = "", user: str = "default", accent: str = "5ac8d8", bgcolor: str = "transparent"): """Serve the Todo widget HTML page.""" expected_key = os.environ.get("GLANCE_HELPER_KEY", "") if key != expected_key: return Response(content="Unauthorized", status_code=401) safe_user = re.sub(r'[^a-zA-Z0-9_-]', '', user) or "default" - safe_accent = re.sub(r'[^a-fA-F0-9]', '', accent)[:6] or "4ade80" - safe_bgcolor = re.sub(r'[^a-fA-F0-9]', '', bgcolor)[:6] or "0d1117" + safe_accent = re.sub(r'[^a-fA-F0-9]', '', accent)[:6] or "5ac8d8" + # Handle transparent background + if bgcolor == "transparent" or not bgcolor: + bg_style = "transparent" + else: + safe_bgcolor = re.sub(r'[^a-fA-F0-9]', '', bgcolor)[:6] + bg_style = f"#{safe_bgcolor}" if safe_bgcolor else "transparent" sections = load_userdata(safe_user) todos = sections.get("Todo", []) @@ -345,10 +350,9 @@ data: --accent-20: #{safe_accent}33; --accent-40: #{safe_accent}66; --accent-60: #{safe_accent}99; - --bgcolor: #{safe_bgcolor}; }} * {{ margin: 0; padding: 0; box-sizing: border-box; }} - html, body {{ background: var(--bgcolor); height: 100%; }} + html, body {{ background: {bg_style}; height: 100%; }} body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: rgba(255,255,255,0.9); }} .container {{ display: flex; flex-direction: column; height: 100%; padding: 8px; gap: 8px; }} .todo-list {{ flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }} @@ -364,7 +368,7 @@ data: width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); flex-shrink: 0; }} - .todo-text {{ flex: 1; font-size: 14px; line-height: 1.4; word-break: break-word; }} + .todo-text {{ flex: 1; font-size: 14px; line-height: 1.4; word-break: break-word; color: rgba(255,255,255,0.85); }} .todo-delete {{ opacity: 0; background: none; border: none; cursor: pointer; font-size: 14px; padding: 4px; transition: opacity 0.15s; @@ -377,7 +381,7 @@ data: color: rgba(255,255,255,0.9); font-size: 14px; outline: none; }} .add-input:focus {{ border-color: var(--accent-40); background: rgba(255,255,255,0.1); }} - .add-input::placeholder {{ color: var(--accent-40); }} + .add-input::placeholder {{ color: rgba(255,255,255,0.4); }} .add-btn {{ padding: 10px 16px; background: var(--accent-20); border: none; border-radius: 6px; color: var(--accent); font-size: 14px; cursor: pointer; @@ -491,15 +495,19 @@ data: import random as _random @APP.get("/userdata/motivation") - def motivation_widget(key: str = "", user: str = "default", accent: str = "4ade80", bgcolor: str = "0d1117"): - """Serve the Motivation widget HTML page with random quote and settings modal.""" + def motivation_widget(key: str = "", user: str = "default", accent: str = "5ac8d8", bgcolor: str = "transparent"): + """Serve the Motivation widget HTML page with random quote.""" expected_key = os.environ.get("GLANCE_HELPER_KEY", "") if key != expected_key: return Response(content="Unauthorized", status_code=401) safe_user = re.sub(r'[^a-zA-Z0-9_-]', '', user) or "default" - safe_accent = re.sub(r'[^a-fA-F0-9]', '', accent)[:6] or "4ade80" - safe_bgcolor = re.sub(r'[^a-fA-F0-9]', '', bgcolor)[:6] or "0d1117" + safe_accent = re.sub(r'[^a-fA-F0-9]', '', accent)[:6] or "5ac8d8" + if bgcolor == "transparent" or not bgcolor: + bg_style = "transparent" + else: + safe_bgcolor = re.sub(r'[^a-fA-F0-9]', '', bgcolor)[:6] + bg_style = f"#{safe_bgcolor}" if safe_bgcolor else "transparent" sections = load_userdata(safe_user) quotes = sections.get("Motivation", []) @@ -508,11 +516,8 @@ data: current_quote = _random.choice(quotes) if quotes else "Add your first motivational quote!" current_quote_escaped = current_quote.replace("&", "&").replace("<", "<").replace(">", ">").replace('"', """) - # Build quotes list for modal - quotes_html = "" - for i, q in enumerate(quotes): - q_escaped = q.replace("&", "&").replace("<", "<").replace(">", ">").replace('"', """) - quotes_html += f'
{q_escaped}
' + # Build manage URL (opens in new tab) + manage_url = f"/userdata/motivation/manage?key={expected_key}&user={safe_user}&accent={safe_accent}" html = f""" @@ -522,113 +527,149 @@ data:
- + ⚙️
"{current_quote_escaped}"
-
{len(quotes)} quote{'s' if len(quotes) != 1 else ''}
+
- -