Jaward commited on
Commit
e91af4a
·
verified ·
1 Parent(s): 2c7270f

fixed slide rendering, added reload for slide

Browse files
Files changed (1) hide show
  1. app.py +25 -2
app.py CHANGED
@@ -1,6 +1,6 @@
1
  # Lectūra Research Demo: A Multi-Agent Tool for Self-taught Mastery.
2
  # Author: Jaward Sesay
3
- # © Lectūra Labs. All rights reserved.
4
  import os
5
  import json
6
  import re
@@ -934,7 +934,7 @@ Example: 'Received {total_slides} slides, {total_slides} scripts, and HTML files
934
  <iframe id="slide-iframe" style="width: 100%; height: 100%; border: none;"></iframe>
935
  </div>
936
  <div style="padding: 20px; text-align: center;">
937
- <div style="display: flex; justify-content: center; margin-bottom: 10px;">
938
  {audio_timeline}
939
  </div>
940
  <div style="display: center; justify-content: center; margin-bottom: 10px;">
@@ -942,6 +942,7 @@ Example: 'Received {total_slides} slides, {total_slides} scripts, and HTML files
942
  <button id="play-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: black"><i class="fas fa-play" style="color: #fff !important"></i></button>
943
  <button id="next-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: black"><i class="fas fa-step-forward" style="color: #fff !important"></i></button>
944
  <button id="fullscreen-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: black"><i style="color: #fff !important" class="fas fa-expand"></i></button>
 
945
  <button id="clear-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: black"><i style="color: #fff !important" class="fas fa-paint-brush"></i></button>
946
  </div>
947
  </div>
@@ -1016,6 +1017,18 @@ js_code = """
1016
  console.log(`File exists: ${url}`);
1017
  return true;
1018
  }
 
 
 
 
 
 
 
 
 
 
 
 
1019
  console.log(`File not found (attempt ${i + 1}/${maxRetries}): ${url}`);
1020
  await new Promise(resolve => setTimeout(resolve, delay));
1021
  } catch (error) {
@@ -1409,6 +1422,16 @@ js_code = """
1409
  console.log("Attached event listener to fullscreen-btn");
1410
  });
1411
 
 
 
 
 
 
 
 
 
 
 
1412
  // Initialize audio sources and render first slide
1413
  updateAudioSources(lectureData.audioFiles);
1414
  renderSlide();
 
1
  # Lectūra Research Demo: A Multi-Agent Tool for Self-taught Mastery.
2
  # Author: Jaward Sesay
3
+ # © 2025 Lectūra Labs. All rights reserved.
4
  import os
5
  import json
6
  import re
 
934
  <iframe id="slide-iframe" style="width: 100%; height: 100%; border: none;"></iframe>
935
  </div>
936
  <div style="padding: 20px; text-align: center;">
937
+ <div class="audio-timeline" style="display: flex; justify-content: center; margin-bottom: 10px;">
938
  {audio_timeline}
939
  </div>
940
  <div style="display: center; justify-content: center; margin-bottom: 10px;">
 
942
  <button id="play-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: black"><i class="fas fa-play" style="color: #fff !important"></i></button>
943
  <button id="next-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: black"><i class="fas fa-step-forward" style="color: #fff !important"></i></button>
944
  <button id="fullscreen-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: black"><i style="color: #fff !important" class="fas fa-expand"></i></button>
945
+ <button id="reload-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: black"><i style="color: #fff !important" class="fas fa-sync-alt"></i></button>
946
  <button id="clear-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: black"><i style="color: #fff !important" class="fas fa-paint-brush"></i></button>
947
  </div>
948
  </div>
 
1017
  console.log(`File exists: ${url}`);
1018
  return true;
1019
  }
1020
+ // Fallback: Some servers disallow HEAD, try GET request
1021
+ if (response.status === 405 || response.status === 403) {
1022
+ try {
1023
+ const getResp = await fetch(url, { method: 'GET' });
1024
+ if (getResp.ok) {
1025
+ console.log(`File exists (GET fallback): ${url}`);
1026
+ return true;
1027
+ }
1028
+ } catch (err) {
1029
+ console.error(`GET fallback failed for ${url}:`, err);
1030
+ }
1031
+ }
1032
  console.log(`File not found (attempt ${i + 1}/${maxRetries}): ${url}`);
1033
  await new Promise(resolve => setTimeout(resolve, delay));
1034
  } catch (error) {
 
1422
  console.log("Attached event listener to fullscreen-btn");
1423
  });
1424
 
1425
+ waitForElement('#reload-btn', (reloadBtn) => {
1426
+ reloadBtn.addEventListener('click', () => {
1427
+ console.log("Reload button clicked");
1428
+ currentSlide = 0;
1429
+ updateAudioSources(lectureData.audioFiles);
1430
+ renderSlide();
1431
+ });
1432
+ console.log("Attached event listener to reload-btn");
1433
+ });
1434
+
1435
  // Initialize audio sources and render first slide
1436
  updateAudioSources(lectureData.audioFiles);
1437
  renderSlide();