mirror of
https://git.bolliret.ch/pcs/pcs-website
synced 2026-01-18 16:41:37 +01:00
Starting to replace those ugly shell-scripts with more readable python-scripts (tough more complex to invoke)
This commit is contained in:
parent
eb95dfbad4
commit
260ce34d1b
3 changed files with 36 additions and 1 deletions
|
|
@ -6,6 +6,10 @@ RUN pipx install lektor
|
||||||
RUN mkdir -p /opt/lektor/project && mkdir -p /opt/lektor/output
|
RUN mkdir -p /opt/lektor/project && mkdir -p /opt/lektor/output
|
||||||
RUN sed -i '/de_DE.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
RUN sed -i '/de_DE.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
|
||||||
|
|
||||||
|
RUN python3 -m venv /opt/venv
|
||||||
|
|
||||||
|
RUN . /opt/venv/bin/activate && pip install ics requests
|
||||||
|
|
||||||
COPY entrypoint.sh /opt/entrypoint.sh
|
COPY entrypoint.sh /opt/entrypoint.sh
|
||||||
RUN chmod +x /opt/entrypoint.sh
|
RUN chmod +x /opt/entrypoint.sh
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
/opt/lektor/scripts/calendar-fetcher.sh ${CALENDAR_URL} > /opt/lektor/project/content/termine/contents.lr
|
sh -c ". /opt/venv/bin/activate && exec python /opt/lektor/scripts/calendar-fetcher.py ${CALENDAR_URL} > /opt/lektor/project/content/termine/contents.lr"
|
||||||
/opt/lektor/scripts/calendar-fetcher-main.sh ${CALENDAR_URL} > /opt/lektor/project/content/contents.lr
|
/opt/lektor/scripts/calendar-fetcher-main.sh ${CALENDAR_URL} > /opt/lektor/project/content/contents.lr
|
||||||
/root/.local/bin/lektor --project /opt/lektor/project server --host 0.0.0.0
|
/root/.local/bin/lektor --project /opt/lektor/project server --host 0.0.0.0
|
||||||
31
lektor/lektordata/scripts/calendar-fetcher.py
Normal file
31
lektor/lektordata/scripts/calendar-fetcher.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
import sys
|
||||||
|
import requests
|
||||||
|
from ics import Calendar
|
||||||
|
import arrow
|
||||||
|
import locale
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Usage: python3 {} <ICS_URL>".format(sys.argv[0]))
|
||||||
|
|
||||||
|
url = sys.argv[1]
|
||||||
|
|
||||||
|
c = Calendar(requests.get(url).text)
|
||||||
|
|
||||||
|
locale.setlocale(locale.LC_TIME, locale.normalize("de_DE.UTF-8"))
|
||||||
|
|
||||||
|
print("_model: page")
|
||||||
|
print("---")
|
||||||
|
print("title: Termine")
|
||||||
|
print("---")
|
||||||
|
print("body:")
|
||||||
|
print("")
|
||||||
|
for event in list(c.timeline.start_after(arrow.now())):
|
||||||
|
print("* <div>{}</div> ".format(event.name))
|
||||||
|
print(" * <div>{}</div> ".format(event.begin.strftime("%a. %-d. %B %Y")))
|
||||||
|
print(" * <div>{}</div> ".format(event.begin.strftime("%-H:%M") if not event.all_day else " "))
|
||||||
|
print(" * <div>{}</div> ".format(event.location if event.location != None else " "))
|
||||||
|
print("")
|
||||||
|
print("---")
|
||||||
|
print("_template: page.html")
|
||||||
|
print("")
|
||||||
|
print("")
|
||||||
Loading…
Add table
Reference in a new issue