diff options
| author | Tyler <tyler@tylerhoang.xyz> | 2026-05-16 00:51:08 -0700 |
|---|---|---|
| committer | Tyler <tyler@tylerhoang.xyz> | 2026-05-16 00:51:08 -0700 |
| commit | 775762d75bf2b6b49893f84db1f4910ef1aa1e4b (patch) | |
| tree | 8fd13acd03214605f7d879f42f282d89674f3222 /components/overview.py | |
| parent | 49368331324f201307fd260d288e5c5f65ea3fcc (diff) | |
Harden script embedding, timezone parsing, and layout buffers
- overview: use json_for_script for inline payload/meta to prevent
</script> break-out from yfinance-sourced strings; raise iframe
height to cover responsive single-column collapse under 1100px
- news: treat naive ISO/strptime datetimes as UTC before converting
to local-naive, matching the int-timestamp branch from 75dbe29
- news: bump per-row iframe height to fit summary + metadata under
scrolling=False
- top_movers: drop name column in compact (sidebar) mode and tighten
grid so symbol/price/change fit a default-width Streamlit sidebar
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'components/overview.py')
| -rw-r--r-- | components/overview.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/components/overview.py b/components/overview.py index 27c4166..53358f0 100644 --- a/components/overview.py +++ b/components/overview.py @@ -7,6 +7,7 @@ import streamlit as st import streamlit.components.v1 as components from services.data_service import get_company_info, get_latest_price, get_price_history +from utils.security import json_for_script PERIODS = {"1mo": "1M", "3mo": "3M", "6mo": "6M", "1y": "1Y", "5y": "5Y"} SECTOR_ETF_MAP = { @@ -190,8 +191,6 @@ def _comparison_list(ticker: str, info: dict) -> list[dict]: def render_overview(ticker: str): - import json as _json - info = get_company_info(ticker) or {} if not info: st.error("Could not load data for this ticker.") @@ -271,8 +270,8 @@ def render_overview(ticker: str): "default_comparisons": ["^GSPC"], } - payload_js = "const OVERVIEW_DATA=" + _json.dumps(payload) + ";" - meta_js = "const OVERVIEW_META=" + _json.dumps(meta) + ";" + payload_js = "const OVERVIEW_DATA=" + json_for_script(payload) + ";" + meta_js = "const OVERVIEW_META=" + json_for_script(meta) + ";" if price is not None and prev_close is not None and prev_close > 0: chg_pct = (price - prev_close) / prev_close * 100.0 @@ -497,7 +496,7 @@ def render_overview(ticker: str): + "</script>" ) - height = 1480 + height = 1950 # extra ~470px buffer for responsive single-column collapse at <1100px doc = ( "<!doctype html><html><head><meta charset='utf-8'>" |
