From a836997b5a96e89bffaeab9b078e7326210bc8ff Mon Sep 17 00:00:00 2001 From: s3lph Date: Fri, 6 Jan 2023 00:00:27 +0100 Subject: [PATCH] Cleanup, add deployment job --- .woodpecker.yml | 23 ++++++++++++++++- config.yml | 60 ++++++++++++++++---------------------------- httpd.conf | 15 ----------- run.py | 6 ++--- src/index.html | 2 +- static-src/.htaccess | 21 ++++++++++++++++ 6 files changed, 68 insertions(+), 59 deletions(-) delete mode 100644 httpd.conf create mode 100644 static-src/.htaccess diff --git a/.woodpecker.yml b/.woodpecker.yml index c21ecad..387ec55 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -2,7 +2,28 @@ pipeline: build: - image: python:3.10 + image: python:3.10-bullseye commands: - pip install -r requirements.txt - ./build.py + + upload: + image: python:3.10-bullseye + when: + branch: main + secrets: + - RSYNC_DEST + - SSH_KNOWN_HOSTS + - SSH_PRIVATE_KEY + commands: + - apt-get update + - apt-get install --yes --no-install-recommends rsync openssh-client + - pip3 install -r requirements.txt + - ./build.py + - export SSH_PRIVKEY_FILE=.ssh/id_ed25519 + - export SSH_KNOWN_HOSTS=.ssh/known_hosts + - mkdir -p .ssh && chmod 0700 .ssh + - echo "$SSH_PRIVATE_KEY" > "$SSH_PRIVKEY_FILE" + - echo "$SSH_KNOWN_HOSTS" > "$SSH_KNOWN_HOSTS" + - chmod 0600 "$SSH_PRIVKEY_FILE" + - rsync -v --recursive --delete -e "ssh -oUserKnownHostsFile=${SSH_KNOWN_HOSTS} -i ${SSH_PRIVKEY_FILE}" "out/" "${RSYNC_DEST}" diff --git a/config.yml b/config.yml index d1cb991..f5cebc2 100644 --- a/config.yml +++ b/config.yml @@ -10,7 +10,9 @@ jinja_environment: baseurl_abs: https://chaostreff.ch/ baseurl: / - spaceapi_proxy_endpoint: /spaceapi + spaceapi_proxy_endpoint: /spaceapi-proxy + htaccess_language_redirect: no + htaccess_spaceapi_proxy: yes hackerspaces: @@ -25,6 +27,8 @@ jinja_environment: en: 'Every Tuesday from 19:30' contact: web: 'https://ccc-basel.ch/' + ml: 'https://lists.chaostreff.ch/postorius/lists/basel.chaostreff.ch/' + matrix: 'https://mto.kabelsalat.ch/#/#basel:kabelsalat.ch' spaceapi: '/https/spaceapi.kabelsalat.ch/' - name: 'CCC Zürich' @@ -38,6 +42,8 @@ jinja_environment: en: 'Every Wednesday from 19:00' contact: web: 'https://ccczh.ch/' + ml: 'https://lists.chaostreff.ch/postorius/lists/zuerich.chaostreff.ch/' + ml: 'https://lists.chaostreff.ch/postorius/lists/bitwaescherei.chaostreff.ch/' spaceapi: '/https/www.ccczh.ch/api/v13/' - name: 'Chaostreff Bern' @@ -51,6 +57,8 @@ jinja_environment: en: 'Every Tuesday from 19:00' contact: web: 'https://chaostreffbern.ch/' + ml: 'https://lists.chaostreff.ch/postorius/lists/bern.chaostreff.ch/' + email: 'info(ät)chaostreffbern(punkt)ch' spaceapi: '/https/www.chaosbern.ch/spaceapi.json' - name: 'Coredump' @@ -66,32 +74,19 @@ jinja_environment: web: 'https://coredump.ch/' spaceapi: '/https/status.crdmp.ch/' - - name: 'FIXME Lausanne' - address: 'Les Ateliers de Renens, Chemin du Closel 3, 1020 Renens' - lat: 46.532372 - lon: 6.591292 + - name: 'Eastermundingen' + address: 'Steinbruchweg 16, 3072 Ostermundigen' + lat: 46.95151 + lon: 7.49408 open: - de: 'Mittwochs ab 19:00' - fr: 'Mercredi à partir de 19:00' - it: 'Mercoledì da 19:00' - en: 'Every Wednesday from 19:00' + de: 'Mittwochs ab 18:00' + fr: 'Mercredi à partir de 18:00' + it: 'Mercoledì da 18:00' + en: 'Every Wednesday from 18:00' contact: - web: 'https://fixme.ch/' - spaceapi: '/https/fixme.ch/cgi-bin/spaceapi.py' - - - name: 'LuXeria' - address: 'Ebikonerstrasse 75, CH-6043 Adligenswil' - lat: 47.073 - lon: 8.357 - open: - de: 'Mittwochs ab 20:00 Videokonferenz' - fr: 'Mercredi à partir de 20:00 visioconférence' - it: 'Mercoledì da 20:00 videoconferenza' - en: 'Every Wednesday from 20:00 video conference' - contact: - web: 'https://luxeria.ch/' - spaceapi: '/https/luxeria.ch/spaceapi.json' - + web: 'https://www.eastermundigen.ch/' + ml: 'https://lists.chaostreff.ch/postorius/lists/bern.chaostreff.ch/' + - name: 'ODENWILUSENZ' address: 'Hardmorgenweg 21, 8222 Beringen' lat: 47.6951648 @@ -102,21 +97,8 @@ jinja_environment: it: 'Mercoledì da 19:00' en: 'Every Wednesday from 19:00' contact: - web: '/odenwilusenz.ch/' + web: 'https://odenwilusenz.ch/' - - name: 'Post Tenebras Lab' - address: 'Avenue de la Praille 36, 1227 Carouge' - lat: 46.187134981155396 - lon: 6.133659482002258 - open: - de: 'Dienstags ab 19:00' - fr: 'Mardi à partir de 19:00' - it: 'Martedì da 19:00' - en: 'Every Tuesday from 19:00' - contact: - web: 'https://www.posttenebraslab.ch' - spaceapi: '/https/www.posttenebraslab.ch/status/status.json' - - name: 'Ruum42' address: 'Andreasstrasse 5, 9000 St. Gallen' lat: 47.4207758 diff --git a/httpd.conf b/httpd.conf deleted file mode 100644 index ebe3f29..0000000 --- a/httpd.conf +++ /dev/null @@ -1,15 +0,0 @@ - -# Language-specific index based on Accept-Language header -AddHandler type-map .var -DirectoryIndex index.var index.html -# Optional: Redirect to language specific subsite, rather than showing -# language specific content at the root -#Redirect /index.de.html /de/ -#Redirect /index.fr.html /fr/ -#Redirect /index.it.html /it/ -#Redirect /index.en.html /en/ - -# SpaceAPI proxy service workaround for missing CORS headers -SSLProxyEngine on -RewriteEngine on -RewriteRule /spaceapi/([^/]+)/([^/]+)(/.*+)$ $1://$2/$3 [P,L] \ No newline at end of file diff --git a/run.py b/run.py index 1580c2d..f90c306 100755 --- a/run.py +++ b/run.py @@ -5,9 +5,9 @@ import bottle import urllib.parse import requests -@bottle.get('/spaceapi//') -@bottle.get('/spaceapi///') -@bottle.get('/spaceapi///') +@bottle.get('/spaceapi-proxy//') +@bottle.get('/spaceapi-proxy///') +@bottle.get('/spaceapi-proxy///') def spaceapi_proxy(schema, host, path=''): url = urllib.parse.urlunsplit((schema, host, path, '', '')) import logging diff --git a/src/index.html b/src/index.html index a6627f9..1bb6422 100644 --- a/src/index.html +++ b/src/index.html @@ -85,7 +85,7 @@ {{ space.open[lang] }} {% for key, url in space.contact.items() %} - {{ contacts[key] }} + {{ contacts[key] }}
{% endfor %} diff --git a/static-src/.htaccess b/static-src/.htaccess new file mode 100644 index 0000000..92c0737 --- /dev/null +++ b/static-src/.htaccess @@ -0,0 +1,21 @@ + +# Language-specific index based on Accept-Language header +DirectoryIndex index.var index.html +# Optional: Redirect to language specific subsite, rather than showing +# language specific content at the root + +{% if htaccess_language_redirect %} +{%- for language in languages %} +Redirect /index.{{ language }}.html /{{ language }}/ +{%- endfor %} +{%- endif %} + +{% if htaccess_spaceapi_proxy %} +# SpaceAPI proxy service workaround for missing CORS headers +RewriteEngine on +{%- for space in hackerspaces %} +{%- if 'spaceapi' in space %} +RewriteRule ^/spaceapi-proxy{{ space.spaceapi }}$ {{ space.spaceapi.split('/', 2)[1] }}://{{ space.spaceapi.split('/', 2)[2] }} [P,L] +{%- endif %} +{%- endfor %} +{%- endif %}