updated notes

This commit is contained in:
2026-01-23 09:44:36 +01:00
parent 2dfe56ee53
commit 45930ee1c2
2 changed files with 29 additions and 19 deletions
+27 -18
View File
@@ -64,16 +64,17 @@ data:
return False
@APP.get("/notes")
def notes_widget(key: str = "", user: str = "default"):
"""Serve the notes widget HTML page for a specific user."""
def notes_widget(key: str = "", user: str = "default", accent: str = "ffffff"):
"""Serve the notes widget HTML page for a specific user with optional theme."""
expected_key = os.environ.get("GLANCE_HELPER_KEY", "")
if key != expected_key:
return Response(content="Unauthorized", status_code=401)
# Sanitize user for display
safe_user = re.sub(r'[^a-zA-Z0-9_-]', '', user) or "default"
# Sanitize accent color (hex only, default to white)
safe_accent = re.sub(r'[^a-fA-F0-9]', '', accent)[:6] or "ffffff"
current_notes = load_notes(safe_user)
# Escape for safe HTML embedding
escaped_notes = current_notes.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace('"', "&quot;")
html = f"""<!DOCTYPE html>
@@ -82,35 +83,39 @@ data:
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
:root {{
--accent: #{safe_accent};
--accent-20: #{safe_accent}33;
--accent-40: #{safe_accent}66;
--accent-60: #{safe_accent}99;
}}
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
body {{
background: transparent;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
height: 100vh;
display: flex;
flex-direction: column;
}}
.container {{
display: flex;
flex-direction: column;
height: 100%;
padding: 8px;
padding: 6px;
}}
.status {{
font-size: 11px;
color: rgba(255, 255, 255, 0.5);
padding: 4px 0;
color: var(--accent-60);
padding: 4px 8px;
text-align: right;
min-height: 20px;
}}
.status.saving {{ color: rgba(255, 200, 100, 0.8); }}
.status.saved {{ color: rgba(100, 255, 150, 0.8); }}
.status.error {{ color: rgba(255, 100, 100, 0.8); }}
.status.saving {{ color: rgba(255, 200, 100, 0.9); }}
.status.saved {{ color: rgba(150, 255, 180, 0.9); }}
.status.error {{ color: rgba(255, 120, 120, 0.9); }}
textarea {{
flex: 1;
width: 100%;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(255, 255, 255, 0.06);
border: 1px solid var(--accent-20);
border-radius: 8px;
color: rgba(255, 255, 255, 0.9);
font-size: 14px;
@@ -120,12 +125,16 @@ data:
outline: none;
}}
textarea:focus {{
border-color: rgba(180, 130, 220, 0.5);
background: rgba(255, 255, 255, 0.08);
border-color: var(--accent-40);
background: rgba(255, 255, 255, 0.1);
}}
textarea::placeholder {{
color: rgba(255, 255, 255, 0.3);
color: var(--accent-40);
}}
textarea::-webkit-scrollbar {{ width: 6px; }}
textarea::-webkit-scrollbar-track {{ background: transparent; }}
textarea::-webkit-scrollbar-thumb {{ background: var(--accent-40); border-radius: 3px; }}
textarea::-webkit-scrollbar-thumb:hover {{ background: var(--accent-60); }}
</style>
</head>
<body>
@@ -159,7 +168,7 @@ data:
}});
if (response.ok) {{
lastSaved = content;
updateStatus('Saved', 'saved');
updateStatus('Saved', 'saved');
setTimeout(() => updateStatus(''), 2000);
}} else {{
updateStatus('Save failed', 'error');