removed comment that messes up the injection logic
This commit is contained in:
@@ -44,7 +44,7 @@ from .utils import (
|
|||||||
|
|
||||||
|
|
||||||
main = Blueprint('main', __name__)
|
main = Blueprint('main', __name__)
|
||||||
slidev_deck_pattern = re.compile(r"^\/slides\/[^\/]+\/\d*(?:\?.*)?$")
|
slidev_deck_pattern = re.compile(r"^\/slides\/[^\/]+\/[^\/]+\/(?:\d+|index\.html)(?:\?.*)?$")
|
||||||
slidev_all_pattern = re.compile(r"^\/slides\/([^\/]+)\/([^\/]+)(?:\/presenter)?\/(\d+)(?:\?.*)?$")
|
slidev_all_pattern = re.compile(r"^\/slides\/([^\/]+)\/([^\/]+)(?:\/presenter)?\/(\d+)(?:\?.*)?$")
|
||||||
|
|
||||||
@socketio.on("connect")
|
@socketio.on("connect")
|
||||||
@@ -54,45 +54,45 @@ def on_connect():
|
|||||||
|
|
||||||
@main.after_request
|
@main.after_request
|
||||||
def inject_confused_button(response):
|
def inject_confused_button(response):
|
||||||
if True:
|
if (slidev_deck_pattern.match(request.path) or request.path == '/') and response.content_type.startswith('text/html') and not flask_login.current_user.is_authenticated :
|
||||||
if (slidev_deck_pattern.match(request.path) or request.path == '/') and response.content_type.startswith('text/html') and not flask_login.current_user.is_authenticated :
|
print("** INJECTION TEST PASSED **")
|
||||||
if response.direct_passthrough:
|
if response.direct_passthrough:
|
||||||
response.direct_passthrough = False
|
response.direct_passthrough = False
|
||||||
body = response.get_data(as_text=True)
|
body = response.get_data(as_text=True)
|
||||||
insert_at = body.find('</body>')
|
insert_at = body.find('</body>')
|
||||||
if insert_at != -1:
|
if insert_at != -1:
|
||||||
button_html = """
|
button_html = """
|
||||||
<button id="confused-button" style="
|
<button id="confused-button" style="
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 1.5rem;
|
bottom: 1.5rem;
|
||||||
right: 1.5rem;
|
right: 1.5rem;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
background-color: #4f8cff;
|
background-color: #4f8cff;
|
||||||
color: white;
|
color: white;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 9999px;
|
border-radius: 9999px;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.3s, transform 0.2s;"
|
transition: background-color 0.3s, transform 0.2s;"
|
||||||
title="Didn't understand? Click!">
|
title="Didn't understand? Click!">
|
||||||
Ich habe das nicht verstanden
|
Ich habe das nicht verstanden
|
||||||
</button>
|
</button>
|
||||||
<script>
|
<script>
|
||||||
document.getElementById('confused-button').addEventListener('click', () => {
|
document.getElementById('confused-button').addEventListener('click', () => {
|
||||||
fetch('/confused', {method: 'POST'})
|
fetch('/confused', {method: 'POST'})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
alert('Alles klar! Ich versuche es besser zu erklären. Melde dich, wenn du eine spezifische Frage hast oder noch etwas unklar bleibt.');
|
alert('Alles klar! Ich versuche es besser zu erklären. Melde dich, wenn du eine spezifische Frage hast oder noch etwas unklar bleibt.');
|
||||||
}
|
}
|
||||||
}).catch(error => console.error('Error:', error));
|
}).catch(error => console.error('Error:', error));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
"""
|
"""
|
||||||
body = body[:insert_at] + button_html + body[insert_at:]
|
body = body[:insert_at] + button_html + body[insert_at:]
|
||||||
response.set_data(body)
|
response.set_data(body)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||||
|
|
||||||
<!-- in base.html, in <head> or just before </body> -->
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.7.1/socket.io.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.7.1/socket.io.min.js"></script>
|
||||||
|
|
||||||
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
|
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user