diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2025-11-04 15:38:25 +0000 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2025-11-04 15:38:25 +0000 |
| commit | 95ae3c51cf05425baf739919af9938608f62ad64 (patch) | |
| tree | 0eddc979eb051bd303b3fbbb96a07aa541e872af | |
| parent | 7f528e60f5b9868a5fbcd579466fafc352594d88 (diff) | |
Add support for the new pretalx API
| -rwxr-xr-x | halfnarp2.py | 47 | ||||
| -rwxr-xr-x | scripts/gen_css_tables.py | 2 | ||||
| -rw-r--r-- | static/fullnarp.html | 28 | ||||
| -rw-r--r-- | static/fullnarp.js | 4 |
4 files changed, 41 insertions, 40 deletions
diff --git a/halfnarp2.py b/halfnarp2.py index 0cc3906..5ac9405 100755 --- a/halfnarp2.py +++ b/halfnarp2.py | |||
| @@ -121,14 +121,14 @@ def get_preferences(public_uid): | |||
| 121 | def filter_keys_halfnarp(session): | 121 | def filter_keys_halfnarp(session): |
| 122 | abstract_html = markdown.markdown(session["abstract"], enable_attributes=False) | 122 | abstract_html = markdown.markdown(session["abstract"], enable_attributes=False) |
| 123 | abstract_clean_html = Sanitizer().sanitize(abstract_html) | 123 | abstract_clean_html = Sanitizer().sanitize(abstract_html) |
| 124 | slot = session["slot"] | 124 | slot = next(iter(session["slots"]), {}) |
| 125 | 125 | ||
| 126 | return { | 126 | return { |
| 127 | "title": session.get("title", "!!! NO TITLE !!!"), | 127 | "title": session.get("title", "!!! NO TITLE !!!"), |
| 128 | "duration": 60 * session.get("duration", 40), | 128 | "duration": 60 * session.get("duration", 40), |
| 129 | "event_id": session["code"], | 129 | "event_id": session["code"], |
| 130 | "language": session.get("content_locale", "de"), | 130 | "language": session.get("content_locale", "de"), |
| 131 | "track_id": session["track_id"], | 131 | "track_id": session["track"], |
| 132 | "speaker_names": ", ".join( | 132 | "speaker_names": ", ".join( |
| 133 | [speaker.get("name", "unnamed") for speaker in session.get("speakers", {})] | 133 | [speaker.get("name", "unnamed") for speaker in session.get("speakers", {})] |
| 134 | ), | 134 | ), |
| @@ -141,7 +141,7 @@ def filter_keys_halfnarp(session): | |||
| 141 | def filter_keys_fullnarp(session, speakers): | 141 | def filter_keys_fullnarp(session, speakers): |
| 142 | abstract_html = markdown.markdown(session["abstract"], enable_attributes=False) | 142 | abstract_html = markdown.markdown(session["abstract"], enable_attributes=False) |
| 143 | abstract_clean_html = Sanitizer().sanitize(abstract_html) | 143 | abstract_clean_html = Sanitizer().sanitize(abstract_html) |
| 144 | slot = session["slot"] | 144 | slot = next(iter(session["slots"]), {}) |
| 145 | 145 | ||
| 146 | speaker_info = [] | 146 | speaker_info = [] |
| 147 | for speaker in session.get("speakers", {}): | 147 | for speaker in session.get("speakers", {}): |
| @@ -181,7 +181,7 @@ def filter_keys_fullnarp(session, speakers): | |||
| 181 | "duration": 60 * session.get("duration", 40), | 181 | "duration": 60 * session.get("duration", 40), |
| 182 | "event_id": session["code"], | 182 | "event_id": session["code"], |
| 183 | "language": session.get("content_locale", "de"), | 183 | "language": session.get("content_locale", "de"), |
| 184 | "track_id": session["track_id"], | 184 | "track_id": session["track"], |
| 185 | "speakers": speaker_info, | 185 | "speakers": speaker_info, |
| 186 | "speaker_names": ", ".join( | 186 | "speaker_names": ", ".join( |
| 187 | [speaker.get("name", "unnamed") for speaker in session.get("speakers", {})] | 187 | [speaker.get("name", "unnamed") for speaker in session.get("speakers", {})] |
| @@ -194,27 +194,28 @@ def filter_keys_fullnarp(session, speakers): | |||
| 194 | 194 | ||
| 195 | def fetch_talks(config): | 195 | def fetch_talks(config): |
| 196 | sess = requests.Session() | 196 | sess = requests.Session() |
| 197 | 197 | headers = {'Accept': 'application/json', | |
| 198 | response = sess.get( | 198 | 'Authorization': "Token " + config['pretalx-token'], |
| 199 | config["pretalx-api-url"] + "/submissions/?format=json&limit=20000", | 199 | 'Pretalx-Version' : 'v1'} |
| 200 | stream=True, | 200 | |
| 201 | headers={"Authorization": "Token " + config["pretalx-token"]}, | 201 | speakers_result = [] |
| 202 | ) | 202 | url = config['pretalx-api-url'] + '/speakers/?format=json&limit=20000' |
| 203 | # with open('dump.txt', mode='wb') as localfile: | 203 | while url: |
| 204 | # localfile.write(response.content) | 204 | response = sess.get(url, stream=True, headers=headers).json() |
| 205 | talks_json = json.loads(response.text) | 205 | speakers_result.extend(response['results']) |
| 206 | 206 | url = response['next'] | |
| 207 | response = sess.get( | 207 | speakers = { speaker['code']: speaker for speaker in speakers_result } |
| 208 | config["pretalx-api-url"] + "/speakers/?format=json&limit=20000", | 208 | |
| 209 | stream=True, | 209 | session_results = [] |
| 210 | headers={"Authorization": "Token " + config["pretalx-token"]}, | 210 | url = config['pretalx-api-url'] + '/submissions/?expand=speakers,slot,speakers.availabilities&format=json&limit=20000' |
| 211 | ) | 211 | while url: |
| 212 | speakers_json = json.loads(response.text) | 212 | response = sess.get(url, stream=True, headers=headers).json() |
| 213 | speakers = dict((speaker["code"], speaker) for speaker in speakers_json["results"]) | 213 | session_results.extend(response['results']) |
| 214 | url = response['next'] | ||
| 214 | 215 | ||
| 215 | sessions = [ | 216 | sessions = [ |
| 216 | filter_keys_halfnarp(submission) | 217 | filter_keys_halfnarp(submission) |
| 217 | for submission in talks_json["results"] | 218 | for submission in session_results |
| 218 | if submission["state"] == "confirmed" | 219 | if submission["state"] == "confirmed" |
| 219 | and not "non-public" in submission.get("tags", {}) | 220 | and not "non-public" in submission.get("tags", {}) |
| 220 | ] | 221 | ] |
| @@ -223,7 +224,7 @@ def fetch_talks(config): | |||
| 223 | 224 | ||
| 224 | sessions = [ | 225 | sessions = [ |
| 225 | filter_keys_fullnarp(submission, speakers) | 226 | filter_keys_fullnarp(submission, speakers) |
| 226 | for submission in talks_json["results"] | 227 | for submission in session_results |
| 227 | if submission["state"] == "confirmed" or submission["state"] == "accepted" | 228 | if submission["state"] == "confirmed" or submission["state"] == "accepted" |
| 228 | ] | 229 | ] |
| 229 | with open("var/talks_local_fullnarp", mode="w", encoding="utf8") as sessionsfile: | 230 | with open("var/talks_local_fullnarp", mode="w", encoding="utf8") as sessionsfile: |
diff --git a/scripts/gen_css_tables.py b/scripts/gen_css_tables.py index 4bc5ea8..0eb88f4 100755 --- a/scripts/gen_css_tables.py +++ b/scripts/gen_css_tables.py | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | start_y = 400 | 8 | start_y = 400 |
| 9 | starttime = 10 | 9 | starttime = 10 |
| 10 | endtime = 28 | 10 | endtime = 28 |
| 11 | rooms = 3 | 11 | rooms = 4 |
| 12 | days = 4 | 12 | days = 4 |
| 13 | columns = days * rooms # how many columns does | 13 | columns = days * rooms # how many columns does |
| 14 | event_gap = { 'large': 5, 'medium': 3, 'small': 2 } # how much is an event shorter than what the grid would allow in px | 14 | event_gap = { 'large': 5, 'medium': 3, 'small': 2 } # how much is an event shorter than what the grid would allow in px |
diff --git a/static/fullnarp.html b/static/fullnarp.html index a00f89e..3b86d6c 100644 --- a/static/fullnarp.html +++ b/static/fullnarp.html | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | <head> | 3 | <head> |
| 4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
| 5 | <title>FULLnarp web scheduling helper app</title> | 5 | <title>FULLnarp web scheduling helper app</title> |
| 6 | <link rel="stylesheet" href="style_38c3.css"> | 6 | <link rel="stylesheet" href="style_39c3.css"> |
| 7 | <link rel="stylesheet" href="style_38c3_tables.css"> | 7 | <link rel="stylesheet" href="style_39c3_tables.css"> |
| 8 | <script src="fullnarp.js"></script> | 8 | <script src="fullnarp.js"></script> |
| 9 | <script> | 9 | <script> |
| 10 | document.addEventListener('DOMContentLoaded', () => { do_the_fullnarp(); }); | 10 | document.addEventListener('DOMContentLoaded', () => { do_the_fullnarp(); }); |
| @@ -20,7 +20,7 @@ | |||
| 20 | </div> | 20 | </div> |
| 21 | <div class="trashbin">🗑️</div> | 21 | <div class="trashbin">🗑️</div> |
| 22 | <div class="version">version</div> | 22 | <div class="version">version</div> |
| 23 | <div class="headline">The 38C3 fullnarp</div> | 23 | <div class="headline">The 39C3 fullnarp</div> |
| 24 | <div class="header"> | 24 | <div class="header"> |
| 25 | <div class="leftbox"> | 25 | <div class="leftbox"> |
| 26 | <input id="filter" type="text" placeholder="Filter events"/> | 26 | <input id="filter" type="text" placeholder="Filter events"/> |
| @@ -46,10 +46,10 @@ | |||
| 46 | </div> | 46 | </div> |
| 47 | </div> | 47 | </div> |
| 48 | </div> | 48 | </div> |
| 49 | <div class="day_1 room-label room1">Saal 1</div><div class="day_1 room-label room2">Saal 2</div><div class="day_1 room-label room3">Saal 3</div></div> | 49 | <div class="day_1 room-label room1">Saal 1</div><div class="day_1 room-label room2">Saal 2</div><div class="day_1 room-label room3">Saal 3</div><div class="day_1 room-label room4">Saal 4</div></div> |
| 50 | <div class="day_2 room-label room1">Saal 1</div><div class="day_2 room-label room2">Saal 2</div><div class="day_2 room-label room3">Saal 3</div></div> | 50 | <div class="day_2 room-label room1">Saal 1</div><div class="day_2 room-label room2">Saal 2</div><div class="day_2 room-label room3">Saal 3</div><div class="day_2 room-label room4">Saal 4</div></div> |
| 51 | <div class="day_3 room-label room1">Saal 1</div><div class="day_3 room-label room2">Saal 2</div><div class="day_3 room-label room3">Saal 3</div></div> | 51 | <div class="day_3 room-label room1">Saal 1</div><div class="day_3 room-label room2">Saal 2</div><div class="day_3 room-label room3">Saal 3</div><div class="day_3 room-label room4">Saal 4</div></div> |
| 52 | <div class="day_4 room-label room1">Saal 1</div><div class="day_4 room-label room2">Saal 2</div><div class="day_4 room-label room3">Saal 3</div></div> | 52 | <div class="day_4 room-label room1">Saal 1</div><div class="day_4 room-label room2">Saal 2</div><div class="day_4 room-label room3">Saal 3</div><div class="day_4 room-label room4">Saal 4</div></div> |
| 53 | 53 | ||
| 54 | <div class=" time_1815 duration_3600 guide pause ">P A U S E</div> | 54 | <div class=" time_1815 duration_3600 guide pause ">P A U S E</div> |
| 55 | <div class=" time_1445 wholeblock room1 guide day_1"></div> | 55 | <div class=" time_1445 wholeblock room1 guide day_1"></div> |
| @@ -65,13 +65,13 @@ | |||
| 65 | <div class="wholeday room1 day_1 guide uneven"></div> | 65 | <div class="wholeday room1 day_1 guide uneven"></div> |
| 66 | <div class="wholeday room1 day_3 guide uneven"></div> | 66 | <div class="wholeday room1 day_3 guide uneven"></div> |
| 67 | 67 | ||
| 68 | <div class="track" id="6"><h2>Security</h2></div> | 68 | <div class="track" id="31"><h2>Security</h2></div> |
| 69 | <div class="track" id="4"><h2>Hardware & Making</h2></div> | 69 | <div class="track" id="32"><h2>Hardware & Making</h2></div> |
| 70 | <div class="track" id="7"><h2>Ethics, Society & Politics</h2></div> | 70 | <div class="track" id="28"><h2>Ethics, Society & Politics</h2></div> |
| 71 | <div class="track" id="2"><h2>CCC</h2></div> | 71 | <div class="track" id="30"><h2>CCC</h2></div> |
| 72 | <div class="track" id="3"><h2>Entertainment</h2></div> | 72 | <div class="track" id="27"><h2>Entertainment</h2></div> |
| 73 | <div class="track" id="5"><h2>Science</h2></div> | 73 | <div class="track" id="29"><h2>Science</h2></div> |
| 74 | <div class="track" id="1"><h2>Art & Beauty</div> | 74 | <div class="track" id="33"><h2>Art & Beauty</div> |
| 75 | <div class="track" id="999"><h2>Other</div> | 75 | <div class="track" id="999"><h2>Other</div> |
| 76 | 76 | ||
| 77 | </body> | 77 | </body> |
diff --git a/static/fullnarp.js b/static/fullnarp.js index c4e24f4..34a59c4 100644 --- a/static/fullnarp.js +++ b/static/fullnarp.js | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | let ws; // WebSocket instance | 1 | let ws; // WebSocket instance |
| 2 | let allrooms = ['1','2','3'] | 2 | let allrooms = ['1','2','3','4'] |
| 3 | let allminutes = ['00','05','10','15','20','25','30','35','40','45','50','55'] | 3 | let allminutes = ['00','05','10','15','20','25','30','35','40','45','50','55'] |
| 4 | let allhours = ['10','11','12','13','14','15','16','17','18','19','20','21','22','23','00','01','02']; | 4 | let allhours = ['10','11','12','13','14','15','16','17','18','19','20','21','22','23','00','01','02']; |
| 5 | let alldays = ['1','2','3','4']; | 5 | let alldays = ['1','2','3','4']; |
| @@ -395,7 +395,7 @@ function signalFullnarpConnect(state) { | |||
| 395 | 395 | ||
| 396 | function getFullnarpData() { | 396 | function getFullnarpData() { |
| 397 | signalFullnarpConnect('fullnarp-connecting'); | 397 | signalFullnarpConnect('fullnarp-connecting'); |
| 398 | connect = window.location.href.replace('http', 'ws') + '/ws/'; | 398 | connect = window.location.href.replace('http', 'ws') + 'ws/'; |
| 399 | ws = new WebSocket(connect); | 399 | ws = new WebSocket(connect); |
| 400 | 400 | ||
| 401 | ws.onopen = () => { | 401 | ws.onopen = () => { |
