diff --git a/config.yml b/config.yml index 3873eab..c59966a 100644 --- a/config.yml +++ b/config.yml @@ -10,7 +10,6 @@ jinja_environment: baseurl_abs: https://chaostreff.ch/ baseurl: / - spaceapi_proxy_endpoint: /spaceapi-proxy htaccess_spaceapi_proxy: yes hackerspaces: @@ -28,7 +27,7 @@ jinja_environment: contact: ml: 'https://lists.chaostreff.ch/postorius/lists/basel.chaostreff.ch/' matrix: 'https://mto.kabelsalat.ch/#/#basel:kabelsalat.ch' - spaceapi: '/https/spaceapi.kabelsalat.ch/' + spaceapi: '/spaceapi-proxy/https/spaceapi.kabelsalat.ch/' - name: 'CCC Zürich' address: 'Neue Hard 12, 8005 Zürich' @@ -43,7 +42,7 @@ jinja_environment: contact: 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/' + spaceapi: '/spaceapi-proxy/https/www.ccczh.ch/api/v13/' - name: 'Chaostreff Bern' address: 'Kyburgstrasse 13, 3013 Bern' @@ -58,7 +57,7 @@ jinja_environment: contact: ml: 'https://lists.chaostreff.ch/postorius/lists/bern.chaostreff.ch/' email: 'info(ät)chaostreffbern(punkt)ch' - spaceapi: '/https/www.chaosbern.ch/spaceapi.json' + spaceapi: '/spaceapi-proxy/https/www.chaosbern.ch/spaceapi.json' - name: 'Coredump' address: 'Eichwiesstrasse 4, 8645 Jona' @@ -71,7 +70,7 @@ jinja_environment: en: 'Every Monday from 20:00' web: 'https://coredump.ch/' contact: {} - spaceapi: '/https/status.crdmp.ch/' + spaceapi: '/spaceapi-proxy/https/status.crdmp.ch/' - name: 'Eastermundingen' address: 'Steinbruchweg 16, 3072 Ostermundigen' diff --git a/src/chaostreff.js b/src/chaostreff.js index 97a6431..fe76416 100644 --- a/src/chaostreff.js +++ b/src/chaostreff.js @@ -5,7 +5,6 @@ window.onload = (ev) => { { name: '{{ space.name }}', address: '{{ space.address }}', lat: {{ space.lat }}, lon: {{ space.lon }}, open: '{{ space.open[lang] }}', web: '{{ space.contact.web }}', spaceapi: {% if 'spaceapi' in space %}'{{ space.spaceapi }}'{% else %}null{% endif %} }, {% endfor %} ]; - let SPACEAPI_PROXY = '{{ spaceapi_proxy_endpoint }}'; let blueIcon = new L.Icon({ iconUrl: '{{ baseurl }}static/img/leaflet-marker-blue.png', @@ -29,8 +28,8 @@ window.onload = (ev) => { let marker = L.marker([spaces[i].lat, spaces[i].lon], {icon: blueIcon}) .bindPopup(`${spaces[i].name}
${spaces[i].address.replaceAll(',', '
')}
${spaces[i].web}`) .addTo(map); - if (spaces[i].spaceapi !== undefined) { - fetch(SPACEAPI_PROXY + spaces[i].spaceapi, { + if (spaces[i].spaceapi !== null) { + fetch(spaces[i].spaceapi, { headers: { 'Accept': 'application/json' }, }).then(resp => resp.json()).then(json => { if (json.state == undefined || json.state.open == undefined) { diff --git a/static-src/.htaccess b/static-src/.htaccess index 38054c0..688ba07 100644 --- a/static-src/.htaccess +++ b/static-src/.htaccess @@ -1,15 +1,13 @@ # 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_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] +{%- if 'spaceapi' in space and space.spaceapi.startswith('/') %} +RewriteRule ^{{ space.spaceapi[1:] }}$ {{ space.spaceapi.split('/', 3)[2] }}://{{ space.spaceapi.split('/', 3)[3] }} [P,L] {%- endif %} {%- endfor %} {%- endif %}