Politrack: track Austrian politicians from public sources
Initial import of Politrack, a self-hosted service that tracks Austrian politicians from federal to municipal level - roles, votes, money flows, statements, meetings, social media and legal proceedings - with every claim linked to its sources. - backend: FastAPI + Postgres/pgvector; adapter framework (fetch -> parse -> load -> enrich) with robots.txt/TDM-aware fetching, a raw-response archive for reparsing, and a claim/evidence model with corroboration - sources: Parliament, Wikidata, EU Parliament/Commission, Council of Ministers, Rechnungshof party reports and donations, procurement, RTR media transparency, political ad libraries, WKStA, news feeds, Wikipedia edits, Bluesky, Mastodon, public Telegram channels, YouTube and X (official API) - web: Next.js frontend in German and English with typed API client - mcp: MCP server for AI agents and RAG - docs: architecture, data model, sources, legal notes, Unraid deployment and contributor guides; Docker Compose setup for Unraid Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
583ccba31c
187 files changed
+39890
No files matched your search
@@ -0,0 +1,21 @@
|
||||
FROM node:22-alpine AS deps
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
||||
|
||||
FROM node:22-alpine AS build
|
||||
WORKDIR /app
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 PORT=3000 HOSTNAME=0.0.0.0
|
||||
COPY --from=build /app/.next/standalone ./
|
||||
COPY --from=build /app/.next/static ./.next/static
|
||||
COPY --from=build /app/public ./public
|
||||
USER node
|
||||
EXPOSE 3000
|
||||
CMD ["node", "server.js"]
|
||||
@@ -0,0 +1,394 @@
|
||||
{
|
||||
"Meta": {
|
||||
"title": "Politrack – Österreichs Politik, belegt",
|
||||
"description": "Was Österreichs Politikerinnen und Politiker tun: Abstimmungen, Geld, Auftritte, Aussagen – jede Angabe mit Quelle."
|
||||
},
|
||||
"Nav": {
|
||||
"home": "Start",
|
||||
"persons": "Personen",
|
||||
"parties": "Parteien",
|
||||
"votes": "Abstimmungen",
|
||||
"search": "Suche",
|
||||
"settings": "Meine Filter",
|
||||
"method": "Methodik & Quellen",
|
||||
"language": "English",
|
||||
"calendar": "Kalender",
|
||||
"former": "Ehemalige",
|
||||
"organizations": "Organisationen",
|
||||
"money": "Geld",
|
||||
"social": "Social Media"
|
||||
},
|
||||
"Home": {
|
||||
"headline": "Politik in Österreich – nachvollziehbar.",
|
||||
"intro": "Politrack sammelt öffentlich zugängliche Informationen über Politikerinnen, Politiker und Parteien und verlinkt jede Angabe mit ihren Quellen. Du entscheidest, welchen Quellen du vertraust.",
|
||||
"stats": "{persons} Personen ({active} aktiv) · {claims} belegte Angaben, davon {corroborated} mehrfach bestätigt · {votes} Abstimmungen ({rollCalls} namentlich) · {money} Geldflüsse",
|
||||
"lastUpdate": "Zuletzt aktualisiert: {date}",
|
||||
"latest": "Neueste Angaben",
|
||||
"filtersActive": "Deine Filter sind aktiv: {sources} Quellen ausgeblendet, {topics} Themen gewählt.",
|
||||
"explore": "Entdecken",
|
||||
"exploreMoney": "Geld: Spenden, Aufträge, Inserate, Parteienförderung",
|
||||
"exploreOrganizations": "Unternehmen, Vereine, Behörden – und ihre Verbindungen",
|
||||
"exploreSocial": "Was Politiker:innen öffentlich posten",
|
||||
"exploreWiki": "Wikipedia-Bearbeitungen aus Parlament und Regierung",
|
||||
"exploreFormer": "Was machen Ehemalige heute?",
|
||||
"exploreCalendar": "Kalender: Sitzungen, Reisen, Treffen"
|
||||
},
|
||||
"Search": {
|
||||
"placeholder": "Person, Thema oder Stichwort …",
|
||||
"submit": "Suchen",
|
||||
"results": "Ergebnisse für „{q}“",
|
||||
"none": "Keine Treffer.",
|
||||
"from": "Von",
|
||||
"to": "Bis"
|
||||
},
|
||||
"Persons": {
|
||||
"title": "Personen",
|
||||
"filterParty": "Partei",
|
||||
"filterLevel": "Ebene",
|
||||
"all": "Alle",
|
||||
"none": "Keine Personen gefunden.",
|
||||
"level": {
|
||||
"eu": "EU",
|
||||
"federal": "Bund",
|
||||
"state": "Land",
|
||||
"district": "Bezirk",
|
||||
"municipal": "Gemeinde",
|
||||
"party": "Partei",
|
||||
"other": "Sonstiges"
|
||||
},
|
||||
"filterStatus": "Status",
|
||||
"statusValue": {
|
||||
"active": "Aktiv",
|
||||
"former": "Ehemalig",
|
||||
"party_member": "Ohne Amt (Parteimitglied)",
|
||||
"deceased": "Verstorben",
|
||||
"all": "Alle"
|
||||
},
|
||||
"lastOffice": "Letztes Amt bis {date}"
|
||||
},
|
||||
"Person": {
|
||||
"roles": "Funktionen & Mandate",
|
||||
"current": "aktuell",
|
||||
"since": "seit {date}",
|
||||
"period": "{from} – {to}",
|
||||
"social": "Kanäle",
|
||||
"tabs": {
|
||||
"overview": "Überblick",
|
||||
"votes": "Abstimmungen",
|
||||
"statements": "Aussagen & Reden",
|
||||
"money": "Geld & Netzwerk",
|
||||
"media": "Medien & Werdegang",
|
||||
"legal": "Rechtliches",
|
||||
"timeline": "Zeitleiste",
|
||||
"travel": "Reisen & Treffen",
|
||||
"social": "Social Media"
|
||||
},
|
||||
"factionVoteNote": "Im Nationalrat wird meist per Aufstehen abgestimmt; offiziell protokolliert ist dann nur das Stimmverhalten der Fraktion. Bei namentlichen Abstimmungen zeigen wir die eigene Stimme – und ob sie von der Fraktion abweicht.",
|
||||
"noVotes": "Keine Abstimmungen erfasst.",
|
||||
"faction": "Fraktion {faction}",
|
||||
"statusNote": "Status wird aus den Mandaten und Funktionen berechnet: „aktiv“ nur mit bestätigtem aktuellem Amt.",
|
||||
"roleCorroborated": "mehrfach belegt",
|
||||
"unverified": "laut Wikidata – nicht amtlich bestätigt",
|
||||
"accountUnverified": "Laut Wikidata – nicht amtlich bestätigt"
|
||||
},
|
||||
"Parties": {
|
||||
"title": "Parteien",
|
||||
"activeOfficials": "{count} aktive Funktionsträger:innen",
|
||||
"members": "Aktuelle Funktionsträger:innen",
|
||||
"donations": "Gemeldete Spenden (Rechnungshof)",
|
||||
"year": "Jahr",
|
||||
"total": "Summe",
|
||||
"count": "Anzahl",
|
||||
"voteStats": "Stimmverhalten",
|
||||
"recentVotes": "Letzte Abstimmungen",
|
||||
"claims": "Belegte Angaben",
|
||||
"formerMembers": "Ehemalige – was machen sie heute?",
|
||||
"dissent": "Abweichendes Stimmverhalten (namentliche Abstimmungen)",
|
||||
"money": "Geld nach Jahr und Art",
|
||||
"allMoney": "Alle Geldflüsse",
|
||||
"finance": "Rechenschaftsberichte (Rechnungshof)",
|
||||
"income": "Erträge",
|
||||
"expenses": "Aufwendungen",
|
||||
"related": "Nahestehende Organisationen & Beteiligungen",
|
||||
"relation": {
|
||||
"affiliation": "nahestehend",
|
||||
"ownership": "Beteiligung"
|
||||
},
|
||||
"channels": "Kanäle der Partei und ihrer Mitglieder",
|
||||
"allPosts": "Alle Beiträge"
|
||||
},
|
||||
"Votes": {
|
||||
"title": "Abstimmungen",
|
||||
"accepted": "angenommen",
|
||||
"rejected": "abgelehnt",
|
||||
"for": "dafür",
|
||||
"against": "dagegen",
|
||||
"abstain": "Enthaltung",
|
||||
"absent": "abwesend",
|
||||
"protocol": "Protokoll",
|
||||
"item": "Gegenstand",
|
||||
"rollCall": "namentliche Abstimmung",
|
||||
"dissent": "gegen die eigene Fraktion",
|
||||
"factionVote": "Fraktion",
|
||||
"ownVote": "eigene Stimme",
|
||||
"individualVotes": "Einzelstimmen",
|
||||
"onlyRollCall": "Nur namentliche Abstimmungen",
|
||||
"splitVote": "Getrennte Abstimmung – Details im Protokoll",
|
||||
"spoke": "Rede dazu",
|
||||
"speech": "Rede"
|
||||
},
|
||||
"Claims": {
|
||||
"sources": "{count, plural, one {# Quelle} other {# Quellen}}",
|
||||
"status": {
|
||||
"reported": "einfach belegt",
|
||||
"corroborated": "mehrfach belegt",
|
||||
"disputed": "umstritten",
|
||||
"retracted": "zurückgezogen"
|
||||
},
|
||||
"innocence": "Es gilt die Unschuldsvermutung.",
|
||||
"mentions": "erwähnt",
|
||||
"contradicts": "widerspricht",
|
||||
"none": "Keine Angaben mit deinen Quellen- und Themenfiltern.",
|
||||
"more": "Weitere laden",
|
||||
"type": {
|
||||
"role": "Funktion",
|
||||
"vote": "Abstimmung",
|
||||
"donation": "Spende",
|
||||
"money_flow": "Geldfluss",
|
||||
"statement": "Aussage",
|
||||
"appearance": "Auftritt",
|
||||
"meeting": "Treffen",
|
||||
"travel": "Reise",
|
||||
"side_job": "Nebentätigkeit",
|
||||
"legal_proceeding": "Verfahren",
|
||||
"lobbying": "Lobbying",
|
||||
"media_mention": "Medienbericht",
|
||||
"other": "Sonstiges",
|
||||
"career": "Werdegang",
|
||||
"parliamentary_question": "Parlamentarische Anfrage",
|
||||
"government_decision": "Ministerrat",
|
||||
"wiki_edit": "Wikipedia-Bearbeitung",
|
||||
"declaration": "Erklärung",
|
||||
"ownership": "Beteiligung",
|
||||
"affiliation": "Nahestehend",
|
||||
"party_finance": "Parteifinanzen"
|
||||
},
|
||||
"corroboratedBy": "bestätigt durch {count} unabhängige Quellen",
|
||||
"legalStage": {
|
||||
"allegation_reported": "Vorwurf berichtet",
|
||||
"investigation": "Ermittlungsverfahren",
|
||||
"immunity_waiver_requested": "Ersuchen um Aufhebung der Immunität",
|
||||
"immunity_waived": "Immunität aufgehoben",
|
||||
"immunity_refused": "Aufhebung der Immunität abgelehnt",
|
||||
"indicted": "Anklage",
|
||||
"trial": "Gerichtsverfahren",
|
||||
"convicted_not_final": "Nicht rechtskräftig verurteilt",
|
||||
"convicted_final": "Rechtskräftig verurteilt",
|
||||
"acquitted": "Freispruch",
|
||||
"proceedings_dropped": "Verfahren eingestellt",
|
||||
"diversion": "Diversion (keine Verurteilung)"
|
||||
},
|
||||
"pending": "Noch nicht redaktionell geprüft"
|
||||
},
|
||||
"Settings": {
|
||||
"title": "Meine Filter",
|
||||
"intro": "Wähle aus, welchen Quellen du vertraust und welche Themen dich interessieren. Die Einstellungen werden nur in einem Cookie in deinem Browser gespeichert.",
|
||||
"sources": "Quellen",
|
||||
"topics": "Themen",
|
||||
"topicsHint": "Keine Auswahl = alle Themen.",
|
||||
"minTrust": "Mindest-Vertrauenswert",
|
||||
"save": "Speichern",
|
||||
"saved": "Gespeichert.",
|
||||
"reset": "Zurücksetzen",
|
||||
"kind": {
|
||||
"official": "Amtlich",
|
||||
"ngo": "NGO",
|
||||
"media": "Medien",
|
||||
"social": "Soziale Medien",
|
||||
"aggregator": "Datenbanken",
|
||||
"user": "Community",
|
||||
"derived": "Abgeleitet"
|
||||
}
|
||||
},
|
||||
"Method": {
|
||||
"title": "Methodik & Quellen",
|
||||
"p1": "Jede Angabe auf Politrack ist eine „Behauptung“ mit mindestens einem Beleg. Bestätigen mehrere unabhängige Quellen dieselbe Angabe, gilt sie als mehrfach belegt; widerspricht eine Quelle, wird sie als umstritten markiert.",
|
||||
"p2": "Wir verwenden bevorzugt offizielle offene Daten (Parlament, Rechnungshof, RTR, RIS). Medien werden ausschließlich über die von den Verlagen angebotenen RSS-Feeds ausgewertet: Wir speichern Überschrift, Teaser und Link, niemals den Artikeltext. Websites, die Text- und Data-Mining vorbehalten, werten wir nur anhand der Überschrift aus.",
|
||||
"p3": "Zu strafrechtlichen Angelegenheiten zeigen wir stets den Verfahrensstand. Bis zu einer rechtskräftigen Verurteilung gilt die Unschuldsvermutung.",
|
||||
"license": "Lizenz",
|
||||
"access": "Zugriff",
|
||||
"trust": "Vertrauen"
|
||||
},
|
||||
"Common": {
|
||||
"loadError": "Daten konnten nicht geladen werden.",
|
||||
"notFound": "Nicht gefunden."
|
||||
},
|
||||
"Timeline": {
|
||||
"from": "Von",
|
||||
"to": "Bis",
|
||||
"apply": "Anzeigen",
|
||||
"histogram": "Aktivität pro Monat",
|
||||
"hint": "Klicke auf einen Monat, um nur diesen Zeitraum zu sehen."
|
||||
},
|
||||
"Calendar": {
|
||||
"title": "Kalender",
|
||||
"intro": "Sitzungen, Ausschüsse, Reisen, Treffen und Auftritte – mit Quellen.",
|
||||
"prev": "← Vormonat",
|
||||
"next": "Nächster Monat →",
|
||||
"person": "Person (Kurzname)",
|
||||
"none": "Keine Termine in diesem Zeitraum.",
|
||||
"activity": "{count} Angaben",
|
||||
"kind": {
|
||||
"parliament_session": "Plenarsitzung",
|
||||
"committee": "Ausschuss",
|
||||
"press_conference": "Pressekonferenz",
|
||||
"foreign_trip": "Reise",
|
||||
"meeting": "Treffen",
|
||||
"tv_appearance": "TV-Auftritt",
|
||||
"interview": "Interview",
|
||||
"party_event": "Parteiveranstaltung",
|
||||
"public_event": "Veranstaltung",
|
||||
"other": "Sonstiges",
|
||||
"hearing": "Befragung (U-Ausschuss)",
|
||||
"government_meeting": "Ministerrat"
|
||||
},
|
||||
"datePrecision": "Datum = Veröffentlichungsdatum der Quelle"
|
||||
},
|
||||
"Former": {
|
||||
"title": "Was machen ehemalige Politikerinnen und Politiker?",
|
||||
"intro": "Ehemalige Mandatarinnen, Mandatare und Funktionsträger:innen – sortiert nach der jüngsten Berichterstattung.",
|
||||
"lastRole": "Zuletzt: {role}",
|
||||
"latestNews": "Zuletzt in den Medien",
|
||||
"career": "Werdegang"
|
||||
},
|
||||
"ClaimDetails": {
|
||||
"with": "mit",
|
||||
"reference": "Ref.",
|
||||
"article": "Artikel",
|
||||
"fileNumber": "GZ",
|
||||
"financeDetails": "Details Rechenschaftsbericht {year}"
|
||||
},
|
||||
"Money": {
|
||||
"title": "Geld",
|
||||
"intro": "Spenden an Parteien, öffentliche Aufträge, Regierungsinserate, Medienförderung, Parteienförderung und politische Werbung – aus amtlichen Registern, jede Zeile mit Quelle.",
|
||||
"none": "Keine Geldflüsse gefunden.",
|
||||
"date": "Datum",
|
||||
"kindLabel": "Art",
|
||||
"payer": "Von",
|
||||
"payee": "An",
|
||||
"amount": "Betrag",
|
||||
"sources": "Quellen",
|
||||
"allKinds": "Alle Arten",
|
||||
"searchPlaceholder": "Name, Firma …",
|
||||
"from": "Von",
|
||||
"to": "Bis",
|
||||
"minAmount": "ab €",
|
||||
"filteredBy": "Gefiltert nach",
|
||||
"personNote": "Organisationen, mit denen die Person verbunden ist",
|
||||
"reset": "Filter zurücksetzen",
|
||||
"topPayers": "Größte Zahler",
|
||||
"topPayees": "Größte Empfänger",
|
||||
"sourcesNote": "Quellen: Rechnungshof (Spenden, Rechenschaftsberichte), data.gv.at Vergabe-Kerndaten (Aufträge), RTR Medientransparenz (Inserate, Förderungen), Google/Meta Werbebibliotheken (politische Werbung). Beträge wie gemeldet.",
|
||||
"kind": {
|
||||
"donation": "Spende",
|
||||
"contract": "Öffentlicher Auftrag",
|
||||
"government_ad": "Regierungsinserat",
|
||||
"political_ad": "Politische Werbung",
|
||||
"subsidy": "Förderung",
|
||||
"party_funding": "Parteienförderung",
|
||||
"party_ad": "Inserat (Partei)",
|
||||
"loan": "Kredit",
|
||||
"side_income": "Nebeneinkommen",
|
||||
"sponsorship": "Sponsoring",
|
||||
"other": "Sonstiges"
|
||||
}
|
||||
},
|
||||
"Organizations": {
|
||||
"title": "Organisationen",
|
||||
"intro": "Unternehmen, Vereine, Behörden, Medien und Lobbygruppen, die in den Quellen vorkommen – mit Geldflüssen und Verbindungen zu Politiker:innen.",
|
||||
"searchPlaceholder": "Name …",
|
||||
"kindLabel": "Art",
|
||||
"all": "Alle",
|
||||
"none": "Keine Organisationen gefunden.",
|
||||
"name": "Name",
|
||||
"paid": "gezahlt",
|
||||
"received": "erhalten",
|
||||
"paid_to": "zahlte an",
|
||||
"received_from": "erhielt von",
|
||||
"partOf": "Teil von",
|
||||
"moneyOverview": "Geldflüsse",
|
||||
"counterparties": "Wichtigste Gegenparteien",
|
||||
"people": "Verbundene Personen",
|
||||
"connectionNote": "Eine Verbindung (Nebentätigkeit, Werdegang, Treffen) ist kein Vorwurf.",
|
||||
"flows": "Einzelne Geldflüsse",
|
||||
"allFlows": "Alle Geldflüsse",
|
||||
"claims": "Belegte Angaben",
|
||||
"identifier": {
|
||||
"wikidata": "Wikidata",
|
||||
"firmenbuch": "Firmenbuch",
|
||||
"uid": "UID",
|
||||
"eu_transparency": "EU-Transparenzregister",
|
||||
"rtr": "RTR",
|
||||
"google_advertiser": "Google-Werbetreibender",
|
||||
"facebook_page": "Facebook-Seite",
|
||||
"other": "Kennung"
|
||||
},
|
||||
"kind": {
|
||||
"party": "Partei",
|
||||
"parliamentary_group": "Klub",
|
||||
"parliament": "Parlament",
|
||||
"government": "Regierung",
|
||||
"ministry": "Ministerium",
|
||||
"state_government": "Landesregierung",
|
||||
"municipality": "Gemeinde",
|
||||
"public_body": "Öffentliche Einrichtung",
|
||||
"company": "Unternehmen",
|
||||
"ngo": "NGO / Verein",
|
||||
"media": "Medium",
|
||||
"lobby": "Interessenvertretung",
|
||||
"court": "Gericht",
|
||||
"authority": "Behörde",
|
||||
"eu_institution": "EU-Institution",
|
||||
"other": "Sonstige"
|
||||
}
|
||||
},
|
||||
"Network": {
|
||||
"title": "Netzwerk: verbundene Organisationen",
|
||||
"note": "Organisationen, mit denen die Person laut Quellen verbunden ist, und Geld, das diese Organisationen gezahlt oder erhalten haben. Eine Verbindung ist kein Vorwurf.",
|
||||
"flows": "Geldflüsse dieser Organisationen",
|
||||
"allFlows": "Alle Geldflüsse",
|
||||
"paid": "gezahlt",
|
||||
"received": "erhalten",
|
||||
"via": {
|
||||
"side_job": "Nebentätigkeit",
|
||||
"career": "Werdegang",
|
||||
"meeting": "Treffen",
|
||||
"role": "Funktion",
|
||||
"lobbying": "Lobbying",
|
||||
"party": "Partei"
|
||||
}
|
||||
},
|
||||
"Social": {
|
||||
"title": "Social Media",
|
||||
"intro": "Öffentliche Beiträge von Politiker:innen und Parteien auf Bluesky, Mastodon, öffentlichen Telegram-Kanälen und YouTube.",
|
||||
"none": "Keine Beiträge.",
|
||||
"original": "Original ansehen",
|
||||
"unverified": "Konto nicht bestätigt",
|
||||
"unverifiedHint": "Das Konto stammt aus Wikidata und wurde von keiner offiziellen Seite bestätigt.",
|
||||
"platform": "Plattform",
|
||||
"allPlatforms": "Alle Plattformen",
|
||||
"party": "Partei",
|
||||
"allParties": "Alle Parteien",
|
||||
"policy": "X/Twitter nur über die offizielle API, Facebook/Instagram gar nicht (Nutzungsbedingungen). WhatsApp- und Signal-Gruppen sowie private Telegram-Gruppen werden nie erfasst."
|
||||
},
|
||||
"WikiEdits": {
|
||||
"title": "Wikipedia-Bearbeitungen aus Parlament und Regierung",
|
||||
"intro": "Anonyme Wikipedia-Bearbeitungen von IP-Adressen, die dem Parlament oder der Bundesregierung zugeordnet sind.",
|
||||
"none": "Keine Bearbeitungen gefunden.",
|
||||
"date": "Datum",
|
||||
"network": "Netzwerk",
|
||||
"article": "Artikel",
|
||||
"change": "Änderung",
|
||||
"note": "Eine Bearbeitung aus einem Netzwerk sagt nichts darüber, welche Person sie vorgenommen hat. IP-Bereiche: config/ip_ranges.yaml."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,394 @@
|
||||
{
|
||||
"Meta": {
|
||||
"title": "Politrack – Austrian politics, sourced",
|
||||
"description": "What Austria's politicians do: votes, money, appearances, statements – every claim with its sources."
|
||||
},
|
||||
"Nav": {
|
||||
"home": "Home",
|
||||
"persons": "People",
|
||||
"parties": "Parties",
|
||||
"votes": "Votes",
|
||||
"search": "Search",
|
||||
"settings": "My filters",
|
||||
"method": "Method & sources",
|
||||
"language": "Deutsch",
|
||||
"calendar": "Calendar",
|
||||
"former": "Former politicians",
|
||||
"organizations": "Organisations",
|
||||
"money": "Money",
|
||||
"social": "Social media"
|
||||
},
|
||||
"Home": {
|
||||
"headline": "Austrian politics – traceable.",
|
||||
"intro": "Politrack collects publicly available information about politicians and parties and links every claim to its sources. You decide which sources you trust.",
|
||||
"stats": "{persons} people ({active} active) · {claims} sourced claims, {corroborated} corroborated · {votes} votes ({rollCalls} roll calls) · {money} money flows",
|
||||
"lastUpdate": "Last updated: {date}",
|
||||
"latest": "Latest claims",
|
||||
"filtersActive": "Your filters are active: {sources} sources hidden, {topics} topics selected.",
|
||||
"explore": "Explore",
|
||||
"exploreMoney": "Money: donations, contracts, ads, party funding",
|
||||
"exploreOrganizations": "Companies, associations, authorities – and their connections",
|
||||
"exploreSocial": "What politicians post publicly",
|
||||
"exploreWiki": "Wikipedia edits from parliament and government",
|
||||
"exploreFormer": "What are former politicians doing?",
|
||||
"exploreCalendar": "Calendar: sessions, trips, meetings"
|
||||
},
|
||||
"Search": {
|
||||
"placeholder": "Person, topic or keyword …",
|
||||
"submit": "Search",
|
||||
"results": "Results for “{q}”",
|
||||
"none": "No results.",
|
||||
"from": "From",
|
||||
"to": "To"
|
||||
},
|
||||
"Persons": {
|
||||
"title": "People",
|
||||
"filterParty": "Party",
|
||||
"filterLevel": "Level",
|
||||
"all": "All",
|
||||
"none": "No people found.",
|
||||
"level": {
|
||||
"eu": "EU",
|
||||
"federal": "Federal",
|
||||
"state": "State",
|
||||
"district": "District",
|
||||
"municipal": "Municipal",
|
||||
"party": "Party",
|
||||
"other": "Other"
|
||||
},
|
||||
"filterStatus": "Status",
|
||||
"statusValue": {
|
||||
"active": "Active",
|
||||
"former": "Former",
|
||||
"party_member": "No current office (party member)",
|
||||
"deceased": "Deceased",
|
||||
"all": "All"
|
||||
},
|
||||
"lastOffice": "Last office until {date}"
|
||||
},
|
||||
"Person": {
|
||||
"roles": "Offices & mandates",
|
||||
"current": "current",
|
||||
"since": "since {date}",
|
||||
"period": "{from} – {to}",
|
||||
"social": "Channels",
|
||||
"tabs": {
|
||||
"overview": "Overview",
|
||||
"votes": "Votes",
|
||||
"statements": "Statements & speeches",
|
||||
"money": "Money & network",
|
||||
"media": "Media & career",
|
||||
"legal": "Legal",
|
||||
"timeline": "Timeline",
|
||||
"travel": "Travel & meetings",
|
||||
"social": "Social media"
|
||||
},
|
||||
"factionVoteNote": "The National Council mostly votes by standing up; then only each faction's vote is recorded. For roll-call votes we show the person's own vote – and whether it differs from their faction.",
|
||||
"noVotes": "No votes recorded.",
|
||||
"faction": "Faction {faction}",
|
||||
"statusNote": "Status is derived from mandates and functions: \"active\" only with a verified current office.",
|
||||
"roleCorroborated": "corroborated",
|
||||
"unverified": "per Wikidata – not officially confirmed",
|
||||
"accountUnverified": "According to Wikidata – not officially confirmed"
|
||||
},
|
||||
"Parties": {
|
||||
"title": "Parties",
|
||||
"activeOfficials": "{count} active officials",
|
||||
"members": "Current officials",
|
||||
"donations": "Reported donations (Court of Audit)",
|
||||
"year": "Year",
|
||||
"total": "Total",
|
||||
"count": "Count",
|
||||
"voteStats": "Voting record",
|
||||
"recentVotes": "Recent votes",
|
||||
"claims": "Sourced claims",
|
||||
"formerMembers": "Former members – what are they doing now?",
|
||||
"dissent": "Votes against own faction (roll calls)",
|
||||
"money": "Money by year and kind",
|
||||
"allMoney": "All money flows",
|
||||
"finance": "Annual financial reports (Court of Audit)",
|
||||
"income": "Income",
|
||||
"expenses": "Expenses",
|
||||
"related": "Affiliated organisations & holdings",
|
||||
"relation": {
|
||||
"affiliation": "affiliated",
|
||||
"ownership": "holding"
|
||||
},
|
||||
"channels": "Channels of the party and its members",
|
||||
"allPosts": "All posts"
|
||||
},
|
||||
"Votes": {
|
||||
"title": "Votes",
|
||||
"accepted": "accepted",
|
||||
"rejected": "rejected",
|
||||
"for": "for",
|
||||
"against": "against",
|
||||
"abstain": "abstained",
|
||||
"absent": "absent",
|
||||
"protocol": "Transcript",
|
||||
"item": "Item",
|
||||
"rollCall": "roll-call vote",
|
||||
"dissent": "against own faction",
|
||||
"factionVote": "faction",
|
||||
"ownVote": "own vote",
|
||||
"individualVotes": "Individual votes",
|
||||
"onlyRollCall": "Roll-call votes only",
|
||||
"splitVote": "Split vote – see transcript",
|
||||
"spoke": "Spoke on this",
|
||||
"speech": "Speech"
|
||||
},
|
||||
"Claims": {
|
||||
"sources": "{count, plural, one {# source} other {# sources}}",
|
||||
"status": {
|
||||
"reported": "single source",
|
||||
"corroborated": "corroborated",
|
||||
"disputed": "disputed",
|
||||
"retracted": "retracted"
|
||||
},
|
||||
"innocence": "The presumption of innocence applies.",
|
||||
"mentions": "mentions",
|
||||
"contradicts": "contradicts",
|
||||
"none": "No claims match your source and topic filters.",
|
||||
"more": "Load more",
|
||||
"type": {
|
||||
"role": "Office",
|
||||
"vote": "Vote",
|
||||
"donation": "Donation",
|
||||
"money_flow": "Money flow",
|
||||
"statement": "Statement",
|
||||
"appearance": "Appearance",
|
||||
"meeting": "Meeting",
|
||||
"travel": "Travel",
|
||||
"side_job": "Side job",
|
||||
"legal_proceeding": "Proceedings",
|
||||
"lobbying": "Lobbying",
|
||||
"media_mention": "Media report",
|
||||
"other": "Other",
|
||||
"career": "Career",
|
||||
"parliamentary_question": "Parliamentary question",
|
||||
"government_decision": "Council of Ministers",
|
||||
"wiki_edit": "Wikipedia edit",
|
||||
"declaration": "Declaration",
|
||||
"ownership": "Holding",
|
||||
"affiliation": "Affiliation",
|
||||
"party_finance": "Party finances"
|
||||
},
|
||||
"corroboratedBy": "confirmed by {count} independent sources",
|
||||
"legalStage": {
|
||||
"allegation_reported": "Allegation reported",
|
||||
"investigation": "Investigation",
|
||||
"immunity_waiver_requested": "Request to lift immunity",
|
||||
"immunity_waived": "Immunity lifted",
|
||||
"immunity_refused": "Request to lift immunity refused",
|
||||
"indicted": "Indicted",
|
||||
"trial": "Trial",
|
||||
"convicted_not_final": "Convicted (not final)",
|
||||
"convicted_final": "Final conviction",
|
||||
"acquitted": "Acquitted",
|
||||
"proceedings_dropped": "Proceedings dropped",
|
||||
"diversion": "Diversion (no conviction)"
|
||||
},
|
||||
"pending": "Not yet reviewed"
|
||||
},
|
||||
"Settings": {
|
||||
"title": "My filters",
|
||||
"intro": "Choose which sources you trust and which topics you care about. Settings are only stored in a cookie in your browser.",
|
||||
"sources": "Sources",
|
||||
"topics": "Topics",
|
||||
"topicsHint": "No selection = all topics.",
|
||||
"minTrust": "Minimum trust score",
|
||||
"save": "Save",
|
||||
"saved": "Saved.",
|
||||
"reset": "Reset",
|
||||
"kind": {
|
||||
"official": "Official",
|
||||
"ngo": "NGO",
|
||||
"media": "Media",
|
||||
"social": "Social media",
|
||||
"aggregator": "Databases",
|
||||
"user": "Community",
|
||||
"derived": "Derived"
|
||||
}
|
||||
},
|
||||
"Method": {
|
||||
"title": "Method & sources",
|
||||
"p1": "Every item on Politrack is a claim backed by at least one piece of evidence. When several independent sources confirm the same claim it is marked corroborated; if a source contradicts it, it is marked disputed.",
|
||||
"p2": "We prefer official open data (Parliament, Court of Audit, RTR, RIS). News media are only processed through the RSS feeds publishers offer: we store headline, teaser and link, never the article text. Sites that reserve text and data mining are analysed by headline only.",
|
||||
"p3": "For criminal matters we always show the procedural stage. The presumption of innocence applies until a final conviction.",
|
||||
"license": "Licence",
|
||||
"access": "Access",
|
||||
"trust": "Trust"
|
||||
},
|
||||
"Common": {
|
||||
"loadError": "Could not load data.",
|
||||
"notFound": "Not found."
|
||||
},
|
||||
"Timeline": {
|
||||
"from": "From",
|
||||
"to": "To",
|
||||
"apply": "Show",
|
||||
"histogram": "Activity per month",
|
||||
"hint": "Click a month to show only that period."
|
||||
},
|
||||
"Calendar": {
|
||||
"title": "Calendar",
|
||||
"intro": "Sessions, committees, trips, meetings and appearances – with sources.",
|
||||
"prev": "← Previous month",
|
||||
"next": "Next month →",
|
||||
"person": "Person (slug)",
|
||||
"none": "No events in this period.",
|
||||
"activity": "{count} claims",
|
||||
"kind": {
|
||||
"parliament_session": "Plenary session",
|
||||
"committee": "Committee",
|
||||
"press_conference": "Press conference",
|
||||
"foreign_trip": "Trip",
|
||||
"meeting": "Meeting",
|
||||
"tv_appearance": "TV appearance",
|
||||
"interview": "Interview",
|
||||
"party_event": "Party event",
|
||||
"public_event": "Event",
|
||||
"other": "Other",
|
||||
"hearing": "Hearing (inquiry committee)",
|
||||
"government_meeting": "Council of Ministers"
|
||||
},
|
||||
"datePrecision": "Date = publication date of the source"
|
||||
},
|
||||
"Former": {
|
||||
"title": "What are former politicians up to?",
|
||||
"intro": "Former office holders – sorted by most recent news coverage.",
|
||||
"lastRole": "Last: {role}",
|
||||
"latestNews": "Latest coverage",
|
||||
"career": "Career"
|
||||
},
|
||||
"ClaimDetails": {
|
||||
"with": "with",
|
||||
"reference": "Ref.",
|
||||
"article": "Article",
|
||||
"fileNumber": "File no.",
|
||||
"financeDetails": "Annual report {year} details"
|
||||
},
|
||||
"Money": {
|
||||
"title": "Money",
|
||||
"intro": "Donations to parties, public contracts, government advertising, media subsidies, party funding and political ads – from official registers, every row with its source.",
|
||||
"none": "No money flows found.",
|
||||
"date": "Date",
|
||||
"kindLabel": "Kind",
|
||||
"payer": "From",
|
||||
"payee": "To",
|
||||
"amount": "Amount",
|
||||
"sources": "Sources",
|
||||
"allKinds": "All kinds",
|
||||
"searchPlaceholder": "Name, company …",
|
||||
"from": "From",
|
||||
"to": "To",
|
||||
"minAmount": "min. €",
|
||||
"filteredBy": "Filtered by",
|
||||
"personNote": "organisations connected to the person",
|
||||
"reset": "Reset filter",
|
||||
"topPayers": "Largest payers",
|
||||
"topPayees": "Largest recipients",
|
||||
"sourcesNote": "Sources: Court of Audit (donations, annual reports), data.gv.at procurement core data (contracts), RTR media transparency (ads, subsidies), Google/Meta ad libraries (political ads). Amounts as reported.",
|
||||
"kind": {
|
||||
"donation": "Donation",
|
||||
"contract": "Public contract",
|
||||
"government_ad": "Government ad",
|
||||
"political_ad": "Political ad",
|
||||
"subsidy": "Subsidy",
|
||||
"party_funding": "Party funding",
|
||||
"party_ad": "Ad (party)",
|
||||
"loan": "Loan",
|
||||
"side_income": "Side income",
|
||||
"sponsorship": "Sponsorship",
|
||||
"other": "Other"
|
||||
}
|
||||
},
|
||||
"Organizations": {
|
||||
"title": "Organisations",
|
||||
"intro": "Companies, associations, authorities, media and lobby groups found in the sources – with money flows and connections to politicians.",
|
||||
"searchPlaceholder": "Name …",
|
||||
"kindLabel": "Kind",
|
||||
"all": "All",
|
||||
"none": "No organisations found.",
|
||||
"name": "Name",
|
||||
"paid": "paid",
|
||||
"received": "received",
|
||||
"paid_to": "paid",
|
||||
"received_from": "received from",
|
||||
"partOf": "Part of",
|
||||
"moneyOverview": "Money flows",
|
||||
"counterparties": "Main counterparties",
|
||||
"people": "Connected people",
|
||||
"connectionNote": "A connection (side job, career, meeting) is not an accusation.",
|
||||
"flows": "Individual money flows",
|
||||
"allFlows": "All money flows",
|
||||
"claims": "Sourced claims",
|
||||
"identifier": {
|
||||
"wikidata": "Wikidata",
|
||||
"firmenbuch": "Company register",
|
||||
"uid": "VAT ID",
|
||||
"eu_transparency": "EU Transparency Register",
|
||||
"rtr": "RTR",
|
||||
"google_advertiser": "Google advertiser",
|
||||
"facebook_page": "Facebook page",
|
||||
"other": "Identifier"
|
||||
},
|
||||
"kind": {
|
||||
"party": "Party",
|
||||
"parliamentary_group": "Parliamentary group",
|
||||
"parliament": "Parliament",
|
||||
"government": "Government",
|
||||
"ministry": "Ministry",
|
||||
"state_government": "State government",
|
||||
"municipality": "Municipality",
|
||||
"public_body": "Public body",
|
||||
"company": "Company",
|
||||
"ngo": "NGO / association",
|
||||
"media": "Media",
|
||||
"lobby": "Lobby group",
|
||||
"court": "Court",
|
||||
"authority": "Authority",
|
||||
"eu_institution": "EU institution",
|
||||
"other": "Other"
|
||||
}
|
||||
},
|
||||
"Network": {
|
||||
"title": "Network: connected organisations",
|
||||
"note": "Organisations the person is connected to according to the sources, and money those organisations paid or received. A connection is not an accusation.",
|
||||
"flows": "Money flows of these organisations",
|
||||
"allFlows": "All money flows",
|
||||
"paid": "paid",
|
||||
"received": "received",
|
||||
"via": {
|
||||
"side_job": "side job",
|
||||
"career": "career",
|
||||
"meeting": "meeting",
|
||||
"role": "office",
|
||||
"lobbying": "lobbying",
|
||||
"party": "party"
|
||||
}
|
||||
},
|
||||
"Social": {
|
||||
"title": "Social media",
|
||||
"intro": "Public posts by politicians and parties on Bluesky, Mastodon, public Telegram channels and YouTube.",
|
||||
"none": "No posts.",
|
||||
"original": "View original",
|
||||
"unverified": "account unconfirmed",
|
||||
"unverifiedHint": "The account comes from Wikidata and was not confirmed by an official page.",
|
||||
"platform": "Platform",
|
||||
"allPlatforms": "All platforms",
|
||||
"party": "Party",
|
||||
"allParties": "All parties",
|
||||
"policy": "X/Twitter only via the official API, Facebook/Instagram not at all (terms of service). WhatsApp and Signal groups and private Telegram groups are never collected."
|
||||
},
|
||||
"WikiEdits": {
|
||||
"title": "Wikipedia edits from parliament and government",
|
||||
"intro": "Anonymous Wikipedia edits from IP addresses assigned to parliament or the federal government.",
|
||||
"none": "No edits found.",
|
||||
"date": "Date",
|
||||
"network": "Network",
|
||||
"article": "Article",
|
||||
"change": "Change",
|
||||
"note": "An edit from a network says nothing about which person made it. IP ranges: config/ip_ranges.yaml."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type {NextConfig} from 'next';
|
||||
import createNextIntlPlugin from 'next-intl/plugin';
|
||||
|
||||
const withNextIntl = createNextIntlPlugin('./src/i18n/request.ts');
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
output: 'standalone',
|
||||
images: {unoptimized: true}
|
||||
};
|
||||
|
||||
export default withNextIntl(nextConfig);
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "politrack-web",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "^15.3.0",
|
||||
"next-intl": "^4.1.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.0",
|
||||
"@types/react": "^19.1.0",
|
||||
"@types/react-dom": "^19.1.0",
|
||||
"typescript": "^5.7.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Allow: /
|
||||
@@ -0,0 +1,66 @@
|
||||
import {notFound} from 'next/navigation';
|
||||
import {getLocale, getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api, NotFoundError, type VoteDetail} from '@/lib/api';
|
||||
import {formatDate} from '@/lib/format';
|
||||
|
||||
type Props = {params: Promise<{locale: string; id: string}>};
|
||||
|
||||
export default async function VotePage({params}: Props) {
|
||||
const {locale, id} = await params;
|
||||
setRequestLocale(locale);
|
||||
const t = await getTranslations('Votes');
|
||||
const loc = await getLocale();
|
||||
let vote: VoteDetail;
|
||||
try {
|
||||
vote = await api.vote(id);
|
||||
} catch (error) {
|
||||
if (error instanceof NotFoundError) notFound();
|
||||
throw error;
|
||||
}
|
||||
const groups = new Map<string, VoteDetail['individual']>();
|
||||
for (const v of vote.individual) {
|
||||
const key = v.faction ?? '–';
|
||||
groups.set(key, [...(groups.get(key) ?? []), v]);
|
||||
}
|
||||
|
||||
return (
|
||||
<article>
|
||||
<h1>{vote.item_title}</h1>
|
||||
<p className="muted">
|
||||
{formatDate(vote.voted_on, loc)} · {vote.chamber}
|
||||
{vote.item_ref && <> · {vote.item_ref}</>}
|
||||
{vote.stage && <> · {vote.stage}</>}
|
||||
{vote.roll_call && <> · <strong>{t('rollCall')}</strong></>}
|
||||
{' · '}<span className={`result result-${vote.result}`}>{vote.result !== 'unknown' && t(vote.result)}</span>
|
||||
</p>
|
||||
<p>
|
||||
{vote.url && <a href={vote.url} target="_blank" rel="noopener noreferrer">{t('item')}</a>}
|
||||
{vote.protocol_url && <> · <a href={vote.protocol_url} target="_blank" rel="noopener noreferrer">{t('protocol')}</a></>}
|
||||
</p>
|
||||
{vote.raw_text && <blockquote className="small">{vote.raw_text}</blockquote>}
|
||||
|
||||
{vote.individual.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('individualVotes')}</h2>
|
||||
<div className="grid-2">
|
||||
{[...groups.entries()].map(([faction, members]) => (
|
||||
<div key={faction}>
|
||||
<h3>{faction}</h3>
|
||||
<ul className="compact">
|
||||
{members.map((m) => (
|
||||
<li key={m.slug}>
|
||||
<span className={`pos pos-${m.position}`}>{t(m.position as 'for')}</span>{' '}
|
||||
<Link href={`/personen/${m.slug}`}>{m.full_name}</Link>
|
||||
{m.dissent && <span className="dissent">{t('dissent')}</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {VoteTable} from '@/components/VoteTable';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api} from '@/lib/api';
|
||||
|
||||
type Props = {
|
||||
params: Promise<{locale: string}>;
|
||||
searchParams: Promise<{party?: string; page?: string; roll_call?: string}>;
|
||||
};
|
||||
|
||||
export default async function VotesPage({params, searchParams}: Props) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const sp = await searchParams;
|
||||
const t = await getTranslations('Votes');
|
||||
const page = Math.max(1, Number(sp.page) || 1);
|
||||
const votes = await api.votes({party: sp.party, roll_call: sp.roll_call ? 'true' : undefined, limit: 50, offset: (page - 1) * 50});
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}</h1>
|
||||
<form className="filters" method="get">
|
||||
{sp.party && <input type="hidden" name="party" value={sp.party} />}
|
||||
<label>
|
||||
<input type="checkbox" name="roll_call" value="1" defaultChecked={Boolean(sp.roll_call)} /> {t('onlyRollCall')}
|
||||
</label>
|
||||
<button type="submit">OK</button>
|
||||
</form>
|
||||
<VoteTable votes={votes} />
|
||||
{votes.length === 50 && (
|
||||
<p><Link href={{pathname: '/abstimmungen', query: {...sp, page: String(page + 1)}}}>→</Link></p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import {getLocale, getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api} from '@/lib/api';
|
||||
import {formatDate} from '@/lib/format';
|
||||
|
||||
type Props = {params: Promise<{locale: string}>; searchParams: Promise<{party?: string; page?: string}>};
|
||||
|
||||
export default async function FormerPage({params, searchParams}: Props) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const sp = await searchParams;
|
||||
const t = await getTranslations('Former');
|
||||
const tp = await getTranslations('Persons');
|
||||
const loc = await getLocale();
|
||||
const page = Math.max(1, Number(sp.page) || 1);
|
||||
const [people, parties] = await Promise.all([
|
||||
api.former({party: sp.party, limit: 50, offset: (page - 1) * 50}),
|
||||
api.parties()
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}</h1>
|
||||
<p className="muted">{t('intro')}</p>
|
||||
<form className="filters" method="get">
|
||||
<select name="party" defaultValue={sp.party ?? ''}>
|
||||
<option value="">{tp('all')}</option>
|
||||
{parties.filter((p) => (p.total_people ?? 0) > 20).map((p) => (
|
||||
<option key={p.slug} value={p.slug}>{p.short_name ?? p.name}</option>
|
||||
))}
|
||||
</select>
|
||||
<button type="submit">OK</button>
|
||||
</form>
|
||||
<ul className="claims">
|
||||
{people.map((p) => (
|
||||
<li key={p.slug} className="claim">
|
||||
<div className="claim-head">
|
||||
<Link href={`/personen/${p.slug}`}><strong>{p.full_name}</strong></Link>
|
||||
<span>{tp(`statusValue.${p.status}`)}</span>
|
||||
{p.last_role && <span>{t('lastRole', {role: p.last_role})}</span>}
|
||||
{p.last_office_end && <span>{tp('lastOffice', {date: formatDate(p.last_office_end, loc)})}</span>}
|
||||
</div>
|
||||
{p.latest_news && (
|
||||
<p className="claim-summary">
|
||||
<span className="muted small">{t('latestNews')} ({formatDate(p.latest_news_at, loc)}): </span>
|
||||
{p.latest_news_url ? (
|
||||
<a href={p.latest_news_url} target="_blank" rel="noopener noreferrer nofollow">{p.latest_news}</a>
|
||||
) : (
|
||||
p.latest_news
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
{p.latest_career && (
|
||||
<p className="small"><span className="muted">{t('career')}: </span>{p.latest_career}</p>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{people.length === 50 && (
|
||||
<p><Link href={{pathname: '/ehemalige', query: {...sp, page: String(page + 1)}}}>→</Link></p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {SettingsForm} from '@/components/SettingsForm';
|
||||
import {api, getPrefs} from '@/lib/api';
|
||||
|
||||
export default async function SettingsPage({params}: {params: Promise<{locale: string}>}) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const t = await getTranslations('Settings');
|
||||
const [sources, topics, prefs] = await Promise.all([api.sources(), api.topics(), getPrefs()]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}</h1>
|
||||
<p>{t('intro')}</p>
|
||||
<SettingsForm sources={sources} topics={topics} initial={prefs} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {MoneyTable} from '@/components/MoneyTable';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api} from '@/lib/api';
|
||||
import {formatMoney} from '@/lib/format';
|
||||
|
||||
const KINDS = ['donation', 'party_funding', 'contract', 'government_ad', 'subsidy', 'political_ad', 'party_ad',
|
||||
'sponsorship', 'loan', 'side_income'] as const;
|
||||
const PAGE = 100;
|
||||
|
||||
type Props = {
|
||||
params: Promise<{locale: string}>;
|
||||
searchParams: Promise<{kind?: string; q?: string; org?: string; person?: string; since?: string; until?: string;
|
||||
min?: string; page?: string}>;
|
||||
};
|
||||
|
||||
export default async function MoneyPage({params, searchParams}: Props) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const sp = await searchParams;
|
||||
const t = await getTranslations('Money');
|
||||
const page = Math.max(1, Number(sp.page) || 1);
|
||||
const filtered = Boolean(sp.q || sp.org || sp.person || sp.since || sp.until || sp.min);
|
||||
const [flows, summary] = await Promise.all([
|
||||
api.money({kinds: sp.kind, q: sp.q, org: sp.org, person: sp.person, since: sp.since, until: sp.until,
|
||||
min_amount: sp.min, limit: PAGE, offset: (page - 1) * PAGE}),
|
||||
filtered ? Promise.resolve([]) : api.moneySummary({kinds: sp.kind})
|
||||
]);
|
||||
const payers = summary.filter((row) => row.side === 'payer').slice(0, 15);
|
||||
const payees = summary.filter((row) => row.side === 'payee').slice(0, 15);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}</h1>
|
||||
<p className="muted">{t('intro')}</p>
|
||||
<form className="filters" method="get">
|
||||
<select name="kind" defaultValue={sp.kind ?? ''} aria-label={t('kindLabel')}>
|
||||
<option value="">{t('allKinds')}</option>
|
||||
{KINDS.map((kind) => <option key={kind} value={kind}>{t(`kind.${kind}`)}</option>)}
|
||||
</select>
|
||||
<input type="search" name="q" defaultValue={sp.q} placeholder={t('searchPlaceholder')} />
|
||||
<label>{t('from')} <input type="date" name="since" defaultValue={sp.since} /></label>
|
||||
<label>{t('to')} <input type="date" name="until" defaultValue={sp.until} /></label>
|
||||
<label>{t('minAmount')} <input type="number" name="min" min={0} step={1000} defaultValue={sp.min} /></label>
|
||||
{sp.org && <input type="hidden" name="org" value={sp.org} />}
|
||||
{sp.person && <input type="hidden" name="person" value={sp.person} />}
|
||||
<button type="submit">OK</button>
|
||||
</form>
|
||||
{(sp.org || sp.person) && (
|
||||
<p className="small">
|
||||
{t('filteredBy')}: <strong>{sp.org ?? sp.person}</strong>
|
||||
{sp.person && <> ({t('personNote')})</>} · <Link href="/geld">{t('reset')}</Link>
|
||||
</p>
|
||||
)}
|
||||
|
||||
{!filtered && summary.length > 0 && (
|
||||
<div className="grid-2">
|
||||
{([{label: 'topPayers', rows: payers}, {label: 'topPayees', rows: payees}] as const).map(({label, rows}) => (
|
||||
<section key={label}>
|
||||
<h2>{t(label)}</h2>
|
||||
<ol className="compact">
|
||||
{rows.map((row) => (
|
||||
<li key={`${row.slug}-${row.kind}`}>
|
||||
<Link href={`/organisationen/${row.slug}`}>{row.name}</Link>{' '}
|
||||
<span className="muted small">
|
||||
{t(`kind.${row.kind}` as 'kind.other')} · {row.total ? formatMoney(row.total, locale) : `${row.count}×`}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<MoneyTable flows={flows} />
|
||||
{flows.length === PAGE && (
|
||||
<p><Link href={{pathname: '/geld', query: {...sp, page: String(page + 1)}}}>→</Link></p>
|
||||
)}
|
||||
<p className="small muted">{t('sourcesNote')}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
import {getLocale, getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api, type CalendarEvent} from '@/lib/api';
|
||||
|
||||
type Props = {
|
||||
params: Promise<{locale: string}>;
|
||||
searchParams: Promise<{month?: string; person?: string; party?: string; kind?: string}>;
|
||||
};
|
||||
|
||||
const KINDS = ['parliament_session', 'committee', 'hearing', 'government_meeting', 'press_conference', 'foreign_trip',
|
||||
'meeting', 'public_event'] as const;
|
||||
|
||||
function monthBounds(month: string) {
|
||||
const [y, m] = month.split('-').map(Number);
|
||||
const first = new Date(Date.UTC(y, m - 1, 1));
|
||||
const last = new Date(Date.UTC(y, m, 0));
|
||||
return {first, last};
|
||||
}
|
||||
|
||||
function iso(d: Date) {
|
||||
return d.toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function shiftMonth(month: string, delta: number) {
|
||||
const [y, m] = month.split('-').map(Number);
|
||||
const d = new Date(Date.UTC(y, m - 1 + delta, 1));
|
||||
return `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
export default async function CalendarPage({params, searchParams}: Props) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const sp = await searchParams;
|
||||
const t = await getTranslations('Calendar');
|
||||
const loc = await getLocale();
|
||||
const month = /^\d{4}-\d{2}$/.test(sp.month ?? '') ? sp.month! : new Date().toISOString().slice(0, 7);
|
||||
const {first, last} = monthBounds(month);
|
||||
const kinds = sp.kind && (KINDS as readonly string[]).includes(sp.kind) ? [sp.kind] : undefined;
|
||||
const data = await api.calendar({start: iso(first), end: iso(last), person: sp.person, party: sp.party, kinds});
|
||||
|
||||
const byDay = new Map<string, CalendarEvent[]>();
|
||||
for (const ev of data.events) {
|
||||
if (!ev.starts_at) continue; // the calendar query only returns dated events; guard for the type
|
||||
const day = ev.starts_at.slice(0, 10);
|
||||
byDay.set(day, [...(byDay.get(day) ?? []), ev]);
|
||||
}
|
||||
const activity = new Map<string, number>();
|
||||
for (const d of data.days) activity.set(d.day, (activity.get(d.day) ?? 0) + d.count);
|
||||
|
||||
// Monday-first grid.
|
||||
const lead = (first.getUTCDay() + 6) % 7;
|
||||
const cells: (Date | null)[] = [...Array(lead).fill(null)];
|
||||
for (let day = 1; day <= last.getUTCDate(); day++) cells.push(new Date(Date.UTC(first.getUTCFullYear(), first.getUTCMonth(), day)));
|
||||
const weekdays = [...Array(7)].map((_, i) =>
|
||||
new Date(Date.UTC(2024, 0, 1 + i)).toLocaleDateString(loc === 'de' ? 'de-AT' : 'en-GB', {weekday: 'short'})
|
||||
);
|
||||
const query = {person: sp.person, party: sp.party, kind: sp.kind};
|
||||
const title = first.toLocaleDateString(loc === 'de' ? 'de-AT' : 'en-GB', {month: 'long', year: 'numeric', timeZone: 'UTC'});
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}: {title}</h1>
|
||||
<p className="muted">{t('intro')}</p>
|
||||
<form className="filters" method="get">
|
||||
<input type="month" name="month" defaultValue={month} />
|
||||
<input type="text" name="person" defaultValue={sp.person} placeholder={t('person')} />
|
||||
<select name="kind" defaultValue={sp.kind ?? ''}>
|
||||
<option value="">–</option>
|
||||
{KINDS.map((k) => (
|
||||
<option key={k} value={k}>{t(`kind.${k}`)}</option>
|
||||
))}
|
||||
</select>
|
||||
<button type="submit">OK</button>
|
||||
</form>
|
||||
<p>
|
||||
<Link href={{pathname: '/kalender', query: {...query, month: shiftMonth(month, -1)}}}>{t('prev')}</Link>
|
||||
{' · '}
|
||||
<Link href={{pathname: '/kalender', query: {...query, month: shiftMonth(month, 1)}}}>{t('next')}</Link>
|
||||
</p>
|
||||
|
||||
<div className="calendar">
|
||||
{weekdays.map((w) => (
|
||||
<div key={w} className="calendar-head">{w}</div>
|
||||
))}
|
||||
{cells.map((cell, i) => {
|
||||
if (!cell) return <div key={`empty-${i}`} className="calendar-cell empty" />;
|
||||
const day = iso(cell);
|
||||
const events = byDay.get(day) ?? [];
|
||||
const count = activity.get(day) ?? 0;
|
||||
return (
|
||||
<div key={day} className={`calendar-cell${events.length ? ' has-events' : ''}`}>
|
||||
<div className="calendar-day">
|
||||
<strong>{cell.getUTCDate()}</strong>
|
||||
{count > 0 && (
|
||||
<Link className="small muted" href={{pathname: '/suche', query: {since: day, until: day, q: sp.person ?? ''}}}>
|
||||
{t('activity', {count})}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<ul>
|
||||
{events.slice(0, 6).map((ev) => (
|
||||
<li key={ev.id} className={`ev ev-${ev.kind}`}>
|
||||
<span className="ev-kind">{t(`kind.${(KINDS as readonly string[]).includes(ev.kind) ? ev.kind : 'other'}` as 'kind.other')}</span>{' '}
|
||||
{ev.url ? <a href={ev.url} target="_blank" rel="noopener noreferrer">{ev.title}</a> : ev.title}
|
||||
{ev.participants.length > 0 && (
|
||||
<div className="small">
|
||||
{ev.participants.map((p) => (
|
||||
<Link key={p.slug} href={`/personen/${p.slug}`}>{p.name}</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
{events.length > 6 && <li className="small muted">+{events.length - 6}</li>}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{data.events.length === 0 && <p className="muted">{t('none')}</p>}
|
||||
<p className="small muted">{t('datePrecision')}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import type {Metadata} from 'next';
|
||||
import {notFound} from 'next/navigation';
|
||||
import {Suspense} from 'react';
|
||||
import {hasLocale, NextIntlClientProvider} from 'next-intl';
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {LocaleSwitcher} from '@/components/LocaleSwitcher';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {routing} from '@/i18n/routing';
|
||||
import '../globals.css';
|
||||
|
||||
type Props = {children: React.ReactNode; params: Promise<{locale: string}>};
|
||||
|
||||
export function generateStaticParams() {
|
||||
return routing.locales.map((locale) => ({locale}));
|
||||
}
|
||||
|
||||
export async function generateMetadata({params}: Props): Promise<Metadata> {
|
||||
const {locale} = await params;
|
||||
const t = await getTranslations({locale, namespace: 'Meta'});
|
||||
return {title: {default: t('title'), template: '%s · Politrack'}, description: t('description')};
|
||||
}
|
||||
|
||||
export default async function LocaleLayout({children, params}: Props) {
|
||||
const {locale} = await params;
|
||||
if (!hasLocale(routing.locales, locale)) notFound();
|
||||
setRequestLocale(locale);
|
||||
const t = await getTranslations('Nav');
|
||||
|
||||
return (
|
||||
<html lang={locale}>
|
||||
<body>
|
||||
<NextIntlClientProvider>
|
||||
<header className="site-header">
|
||||
<Link href="/" className="brand">Politrack</Link>
|
||||
<nav>
|
||||
<Link href="/personen">{t('persons')}</Link>
|
||||
<Link href="/parteien">{t('parties')}</Link>
|
||||
<Link href="/organisationen">{t('organizations')}</Link>
|
||||
<Link href="/geld">{t('money')}</Link>
|
||||
<Link href="/abstimmungen">{t('votes')}</Link>
|
||||
<Link href="/social">{t('social')}</Link>
|
||||
<Link href="/kalender">{t('calendar')}</Link>
|
||||
<Link href="/ehemalige">{t('former')}</Link>
|
||||
<Link href="/suche">{t('search')}</Link>
|
||||
<Link href="/einstellungen">{t('settings')}</Link>
|
||||
<Link href="/methodik">{t('method')}</Link>
|
||||
<Suspense>
|
||||
<LocaleSwitcher />
|
||||
</Suspense>
|
||||
</nav>
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
</NextIntlClientProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {api} from '@/lib/api';
|
||||
|
||||
export default async function MethodPage({params}: {params: Promise<{locale: string}>}) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const t = await getTranslations('Method');
|
||||
const sources = await api.sources();
|
||||
|
||||
return (
|
||||
<article className="prose">
|
||||
<h1>{t('title')}</h1>
|
||||
<p>{t('p1')}</p>
|
||||
<p>{t('p2')}</p>
|
||||
<p>{t('p3')}</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th></th><th>{t('license')}</th><th>{t('access')}</th><th>{t('trust')}</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{sources.map((s) => (
|
||||
<tr key={s.slug}>
|
||||
<td>
|
||||
{s.homepage ? <a href={s.homepage} target="_blank" rel="noopener noreferrer">{s.name}</a> : s.name}
|
||||
{s.tos_notes && <div className="muted small">{s.tos_notes}</div>}
|
||||
</td>
|
||||
<td className="small">{s.license}</td>
|
||||
<td className="small">{s.access_method}</td>
|
||||
<td className="num">{s.default_trust}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import {useTranslations} from 'next-intl';
|
||||
|
||||
export default function NotFound() {
|
||||
const t = useTranslations('Common');
|
||||
return <p className="muted">{t('notFound')}</p>;
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import type {Metadata} from 'next';
|
||||
import {notFound} from 'next/navigation';
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {ClaimList} from '@/components/ClaimList';
|
||||
import {MoneyTable} from '@/components/MoneyTable';
|
||||
import {Link, redirect} from '@/i18n/navigation';
|
||||
import {api, NotFoundError, type OrganizationDetail} from '@/lib/api';
|
||||
import {formatMoney} from '@/lib/format';
|
||||
|
||||
type Props = {params: Promise<{locale: string; slug: string}>};
|
||||
|
||||
const IDENTIFIER_LINKS: Record<string, (value: string) => string> = {
|
||||
wikidata: (v) => `https://www.wikidata.org/wiki/${v}`,
|
||||
eu_transparency: (v) => `https://transparency-register.europa.eu/searchregister-or-update/organisation-detail_en?id=${v}`
|
||||
};
|
||||
|
||||
async function loadOrganization(slug: string): Promise<OrganizationDetail> {
|
||||
try {
|
||||
return await api.organization(slug);
|
||||
} catch (error) {
|
||||
if (error instanceof NotFoundError) notFound();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateMetadata({params}: Props): Promise<Metadata> {
|
||||
const {slug} = await params;
|
||||
const org = await loadOrganization(slug);
|
||||
return {title: org.short_name ?? org.name};
|
||||
}
|
||||
|
||||
export default async function OrganizationPage({params}: Props) {
|
||||
const {locale, slug} = await params;
|
||||
setRequestLocale(locale);
|
||||
const org = await loadOrganization(slug);
|
||||
if (org.kind === 'party') redirect({href: `/parteien/${slug}`, locale});
|
||||
const t = await getTranslations('Organizations');
|
||||
const tm = await getTranslations('Money');
|
||||
const [flows, claims] = await Promise.all([
|
||||
api.money({org: slug, limit: 50}),
|
||||
api.claims({organization: slug, limit: 50})
|
||||
]);
|
||||
|
||||
return (
|
||||
<article>
|
||||
<h1>{org.name} {org.short_name && org.short_name !== org.name && <span className="muted small">{org.short_name}</span>}</h1>
|
||||
<p className="muted">
|
||||
{t(`kind.${org.kind}` as 'kind.other')}
|
||||
{org.parent_slug && <> · {t('partOf')} <Link href={`/organisationen/${org.parent_slug}`}>{org.parent_name}</Link></>}
|
||||
</p>
|
||||
{org.identifiers && Object.keys(org.identifiers).length > 0 && (
|
||||
<p className="small">
|
||||
{Object.entries(org.identifiers).map(([scheme, value]) => (
|
||||
<span key={scheme} className="identifier">
|
||||
{t(`identifier.${scheme}` as 'identifier.other')}:{' '}
|
||||
{IDENTIFIER_LINKS[scheme] ? <a href={IDENTIFIER_LINKS[scheme](value)} target="_blank" rel="noopener noreferrer">{value}</a> : value}
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="grid-2">
|
||||
<section>
|
||||
<h2>{t('moneyOverview')}</h2>
|
||||
{org.money.length === 0 ? <p className="muted">–</p> : (
|
||||
<table>
|
||||
<tbody>
|
||||
{org.money.map((m) => (
|
||||
<tr key={`${m.kind}-${m.direction}`}>
|
||||
<td>{tm(`kind.${m.kind}` as 'kind.other')}</td>
|
||||
<td className="muted small">{t(m.direction)}</td>
|
||||
<td className="num">{m.total ? formatMoney(m.total, locale) : ''}</td>
|
||||
<td className="num muted small">{m.count}×</td>
|
||||
<td className="muted small">{m.first?.slice(0, 4)}–{m.last?.slice(0, 4)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</section>
|
||||
<section>
|
||||
<h2>{t('counterparties')}</h2>
|
||||
{org.counterparties.length === 0 ? <p className="muted">–</p> : (
|
||||
<ul className="compact">
|
||||
{org.counterparties.map((c) => (
|
||||
<li key={`${c.slug}-${c.money_kind}-${c.direction}`}>
|
||||
<span className="muted small">{t(c.direction)}</span>{' '}
|
||||
<Link href={`/organisationen/${c.slug}`}>{c.name}</Link>{' '}
|
||||
<span className="muted small">
|
||||
{tm(`kind.${c.money_kind}` as 'kind.other')} · {c.total ? formatMoney(c.total, locale) : `${c.count}×`}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{org.people.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('people')}</h2>
|
||||
<p className="notice small">{t('connectionNote')}</p>
|
||||
<ul className="compact">
|
||||
{org.people.map((p, i) => (
|
||||
<li key={`${p.slug}-${i}`}>
|
||||
<Link href={`/personen/${p.slug}`}>{p.full_name}</Link>{' '}
|
||||
<span className="muted small">{p.summary_de}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section>
|
||||
<h2>{t('flows')}</h2>
|
||||
<MoneyTable flows={flows} />
|
||||
{flows.length === 50 && <p><Link href={`/geld?org=${slug}`}>→ {t('allFlows')}</Link></p>}
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>{t('claims')}</h2>
|
||||
<ClaimList claims={claims} />
|
||||
</section>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import {getLocale, getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api} from '@/lib/api';
|
||||
import {formatMoney} from '@/lib/format';
|
||||
|
||||
const ORG_KINDS =['party', 'company', 'public_body', 'ministry', 'municipality', 'media', 'ngo', 'lobby',
|
||||
'parliament', 'government', 'eu_institution', 'other'] as const;
|
||||
|
||||
type Props = {
|
||||
params: Promise<{locale: string}>;
|
||||
searchParams: Promise<{q?: string; kind?: string; page?: string}>;
|
||||
};
|
||||
|
||||
export default async function OrganizationsPage({params, searchParams}: Props) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const sp = await searchParams;
|
||||
const t = await getTranslations('Organizations');
|
||||
const loc = await getLocale();
|
||||
const page = Math.max(1, Number(sp.page) || 1);
|
||||
const orgs = await api.organizations({q: sp.q, kind: sp.kind, limit: 100, offset: (page - 1) * 100});
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}</h1>
|
||||
<p className="muted">{t('intro')}</p>
|
||||
<form className="filters" method="get">
|
||||
<input type="search" name="q" defaultValue={sp.q} placeholder={t('searchPlaceholder')} />
|
||||
<label>
|
||||
{t('kindLabel')}{' '}
|
||||
<select name="kind" defaultValue={sp.kind ?? ''}>
|
||||
<option value="">{t('all')}</option>
|
||||
{ORG_KINDS.map((kind) => <option key={kind} value={kind}>{t(`kind.${kind}`)}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
<button type="submit">OK</button>
|
||||
</form>
|
||||
|
||||
{orgs.length === 0 ? <p className="muted">{t('none')}</p> : (
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>{t('name')}</th><th>{t('kindLabel')}</th><th className="num">{t('paid')}</th><th className="num">{t('received')}</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{orgs.map((org) => (
|
||||
<tr key={org.slug}>
|
||||
<td><Link href={`/organisationen/${org.slug}`}>{org.name}</Link></td>
|
||||
<td className="muted small">{t(`kind.${org.kind}` as 'kind.other')}</td>
|
||||
<td className="num">{org.paid ? formatMoney(org.paid, loc) : ''}</td>
|
||||
<td className="num">{org.received ? formatMoney(org.received, loc) : ''}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
{orgs.length === 100 && (
|
||||
<p><Link href={{pathname: '/organisationen', query: {...sp, page: String(page + 1)}}}>→</Link></p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {ClaimList} from '@/components/ClaimList';
|
||||
import {SearchForm} from '@/components/SearchForm';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api, getPrefs} from '@/lib/api';
|
||||
import {formatDate} from '@/lib/format';
|
||||
|
||||
export default async function HomePage({params}: {params: Promise<{locale: string}>}) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const t = await getTranslations('Home');
|
||||
const [stats, claims, prefs] = await Promise.all([
|
||||
api.stats(),
|
||||
api.claims({types: ['vote', 'donation', 'statement', 'media_mention', 'side_job', 'legal_proceeding', 'travel', 'meeting'], limit: 30}),
|
||||
getPrefs()
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<section className="hero">
|
||||
<h1>{t('headline')}</h1>
|
||||
<p>{t('intro')}</p>
|
||||
<SearchForm />
|
||||
<p className="muted small">
|
||||
{t('stats', {persons: stats.persons, active: stats.active_persons, claims: stats.claims, corroborated: stats.corroborated, votes: stats.vote_events, rollCalls: stats.roll_call_votes, money: stats.money_flows})}
|
||||
{stats.last_update && <> · {t('lastUpdate', {date: formatDate(stats.last_update, locale)})}</>}
|
||||
</p>
|
||||
{(prefs.excludedSources.length > 0 || prefs.topics.length > 0) && (
|
||||
<p className="notice">
|
||||
{t('filtersActive', {sources: prefs.excludedSources.length, topics: prefs.topics.length})}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<section className="explore">
|
||||
<h2>{t('explore')}</h2>
|
||||
<ul className="cards">
|
||||
{([['/geld', 'exploreMoney'], ['/organisationen', 'exploreOrganizations'], ['/social', 'exploreSocial'],
|
||||
['/wikipedia', 'exploreWiki'], ['/ehemalige', 'exploreFormer'], ['/kalender', 'exploreCalendar']] as const).map(([href, key]) => (
|
||||
<li key={href} className="card"><Link href={href} className="card-link">{t(key)}</Link></li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
<section>
|
||||
<h2>{t('latest')}</h2>
|
||||
<ClaimList claims={claims} />
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
import type {Metadata} from 'next';
|
||||
import {notFound} from 'next/navigation';
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {ClaimList} from '@/components/ClaimList';
|
||||
import {SocialFeed} from '@/components/SocialFeed';
|
||||
import {VoteTable} from '@/components/VoteTable';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api, NotFoundError, type PartyDetail} from '@/lib/api';
|
||||
import {formatDate, formatMoney} from '@/lib/format';
|
||||
|
||||
type Props = {params: Promise<{locale: string; slug: string}>};
|
||||
|
||||
async function loadParty(slug: string): Promise<PartyDetail> {
|
||||
try {
|
||||
return await api.party(slug);
|
||||
} catch (error) {
|
||||
if (error instanceof NotFoundError) notFound();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateMetadata({params}: Props): Promise<Metadata> {
|
||||
const {slug} = await params;
|
||||
const party = await loadParty(slug);
|
||||
return {title: party.short_name ?? party.name};
|
||||
}
|
||||
|
||||
export default async function PartyPage({params}: Props) {
|
||||
const {locale, slug} = await params;
|
||||
setRequestLocale(locale);
|
||||
const t = await getTranslations('Parties');
|
||||
const tv = await getTranslations('Votes');
|
||||
const tl = await getTranslations('Persons');
|
||||
const tm = await getTranslations('Money');
|
||||
const party = await loadParty(slug);
|
||||
const [votes, claims, posts] = await Promise.all([
|
||||
api.votes({party: slug, limit: 15}),
|
||||
api.claims({party: slug, types: ['donation', 'media_mention', 'legal_proceeding', 'money_flow', 'lobbying'], limit: 30}),
|
||||
api.social({party: slug, limit: 5})
|
||||
]);
|
||||
const years = [...new Set(party.money_by_year.map((row) => row.year))].sort((a, b) => b - a);
|
||||
const kinds = [...new Set(party.money_by_year.map((row) => row.kind))];
|
||||
const cell = (year: number, kind: string) => party.money_by_year.find((row) => row.year === year && row.kind === kind);
|
||||
|
||||
return (
|
||||
<article>
|
||||
<h1 style={{borderBottomColor: party.color ?? undefined}} className="party-title">
|
||||
{party.short_name ?? party.name} <span className="muted small">{party.short_name && party.name}</span>
|
||||
</h1>
|
||||
|
||||
<div className="grid-2">
|
||||
<section>
|
||||
<h2>{t('members')} ({party.members.length})</h2>
|
||||
<ul className="compact">
|
||||
{party.members.slice(0, 200).map((m) => (
|
||||
<li key={m.slug}>
|
||||
<Link href={`/personen/${m.slug}`}>{m.full_name}</Link>{' '}
|
||||
<span className="muted small">
|
||||
{m.role === 'mp' ? m.body : m.role} · {tl(`level.${m.level}` as 'level.other')}
|
||||
{m.region && <> · {m.region}</>}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>{t('money')}</h2>
|
||||
{years.length ? (
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>{t('year')}</th>{kinds.map((kind) => <th key={kind}>{tm(`kind.${kind}` as 'kind.other')}</th>)}</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{years.map((year) => (
|
||||
<tr key={year}>
|
||||
<td>{year}</td>
|
||||
{kinds.map((kind) => {
|
||||
const row = cell(year, kind);
|
||||
return (
|
||||
<td key={kind} className="num" title={row ? `${row.count}×` : undefined}>
|
||||
{row?.total ? formatMoney(row.total, locale) : row ? `${row.count}×` : ''}
|
||||
</td>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
) : <p className="muted">–</p>}
|
||||
<p className="small"><Link href={`/geld?org=${slug}`}>→ {t('allMoney')}</Link></p>
|
||||
|
||||
<h2>{t('voteStats')}</h2>
|
||||
<p>
|
||||
{party.vote_stats.map((s) => (
|
||||
<span key={s.position} className={`pos pos-${s.position}`}>{tv(s.position as 'for')}: {s.count}</span>
|
||||
))}
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{(party.finance.length > 0 || party.related.length > 0) && (
|
||||
<div className="grid-2">
|
||||
{party.finance.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('finance')}</h2>
|
||||
<table>
|
||||
<tbody>
|
||||
{party.finance.map((f) => (
|
||||
<tr key={String(f.data.year ?? f.valid_from)}>
|
||||
<td>{String(f.data.year ?? formatDate(f.valid_from, locale))}</td>
|
||||
<td className="num">
|
||||
{f.data.total_income ? `${t('income')} ${formatMoney(Number(f.data.total_income), locale)}` : ''}
|
||||
</td>
|
||||
<td className="num">
|
||||
{f.data.total_expenses ? `${t('expenses')} ${formatMoney(Number(f.data.total_expenses), locale)}` : ''}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
)}
|
||||
{party.related.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('related')}</h2>
|
||||
<ul className="compact">
|
||||
{party.related.map((org) => (
|
||||
<li key={`${org.claim_type}-${org.slug}`}>
|
||||
<Link href={`/organisationen/${org.slug}`}>{org.name}</Link>{' '}
|
||||
<span className="muted small">({t(`relation.${org.claim_type}` as 'relation.affiliation')})</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid-2">
|
||||
<section>
|
||||
<h2>{t('formerMembers')}</h2>
|
||||
<ul className="compact">
|
||||
{party.former_members.map((m) => (
|
||||
<li key={m.slug}>
|
||||
<Link href={`/personen/${m.slug}?tab=media`}>{m.full_name}</Link>{' '}
|
||||
<span className="muted small">
|
||||
{m.last_office_end && `${tl('lastOffice', {date: formatDate(m.last_office_end, locale)})}`}
|
||||
{m.last_mention && ` · ${formatDate(m.last_mention, locale)}`}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p><Link href={`/ehemalige?party=${slug}`}>→ {t('formerMembers')}</Link></p>
|
||||
</section>
|
||||
{party.dissent.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('dissent')}</h2>
|
||||
<ul className="compact">
|
||||
{party.dissent.map((d) => (
|
||||
<li key={d.slug}>
|
||||
<Link href={`/personen/${d.slug}?tab=votes`}>{d.full_name}</Link>{' '}
|
||||
<span className="muted small">({d.dissenting_votes})</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h2>{t('recentVotes')}</h2>
|
||||
<VoteTable votes={votes} />
|
||||
<p><Link href={`/abstimmungen?party=${slug}`}>→ {tv('title')}</Link></p>
|
||||
</section>
|
||||
|
||||
{posts.length > 0 && (
|
||||
<section>
|
||||
<h2>{t('channels')}</h2>
|
||||
<SocialFeed posts={posts} />
|
||||
<p><Link href={`/social?party=${slug}`}>→ {t('allPosts')}</Link></p>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section>
|
||||
<h2>{t('claims')}</h2>
|
||||
<ClaimList claims={claims} showSubject={false} />
|
||||
</section>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api} from '@/lib/api';
|
||||
|
||||
export default async function PartiesPage({params}: {params: Promise<{locale: string}>}) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const t = await getTranslations('Parties');
|
||||
const parties = (await api.parties()).filter((p) => (p.total_people ?? 0) > 0);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}</h1>
|
||||
<ul className="cards">
|
||||
{parties.map((party) => (
|
||||
<li key={party.slug} className="card" style={{borderLeftColor: party.color ?? undefined}}>
|
||||
<Link href={`/parteien/${party.slug}`} className="card-link">
|
||||
<span>
|
||||
<strong>{party.short_name ?? party.name}</strong>
|
||||
<span className="muted small block">{party.name}</span>
|
||||
<span className="small">{t('activeOfficials', {count: party.active_officials ?? 0})}</span>
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
import type {Metadata} from 'next';
|
||||
import {notFound} from 'next/navigation';
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {ClaimList} from '@/components/ClaimList';
|
||||
import {MoneyTable} from '@/components/MoneyTable';
|
||||
import {SocialFeed} from '@/components/SocialFeed';
|
||||
import {DateRangeForm, Timeline} from '@/components/Timeline';
|
||||
import {VoteTable} from '@/components/VoteTable';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api, NotFoundError, type Person} from '@/lib/api';
|
||||
import {formatDate, formatMoney} from '@/lib/format';
|
||||
|
||||
// Claim types per tab; tabs with an empty list render their own component (see below).
|
||||
const TABS = {
|
||||
overview: ['statement', 'vote', 'donation', 'side_job', 'media_mention', 'meeting', 'travel', 'legal_proceeding',
|
||||
'career', 'government_decision', 'declaration'],
|
||||
timeline: [],
|
||||
votes: [],
|
||||
travel: ['travel', 'meeting', 'appearance', 'government_decision'],
|
||||
statements: ['statement', 'parliamentary_question'],
|
||||
social: [],
|
||||
money: ['side_job', 'donation', 'money_flow', 'lobbying', 'declaration', 'ownership'],
|
||||
media: ['media_mention', 'career', 'wiki_edit'],
|
||||
legal: ['legal_proceeding']
|
||||
} as const;
|
||||
const CUSTOM_TABS: Tab[] = ['overview', 'timeline', 'votes', 'social', 'money'];
|
||||
type Tab = keyof typeof TABS;
|
||||
|
||||
type Props = {
|
||||
params: Promise<{locale: string; slug: string}>;
|
||||
searchParams: Promise<{tab?: string; since?: string; until?: string}>;
|
||||
};
|
||||
|
||||
async function loadPerson(slug: string): Promise<Person> {
|
||||
try {
|
||||
return await api.person(slug);
|
||||
} catch (error) {
|
||||
if (error instanceof NotFoundError) notFound();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateMetadata({params}: Props): Promise<Metadata> {
|
||||
const {slug} = await params;
|
||||
const person = await loadPerson(slug);
|
||||
return {title: person.full_name};
|
||||
}
|
||||
|
||||
export default async function PersonPage({params, searchParams}: Props) {
|
||||
const {locale, slug} = await params;
|
||||
setRequestLocale(locale);
|
||||
const {tab: rawTab, since, until} = await searchParams;
|
||||
const tab: Tab = rawTab && rawTab in TABS ? (rawTab as Tab) : 'overview';
|
||||
const t = await getTranslations('Person');
|
||||
const tl = await getTranslations('Persons');
|
||||
const person = await loadPerson(slug);
|
||||
|
||||
const today = new Date();
|
||||
const currentRoles = person.roles.filter((r) => !r.end_date || new Date(r.end_date) >= today);
|
||||
const pastRoles = person.roles.filter((r) => r.end_date && new Date(r.end_date) < today);
|
||||
|
||||
return (
|
||||
<article className="profile">
|
||||
<header className="profile-head">
|
||||
{person.photo_url && <img src={person.photo_url} alt="" className="portrait" />}
|
||||
<div>
|
||||
<h1>{person.full_name}</h1>
|
||||
<p>
|
||||
<span className={`status-badge status-${person.status}`} title={t('statusNote')}>
|
||||
{tl(`statusValue.${person.status}`)}
|
||||
</span>
|
||||
{person.status === 'active' && !person.status_verified && (
|
||||
<span className="muted small"> ({t('unverified')})</span>
|
||||
)}
|
||||
{person.status !== 'active' && person.last_office_end && (
|
||||
<span className="muted small"> · {tl('lastOffice', {date: formatDate(person.last_office_end, locale)})}</span>
|
||||
)}
|
||||
</p>
|
||||
{person.birth_date && (
|
||||
<p className="muted">
|
||||
* {formatDate(person.birth_date, locale)}
|
||||
{person.death_date && <> · † {formatDate(person.death_date, locale)}</>}
|
||||
</p>
|
||||
)}
|
||||
<p>
|
||||
{currentRoles
|
||||
.filter((r) => r.level !== 'party')
|
||||
.slice(0, 4)
|
||||
.map((r, i) => (
|
||||
<span key={i} className="role-pill">
|
||||
{r.role === 'mp' ? r.body : r.role}
|
||||
{r.party_short && <> · {r.party_slug ? <Link href={`/parteien/${r.party_slug}`}>{r.party_short}</Link> : r.party_short}</>}
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
{person.social_accounts.length > 0 && (
|
||||
<p className="small">
|
||||
{t('social')}:{' '}
|
||||
{person.social_accounts.map((a) => (
|
||||
<a key={a.url} href={a.url} target="_blank" rel="noopener noreferrer nofollow"
|
||||
className={a.verified ? 'social' : 'social unverified'} title={a.verified ? undefined : t('accountUnverified')}>
|
||||
{a.platform}{!a.verified && '*'}
|
||||
</a>
|
||||
))}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<nav className="tabs">
|
||||
{(Object.keys(TABS) as Tab[]).map((key) => (
|
||||
<Link key={key} href={`/personen/${slug}?tab=${key}`} className={key === tab ? 'active' : undefined}>
|
||||
{t(`tabs.${key}`)}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
{tab === 'overview' && (
|
||||
<section>
|
||||
<h2>{t('roles')}</h2>
|
||||
<ul className="roles">
|
||||
{[...currentRoles, ...pastRoles].map((role, i) => (
|
||||
<li key={i}>
|
||||
<strong>{role.role === 'mp' ? role.body : role.role === 'party_member' ? role.party_short ?? role.body : role.role}</strong>
|
||||
{role.party_short && role.role !== 'party_member' && <> · {role.party_short}</>}
|
||||
{role.region && <> · {role.region}</>}
|
||||
<span className="muted small">
|
||||
{' '}({tl(`level.${role.level}` as 'level.other')},{' '}
|
||||
{role.end_date
|
||||
? t('period', {from: formatDate(role.start_date, locale), to: formatDate(role.end_date, locale)})
|
||||
: t('since', {date: formatDate(role.start_date, locale) || '?'})}
|
||||
)
|
||||
</span>
|
||||
{role.claim_status === 'corroborated' && <span className="status-corroborated small"> ✓ {t('roleCorroborated')}</span>}
|
||||
{(role.evidence ?? []).map((ev) => (
|
||||
<a key={ev.url} href={ev.url} className="cite" target="_blank" rel="noopener noreferrer">[{ev.source}]</a>
|
||||
))}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<ClaimList claims={await api.claims({person: slug, types: [...TABS.overview], limit: 25})} showSubject={false} />
|
||||
</section>
|
||||
)}
|
||||
|
||||
{tab === 'timeline' && (
|
||||
<section>
|
||||
<Timeline buckets={await api.timeline({person: slug})} basePath={`/personen/${slug}`} query={{tab: 'timeline'}} />
|
||||
<DateRangeForm since={since} until={until} hidden={{tab: 'timeline'}} />
|
||||
<ClaimList claims={await api.claims({person: slug, since, until, limit: 200})} showSubject={false} />
|
||||
</section>
|
||||
)}
|
||||
|
||||
{tab === 'votes' && <PersonVotes slug={slug} />}
|
||||
|
||||
{tab === 'social' && <SocialFeed posts={await api.social({person: slug, limit: 100})} showAuthor={false} />}
|
||||
|
||||
{tab === 'money' && (
|
||||
<>
|
||||
<PersonNetwork slug={slug} locale={locale} />
|
||||
<DateRangeForm since={since} until={until} hidden={{tab}} />
|
||||
<ClaimList claims={await api.claims({person: slug, types: [...TABS.money], since, until, limit: 100})} showSubject={false} />
|
||||
</>
|
||||
)}
|
||||
|
||||
{!CUSTOM_TABS.includes(tab) && (
|
||||
<>
|
||||
<DateRangeForm since={since} until={until} hidden={{tab}} />
|
||||
<ClaimList claims={await api.claims({person: slug, types: [...TABS[tab]], since, until, limit: 100})} showSubject={false} />
|
||||
</>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
async function PersonNetwork({slug, locale}: {slug: string; locale: string}) {
|
||||
const t = await getTranslations('Network');
|
||||
const tm = await getTranslations('Money');
|
||||
const [network, flows] = await Promise.all([api.personNetwork(slug), api.money({person: slug, limit: 30})]);
|
||||
if (!network.organizations.length) return null;
|
||||
return (
|
||||
<section>
|
||||
<h2>{t('title')}</h2>
|
||||
<p className="notice small">{t('note')}</p>
|
||||
<table>
|
||||
<tbody>
|
||||
{network.organizations.map((org) => (
|
||||
<tr key={org.id}>
|
||||
<td><Link href={`/organisationen/${org.slug}`}>{org.name}</Link></td>
|
||||
<td className="muted small">{org.via.map((v) => t(`via.${v}` as 'via.side_job')).join(', ')}</td>
|
||||
<td className="small">
|
||||
{Object.entries(org.money ?? {}).map(([key, value]) => {
|
||||
// key = '<money kind>_paid' | '<money kind>_received', value = {total, count}
|
||||
const split = key.lastIndexOf('_');
|
||||
const {total, count} = value as {total: number | null; count: number};
|
||||
return (
|
||||
<span key={key} className="chip">
|
||||
{tm(`kind.${key.slice(0, split)}` as 'kind.other')} ({t(key.slice(split + 1) as 'paid')}):{' '}
|
||||
{total ? formatMoney(total, locale) : `${count}×`}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
{flows.length > 0 && (
|
||||
<>
|
||||
<h3>{t('flows')}</h3>
|
||||
<MoneyTable flows={flows} />
|
||||
<p><Link href={`/geld?person=${slug}`}>→ {t('allFlows')}</Link></p>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
async function PersonVotes({slug}: {slug: string}) {
|
||||
const t = await getTranslations('Person');
|
||||
const votes = await api.personVotes(slug);
|
||||
return (
|
||||
<section>
|
||||
<p className="notice">{t('factionVoteNote')}</p>
|
||||
{votes.length ? <VoteTable votes={votes} /> : <p className="muted">{t('noVotes')}</p>}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api} from '@/lib/api';
|
||||
|
||||
const LEVELS = ['eu', 'federal', 'state', 'municipal', 'party'] as const;
|
||||
const STATUSES = ['active', 'former', 'party_member', 'deceased', 'all'] as const;
|
||||
|
||||
type Props = {
|
||||
params: Promise<{locale: string}>;
|
||||
searchParams: Promise<{q?: string; party?: string; level?: string; status?: string; page?: string}>;
|
||||
};
|
||||
|
||||
export default async function PersonsPage({params, searchParams}: Props) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const sp = await searchParams;
|
||||
const t = await getTranslations('Persons');
|
||||
const page = Math.max(1, Number(sp.page) || 1);
|
||||
const status = STATUSES.includes(sp.status as (typeof STATUSES)[number]) ? sp.status! : 'active';
|
||||
const [persons, parties] = await Promise.all([
|
||||
api.persons({q: sp.q, party: sp.party, level: sp.level, status: status, limit: 60, offset: (page - 1) * 60}),
|
||||
api.parties()
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}</h1>
|
||||
<form className="filters" method="get">
|
||||
<input type="search" name="q" defaultValue={sp.q} placeholder="Name …" />
|
||||
<label>
|
||||
{t('filterParty')}{' '}
|
||||
<select name="party" defaultValue={sp.party ?? ''}>
|
||||
<option value="">{t('all')}</option>
|
||||
{parties.filter((p) => (p.active_officials ?? 0) > 0 || p.slug === sp.party).map((p) => (
|
||||
<option key={p.slug} value={p.slug}>{p.short_name ?? p.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
{t('filterLevel')}{' '}
|
||||
<select name="level" defaultValue={sp.level ?? ''}>
|
||||
<option value="">{t('all')}</option>
|
||||
{LEVELS.map((level) => (
|
||||
<option key={level} value={level}>{t(`level.${level}`)}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
{t('filterStatus')}{' '}
|
||||
<select name="status" defaultValue={status}>
|
||||
{STATUSES.map((s) => (
|
||||
<option key={s} value={s}>{t(`statusValue.${s}`)}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<button type="submit">OK</button>
|
||||
</form>
|
||||
|
||||
{persons.length === 0 && <p className="muted">{t('none')}</p>}
|
||||
<ul className="cards">
|
||||
{persons.map((person) => (
|
||||
<li key={person.slug} className="card">
|
||||
<Link href={`/personen/${person.slug}`} className="card-link">
|
||||
{person.photo_url ? <img src={person.photo_url} alt="" className="avatar" loading="lazy" /> : <span className="avatar" />}
|
||||
<span>
|
||||
<strong>{person.full_name}</strong>
|
||||
<span className="muted small block">
|
||||
{person.status === 'active'
|
||||
? (person.current_roles ?? []).slice(0, 2).join(' · ')
|
||||
: <>{t(`statusValue.${person.status}`)}{person.last_office_end && ` · ${t('lastOffice', {date: person.last_office_end.slice(0, 4)})}`}</>}
|
||||
</span>
|
||||
{(person.parties ?? []).map((party) => (
|
||||
<span key={party.slug} className="party-pill" style={{borderColor: party.color ?? undefined}}>
|
||||
{party.short_name ?? party.slug}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{persons.length === 60 && (
|
||||
<p>
|
||||
<Link href={{pathname: '/personen', query: {...sp, page: String(page + 1)}}}>→</Link>
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {SocialFeed} from '@/components/SocialFeed';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api} from '@/lib/api';
|
||||
|
||||
const PLATFORMS = ['bluesky', 'mastodon', 'telegram', 'youtube', 'x'] as const;
|
||||
const PAGE = 50;
|
||||
|
||||
type Props = {
|
||||
params: Promise<{locale: string}>;
|
||||
searchParams: Promise<{platform?: string; party?: string; page?: string}>;
|
||||
};
|
||||
|
||||
export default async function SocialPage({params, searchParams}: Props) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const sp = await searchParams;
|
||||
const t = await getTranslations('Social');
|
||||
const page = Math.max(1, Number(sp.page) || 1);
|
||||
const [posts, parties] = await Promise.all([
|
||||
api.social({platforms: sp.platform, party: sp.party, limit: PAGE, offset: (page - 1) * PAGE}),
|
||||
api.parties()
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}</h1>
|
||||
<p className="muted">{t('intro')}</p>
|
||||
<form className="filters" method="get">
|
||||
<select name="platform" defaultValue={sp.platform ?? ''} aria-label={t('platform')}>
|
||||
<option value="">{t('allPlatforms')}</option>
|
||||
{PLATFORMS.map((p) => <option key={p} value={p}>{p}</option>)}
|
||||
</select>
|
||||
<select name="party" defaultValue={sp.party ?? ''} aria-label={t('party')}>
|
||||
<option value="">{t('allParties')}</option>
|
||||
{parties.map((p) => <option key={p.slug} value={p.slug}>{p.short_name ?? p.name}</option>)}
|
||||
</select>
|
||||
<button type="submit">OK</button>
|
||||
</form>
|
||||
<SocialFeed posts={posts} />
|
||||
{posts.length === PAGE && (
|
||||
<p><Link href={{pathname: '/social', query: {...sp, page: String(page + 1)}}}>→</Link></p>
|
||||
)}
|
||||
<p className="small muted">{t('policy')}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {ClaimList} from '@/components/ClaimList';
|
||||
import {SearchForm} from '@/components/SearchForm';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api} from '@/lib/api';
|
||||
|
||||
type Props = {params: Promise<{locale: string}>; searchParams: Promise<{q?: string; since?: string; until?: string}>};
|
||||
|
||||
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
||||
|
||||
export default async function SearchPage({params, searchParams}: Props) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const sp = await searchParams;
|
||||
const q = sp.q?.trim() || undefined;
|
||||
const since = sp.since && DATE.test(sp.since) ? sp.since : undefined;
|
||||
const until = sp.until && DATE.test(sp.until) ? sp.until : undefined;
|
||||
const t = await getTranslations('Search');
|
||||
|
||||
const hits = q && q.length >= 2 ? await api.search(q, since, until) : [];
|
||||
// Without a query, a date range lists everything that happened in that period ("search in time").
|
||||
const inRange = !q && (since || until) ? await api.claims({since, until, limit: 200}) : [];
|
||||
|
||||
return (
|
||||
<>
|
||||
<SearchForm defaultValue={q} since={since} until={until} withDates />
|
||||
{q && <h1>{t('results', {q})}</h1>}
|
||||
{q && hits.length === 0 && <p className="muted">{t('none')}</p>}
|
||||
<ul className="claims">
|
||||
{hits.map((hit) => (
|
||||
<li key={hit.id} className="claim">
|
||||
{hit.person_slug && <Link href={`/personen/${hit.person_slug}`}>{hit.person_name}</Link>}
|
||||
{hit.summary_de ? (
|
||||
<p className="claim-summary">{hit.summary_de}</p>
|
||||
) : (
|
||||
<p className="claim-summary">
|
||||
{hit.document_url && (
|
||||
<a href={hit.document_url} target="_blank" rel="noopener noreferrer nofollow">
|
||||
<strong>{hit.document_title ?? hit.document_url}</strong>
|
||||
</a>
|
||||
)}
|
||||
<span className="block small muted">{hit.text.slice(0, 280)}…</span>
|
||||
</p>
|
||||
)}
|
||||
<ol className="small">
|
||||
{(hit.evidence ?? []).map((ev) => (
|
||||
<li key={ev.url}>
|
||||
<a href={ev.url} target="_blank" rel="noopener noreferrer nofollow">{ev.title || ev.url}</a>{' '}
|
||||
<span className="muted">({ev.source})</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{!q && (since || until) && <ClaimList claims={inRange} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import {getTranslations, setRequestLocale} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import {api} from '@/lib/api';
|
||||
import {formatDate} from '@/lib/format';
|
||||
|
||||
const PAGE = 100;
|
||||
|
||||
type Props = {params: Promise<{locale: string}>; searchParams: Promise<{page?: string}>};
|
||||
|
||||
export default async function WikiEditsPage({params, searchParams}: Props) {
|
||||
const {locale} = await params;
|
||||
setRequestLocale(locale);
|
||||
const sp = await searchParams;
|
||||
const t = await getTranslations('WikiEdits');
|
||||
const page = Math.max(1, Number(sp.page) || 1);
|
||||
const edits = await api.wikiEdits({limit: PAGE, offset: (page - 1) * PAGE});
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{t('title')}</h1>
|
||||
<p className="muted">{t('intro')}</p>
|
||||
{edits.length === 0 ? <p className="muted">{t('none')}</p> : (
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>{t('date')}</th><th>{t('network')}</th><th>{t('article')}</th><th>{t('change')}</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{edits.map((edit) => (
|
||||
<tr key={edit.id}>
|
||||
<td className="nowrap">{formatDate(edit.occurred_at, locale)}</td>
|
||||
<td><Link href={`/organisationen/${edit.org_slug}`}>{edit.org_name}</Link></td>
|
||||
<td>
|
||||
{edit.url ? <a href={edit.url} target="_blank" rel="noopener noreferrer">{String(edit.data.title ?? '')}</a>
|
||||
: String(edit.data.title ?? '')}
|
||||
{edit.person_slug && <> · <Link href={`/personen/${edit.person_slug}`}>{edit.person_name}</Link></>}
|
||||
</td>
|
||||
<td className="small">
|
||||
{edit.data.sizediff !== undefined && <span className="num">{Number(edit.data.sizediff) > 0 ? '+' : ''}{String(edit.data.sizediff)}</span>}
|
||||
{edit.data.comment ? <span className="muted"> {String(edit.data.comment)}</span> : null}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
{edits.length === PAGE && (
|
||||
<p><Link href={{pathname: '/wikipedia', query: {page: String(page + 1)}}}>→</Link></p>
|
||||
)}
|
||||
<p className="small muted">{t('note')}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
:root {
|
||||
--bg: #fbfaf8;
|
||||
--fg: #1d1d1f;
|
||||
--muted: #6b6b70;
|
||||
--line: #e4e2dd;
|
||||
--card: #ffffff;
|
||||
--accent: #c8102e; /* Austrian red */
|
||||
--ok: #2e7d32;
|
||||
--bad: #b71c1c;
|
||||
--warn: #8a6d00;
|
||||
--warn-bg: #fff6d6;
|
||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||
color-scheme: light dark;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--bg: #151517;
|
||||
--fg: #ececee;
|
||||
--muted: #9a9aa2;
|
||||
--line: #2c2c31;
|
||||
--card: #1d1d21;
|
||||
--warn-bg: #3a3112;
|
||||
--warn: #f0d070;
|
||||
}
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; background: var(--bg); color: var(--fg); line-height: 1.5; }
|
||||
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 2px; }
|
||||
img { max-width: 100%; }
|
||||
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
|
||||
h1 { font-size: 1.8rem; line-height: 1.2; }
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th, td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
|
||||
input, select, button { font: inherit; padding: 0.4rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); }
|
||||
button { background: var(--accent); color: #fff; border: none; cursor: pointer; }
|
||||
button.secondary { background: transparent; color: var(--fg); border: 1px solid var(--line); }
|
||||
|
||||
.site-header { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-bottom: 3px solid var(--accent); background: var(--card); }
|
||||
.site-header nav { display: flex; flex-wrap: wrap; gap: 1rem; }
|
||||
.site-header nav a { text-decoration: none; }
|
||||
.brand { font-weight: 800; font-size: 1.2rem; text-decoration: none; }
|
||||
|
||||
.hero { padding: 1rem 0 0.5rem; }
|
||||
.search { display: flex; gap: 0.5rem; margin: 1rem 0; }
|
||||
.search input { flex: 1; }
|
||||
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
|
||||
|
||||
.muted { color: var(--muted); }
|
||||
.small { font-size: 0.85rem; }
|
||||
.block { display: block; }
|
||||
.nowrap { white-space: nowrap; }
|
||||
.num { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
.notice { background: var(--warn-bg); color: var(--warn); padding: 0.5rem 0.75rem; border-radius: 6px; font-size: 0.9rem; }
|
||||
|
||||
.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; }
|
||||
.card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; }
|
||||
.card-link { display: flex; gap: 0.75rem; padding: 0.75rem; text-decoration: none; align-items: center; }
|
||||
.avatar { width: 48px; height: 60px; object-fit: cover; border-radius: 4px; background: var(--line); flex-shrink: 0; }
|
||||
.party-pill, .role-pill, .chip { display: inline-block; font-size: 0.8rem; padding: 0 0.45rem; margin: 0.15rem 0.25rem 0 0; border: 1px solid var(--line); border-radius: 999px; }
|
||||
.party-pill { border-width: 2px; }
|
||||
|
||||
.claims { list-style: none; padding: 0; }
|
||||
.claim { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.6rem; }
|
||||
.claim-head { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
|
||||
.claim-summary { margin: 0.35rem 0; }
|
||||
.claim-disputed { border-color: var(--warn); }
|
||||
.tag { font-weight: 600; color: var(--fg); }
|
||||
.status { margin-left: auto; }
|
||||
.status-corroborated { color: var(--ok); }
|
||||
.status-disputed { color: var(--warn); }
|
||||
.evidence summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
|
||||
.evidence ol { font-size: 0.9rem; padding-left: 1.25rem; }
|
||||
.evidence blockquote { margin: 0.25rem 0 0.5rem; padding-left: 0.75rem; border-left: 3px solid var(--line); color: var(--muted); }
|
||||
.source { font-weight: 600; }
|
||||
.cite { margin-left: 0.3rem; font-size: 0.8rem; color: var(--muted); }
|
||||
|
||||
.profile-head { display: flex; gap: 1.25rem; align-items: flex-start; }
|
||||
.portrait { width: 140px; border-radius: 8px; }
|
||||
.social { margin-right: 0.5rem; }
|
||||
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--line); margin: 1rem 0; }
|
||||
.tabs a { padding: 0.5rem 0.75rem; text-decoration: none; border-bottom: 3px solid transparent; }
|
||||
.tabs a.active { border-bottom-color: var(--accent); font-weight: 600; }
|
||||
.roles { padding-left: 1.2rem; }
|
||||
.compact { padding-left: 1.2rem; max-height: 32rem; overflow: auto; }
|
||||
|
||||
.votes td { font-size: 0.92rem; }
|
||||
.pos { display: inline-block; padding: 0 0.4rem; margin: 0 0.25rem 0.25rem 0; border-radius: 4px; font-size: 0.82rem; }
|
||||
.pos-for { background: #e3f3e4; color: #1b5e20; }
|
||||
.pos-against { background: #fbe4e4; color: #8e1b1b; }
|
||||
.pos-abstain, .pos-absent { background: var(--line); }
|
||||
.result-accepted { color: var(--ok); }
|
||||
.result-rejected { color: var(--bad); }
|
||||
|
||||
.party-title { border-bottom: 4px solid var(--line); padding-bottom: 0.3rem; }
|
||||
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
|
||||
|
||||
.settings fieldset { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1rem; }
|
||||
.check { display: block; padding: 0.15rem 0; }
|
||||
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
|
||||
.source-group h3 { font-size: 1rem; margin: 0.75rem 0 0.25rem; }
|
||||
.prose { max-width: 60rem; }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.profile-head { flex-direction: column; }
|
||||
.status { margin-left: 0; }
|
||||
}
|
||||
|
||||
/* --- status, legal, votes --- */
|
||||
.status-badge { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600; border: 1px solid var(--line); }
|
||||
.status-badge.status-active { background: #e3f3e4; color: #1b5e20; border-color: #b7dfb9; }
|
||||
.status-badge.status-former, .status-badge.status-party_member { background: var(--line); color: var(--fg); }
|
||||
.status-badge.status-deceased { background: transparent; color: var(--muted); }
|
||||
.innocence { font-weight: 600; }
|
||||
.claim-legal { border-left: 4px solid var(--warn); }
|
||||
.legal-stage { margin: 0.3rem 0 0; font-size: 0.9rem; }
|
||||
.dissent { display: inline-block; margin-left: 0.4rem; padding: 0 0.4rem; border-radius: 4px; font-size: 0.78rem; background: var(--warn-bg); color: var(--warn); }
|
||||
|
||||
/* --- timeline --- */
|
||||
.timeline { margin: 0 0 1rem; }
|
||||
.timeline-bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; border-bottom: 1px solid var(--line); }
|
||||
.timeline-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 3px; }
|
||||
.timeline-bar span { display: block; width: 100%; background: var(--accent); opacity: 0.75; border-radius: 2px 2px 0 0; }
|
||||
.timeline-bar:hover span { opacity: 1; }
|
||||
.timeline-axis { display: flex; justify-content: space-between; }
|
||||
|
||||
/* --- calendar --- */
|
||||
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
|
||||
.calendar-head { font-weight: 600; font-size: 0.85rem; text-align: center; color: var(--muted); }
|
||||
.calendar-cell { min-height: 6.5rem; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 0.3rem; font-size: 0.8rem; overflow: hidden; }
|
||||
.calendar-cell.empty { background: transparent; border: none; }
|
||||
.calendar-cell.has-events { border-color: var(--accent); }
|
||||
.calendar-day { display: flex; justify-content: space-between; gap: 0.25rem; }
|
||||
.calendar-cell ul { list-style: none; padding: 0; margin: 0.25rem 0 0; }
|
||||
.calendar-cell li { margin-bottom: 0.25rem; line-height: 1.25; }
|
||||
.ev-kind { font-weight: 600; color: var(--muted); }
|
||||
.ev-foreign_trip .ev-kind, .ev-meeting .ev-kind { color: var(--accent); }
|
||||
@media (max-width: 760px) {
|
||||
.calendar { grid-template-columns: 1fr; }
|
||||
.calendar-head, .calendar-cell.empty { display: none; }
|
||||
.calendar-cell { min-height: 0; }
|
||||
}
|
||||
|
||||
/* v2: claim details, money, social, organisations */
|
||||
.claim-detail { margin: 0.2rem 0; font-size: 0.92rem; }
|
||||
.money-line strong { font-variant-numeric: tabular-nums; }
|
||||
.compact-table td { padding: 0.1rem 0.5rem; font-size: 0.85rem; }
|
||||
table.money td { vertical-align: top; }
|
||||
.platform { text-transform: capitalize; }
|
||||
.platform-bluesky { border-color: #1185fe; }
|
||||
.platform-mastodon { border-color: #6364ff; }
|
||||
.platform-telegram { border-color: #229ed9; }
|
||||
.platform-youtube { border-color: #ff0000; }
|
||||
.post-text { white-space: pre-line; }
|
||||
.social.unverified { color: var(--muted); }
|
||||
.say-vote { margin-top: 0.2rem; }
|
||||
.identifier { margin-right: 1rem; }
|
||||
.explore .card-link { display: block; }
|
||||
@@ -0,0 +1,115 @@
|
||||
// Type-specific details under a claim's summary. To support a new claim type (or show more of an existing
|
||||
// one), add a renderer to DETAILS - see docs/contributing/frontend.md.
|
||||
import {Fragment, type ReactNode} from 'react';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import type {Claim, ClaimType} from '@/lib/api';
|
||||
import {formatDate, formatMoney} from '@/lib/format';
|
||||
|
||||
type Ctx = {locale: string; t: (key: string, values?: Record<string, string | number>) => string};
|
||||
type Renderer = (claim: Claim, ctx: Ctx) => ReactNode;
|
||||
|
||||
export function OrgLink({slug, name}: {slug: string | null | undefined; name: string | null | undefined}) {
|
||||
if (!name) return null;
|
||||
return slug ? <Link href={`/organisationen/${slug}`}>{name}</Link> : <>{name}</>;
|
||||
}
|
||||
|
||||
function str(value: unknown): string | null {
|
||||
return value === null || value === undefined || value === '' ? null : String(value);
|
||||
}
|
||||
|
||||
const money: Renderer = (claim, {locale, t}) => {
|
||||
const m = claim.money;
|
||||
if (!m) return null;
|
||||
const amount = m.amount !== null && m.amount !== undefined ? formatMoney(m.amount, locale) : m.amount_category;
|
||||
return (
|
||||
<p className="claim-detail money-line">
|
||||
{amount && <strong>{amount}</strong>}
|
||||
{(m.payer_name || m.payee_name) && (
|
||||
<> · {m.payer_name ?? '?'} → {m.payee_name ?? '?'}</>
|
||||
)}
|
||||
{m.paid_on ? <> · {formatDate(m.paid_on, locale)}</> : m.period ? <> · {m.period}</> : null}
|
||||
{m.category && <> · <span className="muted">{m.category}</span></>}
|
||||
{m.reference && <> · <span className="muted small">{t('reference')} {m.reference}</span></>}
|
||||
</p>
|
||||
);
|
||||
};
|
||||
|
||||
const counterpart: Renderer = (claim, {t}) => {
|
||||
if (!claim.counterpart_name && !claim.counterpart_person_name) return null;
|
||||
return (
|
||||
<p className="claim-detail">
|
||||
{t('with')}{' '}
|
||||
{claim.counterpart_person_slug ? (
|
||||
<Link href={`/personen/${claim.counterpart_person_slug}`}>{claim.counterpart_person_name}</Link>
|
||||
) : (
|
||||
<OrgLink slug={claim.counterpart_slug} name={claim.counterpart_name} />
|
||||
)}
|
||||
</p>
|
||||
);
|
||||
};
|
||||
|
||||
const social: Renderer = (claim) => {
|
||||
const platform = str(claim.data.platform) ?? claim.platform;
|
||||
if (!platform) return null;
|
||||
const metrics = ['likes', 'reposts', 'favourites', 'reblogs', 'views']
|
||||
.map((key) => (claim.data[key] !== null && claim.data[key] !== undefined ? `${claim.data[key]} ${key}` : null))
|
||||
.filter(Boolean);
|
||||
return (
|
||||
<p className="claim-detail small">
|
||||
<span className={`chip platform platform-${platform}`}>{platform}</span>
|
||||
{metrics.length > 0 && <span className="muted"> {metrics.join(' · ')}</span>}
|
||||
</p>
|
||||
);
|
||||
};
|
||||
|
||||
const wikiEdit: Renderer = (claim, {t}) => (
|
||||
<p className="claim-detail small">
|
||||
{t('article')}: <strong>{str(claim.data.title)}</strong> ({str(claim.data.wiki)})
|
||||
{claim.data.sizediff !== undefined && <> · {Number(claim.data.sizediff) > 0 ? '+' : ''}{str(claim.data.sizediff)} Bytes</>}
|
||||
{str(claim.data.comment) && <> · <em>{str(claim.data.comment)}</em></>}
|
||||
</p>
|
||||
);
|
||||
|
||||
const governmentDecision: Renderer = (claim, {t}) => (
|
||||
<p className="claim-detail small muted">
|
||||
{str(claim.data.office)} · {t('fileNumber')} {str(claim.data.zahl)}
|
||||
</p>
|
||||
);
|
||||
|
||||
const partyFinance: Renderer = (claim, {locale, t}) => {
|
||||
const rows = Object.entries(claim.data).filter(([key, value]) => key !== 'year' && !Number.isNaN(Number(value)));
|
||||
if (!rows.length) return null;
|
||||
return (
|
||||
<details className="claim-detail">
|
||||
<summary>{t('financeDetails', {year: str(claim.data.year) ?? ''})}</summary>
|
||||
<table className="compact-table">
|
||||
<tbody>
|
||||
{rows.map(([key, value]) => (
|
||||
<tr key={key}><td>{key}</td><td className="num">{formatMoney(Number(value), locale)}</td></tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</details>
|
||||
);
|
||||
};
|
||||
|
||||
const DETAILS: Partial<Record<ClaimType, Renderer[]>> = {
|
||||
donation: [money],
|
||||
money_flow: [money],
|
||||
party_finance: [partyFinance, money],
|
||||
side_job: [counterpart, money],
|
||||
career: [counterpart],
|
||||
meeting: [counterpart],
|
||||
lobbying: [counterpart],
|
||||
ownership: [counterpart],
|
||||
affiliation: [counterpart],
|
||||
travel: [counterpart],
|
||||
statement: [social],
|
||||
wiki_edit: [wikiEdit],
|
||||
government_decision: [governmentDecision]
|
||||
};
|
||||
|
||||
export function ClaimDetails({claim, ctx}: {claim: Claim; ctx: Ctx}) {
|
||||
const renderers = DETAILS[claim.claim_type] ?? [];
|
||||
return <>{renderers.map((render, i) => <Fragment key={i}>{render(claim, ctx)}</Fragment>)}</>;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import {getLocale, getTranslations} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import type {Claim} from '@/lib/api';
|
||||
import {formatDate, localized} from '@/lib/format';
|
||||
import {ClaimDetails, OrgLink} from './ClaimDetails';
|
||||
|
||||
/**
|
||||
* Legal matters: the presumption of innocence applies to every stage except an
|
||||
* undisputed final conviction (§7b MedienG). Acquittals, dropped proceedings and
|
||||
* diversions also keep the notice - they confirm there is no finding of guilt.
|
||||
*/
|
||||
export function needsInnocenceNotice(claim: Claim): boolean {
|
||||
if (claim.claim_type !== 'legal_proceeding' && !claim.sensitive) return false;
|
||||
return !(claim.legal_stage === 'convicted_final' && claim.status !== 'disputed');
|
||||
}
|
||||
|
||||
export async function ClaimList({claims, showSubject = true}: {claims: Claim[]; showSubject?: boolean}) {
|
||||
const t = await getTranslations('Claims');
|
||||
const td = await getTranslations('ClaimDetails');
|
||||
const locale = await getLocale();
|
||||
if (!claims.length) return <p className="muted">{t('none')}</p>;
|
||||
const ctx = {locale, t: (key: string, values?: Record<string, string | number>) => td(key as 'with', values)};
|
||||
|
||||
return (
|
||||
<ul className="claims">
|
||||
{claims.map((claim) => {
|
||||
const summary = locale === 'en' && claim.summary_en ? claim.summary_en : claim.summary_de;
|
||||
const when = claim.occurred_at ?? claim.valid_from;
|
||||
return (
|
||||
<li key={claim.id} className={`claim claim-${claim.status}${claim.claim_type === 'legal_proceeding' ? ' claim-legal' : ''}`}>
|
||||
<div className="claim-head">
|
||||
<span className={`tag tag-${claim.claim_type}`}>{t(`type.${claim.claim_type}` as 'type.other')}</span>
|
||||
{when && <time>{formatDate(when, locale)}</time>}
|
||||
{showSubject && claim.person_slug && (
|
||||
<Link href={`/personen/${claim.person_slug}`}>{claim.person_name}</Link>
|
||||
)}
|
||||
{showSubject && !claim.person_slug && claim.organization_slug && (
|
||||
<OrgLink slug={claim.organization_slug} name={claim.organization_short ?? claim.organization_name} />
|
||||
)}
|
||||
<span
|
||||
className={`status status-${claim.status}`}
|
||||
title={claim.status === 'corroborated' ? t('corroboratedBy', {count: claim.source_count}) : undefined}
|
||||
>
|
||||
{t(`status.${claim.status}`)}
|
||||
{claim.status === 'corroborated' && ` (${claim.source_count})`}
|
||||
</span>
|
||||
</div>
|
||||
{claim.legal_stage && (
|
||||
<p className="legal-stage">
|
||||
<strong>{t(`legalStage.${claim.legal_stage}`)}</strong>
|
||||
{claim.legal_offense && <> · {claim.legal_offense}</>}
|
||||
{claim.legal_authority && <> · {claim.legal_authority}</>}
|
||||
</p>
|
||||
)}
|
||||
<p className="claim-summary">{summary}</p>
|
||||
<ClaimDetails claim={claim} ctx={ctx} />
|
||||
{needsInnocenceNotice(claim) && <p className="notice innocence">{t('innocence')}</p>}
|
||||
{claim.review_status === 'pending' && <p className="notice">{t('pending')}</p>}
|
||||
{claim.topics && claim.topics.length > 0 && (
|
||||
<div className="topics">
|
||||
{claim.topics.map((topic) => (
|
||||
<span key={topic.slug} className="chip">{localized(topic, locale)}</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<details className="evidence">
|
||||
<summary>{t('sources', {count: claim.evidence.length})}</summary>
|
||||
<ol>
|
||||
{claim.evidence.map((ev, i) => (
|
||||
<li key={`${ev.url}-${i}`}>
|
||||
<span className={`source source-${ev.source_kind}`}>{ev.source_name ?? ev.source}</span>{' '}
|
||||
<a href={ev.url} target="_blank" rel="noopener noreferrer nofollow">
|
||||
{ev.title || ev.url}
|
||||
</a>
|
||||
{ev.published_at && <> · {formatDate(ev.published_at, locale)}</>}
|
||||
{ev.stance !== 'supports' && <> · <em>{t(ev.stance)}</em></>}
|
||||
{ev.archive_url && <> · <a href={ev.archive_url} target="_blank" rel="noopener noreferrer">archive</a></>}
|
||||
{ev.quote && ev.quote !== ev.title && <blockquote>{ev.quote}</blockquote>}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</details>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
'use client';
|
||||
|
||||
import {useLocale, useTranslations} from 'next-intl';
|
||||
import {useSearchParams} from 'next/navigation';
|
||||
import {Link, usePathname} from '@/i18n/navigation';
|
||||
|
||||
export function LocaleSwitcher() {
|
||||
const t = useTranslations('Nav');
|
||||
const locale = useLocale();
|
||||
const pathname = usePathname();
|
||||
const search = useSearchParams().toString();
|
||||
const target = locale === 'de' ? 'en' : 'de';
|
||||
return (
|
||||
<Link href={search ? `${pathname}?${search}` : pathname} locale={target} hrefLang={target}>
|
||||
{t('language')}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import {getLocale, getTranslations} from 'next-intl/server';
|
||||
import type {MoneyFlow} from '@/lib/api';
|
||||
import {formatDate, formatMoney} from '@/lib/format';
|
||||
import {OrgLink} from './ClaimDetails';
|
||||
|
||||
/** Money flows from official registers: who paid whom, how much, when - each row with its sources. */
|
||||
export async function MoneyTable({flows}: {flows: MoneyFlow[]}) {
|
||||
const t = await getTranslations('Money');
|
||||
const locale = await getLocale();
|
||||
if (!flows.length) return <p className="muted">{t('none')}</p>;
|
||||
return (
|
||||
<table className="money">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t('date')}</th><th>{t('kindLabel')}</th><th>{t('payer')}</th><th>{t('payee')}</th>
|
||||
<th className="num">{t('amount')}</th><th>{t('sources')}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{flows.map((flow) => (
|
||||
<tr key={flow.id}>
|
||||
<td className="nowrap">{flow.paid_on ? formatDate(flow.paid_on, locale) : flow.period ?? formatDate(flow.occurred_at, locale)}</td>
|
||||
<td><span className={`tag tag-money-${flow.kind}`}>{t(`kind.${flow.kind}` as 'kind.other')}</span></td>
|
||||
<td><OrgLink slug={flow.payer_slug} name={flow.payer_name} /></td>
|
||||
<td><OrgLink slug={flow.payee_slug} name={flow.payee_name} /></td>
|
||||
<td className="num nowrap">
|
||||
{flow.amount !== null && flow.amount !== undefined ? formatMoney(flow.amount, locale) : flow.amount_category}
|
||||
</td>
|
||||
<td className="small">
|
||||
{flow.evidence.map((ev, i) => (
|
||||
<a key={`${ev.url}-${i}`} href={ev.url} className="cite" target="_blank" rel="noopener noreferrer">
|
||||
[{ev.source}]
|
||||
</a>
|
||||
))}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import {getLocale, getTranslations} from 'next-intl/server';
|
||||
import {getPathname} from '@/i18n/navigation';
|
||||
|
||||
export async function SearchForm({defaultValue = '', since, until, withDates = false}: {
|
||||
defaultValue?: string;
|
||||
since?: string;
|
||||
until?: string;
|
||||
withDates?: boolean;
|
||||
}) {
|
||||
const t = await getTranslations('Search');
|
||||
const locale = await getLocale();
|
||||
return (
|
||||
<form className="search" action={getPathname({href: '/suche', locale})} method="get" role="search">
|
||||
<input type="search" name="q" defaultValue={defaultValue} placeholder={t('placeholder')} minLength={2} required={!withDates} />
|
||||
{withDates && (
|
||||
<>
|
||||
<label className="small">
|
||||
{t('from')} <input type="date" name="since" defaultValue={since} />
|
||||
</label>
|
||||
<label className="small">
|
||||
{t('to')} <input type="date" name="until" defaultValue={until} />
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
<button type="submit">{t('submit')}</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
'use client';
|
||||
|
||||
import {useLocale, useTranslations} from 'next-intl';
|
||||
import {useState} from 'react';
|
||||
import {useRouter} from '@/i18n/navigation';
|
||||
import type {Source, Topic} from '@/lib/api';
|
||||
import {localized} from '@/lib/format';
|
||||
import {DEFAULT_PREFS, PREFS_COOKIE, serializePrefs, type Prefs} from '@/lib/prefs';
|
||||
|
||||
export function SettingsForm({sources, topics, initial}: {sources: Source[]; topics: Topic[]; initial: Prefs}) {
|
||||
const t = useTranslations('Settings');
|
||||
const locale = useLocale();
|
||||
const router = useRouter();
|
||||
const [prefs, setPrefs] = useState<Prefs>(initial);
|
||||
const [saved, setSaved] = useState(false);
|
||||
|
||||
const kinds = [...new Set(sources.map((s) => s.kind))];
|
||||
|
||||
function toggle(list: string[], value: string): string[] {
|
||||
return list.includes(value) ? list.filter((v) => v !== value) : [...list, value];
|
||||
}
|
||||
|
||||
function save(next: Prefs) {
|
||||
document.cookie = `${PREFS_COOKIE}=${serializePrefs(next)}; path=/; max-age=31536000; samesite=lax`;
|
||||
setPrefs(next);
|
||||
setSaved(true);
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
return (
|
||||
<form
|
||||
className="settings"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
save(prefs);
|
||||
}}
|
||||
>
|
||||
<fieldset>
|
||||
<legend>{t('sources')}</legend>
|
||||
{kinds.map((kind) => (
|
||||
<div key={kind} className="source-group">
|
||||
<h3>{t(`kind.${kind}` as 'kind.official')}</h3>
|
||||
{sources.filter((s) => s.kind === kind).map((source) => (
|
||||
<label key={source.slug} className="check" title={source.tos_notes ?? undefined}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={!prefs.excludedSources.includes(source.slug)}
|
||||
onChange={() => {
|
||||
setSaved(false);
|
||||
setPrefs({...prefs, excludedSources: toggle(prefs.excludedSources, source.slug)});
|
||||
}}
|
||||
/>{' '}
|
||||
{source.name} <span className="muted small">({source.default_trust})</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
<label>
|
||||
{t('minTrust')}: {prefs.minTrust}{' '}
|
||||
<input
|
||||
type="range" min={0} max={100} step={5} value={prefs.minTrust}
|
||||
onChange={(e) => {
|
||||
setSaved(false);
|
||||
setPrefs({...prefs, minTrust: Number(e.target.value)});
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>{t('topics')}</legend>
|
||||
<p className="muted small">{t('topicsHint')}</p>
|
||||
<div className="topic-grid">
|
||||
{topics.map((topic) => (
|
||||
<label key={topic.slug} className="check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={prefs.topics.includes(topic.slug)}
|
||||
onChange={() => {
|
||||
setSaved(false);
|
||||
setPrefs({...prefs, topics: toggle(prefs.topics, topic.slug)});
|
||||
}}
|
||||
/>{' '}
|
||||
{localized(topic, locale)}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit">{t('save')}</button>{' '}
|
||||
<button type="button" className="secondary" onClick={() => save(DEFAULT_PREFS)}>{t('reset')}</button>{' '}
|
||||
{saved && <span role="status">{t('saved')}</span>}
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import {getLocale, getTranslations} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import type {SocialPost} from '@/lib/api';
|
||||
import {formatDate} from '@/lib/format';
|
||||
|
||||
/** Public posts (Bluesky, Mastodon, Telegram channels, YouTube, X via API) with a link to the original. */
|
||||
export async function SocialFeed({posts, showAuthor = true}: {posts: SocialPost[]; showAuthor?: boolean}) {
|
||||
const t = await getTranslations('Social');
|
||||
const locale = await getLocale();
|
||||
if (!posts.length) return <p className="muted">{t('none')}</p>;
|
||||
return (
|
||||
<ul className="claims social-feed">
|
||||
{posts.map((post) => (
|
||||
<li key={post.id} className="claim">
|
||||
<div className="claim-head">
|
||||
<span className={`chip platform platform-${post.platform}`}>{post.platform}</span>
|
||||
{post.said_at && <time>{formatDate(post.said_at, locale)}</time>}
|
||||
{showAuthor && post.person_slug && <Link href={`/personen/${post.person_slug}`}>{post.person_name}</Link>}
|
||||
{showAuthor && !post.person_slug && post.org_slug && (
|
||||
<Link href={`/organisationen/${post.org_slug}`}>{post.org_name}</Link>
|
||||
)}
|
||||
{post.data.account_verified === false && <span className="muted small" title={t('unverifiedHint')}>{t('unverified')}</span>}
|
||||
</div>
|
||||
{post.title && <p><strong>{post.title}</strong></p>}
|
||||
{post.excerpt && <p className="claim-summary post-text">{post.excerpt}</p>}
|
||||
<p className="small">
|
||||
<a href={post.url} target="_blank" rel="noopener noreferrer nofollow">{t('original')}</a>
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import {getTranslations} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import type {TimelineBucket} from '@/lib/api';
|
||||
|
||||
/** Bar chart of claims per month; each bar links to that month (search-in-time). */
|
||||
export async function Timeline({buckets, basePath, query}: {buckets: TimelineBucket[]; basePath: string; query: Record<string, string>}) {
|
||||
const t = await getTranslations('Timeline');
|
||||
const months = new Map<string, number>();
|
||||
for (const b of buckets) months.set(b.month, (months.get(b.month) ?? 0) + b.count);
|
||||
if (!months.size) return null;
|
||||
|
||||
// Fill gaps so the axis is continuous.
|
||||
const keys = [...months.keys()].sort();
|
||||
const all: string[] = [];
|
||||
let [y, m] = keys[0].split('-').map(Number);
|
||||
const [ly, lm] = keys[keys.length - 1].split('-').map(Number);
|
||||
while (y < ly || (y === ly && m <= lm)) {
|
||||
all.push(`${y}-${String(m).padStart(2, '0')}`);
|
||||
m += 1;
|
||||
if (m > 12) {
|
||||
m = 1;
|
||||
y += 1;
|
||||
}
|
||||
}
|
||||
const visible = all.slice(-120);
|
||||
const max = Math.max(...visible.map((k) => months.get(k) ?? 0), 1);
|
||||
|
||||
return (
|
||||
<figure className="timeline">
|
||||
<figcaption className="small muted">{t('histogram')} – {t('hint')}</figcaption>
|
||||
<div className="timeline-bars">
|
||||
{visible.map((month) => {
|
||||
const count = months.get(month) ?? 0;
|
||||
const [yy, mm] = month.split('-').map(Number);
|
||||
const last = new Date(Date.UTC(yy, mm, 0)).getUTCDate();
|
||||
return (
|
||||
<Link
|
||||
key={month}
|
||||
href={{pathname: basePath, query: {...query, since: `${month}-01`, until: `${month}-${last}`}}}
|
||||
className="timeline-bar"
|
||||
title={`${month}: ${count}`}
|
||||
>
|
||||
<span style={{height: `${Math.max((count / max) * 100, count ? 4 : 0)}%`}} />
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="timeline-axis small muted">
|
||||
<span>{visible[0]}</span>
|
||||
<span>{visible[visible.length - 1]}</span>
|
||||
</div>
|
||||
</figure>
|
||||
);
|
||||
}
|
||||
|
||||
export async function DateRangeForm({since, until, hidden}: {since?: string; until?: string; hidden: Record<string, string>}) {
|
||||
const t = await getTranslations('Timeline');
|
||||
return (
|
||||
<form className="filters" method="get">
|
||||
{Object.entries(hidden).map(([k, v]) => (
|
||||
<input key={k} type="hidden" name={k} value={v} />
|
||||
))}
|
||||
<label>
|
||||
{t('from')} <input type="date" name="since" defaultValue={since} />
|
||||
</label>
|
||||
<label>
|
||||
{t('to')} <input type="date" name="until" defaultValue={until} />
|
||||
</label>
|
||||
<button type="submit">{t('apply')}</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import {getLocale, getTranslations} from 'next-intl/server';
|
||||
import {Link} from '@/i18n/navigation';
|
||||
import type {VoteRow} from '@/lib/api';
|
||||
import {formatDate} from '@/lib/format';
|
||||
|
||||
export async function VoteTable({votes}: {votes: VoteRow[]}) {
|
||||
const t = await getTranslations('Votes');
|
||||
const locale = await getLocale();
|
||||
return (
|
||||
<table className="votes">
|
||||
<tbody>
|
||||
{votes.map((vote) => {
|
||||
const personal = 'position' in vote ? vote : null;
|
||||
const positions = 'positions' in vote ? vote.positions : null;
|
||||
return (
|
||||
<tr key={`${vote.id}-${personal ? `${personal.individual ? 'i' : 'f'}-${personal.position}` : 'v'}`}>
|
||||
<td className="nowrap">{formatDate(vote.voted_on, locale)}</td>
|
||||
<td>
|
||||
<Link href={`/abstimmungen/${vote.id}`}>{vote.item_title}</Link>
|
||||
<div className="muted small">
|
||||
{vote.chamber}
|
||||
{vote.item_ref && <> · {vote.item_ref}</>}
|
||||
{vote.stage && <> · {vote.stage}</>}
|
||||
{vote.roll_call && <> · <strong>{t('rollCall')}</strong></>}
|
||||
{vote.url && (
|
||||
<> · <a href={vote.url} target="_blank" rel="noopener noreferrer">{t('item')}</a></>
|
||||
)}
|
||||
{vote.protocol_url && (
|
||||
<> · <a href={vote.protocol_url} target="_blank" rel="noopener noreferrer">{t('protocol')}</a></>
|
||||
)}
|
||||
</div>
|
||||
{personal?.spoke && (
|
||||
<div className="small say-vote">
|
||||
{t('spoke')}:{' '}
|
||||
<a href={personal.spoke.url} target="_blank" rel="noopener noreferrer">{personal.spoke.title ?? t('speech')}</a>
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{personal && (
|
||||
<span className={`pos pos-${personal.position}`}>
|
||||
{t(personal.position as 'for')}
|
||||
<span className="muted small">
|
||||
{' '}({personal.individual ? t('ownVote') : `${t('factionVote')} ${personal.faction ?? ''}`})
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
{personal?.dissent && <span className="dissent">{t('dissent')}</span>}
|
||||
{positions && positions.length > 0 && (
|
||||
<div className="positions">
|
||||
{positions.map((p) => (
|
||||
<span key={p.slug} className={`pos pos-${p.position}`} title={t(p.position as 'for')}>
|
||||
{p.party}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{positions && positions.length === 0 && !vote.roll_call && (
|
||||
<span className="muted small">{t('splitVote')}</span>
|
||||
)}
|
||||
</td>
|
||||
<td className={`result result-${vote.result}`}>
|
||||
{vote.result && vote.result !== 'unknown' && t(vote.result as 'accepted')}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import {createNavigation} from 'next-intl/navigation';
|
||||
import {routing} from './routing';
|
||||
|
||||
export const {Link, redirect, usePathname, useRouter, getPathname} = createNavigation(routing);
|
||||
@@ -0,0 +1,12 @@
|
||||
import {hasLocale} from 'next-intl';
|
||||
import {getRequestConfig} from 'next-intl/server';
|
||||
import {routing} from './routing';
|
||||
|
||||
export default getRequestConfig(async ({requestLocale}) => {
|
||||
const requested = await requestLocale;
|
||||
const locale = hasLocale(routing.locales, requested) ? requested : routing.defaultLocale;
|
||||
return {
|
||||
locale,
|
||||
messages: (await import(`../../messages/${locale}.json`)).default
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
import {defineRouting} from 'next-intl/routing';
|
||||
|
||||
// German is the default and lives at "/", English at "/en".
|
||||
export const routing = defineRouting({
|
||||
locales: ['de', 'en'],
|
||||
defaultLocale: 'de',
|
||||
localePrefix: 'as-needed'
|
||||
});
|
||||
@@ -0,0 +1,523 @@
|
||||
// Generated by `politrack openapi --ts` from the FastAPI schema. Do not edit by hand.
|
||||
|
||||
|
||||
export type CalendarData = {
|
||||
events: CalendarEvent[];
|
||||
days: DayCount[];
|
||||
};
|
||||
|
||||
export type CalendarEvent = {
|
||||
id: number;
|
||||
kind: string;
|
||||
title: string;
|
||||
starts_at: string | null;
|
||||
ends_at: string | null;
|
||||
location_name: string | null;
|
||||
country: string | null;
|
||||
url: string | null;
|
||||
description: string | null;
|
||||
body: string | null;
|
||||
participants: Participant[];
|
||||
};
|
||||
|
||||
export type Claim = {
|
||||
id: number;
|
||||
claim_type: 'role' | 'vote' | 'donation' | 'money_flow' | 'statement' | 'appearance' | 'meeting' | 'travel' | 'side_job' | 'legal_proceeding' | 'lobbying' | 'media_mention' | 'career' | 'parliamentary_question' | 'government_decision' | 'wiki_edit' | 'declaration' | 'ownership' | 'affiliation' | 'party_finance' | 'other';
|
||||
summary_de: string;
|
||||
summary_en: string | null;
|
||||
occurred_at: string | null;
|
||||
valid_from: string | null;
|
||||
valid_to: string | null;
|
||||
status: 'reported' | 'corroborated' | 'disputed' | 'retracted';
|
||||
sensitive: boolean;
|
||||
review_status: 'pending' | 'published' | 'rejected';
|
||||
data: Record<string, unknown>;
|
||||
person_slug: string | null;
|
||||
person_name: string | null;
|
||||
organization_slug: string | null;
|
||||
organization_short: string | null;
|
||||
organization_name: string | null;
|
||||
counterpart_slug: string | null;
|
||||
counterpart_name: string | null;
|
||||
counterpart_kind: string | null;
|
||||
counterpart_person_slug: string | null;
|
||||
counterpart_person_name: string | null;
|
||||
legal_stage: string | null;
|
||||
legal_offense: string | null;
|
||||
legal_authority: string | null;
|
||||
money: MoneyFacet | null;
|
||||
platform: string | null;
|
||||
topics: Topic[] | null;
|
||||
evidence: Evidence[];
|
||||
source_count: number;
|
||||
};
|
||||
|
||||
export type CountByPosition = {
|
||||
position: string;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export type Counterparty = {
|
||||
slug: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
money_kind: string;
|
||||
direction: 'paid_to' | 'received_from';
|
||||
total: number | null;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export type DayCount = {
|
||||
day: string;
|
||||
claim_type: string;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export type Dissenter = {
|
||||
slug: string;
|
||||
full_name: string;
|
||||
dissenting_votes: number;
|
||||
};
|
||||
|
||||
export type Evidence = {
|
||||
url: string;
|
||||
title: string | null;
|
||||
source: string;
|
||||
source_name: string | null;
|
||||
source_kind: string | null;
|
||||
published_at: string | null;
|
||||
quote: string | null;
|
||||
stance: 'supports' | 'contradicts' | 'mentions';
|
||||
archive_url: string | null;
|
||||
};
|
||||
|
||||
export type Finance = {
|
||||
data: Record<string, unknown>;
|
||||
valid_from: string | null;
|
||||
};
|
||||
|
||||
export type FormerMember = {
|
||||
slug: string;
|
||||
full_name: string;
|
||||
last_office_end: string | null;
|
||||
last_mention: string | null;
|
||||
};
|
||||
|
||||
export type FormerPerson = {
|
||||
slug: string;
|
||||
full_name: string;
|
||||
photo_url: string | null;
|
||||
status: 'active' | 'former' | 'party_member' | 'deceased';
|
||||
last_office_end: string | null;
|
||||
last_role: string | null;
|
||||
latest_news: string | null;
|
||||
latest_news_at: string | null;
|
||||
latest_news_url: string | null;
|
||||
latest_career: string | null;
|
||||
};
|
||||
|
||||
export type IndividualVote = {
|
||||
slug: string;
|
||||
full_name: string;
|
||||
position: string;
|
||||
faction: string | null;
|
||||
dissent: boolean;
|
||||
};
|
||||
|
||||
export type MoneyByYear = {
|
||||
year: number;
|
||||
kind: string;
|
||||
total: number | null;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export type MoneyFacet = {
|
||||
kind: string;
|
||||
amount: number | null;
|
||||
amount_category: string | null;
|
||||
currency: string | null;
|
||||
paid_on: string | null;
|
||||
period: string | null;
|
||||
reference: string | null;
|
||||
category: string | null;
|
||||
payer_name: string | null;
|
||||
payee_name: string | null;
|
||||
};
|
||||
|
||||
export type MoneyFlow = {
|
||||
id: number;
|
||||
summary_de: string;
|
||||
summary_en: string | null;
|
||||
occurred_at: string | null;
|
||||
status: string;
|
||||
data: Record<string, unknown>;
|
||||
kind: string;
|
||||
amount: number | null;
|
||||
amount_category: string | null;
|
||||
currency: string | null;
|
||||
paid_on: string | null;
|
||||
period: string | null;
|
||||
reference: string | null;
|
||||
category: string | null;
|
||||
payer_name: string | null;
|
||||
payee_name: string | null;
|
||||
payer_slug: string | null;
|
||||
payer_kind: string | null;
|
||||
payee_slug: string | null;
|
||||
payee_kind: string | null;
|
||||
evidence: Evidence[];
|
||||
source_count: number;
|
||||
};
|
||||
|
||||
export type MoneySummaryRow = {
|
||||
kind: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
org_kind: string;
|
||||
side: 'payer' | 'payee';
|
||||
total: number | null;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export type Network = {
|
||||
organizations: NetworkOrg[];
|
||||
};
|
||||
|
||||
export type NetworkOrg = {
|
||||
id: number;
|
||||
slug: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
via: string[];
|
||||
label: string | null;
|
||||
money: Record<string, unknown> | null;
|
||||
};
|
||||
|
||||
export type OrgMoney = {
|
||||
kind: string;
|
||||
direction: 'paid' | 'received';
|
||||
total: number | null;
|
||||
count: number;
|
||||
first: string | null;
|
||||
last: string | null;
|
||||
};
|
||||
|
||||
export type OrgPerson = {
|
||||
slug: string;
|
||||
full_name: string;
|
||||
via: string;
|
||||
summary_de: string;
|
||||
};
|
||||
|
||||
export type OrganizationDetail = {
|
||||
slug: string;
|
||||
name: string;
|
||||
short_name: string | null;
|
||||
kind: string;
|
||||
parent_slug: string | null;
|
||||
parent_name: string | null;
|
||||
identifiers: Record<string, string> | null;
|
||||
money: OrgMoney[];
|
||||
counterparties: Counterparty[];
|
||||
people: OrgPerson[];
|
||||
};
|
||||
|
||||
export type OrganizationListItem = {
|
||||
slug: string;
|
||||
name: string;
|
||||
short_name: string | null;
|
||||
kind: string;
|
||||
paid: number | null;
|
||||
received: number | null;
|
||||
};
|
||||
|
||||
export type Participant = {
|
||||
slug: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type Party = {
|
||||
slug: string;
|
||||
name: string;
|
||||
short_name: string | null;
|
||||
color: string | null;
|
||||
logo_url: string | null;
|
||||
active_officials: number;
|
||||
total_people: number;
|
||||
};
|
||||
|
||||
export type PartyDetail = {
|
||||
slug: string;
|
||||
name: string;
|
||||
short_name: string | null;
|
||||
color: string | null;
|
||||
logo_url: string | null;
|
||||
kind: string;
|
||||
members: PartyMember[];
|
||||
former_members: FormerMember[];
|
||||
money_by_year: MoneyByYear[];
|
||||
finance: Finance[];
|
||||
vote_stats: CountByPosition[];
|
||||
dissent: Dissenter[];
|
||||
related: RelatedOrg[];
|
||||
};
|
||||
|
||||
export type PartyMember = {
|
||||
slug: string;
|
||||
full_name: string;
|
||||
photo_url: string | null;
|
||||
role: string;
|
||||
level: string;
|
||||
region: string | null;
|
||||
body: string | null;
|
||||
};
|
||||
|
||||
export type PartyPosition = {
|
||||
party: string | null;
|
||||
slug: string;
|
||||
color: string | null;
|
||||
position: string;
|
||||
};
|
||||
|
||||
export type PartyRef = {
|
||||
slug: string;
|
||||
short_name: string | null;
|
||||
color: string | null;
|
||||
};
|
||||
|
||||
export type PersonDetail = {
|
||||
slug: string;
|
||||
full_name: string;
|
||||
given_name: string | null;
|
||||
family_name: string | null;
|
||||
birth_date: string | null;
|
||||
death_date: string | null;
|
||||
photo_url: string | null;
|
||||
wikidata_qid: string | null;
|
||||
parlament_pad: string | null;
|
||||
ep_id: string | null;
|
||||
status: 'active' | 'former' | 'party_member' | 'deceased';
|
||||
status_verified: boolean;
|
||||
last_office_end: string | null;
|
||||
roles: Role[];
|
||||
social_accounts: SocialAccountOut[];
|
||||
claim_counts: Record<string, number>;
|
||||
};
|
||||
|
||||
export type PersonListItem = {
|
||||
slug: string;
|
||||
full_name: string;
|
||||
photo_url: string | null;
|
||||
status: 'active' | 'former' | 'party_member' | 'deceased';
|
||||
status_verified: boolean;
|
||||
last_office_end: string | null;
|
||||
current_roles: string[] | null;
|
||||
parties: PartyRef[] | null;
|
||||
};
|
||||
|
||||
export type PersonVote = {
|
||||
id: number;
|
||||
item_title: string;
|
||||
item_ref: string | null;
|
||||
stage: string | null;
|
||||
voted_on: string | null;
|
||||
result: string | null;
|
||||
url: string | null;
|
||||
protocol_url: string | null;
|
||||
roll_call: boolean;
|
||||
position: string;
|
||||
faction: string | null;
|
||||
chamber: string;
|
||||
individual: boolean;
|
||||
dissent: boolean;
|
||||
spoke: Speech | null;
|
||||
topics: string[] | null;
|
||||
};
|
||||
|
||||
export type RelatedOrg = {
|
||||
claim_type: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
};
|
||||
|
||||
export type Role = {
|
||||
role: string;
|
||||
level: string;
|
||||
region: string | null;
|
||||
start_date: string | null;
|
||||
end_date: string | null;
|
||||
body: string | null;
|
||||
body_slug: string | null;
|
||||
party_slug: string | null;
|
||||
party_short: string | null;
|
||||
party_color: string | null;
|
||||
claim_status: string;
|
||||
evidence: RoleEvidence[] | null;
|
||||
};
|
||||
|
||||
export type RoleEvidence = {
|
||||
url: string;
|
||||
source: string;
|
||||
};
|
||||
|
||||
export type SearchEvidence = {
|
||||
url: string;
|
||||
title: string | null;
|
||||
source: string;
|
||||
};
|
||||
|
||||
export type SearchHit = {
|
||||
id: number;
|
||||
text: string;
|
||||
claim_id: number | null;
|
||||
document_id: number | null;
|
||||
summary_de: string | null;
|
||||
claim_type: string | null;
|
||||
occurred_at: string | null;
|
||||
person_slug: string | null;
|
||||
person_name: string | null;
|
||||
organization_slug: string | null;
|
||||
document_url: string | null;
|
||||
document_title: string | null;
|
||||
document_date: string | null;
|
||||
evidence: SearchEvidence[] | null;
|
||||
score: number;
|
||||
};
|
||||
|
||||
export type SocialAccountOut = {
|
||||
platform: string;
|
||||
handle: string | null;
|
||||
url: string;
|
||||
verified: boolean;
|
||||
};
|
||||
|
||||
export type SocialPost = {
|
||||
id: number;
|
||||
platform: string | null;
|
||||
said_at: string | null;
|
||||
excerpt: string | null;
|
||||
url: string;
|
||||
title: string | null;
|
||||
data: Record<string, unknown>;
|
||||
person_slug: string | null;
|
||||
person_name: string | null;
|
||||
org_slug: string | null;
|
||||
org_name: string | null;
|
||||
evidence: Evidence[];
|
||||
};
|
||||
|
||||
export type Source = {
|
||||
slug: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
homepage: string | null;
|
||||
license: string | null;
|
||||
access_method: string;
|
||||
default_trust: number;
|
||||
tos_notes: string | null;
|
||||
documents: number;
|
||||
};
|
||||
|
||||
export type Speech = {
|
||||
url: string;
|
||||
title: string | null;
|
||||
};
|
||||
|
||||
export type Stats = {
|
||||
persons: number;
|
||||
active_persons: number;
|
||||
parties: number;
|
||||
claims: number;
|
||||
corroborated: number;
|
||||
pending_review: number;
|
||||
documents: number;
|
||||
vote_events: number;
|
||||
roll_call_votes: number;
|
||||
events: number;
|
||||
money_flows: number;
|
||||
last_update: string | null;
|
||||
};
|
||||
|
||||
export type TimelineBucket = {
|
||||
month: string;
|
||||
claim_type: string;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export type Topic = {
|
||||
slug: string;
|
||||
name_de: string;
|
||||
name_en: string;
|
||||
};
|
||||
|
||||
export type VoteDetail = {
|
||||
id: number;
|
||||
item_title: string;
|
||||
item_ref: string | null;
|
||||
stage: string | null;
|
||||
voted_on: string | null;
|
||||
result: string | null;
|
||||
url: string | null;
|
||||
protocol_url: string | null;
|
||||
roll_call: boolean;
|
||||
raw_text: string | null;
|
||||
chamber: string;
|
||||
positions: PartyPosition[];
|
||||
individual: IndividualVote[];
|
||||
};
|
||||
|
||||
export type VoteItem = {
|
||||
id: number;
|
||||
item_title: string;
|
||||
item_ref: string | null;
|
||||
stage: string | null;
|
||||
voted_on: string | null;
|
||||
result: string | null;
|
||||
url: string | null;
|
||||
protocol_url: string | null;
|
||||
roll_call: boolean;
|
||||
raw_text: string | null;
|
||||
chamber: string;
|
||||
positions: PartyPosition[];
|
||||
individual_votes: number;
|
||||
};
|
||||
|
||||
export type WikiEdit = {
|
||||
id: number;
|
||||
occurred_at: string | null;
|
||||
summary_de: string;
|
||||
summary_en: string | null;
|
||||
data: Record<string, unknown>;
|
||||
org_slug: string;
|
||||
org_name: string;
|
||||
person_slug: string | null;
|
||||
person_name: string | null;
|
||||
url: string | null;
|
||||
};
|
||||
|
||||
|
||||
export type Paths = {
|
||||
'/api/v1/calendar': CalendarData;
|
||||
'/api/v1/claims': Claim[];
|
||||
'/api/v1/former': FormerPerson[];
|
||||
'/api/v1/money': MoneyFlow[];
|
||||
'/api/v1/money/summary': MoneySummaryRow[];
|
||||
'/api/v1/organizations': OrganizationListItem[];
|
||||
'/api/v1/organizations/{slug}': OrganizationDetail;
|
||||
'/api/v1/parties': Party[];
|
||||
'/api/v1/parties/{slug}': PartyDetail;
|
||||
'/api/v1/persons': PersonListItem[];
|
||||
'/api/v1/persons/{slug}': PersonDetail;
|
||||
'/api/v1/persons/{slug}/network': Network;
|
||||
'/api/v1/persons/{slug}/votes': PersonVote[];
|
||||
'/api/v1/search': SearchHit[];
|
||||
'/api/v1/social': SocialPost[];
|
||||
'/api/v1/sources': Source[];
|
||||
'/api/v1/stats': Stats;
|
||||
'/api/v1/timeline': TimelineBucket[];
|
||||
'/api/v1/topics': Topic[];
|
||||
'/api/v1/votes': VoteItem[];
|
||||
'/api/v1/votes/{vote_id}': VoteDetail;
|
||||
'/api/v1/wiki-edits': WikiEdit[];
|
||||
};
|
||||
@@ -0,0 +1,100 @@
|
||||
// Server-side only: reads the preferences cookie and talks to the internal API URL.
|
||||
// Response types are generated from the backend's Pydantic models (src/lib/api-types.ts):
|
||||
// cd backend && politrack openapi --ts ../web/src/lib/api-types.ts
|
||||
import {cookies} from 'next/headers';
|
||||
import type * as T from './api-types';
|
||||
import {PREFS_COOKIE, parsePrefs, type Prefs} from './prefs';
|
||||
|
||||
export type {
|
||||
CalendarData, CalendarEvent, Claim, Counterparty, Evidence, FormerPerson, MoneyFacet, MoneyFlow, MoneySummaryRow,
|
||||
Network, NetworkOrg, OrganizationDetail, OrganizationListItem, Party, PartyDetail, PartyRef, PersonDetail,
|
||||
PersonListItem, PersonVote, Role, SearchHit, SocialPost, Source, Stats, TimelineBucket, Topic, VoteDetail, VoteItem,
|
||||
WikiEdit
|
||||
} from './api-types';
|
||||
|
||||
export type Person = T.PersonDetail;
|
||||
export type ClaimType = T.Claim['claim_type'];
|
||||
export type PersonStatus = T.PersonDetail['status'];
|
||||
export type LegalStage =
|
||||
| 'allegation_reported' | 'investigation' | 'immunity_waiver_requested' | 'immunity_waived' | 'immunity_refused'
|
||||
| 'indicted' | 'trial' | 'convicted_not_final' | 'convicted_final' | 'acquitted' | 'proceedings_dropped' | 'diversion';
|
||||
/** A row of a vote table: either a vote item (party positions) or a person's vote. */
|
||||
export type VoteRow = T.VoteItem | T.PersonVote;
|
||||
|
||||
const API = process.env.API_INTERNAL_URL ?? 'http://localhost:8000';
|
||||
|
||||
export async function getPrefs(): Promise<Prefs> {
|
||||
const store = await cookies();
|
||||
return parsePrefs(store.get(PREFS_COOKIE)?.value);
|
||||
}
|
||||
|
||||
type Params = Record<string, string | number | boolean | string[] | undefined | null>;
|
||||
|
||||
async function get<R>(path: string, params: Params = {}): Promise<R> {
|
||||
const url = new URL(path, API);
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (value === undefined || value === null || value === '') continue;
|
||||
if (Array.isArray(value)) {
|
||||
if (value.length) url.searchParams.set(key, value.join(','));
|
||||
} else {
|
||||
url.searchParams.set(key, String(value));
|
||||
}
|
||||
}
|
||||
const res = await fetch(url, {cache: 'no-store'});
|
||||
if (res.status === 404) throw new NotFoundError(path);
|
||||
if (!res.ok) throw new Error(`API ${res.status} for ${url}`);
|
||||
return res.json() as Promise<R>;
|
||||
}
|
||||
|
||||
export class NotFoundError extends Error {}
|
||||
|
||||
/** Adds the visitor's source filter (and topic filter, if wanted) from the preferences cookie. */
|
||||
async function withPrefs(params: Params, useTopics = true): Promise<Params> {
|
||||
const prefs = await getPrefs();
|
||||
return {
|
||||
...params,
|
||||
exclude_sources: prefs.excludedSources,
|
||||
min_trust: prefs.minTrust || undefined,
|
||||
...(useTopics && !params.topics ? {topics: prefs.topics} : {})
|
||||
};
|
||||
}
|
||||
|
||||
const enc = encodeURIComponent;
|
||||
|
||||
export const api = {
|
||||
stats: () => get<T.Stats>('/api/v1/stats'),
|
||||
sources: () => get<T.Source[]>('/api/v1/sources'),
|
||||
topics: () => get<T.Topic[]>('/api/v1/topics'),
|
||||
|
||||
parties: () => get<T.Party[]>('/api/v1/parties'),
|
||||
party: (slug: string) => get<T.PartyDetail>(`/api/v1/parties/${enc(slug)}`),
|
||||
organizations: (params: Params) => get<T.OrganizationListItem[]>('/api/v1/organizations', params),
|
||||
organization: (slug: string) => get<T.OrganizationDetail>(`/api/v1/organizations/${enc(slug)}`),
|
||||
|
||||
persons: (params: Params) => get<T.PersonListItem[]>('/api/v1/persons', params),
|
||||
person: (slug: string) => get<T.PersonDetail>(`/api/v1/persons/${enc(slug)}`),
|
||||
personNetwork: (slug: string) => get<T.Network>(`/api/v1/persons/${enc(slug)}/network`),
|
||||
personVotes: async (slug: string) => {
|
||||
const prefs = await getPrefs();
|
||||
return get<T.PersonVote[]>(`/api/v1/persons/${enc(slug)}/votes`, {topics: prefs.topics});
|
||||
},
|
||||
former: (params: Params) => get<T.FormerPerson[]>('/api/v1/former', params),
|
||||
|
||||
votes: async (params: Params) => {
|
||||
const prefs = await getPrefs();
|
||||
return get<T.VoteItem[]>('/api/v1/votes', {topics: prefs.topics, ...params});
|
||||
},
|
||||
vote: (id: string) => get<T.VoteDetail>(`/api/v1/votes/${enc(id)}`),
|
||||
|
||||
claims: async (params: Params) => get<T.Claim[]>('/api/v1/claims', await withPrefs(params)),
|
||||
timeline: async (params: Params) => get<T.TimelineBucket[]>('/api/v1/timeline', await withPrefs(params, false)),
|
||||
calendar: async (params: Params) => get<T.CalendarData>('/api/v1/calendar', await withPrefs(params, false)),
|
||||
|
||||
money: async (params: Params) => get<T.MoneyFlow[]>('/api/v1/money', await withPrefs(params, false)),
|
||||
moneySummary: (params: Params) => get<T.MoneySummaryRow[]>('/api/v1/money/summary', params),
|
||||
social: async (params: Params) => get<T.SocialPost[]>('/api/v1/social', await withPrefs(params, false)),
|
||||
wikiEdits: (params: Params) => get<T.WikiEdit[]>('/api/v1/wiki-edits', params),
|
||||
|
||||
search: async (q: string, since?: string, until?: string) =>
|
||||
get<T.SearchHit[]>('/api/v1/search', await withPrefs({q, since, until}, false))
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
export function formatDate(value: string | null | undefined, locale: string): string {
|
||||
if (!value) return '';
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
return date.toLocaleDateString(locale === 'de' ? 'de-AT' : 'en-GB', {year: 'numeric', month: 'short', day: 'numeric'});
|
||||
}
|
||||
|
||||
export function formatMoney(value: string | number, locale: string): string {
|
||||
return Number(value).toLocaleString(locale === 'de' ? 'de-AT' : 'en-GB', {style: 'currency', currency: 'EUR'});
|
||||
}
|
||||
|
||||
export function localized<T extends {name_de: string; name_en: string}>(item: T, locale: string): string {
|
||||
return locale === 'en' ? item.name_en || item.name_de : item.name_de;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// User preferences live in a cookie so server components can apply them.
|
||||
export const PREFS_COOKIE = 'pt_prefs';
|
||||
|
||||
export type Prefs = {
|
||||
excludedSources: string[];
|
||||
topics: string[];
|
||||
minTrust: number;
|
||||
};
|
||||
|
||||
export const DEFAULT_PREFS: Prefs = {excludedSources: [], topics: [], minTrust: 0};
|
||||
|
||||
export function parsePrefs(raw: string | undefined): Prefs {
|
||||
if (!raw) return DEFAULT_PREFS;
|
||||
try {
|
||||
const value = JSON.parse(decodeURIComponent(raw));
|
||||
return {
|
||||
excludedSources: Array.isArray(value.excludedSources) ? value.excludedSources.map(String) : [],
|
||||
topics: Array.isArray(value.topics) ? value.topics.map(String) : [],
|
||||
minTrust: Number.isFinite(value.minTrust) ? Number(value.minTrust) : 0
|
||||
};
|
||||
} catch {
|
||||
return DEFAULT_PREFS;
|
||||
}
|
||||
}
|
||||
|
||||
export function serializePrefs(prefs: Prefs): string {
|
||||
return encodeURIComponent(JSON.stringify(prefs));
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import createMiddleware from 'next-intl/middleware';
|
||||
import {routing} from './i18n/routing';
|
||||
|
||||
export default createMiddleware(routing);
|
||||
|
||||
export const config = {
|
||||
matcher: '/((?!api|_next|_vercel|.*\\..*).*)'
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"plugins": [{"name": "next"}],
|
||||
"paths": {"@/*": ["./src/*"]}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in new issue
Block a user