Compare commits

...

27 Commits

Author SHA1 Message Date
881e16b8d7 be a bit more verbose with text 2025-08-27 18:41:48 +02:00
5174453261 proper quotes 2025-08-27 18:35:18 +02:00
be5b561799 more consistency 2025-08-27 18:33:07 +02:00
943a51ec5e remove unused locales 2025-08-27 17:56:55 +02:00
ac4268c0c7 now even with proper tag closings! 2025-08-27 17:53:26 +02:00
56b717cfab add feedback from Ilona; various other changes 2025-08-27 17:49:51 +02:00
fc74957bb7 cache theme 2025-08-27 17:14:04 +02:00
d88a85233a gender.. 2025-08-26 18:48:21 +02:00
09549aabea hide those with 0 cams in highscore list 2025-08-25 18:29:55 +02:00
Marie Birner
f2423b34a8 [TASK] finalise registration box 2025-08-24 16:51:27 +02:00
d2c4210757 add drafts of texts 2025-08-24 16:46:07 +02:00
Marie Birner
a62ba324f2 [TASK] add registration box 2025-08-24 16:26:06 +02:00
ce3084f5ff try better hyphenation 2025-08-23 18:28:01 +02:00
ca0f9fbd68 more hyphens 2025-08-23 17:29:18 +02:00
2ffed940c0 add /cam page 2025-08-23 17:22:26 +02:00
52efb51a3c only count those who have found at least 1 cam as participant 2025-08-22 08:51:37 +02:00
7cd5107c8a update to new syntax 2025-08-21 15:02:26 +02:00
aab0e0b780 add camera edit and add functionality 2025-08-21 14:58:00 +02:00
a0eddece86 add function to be able to delete names 2025-08-21 12:31:31 +02:00
c74500adfd add missing language 2025-08-21 09:12:43 +02:00
c8d5868c60 incorporate feedback from MS 2025-08-21 08:45:21 +02:00
f7647829bd create a delete-my-data button 2025-08-20 21:04:55 +02:00
ea65f51704 make cookie auto-expire at the end of the festival 2025-08-20 20:56:06 +02:00
965ba4c80b include feedback from MS 2025-08-20 20:48:03 +02:00
de01d2507f text is good enough :-) 2025-08-15 17:41:41 +02:00
2583544779 proper language :-) 2025-08-15 17:32:43 +02:00
ff72f7c9fa add privacy page 2025-08-15 17:30:44 +02:00
17 changed files with 1350 additions and 109 deletions

1
Cargo.lock generated
View File

