Move spaceapi proxy prefix from config to spaceapi urls
This commit is contained in:
parent
22c97c3155
commit
474fc0ef53
3 changed files with 8 additions and 12 deletions
|
@ -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'
|
||||
|
|
|
@ -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(`<b>${spaces[i].name}</b><address>${spaces[i].address.replaceAll(',', '<br/>')}</address><a href="${spaces[i].web}">${spaces[i].web}</a>`)
|
||||
.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) {
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in a new issue