Compare commits

...

2 Commits

Author SHA1 Message Date
527d9642bc Fix date/time localization 2023-04-20 03:01:24 +02:00
f2b25ce868 Mount configuration read-only 2023-04-20 03:01:24 +02:00
4 changed files with 12 additions and 16 deletions

View File

@ -8,8 +8,10 @@ services:
- 5000:5000 - 5000:5000
environment: environment:
- FABCAL_CACHE_EXPIRE=120 - FABCAL_CACHE_EXPIRE=120
- LANG=de
- LC_ALL=de_DE.UTF-8
volumes: volumes:
- ./config.yml:/app/config.yml - ./config.yml:/app/config.yml:ro
# use the line below when running this behind reverse proxy (only if it sets the proxy headers, though) # use the line below when running this behind reverse proxy (only if it sets the proxy headers, though)
#command: --proxy-headers --forwarded-allow-ips="*" #command: --proxy-headers --forwarded-allow-ips="*"

View File

@ -1,5 +1,6 @@
import re import re
from babel.dates import format_datetime
from jinja2 import pass_eval_context from jinja2 import pass_eval_context
from markupsafe import Markup, escape from markupsafe import Markup, escape
from starlette.templating import Jinja2Templates from starlette.templating import Jinja2Templates
@ -7,6 +8,9 @@ from starlette.templating import Jinja2Templates
templates = Jinja2Templates(directory="templates") templates = Jinja2Templates(directory="templates")
# custom filters
templates.env.filters["format_datetime"] = lambda value, format: format_datetime(value, format) #, locale="de_DE")
@pass_eval_context @pass_eval_context
def nl2br(eval_ctx, value): def nl2br(eval_ctx, value):

View File

@ -18,19 +18,9 @@ async def generate_response(request: Request, template_name: str, **additional_c
grouped_events = list(group_by_date(events).items()) grouped_events = list(group_by_date(events).items())
# couple of helpers
def localized_abbreviated_month(dt: datetime):
return babel.dates.format_datetime(dt, format="%b", locale="de_DE")
# couple of helpers
def localized_abbreviated_weekday(dt: datetime):
return babel.dates.format_datetime(dt, format="%b", locale="de_DE")
context = { context = {
"request": request, "request": request,
"grouped_events": grouped_events, "grouped_events": grouped_events,
"localized_abbreviated_month": localized_abbreviated_month,
"localized_abbreviated_weekday": localized_abbreviated_weekday,
} }
context.update(additional_context) context.update(additional_context)

View File

@ -6,22 +6,22 @@
<div class="calendar-date"> <div class="calendar-date">
<div class="calendar-date-date"> <div class="calendar-date-date">
<div class="calendar-date-month"> <div class="calendar-date-month">
{{ start_date.strftime("%b") }} {{ start_date | format_datetime("MMM") }}
</div> </div>
<div class="calendar-date-day"> <div class="calendar-date-day">
{{ start_date.strftime("%d") }} {{ start_date | format_datetime("d") }}
</div> </div>
<div class="calendar-date-weekday"> <div class="calendar-date-weekday">
{{ start_date.strftime("%a") }} {{ start_date | format_datetime("EEE") }}
</div> </div>
</div> </div>
<div class="calendar-events"> <div class="calendar-events">
{% for event in events %} {% for event in events %}
<div class="calendar-event" title="{{ event.summary }}{% if event.description %} &mdash; {{ event.description }}{% endif %}"> <div class="calendar-event" title="{{ event.summary }}{% if event.description %} &mdash; {{ event.description }}{% endif %}">
<div class="calendar-event-time"> <div class="calendar-event-time">
<div class="calendar-event-starttime">{{ event.start.strftime("%H:%M") }}</div> <div class="calendar-event-starttime">{{ event.start | format_datetime("HH:mm") }}</div>
<div class="calendar-event-timesep"></div> <div class="calendar-event-timesep"></div>
<div class="calendar-event-endtime">{{ event.end.strftime("%H:%M") }}</div> <div class="calendar-event-endtime">{{ event.end | format_datetime("HH:mm") }}</div>
</div> </div>
<div class="calendar-event-description"> <div class="calendar-event-description">
{% if event.description or event.location %} {% if event.description or event.location %}