httpd config

This commit is contained in:
s3lph 2023-01-04 03:05:25 +01:00
parent 30bf709107
commit 1c96c4273a
Signed by: s3lph
GPG key ID: 8AC98A811E5BEFF5
5 changed files with 46 additions and 12 deletions

View file

@ -3,6 +3,23 @@
Source code and build scripts for [chaostreff.ch](https://chaostreff.ch/)
## Production Deployment
```shell-session
$ python3 -m virtualenv venv
$ . venv/bin/activate
(venv) $ pip install -r requirements.txt
(venv) $ ./build.py
```
Then deploy the contents of `out/` to the webroot.
To make the site really usable, the following features should be configured:
* A proxying service for SpaceAPI endpoints (since some of them don't set CORS headers)
* Automatic redirection to the correct language subpage based on the `Accept-Language` header
An example configuration for Apache httpd can be found in the `httpd.conf` file.
## Local Development Setup
```shell-session
@ -15,17 +32,6 @@ $ . venv/bin/activate
run.py includes a SpaceAPI proxy to work around missing CORS headers.
## Production Deployment
```shell-session
$ python3 -m virtualenv venv
$ . venv/bin/activate
(venv) $ pip install -r requirements.txt
(venv) $ ./build.py
```
Then deploy the contents of `out/` to the webroot.
## License
With exception of the sources listed below, this project is licensed under the [MIT License](LICENSE).

View file

@ -12,11 +12,19 @@ with open('config.yml', 'r') as f:
os.makedirs('out', exist_ok = True)
shutil.copytree('static', 'out/static', dirs_exist_ok=True)
env = jinja2.Environment(loader=jinja2.FileSystemLoader('static-src'))
env.globals.update(config['jinja_environment'])
env.globals['languages'] = config['languages']
for fname in os.listdir('static-src'):
tmpl = env.get_template(fname)
with open(os.path.join('out', fname), 'w') as of:
of.write(tmpl.render())
for lang in config['languages'].keys():
with open(f'l10n/{lang}.yml', 'r') as l:
l10n = yaml.safe_load(l)
env = jinja2.Environment(loader=jinja2.FileSystemLoader("src"))
env = jinja2.Environment(loader=jinja2.FileSystemLoader('src'))
env.globals.update(config['jinja_environment'])
env.globals.update(l10n)
env.globals['languages'] = config['languages']

13
httpd.conf Normal file
View file

@ -0,0 +1,13 @@
# Redirect to language-specific index based on Accept-Language header
AddHandler type-map .var
DirectoryIndex index.var index.html
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]

7
static-src/index.var Normal file
View file

@ -0,0 +1,7 @@
URI: index; vary="language"
{% for language in languages %}
URI: index.{{ language }}.html
Content-Type: text/html
Content-Language: {{ language }}
{% endfor %}