#!/usr/bin/env python3 """Generate results/index.html — a landing page linking to every dashboard in the results/ directory. Rerun anytime new dashboards are added.""" import os, re, html RESULTS = "/home/user/polisci/results" # Metadata for each dashboard (name, party, chamber, district/state). # Anything not listed here is auto-rendered with just the filename. META = { "ThomasMassie119.html": ("Thomas Massie", "R", "House", "KY-4"), "RoKhanna119.html": ("Ro Khanna", "D", "House", "CA-17"), "AlexandriaOcasioCortez119.html":("Alexandria Ocasio-Cortez", "D", "House", "NY-14"), "IlhanOmar119.html": ("Ilhan Omar", "D", "House", "MN-5"), "MarjorieTaylorGreene119.html": ("Marjorie Taylor Greene", "R", "House", "GA-14"), "JimJordan119.html": ("Jim Jordan", "R", "House", "OH-4"), "ByronDonalds119.html": ("Byron Donalds", "R", "House", "FL-19"), "LindseyGraham119.html": ("Lindsey Graham", "R", "Senate", "SC"), } PARTY_COLOR = {"R": "#d93b3b", "D": "#3b6ed9", "I": "#888"} CHAMBER_COLOR = {"House": "#1e6b1e", "Senate": "#5a3d8a"} def main(): files = sorted(f for f in os.listdir(RESULTS) if f.endswith(".html") and f != "index.html") cards = [] for f in files: meta = META.get(f) if meta: name, party, chamber, loc = meta else: name = re.sub(r"119\.html$", "", f) party, chamber, loc = "?", "?", "" pc = PARTY_COLOR.get(party, "#888") cc = CHAMBER_COLOR.get(chamber, "#888") cards.append(f"""
{html.escape(name)}
{html.escape(party)} {html.escape(chamber)} {html.escape(loc)}
{html.escape(f)}
""") page = f""" 119th Congress Voting Dashboards — Index

119th Congress — Voting Dashboards

Per-member voting analysis for the 119th U.S. Congress (Jan 2025 – present). Click any card to open its dashboard. See DOCUMENTATION.md for methodology, data sources, and roster notes.
{''.join(cards)}
""" out = os.path.join(RESULTS, "index.html") with open(out, "w") as f: f.write(page) print(f"Wrote {out} with {len(files)} entries") if __name__ == "__main__": main()