updated notes
This commit is contained in:
@@ -64,16 +64,17 @@ data:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@APP.get("/notes")
|
@APP.get("/notes")
|
||||||
def notes_widget(key: str = "", user: str = "default"):
|
def notes_widget(key: str = "", user: str = "default", accent: str = "ffffff"):
|
||||||
"""Serve the notes widget HTML page for a specific user."""
|
"""Serve the notes widget HTML page for a specific user with optional theme."""
|
||||||
expected_key = os.environ.get("GLANCE_HELPER_KEY", "")
|
expected_key = os.environ.get("GLANCE_HELPER_KEY", "")
|
||||||
if key != expected_key:
|
if key != expected_key:
|
||||||
return Response(content="Unauthorized", status_code=401)
|
return Response(content="Unauthorized", status_code=401)
|
||||||
|
|
||||||
# Sanitize user for display
|
|
||||||
safe_user = re.sub(r'[^a-zA-Z0-9_-]', '', user) or "default"
|
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)
|
current_notes = load_notes(safe_user)
|
||||||
# Escape for safe HTML embedding
|
|
||||||
escaped_notes = current_notes.replace("&", "&").replace("<", "<").replace(">", ">").replace('"', """)
|
escaped_notes = current_notes.replace("&", "&").replace("<", "<").replace(">", ">").replace('"', """)
|
||||||
|
|
||||||
html = f"""<!DOCTYPE html>
|
html = f"""<!DOCTYPE html>
|
||||||
@@ -82,35 +83,39 @@ data:
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<style>
|
<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; }}
|
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
|
||||||
body {{
|
body {{
|
||||||
background: transparent;
|
background: transparent;
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}}
|
}}
|
||||||
.container {{
|
.container {{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 8px;
|
padding: 6px;
|
||||||
}}
|
}}
|
||||||
.status {{
|
.status {{
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: rgba(255, 255, 255, 0.5);
|
color: var(--accent-60);
|
||||||
padding: 4px 0;
|
padding: 4px 8px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
min-height: 20px;
|
min-height: 20px;
|
||||||
}}
|
}}
|
||||||
.status.saving {{ color: rgba(255, 200, 100, 0.8); }}
|
.status.saving {{ color: rgba(255, 200, 100, 0.9); }}
|
||||||
.status.saved {{ color: rgba(100, 255, 150, 0.8); }}
|
.status.saved {{ color: rgba(150, 255, 180, 0.9); }}
|
||||||
.status.error {{ color: rgba(255, 100, 100, 0.8); }}
|
.status.error {{ color: rgba(255, 120, 120, 0.9); }}
|
||||||
textarea {{
|
textarea {{
|
||||||
flex: 1;
|
flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: rgba(255, 255, 255, 0.05);
|
background: rgba(255, 255, 255, 0.06);
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
border: 1px solid var(--accent-20);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
color: rgba(255, 255, 255, 0.9);
|
color: rgba(255, 255, 255, 0.9);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@@ -120,12 +125,16 @@ data:
|
|||||||
outline: none;
|
outline: none;
|
||||||
}}
|
}}
|
||||||
textarea:focus {{
|
textarea:focus {{
|
||||||
border-color: rgba(180, 130, 220, 0.5);
|
border-color: var(--accent-40);
|
||||||
background: rgba(255, 255, 255, 0.08);
|
background: rgba(255, 255, 255, 0.1);
|
||||||
}}
|
}}
|
||||||
textarea::placeholder {{
|
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>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -159,7 +168,7 @@ data:
|
|||||||
}});
|
}});
|
||||||
if (response.ok) {{
|
if (response.ok) {{
|
||||||
lastSaved = content;
|
lastSaved = content;
|
||||||
updateStatus('Saved', 'saved');
|
updateStatus('Saved ✓', 'saved');
|
||||||
setTimeout(() => updateStatus(''), 2000);
|
setTimeout(() => updateStatus(''), 2000);
|
||||||
}} else {{
|
}} else {{
|
||||||
updateStatus('Save failed', 'error');
|
updateStatus('Save failed', 'error');
|
||||||
|
|||||||
@@ -592,7 +592,8 @@ data:
|
|||||||
- size: small
|
- size: small
|
||||||
widgets:
|
widgets:
|
||||||
- type: iframe
|
- type: iframe
|
||||||
source: https://glance-helper.dooplex.hu/notes?key=oplQqnLnJK2vErRVYJpvVUcSDBOSbCHZSbsYY2bwSifgTMfT&user=orsi
|
css-class: iframe-no-tint
|
||||||
|
source: https://glance-helper.dooplex.hu/notes?key=...&user=orsi&accent=e292ff
|
||||||
height: 250
|
height: 250
|
||||||
title: Quick Notes
|
title: Quick Notes
|
||||||
- type: bookmarks
|
- type: bookmarks
|
||||||
|
|||||||
Reference in New Issue
Block a user