Compare commits

...

2 commits

Author SHA1 Message Date
Reto Bollinger
6c4ba2e46c Fixing newline at end of generated page 2024-11-16 18:38:45 +01:00
Reto Bollinger
b9b3f15249 Getting the script executable within docker and making create the whole Termine page 2024-11-16 18:32:56 +01:00
3 changed files with 18 additions and 4 deletions

View file

@ -1,9 +1,10 @@
FROM debian:latest FROM debian:latest
RUN apt update RUN apt update
RUN apt install -y python3-pip python3-venv pipx RUN apt install -y python3-pip python3-venv pipx curl locales
RUN pipx install lektor 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
WORKDIR /opt/lektor/project WORKDIR /opt/lektor/project

View file

@ -11,6 +11,12 @@ ICS_DATA=$(curl -s "$ICS_URL")
TODAY=$(date +%Y%m%d) TODAY=$(date +%Y%m%d)
echo "_model: page"
echo "---"
echo "title: Termine"
echo "---"
echo "body:"
echo ""
echo "| **Datum** | **Anlass** | **Zeit** | **Ort** |" echo "| **Datum** | **Anlass** | **Zeit** | **Ort** |"
echo "|-------|--------|------|-----|" echo "|-------|--------|------|-----|"
@ -30,11 +36,11 @@ echo "$ICS_DATA" | awk 'BEGIN{FS=":"}
if (location == "") location = "Kein Ort" if (location == "") location = "Kein Ort"
date_str = substr(dtstart, 1, 4) "-" substr(dtstart, 5, 2) "-" substr(dtstart, 7, 2) date_str = substr(dtstart, 1, 4) "-" substr(dtstart, 5, 2) "-" substr(dtstart, 7, 2)
cmd = "LC_TIME=de_DE.UTF-8 date -j -f \"%Y-%m-%d\" \"" date_str "\" +%a" cmd = "LC_ALL=de_DE.UTF-8 date -d \"" date_str "\" +%a"
cmd | getline weekday cmd | getline weekday
close(cmd) close(cmd)
cmd = "LC_TIME=de_DE.UTF-8 date -j -f \"%Y-%m-%d\" \"" date_str "\" +%B" cmd = "LC_ALL=de_DE.UTF-8 date -d \"" date_str "\" +%B"
cmd | getline month cmd | getline month
close(cmd) close(cmd)
@ -46,4 +52,6 @@ echo "$ICS_DATA" | awk 'BEGIN{FS=":"}
wholeline=sprintf("%s | %s | %s | %s | %s |", orderstartdate, realstartdate, summarystring, starttime, location) wholeline=sprintf("%s | %s | %s | %s | %s |", orderstartdate, realstartdate, summarystring, starttime, location)
gsub(/\| 00:00 \|/, "| |", wholeline) gsub(/\| 00:00 \|/, "| |", wholeline)
print wholeline print wholeline
}' | awk -v today="$TODAY" 'substr($1,1,8) >= today' | sort | awk '{$1=""}1' | awk '{$1=$1}1' }' | awk -v today="$TODAY" 'substr($1,1,8) >= today' | sort | awk '{$1=""}1' | awk '{$1=$1}1'
echo""

View file

@ -15,6 +15,11 @@ New Lektor Approach:
thats all! thats all!
To update "Termine" page run:
docker run -v ${PWD}/lektor/lektordata:/opt/lektor lektorcontainer /bin/bash -c "/opt/lektor/scripts/calendar-fetcher.sh 'https://backoffice.pc-stammertal.ch/remote.php/dav/public-calendars/RqLX5wj25aY6cpnP?export' > /opt/lektor/project/content/termine/contents.lr"
building the website for deployment is: building the website for deployment is:
docker run -it -v ${PWD}/lektor/lektordata:/opt/lektor -p 5000:5000 lektorcontainer lektor build -O /opt/lektor/output docker run -it -v ${PWD}/lektor/lektordata:/opt/lektor -p 5000:5000 lektorcontainer lektor build -O /opt/lektor/output