Skip to content

Commit

Permalink
Use HTMX for meeting calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjuhrich committed Oct 18, 2023
1 parent 1020047 commit b18fc74
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 13 additions & 1 deletion sipa/blueprints/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
and does not fit into any other blueprint such as “documents”.
"""

from flask import Blueprint, current_app, render_template
from flask import Blueprint, current_app, render_template, render_template_string

from sipa.utils import get_bustimes, meetingcal

bp_features = Blueprint('features', __name__)
Expand Down Expand Up @@ -33,3 +34,14 @@ def bustimes(stopname=None):
def render_meetingcal():
meetings = meetingcal()
return render_template('meetingcal.html', meetings=meetings)


@bp_features.route("/meetings")
def meetings():
return render_template_string(
"""
{%- from "macros/meetingcal.html" import render_meetingcal -%}
{{- render_meetingcal(meetingcal) -}}
""",
meetingcal=meetingcal(),
)
11 changes: 10 additions & 1 deletion sipa/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,16 @@ <h2>
</h2>

<hr class="full">
<ul id="meetings-list">{{ render_meetingcal(meetingcal) }}</ul>
<ul
id="meetings-list"
hx-get="{{ url_for('features.meetings') }}"
hx-swap="innerHTML"
hx-trigger="load"
>
<li class="placeholder-glow"><span class="placeholder col-6 bg-secondary"></span></li>
<li class="placeholder-glow"><span class="placeholder col-3 bg-secondary"></span></li>
<li class="placeholder-glow"><span class="placeholder col-8 bg-secondary"></span></li>
</ul>

</div>
</div>
Expand Down

0 comments on commit b18fc74

Please sign in to comment.