is_online. Internal helper function. This docstring was added automatically to improve maintainability. Args: username: Parameter. scope: Parameter. Returns: Varies.
(username: str, scope: str)
| 1206 | fk = font_key if font_key in FONT_PRESETS else DEFAULT_PREFS["font_key"] |
| 1207 | tk = ui_theme_key if ui_theme_key in UI_THEME_PRESETS else DEFAULT_PREFS["ui_theme_key"] |
| 1208 | try: |
| 1209 | conn = db_connect() |
| 1210 | conn.execute( |
| 1211 | "INSERT OR REPLACE INTO user_prefs(username, accent_key, font_key, ui_theme_key, updated_at) VALUES (?,?,?,?,?)", |
| 1212 | (username, ak, fk, tk, now_z()), |
| 1213 | ) |
| 1214 | conn.commit() |
| 1215 | conn.close() |
| 1216 | except Exception: |
| 1217 | pass |
| 1218 | |
| 1219 | |
| 1220 | def prefs_css(prefs: Dict[str, str]) -> str: |
| 1221 | """Build a small CSS override block for the active user's preferences.""" |
| 1222 | ak = (prefs or {}).get("accent_key") or DEFAULT_PREFS["accent_key"] |
| 1223 | fk = (prefs or {}).get("font_key") or DEFAULT_PREFS["font_key"] |
| 1224 | a = ACCENT_PRESETS.get(ak, ACCENT_PRESETS[DEFAULT_PREFS["accent_key"]]) |
| 1225 | f = FONT_PRESETS.get(fk, FONT_PRESETS[DEFAULT_PREFS["font_key"]]) |
| 1226 | # Later :root overrides earlier ones in BUT_CSS |
| 1227 | return f"\n:root{{--accent:{a['accent']};--accent-hover:{a['hover']};--app-font:{f['stack']};}}\n" |
| 1228 | |
| 1229 |
no outgoing calls
no test coverage detected