@@ -2671,6 +2671,7 @@ dependencies = [
"axum-extra",
"chrono",
"maud",
"rand",
"rust-i18n",
"serde",
"sqlx",

View File

@@ -8,6 +8,7 @@ axum = "0.8"
axum-extra = { version = "0.10", features = ["cookie-private", "cookie"] }
chrono = { version = "0.4", features = ["serde"] }
maud = { version = "0.27", features = ["axum"] }
rand = "0.8"
rust-i18n = "3.1"
serde = { version = "1", features = ["derive"] }
sqlx = { version = "0.8", features = ["runtime-tokio-rustls", "sqlite", "macros", "chrono"] }

View File

@@ -14,22 +14,30 @@ artists_easter_egg: ", Marie Birner (Couch)"
project_quote: "Digital Shadows konfrontiert Besucher*innen mit ihrem digitalen Selbst kopiert, vermessen, analysiert. Ein Experiment über Datenmacht, Sichtbarkeit und Kontrolle im digitalen Zeitalter."
project_quote_attribution: "— Digital Shadows Team"
project_description: "Digital Shadows lädt die Teilnehmer*innen ein, Fragen digitaler und physischer Identität, Datensicherheit und Kontrolle zu erleben. In immersiven Zonen, die mit choreografischen Elementen verwoben sind, begegnen Besucher*innen sich selbst gespiegelt, kopiert, vermessen und verlieren sich gleichzeitig in einem System, das mehr über sie weiß, als sie preisgeben wollen. Zwischen Spiel und Analyse, Verbergen und Transparenz entsteht eine Reflexion über Identität im Zeitalter von Gesichtserkennung, Deepfakes und algorithmischer Profilierung. Wie täuscht man eine Kamera? Wie sichtbar möchte ich sein? Wem gehört, was ich hinterlasse, und wer profitiert davon? Dieses Experiment ist ein kollaboratives Unterfangen zwischen Wissenschaft und Kunst, das Macht, Sichtbarkeit und Selbstbestimmung im digitalen Raum greifbar macht. Durch eine Erkundung digitaler Materialität und algorithmischer Intelligenz entfaltet sich eine manchmal absurde, immer unmittelbare Reflexion über unsere Rolle in datengetriebenen Welten, bis wir unserem digitalen Dilemma gegenüberstehen und die Wahl noch immer bei uns liegt."
what_to_do_title: "Was tun mit diesen Informationen?"
visit_booth_title: "Besuche unseren Stand"
visit_booth_description: "Wir freuen uns darauf, dich an unserem Stand in der Post City Linz zu sehen, wo unser Team dir zeigt, was passiert, wenn dein digitaler Schatten allmächtig wird. "
jku_link_title: "Zur JKU Informationsseite"
what_to_do_title: "Unsere Aktivitäten"
find_out_more: "Erfahre mehr"
location_postcity: "Wo: Postcity Linz"
play_game_title: "Spiele unser Spiel"
play_game_title: "Finde die Überwachungskameras"
play_game_description: "Schon mal durch Linz gewandert mit dem Ziel, (versteckte) Kameras zu finden? Nun, wenn du so jemand bist, dann ist unser 'Kameras entdecken'-Spiel ideal für dich! "
game_link_title: "Zur Spiel-Seite"
location_linz: "Wo: überall in Linz"
tour_aef_title: "Anmeldung zu <q>Finde deinen perfekten Partner</q>"
tour_aef_description: "Digital Shadows lädt dich ein, Fragen nach digitaler und physischer Identität, Datensicherheit und Kontrolle hautnah zu erleben. In immersiven Zonen mit choreografischen Elementen begegnen dir Spiegelungen, Kopien und Messungen deiner selbst während du dich zugleich in einem System verlierst, das mehr über dich weiß, als du preisgeben willst.<br /><br/>Zwischen Spiel und Analyse, zwischen Verbergen und Offenlegen entsteht eine eindringliche Reflexion über Identität im Zeitalter von Gesichtserkennung, Deepfakes und algorithmischem Profiling. Wie täuscht man eine Kamera? Wie sichtbar will ich sein? Wem gehören meine digitalen Spuren und wer profitiert davon?<br /><br />Dieses Experiment, eine Zusammenarbeit von Wissenschaft und Kunst, macht Machtverhältnisse, Sichtbarkeit und Selbstbestimmung im digitalen Raum greifbar. In der Auseinandersetzung mit digitaler Materialität und algorithmischer Intelligenz entfaltet sich ein mitunter absurdes, stets unmittelbares Spiegelbild unserer Rolle in datengetriebenen Welten bis wir unserem eigenen digitalen Dilemma gegenüberstehen und die Entscheidung noch immer bei uns liegt."
tour_register: "Jetzt anmelden"
tour_register_title: "Zur Tour anmelden"
more_infos: "Mehr Infos"
new_header: "Laufende Ausstellung &bullet; Performances &bullet; Immersive Theater Tour"
scientific_background: "Wissenschaftlicher Hintergrund zu Digital Shadows"
calendar: "Kalender"
cal_options: "Wähle wie du den Kalender anzeigen willst"
cal_new_tab: "In neuen Tab öffnen"
cal_show_here: "Hier anzeigen <small>(Google Inhalt laden)</small>"
# Game page
game_title: "Wer findet die meisten Kameras?"
game_explanation_todo: "Willkommen zu unserem Überwachungsbewusstseinsspiel! Als Teil unserer Digital Shadows Ausstellung beim Ars Electronica Festival haben wir QR-Codes bei Überwachungskameras in ganz Linz platziert. Deine Mission: Entdecke die Kameras, scanne unsere Codes und finde heraus, wie allgegenwärtig öffentliche Überwachung wirklich ist. Wir sind aber nur Menschen wir haben nur einen kleinen Teil aller Kameras erfasst, die unsere Stadt beobachten. Wer beobachtet wen in unseren öffentlichen Räumen? Die Jagd beginnt jetzt! 🕵️"
save_button: "Speichern"
amount_participants: "In total there are %{amount} participants so far."
amount_participants: "Aktuell gibt es insgesamt %{amount} Teilnehmer:innen (die mindestens 1 Kamera gefunden haben)."
cameras_found: "Du hast %{found}/%{total} Kameras gefunden:"
highscore_title: "Bestenliste"
not_found_title: "ups"
@@ -49,7 +57,86 @@ received_characters: "Erhaltene Zeichen"
see_ranking: "Sieh deine Platzierung"
new_name_title: "Neuer Name!"
new_name_message: "Fühlt es sich viel anders an?"
footer_text: "Footer "
footer_todo: "noch zu vervollständigen"
footer_links: "mit Links"
impressum: "Impressum"
# Privacy Policy
privacy_policy: "Datenschutz"
privacy_policy_title: "Daten<wbr/>schutz<wbr/>erklärung"
data_controller: "Datenverantwortlicher"
data_controller_info: "Johannes Kepler Universität Linz<br>Institut für Netzwerke und Sicherheit<br>Science Park 3, 2. Stock<br>Altenberger Straße 69, 4040 Linz, Austria<br>https://www.ins.jku.at/<br>+43 732 2468-4120<br>office@digidow.eu<br>Umsatzsteuer-Identifikationsnummer (UID) der JKU: ATU57515567"
overview: "Überblick"
privacy_overview: "Diese Datenschutzerklärung erklärt, wie Daten auf dieser Website gesammelt und verarbeitet werden. Diese Website ist Teil der <a href='https://www.jku.at/ars-electronica-2025-panic-yes-no/digital-shadows/' target='_blank'>Digital Shadows Ausstellung vom Ars Electronica Festival 2025</a> - einem künstlerisch-wissenschaftlichen Projekt, das sich mit der Allgegenwart digitaler Überwachung auseinandersetzt.<br><br>Unser interaktives Spiel lädt Sie ein, die versteckten Überwachungskameras in Linz zu entdecken. Während Sie durch die Stadt wandern und QR-Codes an Kameras scannen, sammeln Sie Punkte und werden Teil einer spielerischen Reflexion über öffentliche Überwachung. Das Spiel macht sichtbar, wie alltäglich und unsichtbar Kameras in unserem urbanen Raum geworden sind. Durch das Sammeln und Vergleichen mit anderen Teilnehmer*innen entsteht ein Bewusstsein für die Dichte des Überwachungsnetzes, in dem wir uns täglich bewegen.<br><br>Da dieses Projekt den bewussten Umgang mit persönlichen Daten thematisiert, legen wir besonderen Wert auf Transparenz bezüglich der Datenverarbeitung auf dieser Website."
data_we_collect: "Daten, die wir sammeln"
cookies: "Cookies"
cookies_description: "Wir verwenden nur zwei Cookies auf dieser Website:"
cookie_client_id: "(notwendig): Ein automatisch generierter, für jede Person eindeutiger Identifikator, der benötigt wird, um zu verfolgen, welche Kameras Sie gefunden haben. Dieser Cookie ist für die Spielfunktionalität notwendig."
cookie_lang: "(optional): Speichert Ihre Spracheinstellung, wenn Sie eine Sprache auswählen. Dieser Cookie wird nur gesetzt, wenn Sie aktiv eine Spracheinstellung wählen."
game_data: "Spieldaten"
game_data_description: "Wenn Sie an unserem Überwachungsbewusstseinsspiel teilnehmen, sammeln wir:"
chosen_name: "Standardmäßig wird ein Name zufällig ausgewählt. Wenn Sie optional einen Namen vergeben wird dieser gespeichert. Hinweis: Der Name wird gemeinsam mit der Anzahl der Kameras die Sie gefunden haben öffentlich in der Bestenliste angezeigt."
game_progress: "Spielfortschritt: Welche Kameras Sie entdeckt haben und wann Sie sie gefunden haben"
random_client_id: "Die zufällig generierte <em>client_id</em> (Cookie, siehe oben) um Ihre Spielsitzungen zu verknüpfen"
purpose_legal_basis: "Zweck und Rechtsgrundlage"
game_functionality: "Spielfunktionalität: Wir verarbeiten Ihre Daten, um das Kamera-Entdeckungsspiel zu betreiben und die Bestenliste anzuzeigen (Einwilligung nach Art. 6(1)(a) DSGVO)"
language_preference: "Spracheinstellung: Wir speichern Ihre Sprachwahl basierend auf Ihrer Einwilligung (Art. 6(1)(a) DSGVO), damit Sie nur einmal die Sprache einstellen müssen."
statistical_analysis: "Statistische Auswertung: Am Ende des Festivals werden statistische, nicht-personenbezogene Auswertungen über die Nutzung der Website gespeichert."
data_retention: "Datenspeicherung"
data_retention_description: "Ihre Spieldaten werden in unserer Datenbank bis zum Ende der Ars Electronica Festival Ausstellungszeit gespeichert. Die Cookies verfallen automatisch zum Festivalende oder wenn Sie Ihre Cookies löschen."
data_sharing: "Datenweitergabe"
data_sharing_description: "Wir teilen, verkaufen oder übertragen Ihre Daten nicht an Dritte. Daten werden ausschließlich für den Betrieb des Kamera-Entdeckungsspiels verwendet."
your_rights_gdpr: "Ihre Rechte unter der DSGVO"
rights_description: "Sie haben das Recht auf:"
right_access: "Auskunft: Anfrage, welche Daten wir über Sie haben"
right_rectification: "Berichtigung: Korrektur ungenauer Daten"
right_erasure: "Löschung: Anfrage zur Löschung Ihrer Daten"
right_restriction: "Einschränkung: Beschränkung der Verarbeitung Ihrer Daten"
right_portability: "Datenübertragbarkeit: Erhalt Ihrer Daten in einem strukturierten Format"
how_to_exercise_rights: "Wie Sie Ihre Rechte ausüben können"
clear_cookies: "Browser-Cookies löschen, um gespeicherte Identifikatoren zu entfernen"
contact_us: "Kontaktieren Sie uns an unserem Postcity Linz Stand oder <a href='https://digidow.eu/impressum' target='_blank'>per E-Mail</a>"
# Additional privacy policy sections
server_logfiles: "Serverlogfiles"
server_logfiles_description: "Unser Webserver legt ausschließlich anonymisierte Server-Logfiles an, in denen keine IP-Adressen oder sonstigen personenbezogenen Daten gespeichert werden."
data_security: "Datensicherheit"
data_security_description: "Alle Daten, die zwischen Ihrem Browser und unseren Servern übertragen werden, sind per SSL mit aktuellen Verschlüsselungsstandards gesichert und bieten eine hohe Übertragungssicherheit. Unsere Server werden an der JKU Linz betrieben und regelmäßig gewartet."
minors: "Minderjährige"
minors_description: "Diese Website darf nur von Personen ab 14 Jahren genutzt werden. Nutzer unter 14 Jahren benötigen die ausdrückliche Einverständniserklärung ihrer Erziehungsberechtigten."
data_protection_officer: "Datenschutzbeauftrager"
data_protection_officer_contact_full: "Stabsstelle Datenschutz der Johannes Kepler Universität Linz<br>Altenberger Straße 69, 4040 Linz<br>+43 732 2468 3802<br>datenschutz@jku.at"
data_collection_timing: "Wann werden Daten gesammelt"
data_collection_timing_description: "Daten werden gesammelt, wenn die Website besucht wird und QR Codes gescannt werden."
delete_personal_data: "Persönliche Daten löschen"
delete_data_description: "Sie können die vollständige Löschung aller Ihrer auf unseren Servern gespeicherten persönlichen Daten beantragen. Dies umfasst Ihren gewählten Namen, Spielfortschritt und alle Sichtungen. Diese Aktion kann nicht rückgängig gemacht werden."
delete_my_data: "Meine Daten löschen"
delete_confirmation: "Sind Sie sicher, dass Sie alle Ihre persönlichen Daten löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden und Sie verlieren Ihren gesamten Spielfortschritt."
data_deletion_success_title: "Daten erfolgreich gelöscht"
data_deletion_success_body: "Alle Ihre persönlichen Daten wurden erfolgreich von unseren Servern entfernt. Ihr Sitzungs-Cookie wurde ebenfalls zerstört."
# Camera demonstration page
cam_title: "Gesichts<wbr/>erkennung"
cam_title2: "@ Ars Electronica Festival 2025"
cam_subtitle: "Bildungsdemonstrationen allgegenwärtiger Überwachungstechnologie"
cam_description: "Erleben Sie hautnah, wie Gesichtserkennungssysteme Ihre biometrischen Daten in vernetzten Umgebungen verfolgen und verarbeiten."
cam_project_by: "Ein Forschungs- und Sensibilisierungsprojekt vom "
cam_institute: "Institut für Netzwerke und Sicherheit, Johannes Kepler Universität"
cam_mission_quote: "Das Ziel dieses Projekts ist es, die Öffentlichkeit über allgegenwärtige Gesichtserkennungstechnologien und deren Auswirkungen auf die Privatsphäre zu informieren, indem Festivalbesucher*innen persönlich erfahren können, wie solche Systeme funktionieren und welche Daten verarbeitet werden."
cam_mission_attribution: "Projekt Mission Statement"
cam_project_description: "Dieses zeitlich begrenzte Forschungs- und Sensibilisierungsprojekt konzentriert sich auf die Verarbeitung biometrischer Daten zu Forschungs-, Bewusstseins- und künstlerischen Zwecken und hilft Besucher*innen, die allgegenwärtige Natur der Gesichtserkennung in unserem täglichen Leben zu verstehen."
cam_how_it_works: "Wie es funktioniert"
cam_tech_setup_title: "Technische Ausstattung"
cam_tech_setup_p1: "Das System besteht aus einer Hauptkamera und bis zu 10 kleineren Sensorstationen, die an verschiedenen Festivalstandorten positioniert sind. Diese Kameras erfassen Bilder und nutzen Gesichtserkennung, um Besucher*innen zu identifizieren und zu verfolgen, während sie sich zwischen den Stationen bewegen."
cam_tech_setup_p2: "Das System verarbeitet biometrische Merkmale (gespeichert als \"Embeddings\"), Zeitstempel, Standortdaten und optional benutzerzugewiesene Pseudonyme, um zu demonstrieren, wie moderne Überwachungssysteme funktionieren."
cam_data_processing_title: "Daten<wbr/>verarbeitung"
cam_data_processing_p1: "<strong>Wichtig ist, dass die tatsächlichen Bilder nicht gespeichert werden</strong> - nur die extrahierten biometrischen Daten und zugehörigen Metadaten werden verarbeitet und vorübergehend auf einem sicheren Server an der JKU gespeichert."
cam_festival_details: "Festival-Details"
cam_when_where_title: "Wann & Wo"
cam_festival_info: "Ars Electronica Festival 2025"
cam_festival_dates: "3. bis 7. September 2025"
cam_festival_location: "Verschiedene Standorte im gesamten Festivalgelände"
cam_legal_compliance: "Rechtliche Konformität"
cam_legal_description: "Wir haben bei der österreichischen Datenschutzbehörde die Genehmigung für diesen experimentellen Aufbau beantragt und die Genehmigung wurde am 28. Juli 2025 erteilt."
cam_legal_request: "Genehmigter Antrag"
cam_legal_decision: "Behördenbescheid"
cam_legal_request_title: "Genehmigungsantrag ansehen"
cam_legal_decision_title: "Behördenbescheid ansehen"

View File

@@ -14,22 +14,31 @@ artists_easter_egg: ", Marie Birner (Couch)"
project_quote: "Digital Shadows confronts visitors with their digital self copied, measured, analyzed. An experiment on data power, visibility, and control in the digital age."
project_quote_attribution: "— Digital Shadows Team"
project_description: "Digital Shadows invites the participants to experience questions of digital and physical identity, data security, and control. In immersive zones woven with choreographic elements, visitors encounter themselves mirrored, copied, measured and simultaneously lose themselves in a system that knows more about them than they intend to reveal. Between play and analysis, concealment and transparency, a reflection emerges on identity in the age of facial recognition, deepfakes, and algorithmic profiling. How does one fool a camera? How visible do I want to be? Who owns what I leave behind, and who profits from it? This experiment is a collaborative endeavor between science and art, making power, visibility, and self-determination in digital space tangible. Through an exploration of digital materiality and algorithmic intelligence, a sometimes absurd, always immediate reflection unfolds on our role in data-driven worlds until we face our digital dilemma, and the choice is still ours to make."
what_to_do_title: "What to do with this information?"
visit_booth_title: "Visit our booth"
visit_booth_description: "We will be delighted to see you at our booth in the Post City Linz, where our team will show you, what happens when your Digital Shadow becomes allmighty. "
jku_link_title: "Go to JKU Information Page"
what_to_do_title: "Our Activities"
find_out_more: "Find out more"
location_postcity: "Where: Postcity Linz"
play_game_title: "Play our game"
play_game_description: "Ever wandered through Linz with the aim to find (hidden) cameras? Well, if you are that kind of person than our 'Discover cameras' game will be ideal for you! "
game_link_title: "Go to Game Page"
location_linz: "Where: all over Linz"
tour_aef_title: "Registration for <q>Find Your Perfect Partner</q>"
tour_aef_description: "Digital Shadows invites you to explore pressing questions about digital and physical identity, data security, and control in an immediate and tangible way. In immersive zones with choreographic elements, you encounter reflections, copies, and measurements of yourself—while at the same time losing yourself in a system that knows more about you than you may wish to reveal.
Between play and analysis, between concealment and disclosure, an intense reflection emerges on identity in the age of facial recognition, deepfakes, and algorithmic profiling. How can one deceive a camera? How visible do I want to be? Who owns my digital traces—and who benefits from them?<br /><br />This experiment, a collaboration between science and art, makes power structures, visibility, and self-determination in digital spaces tangible. In engaging with digital materiality and algorithmic intelligence, an at times absurd yet always immediate mirror of our role in data-driven worlds unfolds—until we face our own digital dilemma, with the decision still in our hands"
tour_register: "Register now"
tour_register_title: "Register a slot"
more_infos: "More infos"
new_header: "Ongoing Exhibition &bullet; Performances &bullet; Immersive Tour"
scientific_background: "Scientific background to Digital Shadows"
calendar: "Calendar"
cal_options: "Choose how you'd like to access the calendar"
cal_new_tab: "Open in New Tab"
cal_show_here: "Show here <small>(load Google content)</small>"
# Game page
game_title: "Who finds the most cameras?"
game_explanation_todo: "Welcome to our public surveillance awareness game! As part of our Digital Shadows exhibition at Ars Electronica Festival, we've placed QR codes near surveillance cameras throughout Linz. Your mission: spot the cameras, scan our codes, and discover how pervasive public monitoring really is. We're only human though we've mapped just a small subset of all the cameras watching our city. Who's watching whom in our public spaces? The hunt begins now! 🕵️"
save_button: "Save"
amount_participants: "Aktuell gibt es insgesamt %{amount} Teilnehmer."
amount_participants: "In total there are %{amount} participants so far (with at least 1 camera)."
cameras_found: "You have found %{found}/%{total} cameras:"
highscore_title: "Highscore"
not_found_title: "uups"
@@ -49,7 +58,86 @@ received_characters: "Received characters"
see_ranking: "See your ranking"
new_name_title: "New name!"
new_name_message: "Does it feel much different?"
footer_text: "Footer "
footer_todo: "to be completed"
footer_links: "with links"
impressum: "Impressum"
# Privacy Policy
privacy_policy: "Privacy Policy"
privacy_policy_title: "Privacy Policy"
data_controller: "Data controller"
data_controller_info: "Johannes Kepler Universität Linz<br>Institut für Netzwerke und Sicherheit<br>Science Park 3, 2nd Floor<br>Altenberger Straße 69, 4040 Linz, Austria<br>https://www.ins.jku.at/<br>+43 732 2468-4120<br>office@digidow.eu<br>VAT identification number (UID) of JKU: ATU57515567"
overview: "Overview"
privacy_overview: "This privacy policy explains how we collect and process data on this website, which is part of the <a href='https://www.jku.at/ars-electronica-2025-panic-yes-no/digital-shadows/' target='_blank'>Digital Shadows exhibition of the Ars Electronica Festival 2025</a>."
data_we_collect: "Data we collect"
cookies: "Cookies"
cookies_description: "We use only two cookies on this website:"
cookie_client_id: "(essential): An automatically generated unique identifier that allows us to tracks which cameras you've found. This cookie is necessary for the game functionality."
cookie_lang: "(optional): Stores your language preference when you select a language. This cookie is only set if you actively choose a language setting."
game_data: "Game data"
game_data_description: "When you participate in our surveillance awareness game, we collect:"
chosen_name: "Your chosen name (optional): The display name you enter to display in the highscore list"
game_progress: "Game progress: Which cameras you've discovered and when you found them"
random_client_id: "The randomly generated <em>client_id</em> to link your game sessions"
purpose_legal_basis: "Purpose and legal basis"
game_functionality: "Game functionality: We process your data to operate the camera discovery game (legitimate interest under Art. 6(1)(f) GDPR)"
language_preference: "Language preference: We store your language choice based on your consent (Art. 6(1)(a) GDPR)"
statistical_analysis: "Statistical analysis: At the end of the festival, statistical, non-personal analyses of website usage will be stored."
data_retention: "Data retention"
data_retention_description: "Your game data is stored in our database until the end of the Ars Electronica Festival exhibition period. The cookies expire automatically after the festival or when you clear your cookies. There is no long-term storage of any data."
data_sharing: "Data sharing"
data_sharing_description: "We do not share, sell, or transfer your data to third parties. Data is used exclusively for operating the camera discovery game."
your_rights_gdpr: "Your rights under GDPR"
rights_description: "You have the right to:"
right_access: "Access: Request what data we have about you"
right_rectification: "Rectification: Correct inaccurate data"
right_erasure: "Erasure: Request deletion of your data"
right_restriction: "Restriction: Limit how we process your data"
right_portability: "Data portability: Receive your data in a structured format"
how_to_exercise_rights: "How to exercise your rights"
clear_cookies: "Clear browser cookies to remove stored identifiers"
contact_us: "Contact us at our Postcity Linz booth or <a href='https://digidow.eu/impressum' target='_blank'>via mail</a>"
# Additional privacy policy sections
server_logfiles: "Server logfiles"
server_logfiles_description: "Our web server creates only anonymized server log files, in which no IP addresses or other personal data are stored."
data_security: "Data security"
data_security_description: "All data transmitted between your browser and our servers is secured by SSL with current encryption standards and provides high transmission security. Our servers are operated at JKU Linz and regularly maintained."
minors: "Minors"
minors_description: "This website may only be used by persons aged 14 and over. Users under 14 require the express consent of their parents or guardians."
data_protection_officer: "Data Protection Officer"
data_protection_officer_contact_full: "Data Protection Office of Johannes Kepler University Linz<br>Altenberger Straße 69, 4040 Linz<br>+43 732 2468 3802<br>datenschutz@jku.at"
data_collection_timing: "When data is collected"
data_collection_timing_description: "Data is collected when the website is visited and QR codes are scanned."
delete_personal_data: "Delete Personal Data"
delete_data_description: "You can request the complete deletion of all your personal data stored on our servers. This includes your chosen name, game progress, and all sightings. This action cannot be undone."
delete_my_data: "Delete My Data"
delete_confirmation: "Are you sure you want to delete all your personal data? This action cannot be undone and you will lose all your game progress."
data_deletion_success_title: "Data Successfully Deleted"
data_deletion_success_body: "All your personal data has been successfully removed from our servers. Your session cookie has also been destroyed."
# Camera demonstration page
cam_title: "Face recognition"
cam_title2: "@ Ars Electronica Festival 2025"
cam_subtitle: "Educational Demonstration of Omnipresent Surveillance Technology"
cam_description: "Experience firsthand how facial recognition systems track and process your biometric data across interconnected environments."
cam_project_by: "A research and sensitization project by the "
cam_institute: "Institute for Networks and Security, Johannes Kepler University"
cam_mission_quote: "The goal of this project is to educate the public about omnipresent facial recognition technologies and their impact on privacy by allowing festival-goers to personally experience how such systems function and what data is processed."
cam_mission_attribution: "Project Mission Statement"
cam_project_description: "This time-limited research and sensitization project focuses on biometric data processing for research, awareness, and artistic purposes, helping visitors understand the pervasive nature of facial recognition in our daily lives."
cam_how_it_works: "How It Works"
cam_tech_setup_title: "Technology Setup"
cam_tech_setup_p1: "The system consists of a main camera and up to 10 smaller sensor-stations positioned at different festival locations. These cameras capture images and use facial recognition to identify and track visitors as they move between stations."
cam_tech_setup_p2: "The system processes biometric features (stored as \"Embeddings\"), timestamps, location data, and optionally, user-assigned pseudonyms to demonstrate how modern surveillance systems function."
cam_data_processing_title: "Data Processing"
cam_data_processing_p1: "<strong>Importantly, the actual images are not stored</strong> - only the extracted biometric data and associated metadata are processed and temporarily stored on a secure server at JKU."
cam_festival_details: "Festival Details"
cam_when_where_title: "When & Where"
cam_festival_info: "Ars Electronica Festival 2025"
cam_festival_dates: "September 3rd to 7th, 2025"
cam_festival_location: "Various locations throughout the festival grounds"
cam_legal_compliance: "Legal Compliance"
cam_legal_description: "We requested approval for this experimental setup from the Austrian Data Protection Authority and the request was approved on July 28, 2025."
cam_legal_request: "Approved Request (Antrag)"
cam_legal_decision: "Authority Decision (Bescheid)"
cam_legal_request_title: "View approval request"
cam_legal_decision_title: "View authority decision"

View File

@@ -24,3 +24,8 @@ CREATE TABLE sightings (
-- Create indexes for better performance on foreign key lookups
CREATE INDEX idx_sightings_client_uuid ON sightings(client_uuid);
CREATE INDEX idx_sightings_camera_id ON sightings(camera_id);
CREATE TABLE banned_names (
name TEXT PRIMARY KEY NOT NULL,
banned_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);

433
src/admin.rs Normal file
View File

@@ -0,0 +1,433 @@
use crate::{language::language, page::Page, AppState};
use axum::{
extract::{Path, Query, State},
http::HeaderMap,
response::{IntoResponse, Redirect, Response},
routing::{get, post},
Form, Router,
};
use axum_extra::extract::{
cookie::{Cookie, Expiration},
CookieJar, PrivateCookieJar,
};
use maud::{html, Markup};
use serde::Deserialize;
use std::collections::HashMap;
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(Deserialize)]
struct LoginForm {
password: String,
}
#[derive(Deserialize)]
struct CameraForm {
uuid: String,
name: String,
desc: Option<String>,
}
#[derive(Deserialize)]
struct DeleteCameraForm {
uuid: String,
}
#[derive(Deserialize)]
struct EditCameraForm {
name: String,
desc: Option<String>,
}
async fn login_page(cookies: CookieJar, headers: HeaderMap) -> Markup {
let lang = language(&cookies, &headers);
rust_i18n::set_locale(lang.to_locale());
Page::new(lang).content(html! {
h1 { "Admin Login" }
form method="POST" action="/admin/login" {
fieldset {
label for="password" { "Password:" }
input
type="password"
name="password"
id="password"
required;
input type="submit" value="Login";
}
}
})
}
async fn login(
State(state): State<AppState>,
private_cookies: PrivateCookieJar,
Form(form): Form<LoginForm>,
) -> Response {
if form.password == state.admin_password {
// Set secure admin session cookie
let expiration_date = OffsetDateTime::now_utc() + time::Duration::days(30);
let mut cookie = Cookie::new("admin_session", "authenticated");
cookie.set_expires(Expiration::DateTime(expiration_date));
cookie.set_http_only(true);
cookie.set_secure(true);
cookie.set_path("/");
let updated_cookies = private_cookies.add(cookie);
(updated_cookies, Redirect::to("/protected")).into_response()
} else {
// Invalid password, redirect back to login
Redirect::to("/admin/login").into_response()
}
}
async fn logout(private_cookies: PrivateCookieJar) -> Response {
// Remove admin session cookie
let expired_cookie = Cookie::build(("admin_session", ""))
.expires(Expiration::DateTime(
OffsetDateTime::now_utc() - time::Duration::days(1),
))
.http_only(true)
.secure(true)
.path("/")
.build();
let updated_cookies = private_cookies.add(expired_cookie);
(updated_cookies, Redirect::to("/")).into_response()
}
async fn protected_page(
private_cookies: PrivateCookieJar,
cookies: CookieJar,
headers: HeaderMap,
) -> Response {
// Check if admin is authenticated
if private_cookies.get("admin_session").is_none() {
return Redirect::to("/admin/login").into_response();
}
let lang = language(&cookies, &headers);
rust_i18n::set_locale(lang.to_locale());
let markup = Page::new(lang).content(html! {
h1 { "Protected Admin Area" }
p { "Welcome to the admin area! This is a protected route." }
p { "Only authenticated administrators can access this page." }
h2 { "Camera Management" }
p { "Manage cameras in the system." }
a href="/admin/cameras/add" { "Add Camera" }
" | "
a href="/admin/cameras" { "Manage Cameras" }
form method="POST" action="/admin/logout" {
input type="submit" value="Logout" class="secondary";
}
});
markup.into_response()
}
async fn add_camera_page(
private_cookies: PrivateCookieJar,
cookies: CookieJar,
headers: HeaderMap,
Query(params): Query<HashMap<String, String>>,
) -> Response {
// Check if admin is authenticated
if private_cookies.get("admin_session").is_none() {
return Redirect::to("/admin/login").into_response();
}
let lang = language(&cookies, &headers);
rust_i18n::set_locale(lang.to_locale());
// Get pre-filled UUID from query params
let prefilled_uuid = params.get("uuid").unwrap_or(&String::new()).clone();
let markup = Page::new(lang).content(html! {
h1 { "Add Camera" }
@if !prefilled_uuid.is_empty() {
p.text-muted { "Auto-detected missing camera with UUID: " strong { (prefilled_uuid) } }
}
form method="POST" action="/admin/cameras/add" {
fieldset {
label for="uuid" { "Camera UUID:" }
input
type="text"
name="uuid"
id="uuid"
placeholder="e.g., 123e4567-e89b-12d3-a456-426614174000"
value=(prefilled_uuid)
required;
label for="name" { "Camera Name:" }
input
type="text"
name="name"
id="name"
placeholder="e.g., Front Entrance Camera"
required;
label for="desc" { "Description (optional):" }
textarea
name="desc"
id="desc"
placeholder="e.g., Camera monitoring the main entrance" {};
input type="submit" value="Add Camera";
}
}
p {
a href="/protected" { "← Back to Admin Dashboard" }
}
});
markup.into_response()
}
async fn manage_cameras_page(
State(state): State<AppState>,
private_cookies: PrivateCookieJar,
cookies: CookieJar,
headers: HeaderMap,
) -> Response {
// Check if admin is authenticated
if private_cookies.get("admin_session").is_none() {
return Redirect::to("/admin/login").into_response();
}
let lang = language(&cookies, &headers);
rust_i18n::set_locale(lang.to_locale());
let cameras = state.backend.get_all_cameras().await;
let markup = Page::new(lang).content(html! {
h1 { "Manage Cameras" }
p { "Total cameras: " strong { (cameras.len()) } }
@if cameras.is_empty() {
p.text-muted { "No cameras found in the system." }
} @else {
table {
thead {
tr {
th { "UUID" }
th { "Name" }
th { "Description" }
th { "Actions" }
}
}
tbody {
@for camera in &cameras {
tr {
td {
code { (camera.uuid) }
}
td { (camera.name) }
td {
@if let Some(desc) = &camera.desc {
(desc)
} @else {
em.text-muted { "No description" }
}
}
td {
a href=(format!("/admin/cameras/{}/edit", camera.uuid)) class="secondary" style="margin-right: 0.5rem;" { "Edit" }
form method="POST" action="/admin/cameras/delete" style="display: inline;" {
input type="hidden" name="uuid" value=(camera.uuid);
input
type="submit"
value="Delete"
class="secondary"
onclick="return confirm('Are you sure you want to delete this camera? This will also remove all associated sightings.')";
}
}
}
}
}
}
}
p {
a href="/admin/cameras/add" { "Add New Camera" }
" | "
a href="/protected" { "← Back to Admin Dashboard" }
}
});
markup.into_response()
}
async fn add_camera(
State(state): State<AppState>,
private_cookies: PrivateCookieJar,
Form(form): Form<CameraForm>,
) -> Response {
// Check if admin is authenticated
if private_cookies.get("admin_session").is_none() {
return Redirect::to("/admin/login").into_response();
}
// Parse UUID
let uuid = match Uuid::parse_str(&form.uuid) {
Ok(uuid) => uuid,
Err(_) => return Redirect::to("/admin/cameras/add?error=invalid_uuid").into_response(),
};
// Check if camera already exists
if state.backend.get_camera(&uuid).await.is_some() {
return Redirect::to("/admin/cameras/add?error=already_exists").into_response();
}
// Create the camera
let desc = if form
.desc
.as_ref()
.map(|s| s.trim().is_empty())
.unwrap_or(true)
{
None
} else {
form.desc.as_deref()
};
match state.backend.create_camera(&uuid, &form.name, desc).await {
Ok(_) => Redirect::to("/admin/cameras?camera_added=1").into_response(),
Err(_) => Redirect::to("/admin/cameras/add?error=creation_failed").into_response(),
}
}
async fn edit_camera_page(
State(state): State<AppState>,
private_cookies: PrivateCookieJar,
cookies: CookieJar,
headers: HeaderMap,
Path(uuid_str): Path<String>,
) -> Response {
// Check if admin is authenticated
if private_cookies.get("admin_session").is_none() {
return Redirect::to("/admin/login").into_response();
}
let lang = language(&cookies, &headers);
rust_i18n::set_locale(lang.to_locale());
// Parse UUID
let uuid = match Uuid::parse_str(&uuid_str) {
Ok(uuid) => uuid,
Err(_) => return Redirect::to("/admin/cameras?error=invalid_uuid").into_response(),
};
// Get camera details
let Some(camera) = state.backend.get_camera(&uuid).await else {
return Redirect::to("/admin/cameras?error=not_found").into_response();
};
let markup = Page::new(lang).content(html! {
h1 { "Edit Camera" }
p.text-muted { "UUID: " code { (camera.uuid) } }
form method="POST" action=(format!("/admin/cameras/{}/edit", camera.uuid)) {
fieldset {
label for="name" { "Camera Name:" }
input
type="text"
name="name"
id="name"
value=(camera.name)
required;
label for="desc" { "Description (optional):" }
textarea
name="desc"
id="desc"
placeholder="e.g., Camera monitoring the main entrance" {
@if let Some(desc) = &camera.desc {
(desc)
}
}
input type="submit" value="Update Camera";
}
}
p {
a href="/admin/cameras" { "← Back to Camera List" }
}
});
markup.into_response()
}
async fn update_camera(
State(state): State<AppState>,
private_cookies: PrivateCookieJar,
Path(uuid_str): Path<String>,
Form(form): Form<EditCameraForm>,
) -> Response {
// Check if admin is authenticated
if private_cookies.get("admin_session").is_none() {
return Redirect::to("/admin/login").into_response();
}
// Parse UUID
let uuid = match Uuid::parse_str(&uuid_str) {
Ok(uuid) => uuid,
Err(_) => return Redirect::to("/admin/cameras?error=invalid_uuid").into_response(),
};
// Process description
let desc = if form
.desc
.as_ref()
.map(|s| s.trim().is_empty())
.unwrap_or(true)
{
None
} else {
form.desc.as_deref()
};
match state.backend.update_camera(&uuid, &form.name, desc).await {
Ok(true) => Redirect::to("/admin/cameras?camera_updated=1").into_response(),
Ok(false) => Redirect::to("/admin/cameras?error=not_found").into_response(),
Err(_) => Redirect::to("/admin/cameras?error=update_failed").into_response(),
}
}
async fn delete_camera(
State(state): State<AppState>,
private_cookies: PrivateCookieJar,
Form(form): Form<DeleteCameraForm>,
) -> Response {
// Check if admin is authenticated
if private_cookies.get("admin_session").is_none() {
return Redirect::to("/admin/login").into_response();
}
// Parse UUID
let uuid = match Uuid::parse_str(&form.uuid) {
Ok(uuid) => uuid,
Err(_) => return Redirect::to("/admin/cameras?error=invalid_uuid").into_response(),
};
match state.backend.delete_camera(&uuid).await {
Ok(true) => Redirect::to("/admin/cameras?camera_deleted=1").into_response(),
Ok(false) => Redirect::to("/admin/cameras?error=not_found").into_response(),
Err(_) => Redirect::to("/admin/cameras?error=deletion_failed").into_response(),
}
}
pub fn routes() -> Router<AppState> {
Router::new()
.route("/admin/login", get(login_page))
.route("/admin/login", post(login))
.route("/admin/logout", post(logout))
.route("/protected", get(protected_page))
.route("/admin/cameras", get(manage_cameras_page))
.route("/admin/cameras/add", get(add_camera_page))
.route("/admin/cameras/add", post(add_camera))
.route("/admin/cameras/{uuid}/edit", get(edit_camera_page))
.route("/admin/cameras/{uuid}/edit", post(update_camera))
.route("/admin/cameras/delete", post(delete_camera))
}

View File

@@ -1,7 +1,7 @@
use crate::{
language::language,
page::{MyMessage, Page},
AppState, Backend, NameUpdateError,
AppState, NameUpdateError,
};
use axum::{
extract::{Path, State},
@@ -13,26 +13,29 @@ use axum::{
use axum_extra::extract::{CookieJar, PrivateCookieJar};
use maud::{html, Markup, PreEscaped};
use serde::Deserialize;
use std::sync::Arc;
use uuid::Uuid;
async fn index(
State(backend): State<Arc<Backend>>,
State(state): State<AppState>,
cookies: PrivateCookieJar,
lang_cookies: CookieJar,
headers: HeaderMap,
) -> Response {
retu(backend, cookies, lang_cookies, headers, None).await
retu(state, cookies, lang_cookies, headers, None).await
}
async fn retu(
backend: Arc<Backend>,
state: AppState,
cookies: PrivateCookieJar,
lang_cookies: CookieJar,
headers: HeaderMap,
message: Option<MyMessage>,
) -> Response {
let backend = &state.backend;
let (cookies, req) = backend.client_full(cookies, &lang_cookies, &headers).await;
// Check if user is admin
let is_admin = cookies.get("admin_session").is_some();
let client = req.client;
rust_i18n::set_locale(&req.lang.to_string());
@@ -50,7 +53,7 @@ async fn retu(
h1 { (t!("game_title")) }
}
p {
mark { (t!("game_explanation_todo")) }
(t!("game_explanation_todo"))
}
div.mb-sm { (t!("ask_to_change_name", name = client.get_display_name())) }
@@ -99,6 +102,12 @@ async fn retu(
@if rank.client == client { (PreEscaped("<mark id='ranking'>")) }
(rank.client.get_display_name())
@if rank.client == client { (PreEscaped("</mark>")) }
@if is_admin && rank.client.name.is_some() && rank.client.name.as_ref().unwrap() != "***" {
form method="POST" action="/game/ban-name" style="display: inline; margin-left: 0.5rem;" {
input type="hidden" name="name" value=(rank.client.name.as_ref().unwrap());
input type="submit" value="Block" class="secondary" style="font-size: 0.8rem; padding: 0.25rem 0.5rem;";
}
}
}
span.font-headline.font-lg {
(rank.amount)
@@ -118,12 +127,13 @@ async fn retu(
}
async fn game(
State(backend): State<Arc<Backend>>,
State(state): State<AppState>,
cookies: PrivateCookieJar,
lang_cookies: CookieJar,
headers: HeaderMap,
Path(uuid): Path<String>,
) -> Response {
let backend = &state.backend;
let (cookies, req) = backend.client_full(cookies, &lang_cookies, &headers).await;
let client = req.client;
rust_i18n::set_locale(req.lang.to_locale());
@@ -133,6 +143,12 @@ async fn game(
};
let Some(camera) = backend.get_camera(&uuid).await else {
// Check if user is admin
if cookies.get("admin_session").is_some() {
// Redirect to camera add form with pre-filled UUID
return axum::response::Redirect::to(&format!("/admin/cameras/add?uuid={}", uuid))
.into_response();
}
return not_found(lang_cookies, headers).await.into_response();
};
@@ -146,7 +162,7 @@ async fn game(
)
};
retu(backend, cookies, lang_cookies, headers, Some(message)).await
retu(state, cookies, lang_cookies, headers, Some(message)).await
}
async fn not_found(cookies: CookieJar, headers: HeaderMap) -> Markup {
@@ -161,13 +177,19 @@ struct NameForm {
name: String,
}
#[derive(Deserialize)]
struct BanNameForm {
name: String,
}
async fn set_name(
State(backend): State<Arc<Backend>>,
State(state): State<AppState>,
cookies: PrivateCookieJar,
lang_cookies: CookieJar,
headers: HeaderMap,
Form(form): Form<NameForm>,
) -> Response {
let backend = &state.backend;
let (cookies, req) = backend.client_full(cookies, &lang_cookies, &headers).await;
let client = req.client;
rust_i18n::set_locale(req.lang.to_locale());
@@ -191,12 +213,36 @@ async fn set_name(
),
};
retu(backend, cookies, lang_cookies, headers, Some(message)).await
retu(state, cookies, lang_cookies, headers, Some(message)).await
}
async fn ban_name(
State(state): State<AppState>,
private_cookies: PrivateCookieJar,
_lang_cookies: CookieJar,
_headers: HeaderMap,
Form(form): Form<BanNameForm>,
) -> Response {
// Check if user is admin
if private_cookies.get("admin_session").is_none() {
return axum::response::Redirect::to("/game").into_response();
}
let backend = &state.backend;
// Ban the name
let _ = backend.ban_name(&form.name).await;
// Replace existing instances with asterisks
let _ = backend.replace_banned_names_with_asterisks().await;
axum::response::Redirect::to("/game").into_response()
}
pub(super) fn routes() -> Router<AppState> {
Router::new()
.route("/game", get(index))
.route("/game", post(set_name))
.route("/game/ban-name", post(ban_name))
.route("/{*uuid}", get(game))
}

View File

@@ -1,7 +1,11 @@
use crate::{language::language, page::Page};
use axum::http::HeaderMap;
use crate::{
language::language,
page::{MyMessage, Page},
};
use axum::{extract::Query, http::HeaderMap};
use axum_extra::extract::CookieJar;
use maud::{Markup, PreEscaped, html};
use maud::{html, Markup, PreEscaped};
use serde::Deserialize;
pub(super) async fn index(cookies: CookieJar, headers: HeaderMap) -> Markup {
let lang = language(&cookies, &headers);
@@ -26,29 +30,290 @@ pub(super) async fn index(cookies: CookieJar, headers: HeaderMap) -> Markup {
}
p { (t!("project_description")) }
h2 { (t!("what_to_do_title")) }
div.grid.gap-lg {
div.grid.gap-lg.grid-cols-2 {
article {
header { (t!("visit_booth_title")) }
(t!("visit_booth_description"))
header { (t!("what_to_do_title")) }
div class="text-center" {
(PreEscaped(t!("new_header")))
}
a
href="https://www.jku.at/ars-electronica-2025-panic-yes-no/digital-shadows/"
href="https://ars.electronica.art/panic/de/view/digital-shadows-22a38ddb450c81d08bc4f50a818b0319/"
target="_blank"
title=(t!("jku_link_title")) { (t!("find_out_more")) }
footer { (t!("location_postcity")) }
class="btn mt-1 block"
role="button" {
(t!("more_infos"))
(PreEscaped("&nbsp;↗️"))
}
}
article {
header { (t!("play_game_title")) }
(t!("play_game_description"))
a href="/game" title=(t!("game_link_title")) { (t!("find_out_more")) }
a
href="/game"
class="btn mt-1 block"
title=(t!("game_link_title"))
role="button" { (t!("find_out_more")) }
}
article.col-span-2 {
header { (PreEscaped(t!("tour_aef_title"))) }
footer { (t!("location_linz")) }
(PreEscaped(t!("tour_aef_description")))
a
href="https://reglist24.com/digital-shadows-tour/form"
target="_blank"
class="btn mt-1 block"
role="button"
title=(t!("tour_register_title")) {
(t!("tour_register"))
(PreEscaped("&nbsp;↗️"))
}
}
}
a
href="https://digidow.eu"
target="_blank"
class="btn mt-1 block"
role="button" { (t!("scientific_background"))(PreEscaped("&nbsp;↗️")) }
h2 { (t!("calendar")) }
div #calendar-options .calendar-options {
p { (t!("cal_options")) }
a href="https://calendar.google.com/calendar/embed?height=600&wkst=2&ctz=Europe%2FVienna&showPrint=0&showTz=0&showCalendars=0&showTabs=0&showDate=0&showNav=0&showTitle=0&mode=AGENDA&hl=en&src=YjA4NTZlZDUyZDAwNmY3ZTczNTgxYTk2NjI4MjFjMDZhYWJkZjUzMDBkMjZmMDZiOWFiYzg2YWE3YzBhNzFlNkBncm91cC5jYWxlbmRhci5nb29nbGUuY29t&color=%23d50000"
target="_blank"
rel="noopener noreferrer"
class="calendar-link" {
(t!("cal_new_tab"))
(PreEscaped("&nbsp;↗️"))
}
button #embed-calendar .embed-button {
(PreEscaped(t!("cal_show_here")))
}
}
iframe #google-calendar
data-src="https://calendar.google.com/calendar/embed?height=600&wkst=2&ctz=Europe%2FVienna&showPrint=0&showTz=0&showCalendars=0&showTabs=0&showDate=0&showNav=0&showTitle=0&mode=AGENDA&hl=en&src=YjA4NTZlZDUyZDAwNmY3ZTczNTgxYTk2NjI4MjFjMDZhYWJkZjUzMDBkMjZmMDZiOWFiYzg2YWE3YzBhNzFlNkBncm91cC5jYWxlbmRhci5nb29nbGUuY29t&color=%23d50000"
width="100%"
height="600"
frameborder="0"
scrolling="no"
class="hidden" {}
script {
(PreEscaped(r#"
document.addEventListener('DOMContentLoaded', function() {
const calendarOptions = document.getElementById('calendar-options');
const embedButton = document.getElementById('embed-calendar');
const iframe = document.getElementById('google-calendar');
embedButton.addEventListener('click', function() {
// Hide the options
calendarOptions.classList.add('hidden');
// Load the iframe by setting src from data-src
const src = iframe.getAttribute('data-src');
iframe.setAttribute('src', src);
// Show the iframe
iframe.classList.remove('hidden');
});
});
"#))
}
})
}
pub(super) async fn cam(cookies: CookieJar, headers: HeaderMap) -> Markup {
let lang = language(&cookies, &headers);
rust_i18n::set_locale(lang.to_locale());
let page = Page::new(lang);
page.content(html! {
hgroup {
h1 { (PreEscaped(t!("cam_title"))) }
p { (t!("cam_title2")) }
}
hgroup {
h2 { (t!("cam_subtitle")) }
p { (t!("cam_description")) }
}
p {
(t!("cam_project_by"))
span.highlight { (t!("cam_institute")) }
}
blockquote {
(t!("cam_mission_quote"))
footer {
cite { (t!("cam_mission_attribution")) }
}
}
p { (t!("cam_project_description")) }
h2 { (t!("cam_how_it_works")) }
div.grid.gap-lg {
article {
header { (t!("cam_tech_setup_title")) }
p { (t!("cam_tech_setup_p1")) }
p { (t!("cam_tech_setup_p2")) }
}
article {
header { (PreEscaped(t!("cam_data_processing_title"))) }
p { (PreEscaped(t!("cam_data_processing_p1"))) }
}
}
h2 { (t!("cam_festival_details")) }
div.info-box {
h3 { (t!("cam_when_where_title")) }
p {
(t!("cam_festival_info")) br;
(t!("cam_festival_dates")) br;
(t!("cam_festival_location"))
}
}
h2 { (t!("cam_legal_compliance")) }
p { (t!("cam_legal_description")) }
div.legal-docs {
a href="/static/dsb-request.pdf" target="_blank" title=(t!("cam_legal_request_title")) { (t!("cam_legal_request"))(PreEscaped("&nbsp;↗️"))}
" | "
a href="/static/dsb-accept.pdf" target="_blank" title=(t!("cam_legal_decision_title")) { (t!("cam_legal_decision"))(PreEscaped("&nbsp;↗️")) }
}
})
}
#[derive(Deserialize)]
pub(super) struct PrivacyQuery {
deleted: Option<u8>,
}
pub(super) async fn data(
cookies: CookieJar,
headers: HeaderMap,
Query(query): Query<PrivacyQuery>,
) -> Markup {
let lang = language(&cookies, &headers);
rust_i18n::set_locale(lang.to_locale());
let mut page = Page::new(lang);
// Show success message if data was deleted
if query.deleted == Some(1) {
page.set_message(MyMessage::DataDeleted);
}
page.content(html! {
h1 { (PreEscaped(t!("privacy_policy_title"))) }
h2 { (t!("data_controller")) }
p {
(PreEscaped(t!("data_controller_info")))
}
h2 { (t!("overview")) }
p {
(PreEscaped(t!("privacy_overview")))
}
h2 { (t!("data_we_collect")) }
h3 { (t!("cookies")) }
p {
(t!("cookies_description"))
ol {
li {
kbd { "client_id" }
" "
(t!("cookie_client_id"))
}
li {
kbd { "lang" }
" "
(t!("cookie_lang"))
}
}
}
h3 { (t!("game_data")) }
p {
(t!("game_data_description"))
ul {
li { (t!("chosen_name")) }
li { (t!("game_progress")) }
li {
(PreEscaped(t!("random_client_id")))
}
}
}
h2 { (t!("purpose_legal_basis")) }
ul {
li { (t!("game_functionality")) }
li { (t!("language_preference")) }
li { (t!("statistical_analysis")) }
}
h2 { (t!("data_retention")) }
p {
(t!("data_retention_description"))
}
h2 { (t!("data_sharing")) }
p {
(t!("data_sharing_description"))
}
h2 { (t!("server_logfiles")) }
p {
(t!("server_logfiles_description"))
}
h2 { (t!("data_security")) }
p {
(t!("data_security_description"))
}
h2 { (t!("minors")) }
p {
(t!("minors_description"))
}
h2 { (t!("data_protection_officer")) }
p {
(PreEscaped(t!("data_protection_officer_contact_full")))
}
h2 { (t!("data_collection_timing")) }
p {
(t!("data_collection_timing_description"))
}
h2 { (t!("your_rights_gdpr")) }
p {
(t!("rights_description"))
ul {
li { (t!("right_access")) }
li { (t!("right_rectification")) }
li { (t!("right_erasure")) }
li { (t!("right_restriction")) }
li { (t!("right_portability")) }
}
}
h3 { (t!("how_to_exercise_rights")) }
ul {
li { (t!("clear_cookies")) }
li {
(PreEscaped(t!("contact_us")))
}
}
h3 { (t!("delete_personal_data")) }
p {
(t!("delete_data_description"))
}
form method="POST" action="/delete-data" onsubmit={"return confirm('" (t!("delete_confirmation")) "');"} {
button type="submit" class="secondary" {
(t!("delete_my_data"))
}
}
})

View File

@@ -1,11 +1,16 @@
use crate::model::client::Client;
use axum::{Router, http::HeaderMap, routing::get};
use axum::{
http::HeaderMap,
response::Redirect,
routing::{get, post},
Router,
};
use axum_extra::extract::{
CookieJar, PrivateCookieJar,
cookie::{Cookie, Expiration, Key},
CookieJar, PrivateCookieJar,
};
use serde::{Deserialize, Serialize};
use sqlx::{SqlitePool, pool::PoolOptions, sqlite::SqliteConnectOptions};
use sqlx::{pool::PoolOptions, sqlite::SqliteConnectOptions, SqlitePool};
use std::{
collections::HashSet,
fmt::Display,
@@ -14,9 +19,9 @@ use std::{
str::FromStr,
sync::{Arc, LazyLock},
};
use time::{Duration, OffsetDateTime};
use time::{Date, Month, OffsetDateTime, Time};
use tower_http::services::ServeDir;
use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
use uuid::Uuid;
#[macro_use]
@@ -24,6 +29,7 @@ extern crate rust_i18n;
i18n!("locales", fallback = "en");
mod admin;
mod game;
mod index;
pub(crate) mod language;
@@ -156,7 +162,10 @@ impl Backend {
Some(uuid) => (cookies, self.get_client(&uuid).await),
None => {
let new_id = Uuid::new_v4();
let expiration_date = OffsetDateTime::now_utc() + Duration::days(30);
let expiration_date = OffsetDateTime::new_utc(
Date::from_calendar_date(2025, Month::September, 7).unwrap(),
Time::from_hms(20, 0, 0).unwrap(),
);
let mut cookie = Cookie::new("client_id", new_id.to_string());
cookie.set_expires(Expiration::DateTime(expiration_date));
cookie.set_http_only(true);
@@ -187,7 +196,7 @@ impl Backend {
if name.len() < 3 {
return Err(NameUpdateError::TooShort(3, name.len()));
}
if contains_bad_word(name) {
if contains_bad_word(name) || self.is_name_banned(name).await {
return Err(NameUpdateError::ContainsBadWord);
}
@@ -206,12 +215,72 @@ impl Backend {
Ok(())
}
async fn is_name_banned(&self, name: &str) -> bool {
match self {
Backend::Sqlite(db) => {
let result = sqlx::query!("SELECT name FROM banned_names WHERE name = ?", name)
.fetch_optional(db)
.await
.unwrap();
result.is_some()
}
}
}
async fn ban_name(&self, name: &str) -> Result<(), sqlx::Error> {
match self {
Backend::Sqlite(db) => {
sqlx::query!("INSERT OR IGNORE INTO banned_names (name) VALUES (?)", name)
.execute(db)
.await?;
Ok(())
}
}
}
async fn unban_name(&self, name: &str) -> Result<(), sqlx::Error> {
match self {
Backend::Sqlite(db) => {
sqlx::query!("DELETE FROM banned_names WHERE name = ?", name)
.execute(db)
.await?;
Ok(())
}
}
}
async fn get_banned_names(&self) -> Vec<String> {
match self {
Backend::Sqlite(db) => {
let rows = sqlx::query!("SELECT name FROM banned_names ORDER BY banned_at DESC")
.fetch_all(db)
.await
.unwrap();
rows.into_iter().map(|row| row.name).collect()
}
}
}
async fn replace_banned_names_with_asterisks(&self) -> Result<(), sqlx::Error> {
match self {
Backend::Sqlite(db) => {
sqlx::query!(
"UPDATE client SET name = '***' WHERE name IN (SELECT name FROM banned_names)"
)
.execute(db)
.await?;
Ok(())
}
}
}
}
#[derive(Clone)]
pub struct AppState {
pub(crate) backend: Arc<Backend>,
pub key: Key,
pub admin_password: String,
}
impl axum::extract::FromRef<AppState> for Key {
@@ -229,32 +298,101 @@ impl axum::extract::FromRef<AppState> for Arc<Backend> {
#[derive(Serialize, Deserialize)]
struct Config {
key: Vec<u8>,
admin_password: String,
}
impl Config {
fn generate() -> Self {
use rand::{distributions::Alphanumeric, thread_rng, Rng};
let admin_password: String = thread_rng()
.sample_iter(&Alphanumeric)
.take(15)
.map(char::from)
.collect();
Self {
key: Key::generate().master().to_vec(),
admin_password,
}
}
}
fn load_or_create_key() -> Result<Key, Box<dyn std::error::Error>> {
fn load_or_create_config() -> Result<(Key, Config), Box<dyn std::error::Error>> {
let config_path = "config.toml";
// Try to read existing config
if Path::new(config_path).exists() {
let content = fs::read_to_string(config_path)?;
let config: Config = toml::from_str(&content)?;
return Ok(Key::from(&config.key));
// Try to parse as complete config first
if let Ok(config) = toml::from_str::<Config>(&content) {
let key = Key::from(&config.key);
return Ok((key, config));
}
// Create new config if file doesn't exist
let config = Config::generate();
// If that fails, try to parse just the key and generate new admin password
#[derive(Deserialize)]
struct PartialConfig {
key: Vec<u8>,
}
if let Ok(partial_config) = toml::from_str::<PartialConfig>(&content) {
use rand::{distributions::Alphanumeric, thread_rng, Rng};
let admin_password: String = thread_rng()
.sample_iter(&Alphanumeric)
.take(15)
.map(char::from)
.collect();
let config = Config {
key: partial_config.key,
admin_password,
};
// Write the updated config back
let toml_string = toml::to_string(&config)?;
fs::write(config_path, toml_string)?;
Ok(Key::from(&config.key))
let key = Key::from(&config.key);
return Ok((key, config));
}
}
// Create new config if file doesn't exist or parsing failed
let config = Config::generate();
let toml_string = toml::to_string(&config)?;
fs::write(config_path, toml_string)?;
let key = Key::from(&config.key);
Ok((key, config))
}
async fn delete_personal_data(
axum::extract::State(state): axum::extract::State<AppState>,
cookies: PrivateCookieJar,
) -> (PrivateCookieJar, Redirect) {
let backend = &state.backend;
// Get the client from cookies
if let Some(client_cookie) = cookies.get("client_id") {
if let Ok(uuid) = Uuid::parse_str(client_cookie.value()) {
// Delete all client data from database
let _ = backend.delete_client_data(&uuid).await;
}
}
// Remove the client_id cookie by setting an expired cookie
let expired_cookie = Cookie::build(("client_id", ""))
.expires(Expiration::DateTime(
OffsetDateTime::now_utc() - time::Duration::days(1),
))
.http_only(true)
.secure(true)
.build();
let updated_cookies = cookies.add(expired_cookie);
// Redirect back to privacy page with success message
(updated_cookies, Redirect::to("/privacy?deleted=1"))
}
#[tokio::main]
@@ -270,16 +408,25 @@ async fn main() {
.await
.unwrap();
let key = load_or_create_key().unwrap();
let (key, config) = load_or_create_config().unwrap();
// Print admin password for convenience
tracing::info!("Admin password: {}", config.admin_password);
let state = AppState {
backend: Arc::new(Backend::Sqlite(db)),
key,
admin_password: config.admin_password,
};
let app = Router::new()
.route("/", get(index::index))
.route("/privacy", get(index::data))
.route("/cam", get(index::cam))
.route("/delete-data", post(delete_personal_data))
.nest_service("/static", ServeDir::new("./static/serve"))
.merge(game::routes())
.merge(admin::routes())
.with_state(state);
// run our app with hyper, listening globally on port 3000

View File

@@ -25,6 +25,69 @@ impl Backend {
}
}
pub(crate) async fn create_camera(&self, uuid: &Uuid, name: &str, desc: Option<&str>) -> Result<(), sqlx::Error> {
let uuid_str = uuid.to_string();
match self {
Backend::Sqlite(db) => {
sqlx::query!(
"INSERT INTO camera (uuid, name, desc) VALUES (?, ?, ?)",
uuid_str,
name,
desc
)
.execute(db)
.await?;
Ok(())
}
}
}
pub(crate) async fn update_camera(&self, uuid: &Uuid, name: &str, desc: Option<&str>) -> Result<bool, sqlx::Error> {
let uuid_str = uuid.to_string();
match self {
Backend::Sqlite(db) => {
let result = sqlx::query!(
"UPDATE camera SET name = ?, desc = ? WHERE uuid = ?",
name,
desc,
uuid_str
)
.execute(db)
.await?;
Ok(result.rows_affected() > 0)
}
}
}
pub(crate) async fn delete_camera(&self, uuid: &Uuid) -> Result<bool, sqlx::Error> {
let uuid_str = uuid.to_string();
match self {
Backend::Sqlite(db) => {
let result = sqlx::query!(
"DELETE FROM camera WHERE uuid = ?",
uuid_str
)
.execute(db)
.await?;
Ok(result.rows_affected() > 0)
}
}
}
pub(crate) async fn get_all_cameras(&self) -> Vec<Camera> {
match self {
Backend::Sqlite(db) => {
sqlx::query_as!(
Camera,
"SELECT uuid, desc, name FROM camera ORDER BY name"
)
.fetch_all(db)
.await
.unwrap_or_default()
}
}
}
pub(crate) async fn amount_total_cameras(&self) -> i64 {
match self {
Backend::Sqlite(db) => {

View File

@@ -41,4 +41,28 @@ impl Backend {
}
}
}
pub(crate) async fn delete_client_data(&self, uuid: &Uuid) -> Result<(), sqlx::Error> {
let uuid_str = uuid.to_string();
match self {
Backend::Sqlite(db) => {
// Start a transaction to ensure data consistency
let mut tx = db.begin().await?;
// Delete sightings first (foreign key constraint)
sqlx::query!("DELETE FROM sightings WHERE client_uuid = ?", uuid_str)
.execute(&mut *tx)
.await?;
// Delete client record
sqlx::query!("DELETE FROM client WHERE uuid = ?", uuid_str)
.execute(&mut *tx)
.await?;
tx.commit().await?;
Ok(())
}
}
}
}

View File

@@ -11,7 +11,8 @@ impl Backend {
pub(crate) async fn amount_participants(&self) -> i64 {
match self {
Backend::Sqlite(db) => {
let row = sqlx::query!("SELECT COUNT(*) as count FROM client")
let row =
sqlx::query!("SELECT COUNT(DISTINCT client_uuid) AS count FROM sightings; ")
.fetch_one(db)
.await
.unwrap();
@@ -37,12 +38,10 @@ impl Backend {
)
SELECT rank, name, uuid, amount
FROM ranked_clients
WHERE rank <= (
SELECT rank
FROM ranked_clients
ORDER BY rank
LIMIT 1 OFFSET 9
)
WHERE rank <= COALESCE(
(SELECT rank FROM ranked_clients ORDER BY rank LIMIT 1 OFFSET 9),
(SELECT MAX(rank) FROM ranked_clients)
) AND amount > 0
ORDER BY rank, name"
)
.fetch_all(db)

View File

@@ -1,5 +1,5 @@
use crate::Language;
use maud::{DOCTYPE, Markup, html};
use maud::{html, Markup, DOCTYPE};
pub(crate) struct Page {
lang: Language,
@@ -10,6 +10,7 @@ pub(crate) enum MyMessage {
NameChanged,
FoundCam(String, i64),
Error(String, String, String),
DataDeleted,
}
impl Page {
@@ -97,6 +98,14 @@ impl Page {
}
}
}
MyMessage::DataDeleted => {
div.flex {
article class="succ msg" {
header { (t!("data_deletion_success_title")) }
(t!("data_deletion_success_body"))
}
}
}
}
}
section { (content) }
@@ -104,9 +113,7 @@ impl Page {
footer.container {
small {
(t!("footer_text"))
mark { (t!("footer_todo")) }
a href="#" { (t!("footer_links")) }
a href="/privacy" { (t!("privacy_policy")) }
""
a target="_blank" href="https://www.digidow.eu/impressum/" {
(t!("impressum"))

BIN
static/serve/dsb-accept.pdf Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -19,6 +19,48 @@
--custom-box-shadow: #015886;
}
body {
hyphens: auto;
}
.calendar-options {
border: 2px solid #ccc;
color: white;
padding: 20px;
text-align: center;
background-color: gray;
border-radius: 5px;
margin: 20px 0;
}
.calendar-link {
display: inline-block;
background-color: #4285f4;
color: white;
padding: 12px 24px;
text-decoration: none;
border-radius: 4px;
font-size: 16px;
margin: 10px;
}
.embed-button {
background-color: #34a853;
color: white;
padding: 12px 24px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
margin: 10px;
}
.text-center {
text-align: center;
}
.hidden {
display: none;
}
/** Headline Styles */
h1 {
font-family: 'Rubik Doodle Shadow', sans-serif;
@@ -40,7 +82,8 @@ h2 {
/** Button Styles */
input[type="submit"],
button:not([class="secondary"]) {
button:not([class="secondary"]),
.btn {
transition: box-shadow 0.3s ease;
background: var(--pico-primary-background);
@@ -94,11 +137,19 @@ input[type="submit"]:active {
margin-bottom: 0;
}
.mt-1 {
margin-top: 1rem;
}
.flex {
display: flex;
flex-wrap: wrap;
}
.block {
display: block !important;
}
.msg {
width: 100%;
max-width: 40rem;
@@ -114,6 +165,14 @@ input[type="submit"]:active {
.gap-lg {
grid-gap: 5rem;
}
.grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.col-span-2 {
grid-column: span 2 / span 2;
}
}
/** custom ol style */
@@ -139,21 +198,14 @@ ul.iterated > li {
border-bottom: 2px solid var(--pico-color);
border-radius: 2% 6% 5% 4% / 1% 1% 2% 4%;
position: relative;
}
&::before {
content: '';
border-bottom: 1px solid var(--pico-color);
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0) scale(1.015) rotate(0.5deg);
border-radius: 1% 1% 2% 4% / 2% 6% 5% 4%;
}
ul.iterated > li > * {
position: relative;
z-index: 1; /* Bring content forward */
}
ul.iterated > li.no-border {
border-bottom: 0;
}

View File

@@ -19,35 +19,58 @@ function setLanguageCookie() {
/** [ph] */
function switchTheme() {
let isLight = true;
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches){
isLight = false
}
const html = document.documentElement
const switchTheme = document.getElementById('theme_switcher')
// Define the SVG icons first
const os_default = '<svg viewBox="0 0 16 16"><path fill="currentColor" d="M8 15A7 7 0 1 0 8 1v14zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16z"/></svg>'
const sun = '<svg viewBox="0 0 16 16"><path fill="currentColor" d="M8 11a3 3 0 1 1 0-6a3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8a4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"/></svg>'
const moon = '<svg viewBox="0 0 16 16"><g fill="currentColor"><path d="M6 .278a.768.768 0 0 1 .08.858a7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277c.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316a.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71C0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278zM4.858 1.311A7.269 7.269 0 0 0 1.025 7.71c0 4.02 3.279 7.276 7.319 7.276a7.316 7.316 0 0 0 5.205-2.162c-.337.042-.68.063-1.029.063c-4.61 0-8.343-3.714-8.343-8.29c0-1.167.242-2.278.681-3.286z"/><path d="M10.794 3.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387a1.734 1.734 0 0 0-1.097 1.097l-.387 1.162a.217.217 0 0 1-.412 0l-.387-1.162A1.734 1.734 0 0 0 9.31 6.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387a1.734 1.734 0 0 0 1.097-1.097l.387-1.162zM13.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.156 1.156 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.156 1.156 0 0 0-.732-.732l-.774-.258a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732L13.863.1z"/></g></svg>'
// Check for saved theme preference first
let savedTheme = localStorage.getItem('theme-preference');
let isLight = true;
if (savedTheme) {
// Use saved preference
isLight = savedTheme === 'light';
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// Fall back to OS preference only if no saved theme
isLight = false;
}
const html = document.documentElement;
const switchTheme = document.getElementById('theme_switcher');
const removeTooltip = (timeInt = 1750) => {
setTimeout(() => {
switchTheme.blur()
},timeInt)
switchTheme.blur();
}, timeInt);
};
// Apply the theme immediately if we have a saved preference
if (savedTheme && savedTheme !== 'auto') {
html.setAttribute('data-theme', savedTheme);
switchTheme.innerHTML = isLight ? sun : moon;
switchTheme.setAttribute('data-tooltip', `theme ${savedTheme}`);
} else {
// Default OS theme
switchTheme.innerHTML = os_default;
switchTheme.setAttribute('data-tooltip', 'os theme');
}
switchTheme.innerHTML = os_default
//html.setAttribute('data-theme', 'auto')
switchTheme.setAttribute('data-tooltip', 'os theme')
switchTheme.focus()
removeTooltip(3000)
switchTheme.focus();
removeTooltip(3000);
switchTheme.addEventListener('click', (e) => {
e.preventDefault()
isLight = !isLight
html.setAttribute('data-theme', isLight? 'light':'dark')
switchTheme.innerHTML = isLight? sun : moon
switchTheme.setAttribute('data-tooltip', `theme ${isLight?'light':'dark'}`)
removeTooltip()
})
e.preventDefault();
isLight = !isLight;
const newTheme = isLight ? 'light' : 'dark';
// Save preference
localStorage.setItem('theme-preference', newTheme);
html.setAttribute('data-theme', newTheme);
switchTheme.innerHTML = isLight ? sun : moon;
switchTheme.setAttribute('data-tooltip', `theme ${newTheme}`);
removeTooltip();
});
}