This commit is contained in:
Lunantic 2022-06-12 18:21:59 +02:00
commit 6eb61deeac
3 changed files with 29 additions and 7 deletions

View file

@ -16,11 +16,11 @@ Note that this repository contains code to build different sites with some share
- **playground/** This directory contains anything that shouldn't be included directly but might be relevant to the project. - **playground/** This directory contains anything that shouldn't be included directly but might be relevant to the project.
- **sites/** Each site gets a subdirectory here containing its content. - **sites/** Each site gets a subdirectory here containing its content.
- **<name>** - **<name>**
- **_assets/** Site-specific static content. This will also be copied into the `assets` directory of the final output. - **\_assets/** Site-specific static content. This will also be copied into the `assets` directory of the final output.
- **_data/** Directory for Eleventy [global data files](https://www.11ty.dev/docs/data-global/). - **\_data/** Directory for Eleventy [global data files](https://www.11ty.dev/docs/data-global/).
- **_images/** Place images that should be rendered by the build system in some way here. - **\_images/** Place images that should be rendered by the build system in some way here.
- **httpd.conf** Configuration file for [lighttpd](https://redmine.lighttpd.net/projects/lighttpd/wiki#Documentation), which will serve the final site. - **httpd.conf** Configuration file for [lighttpd](https://redmine.lighttpd.net/projects/lighttpd/wiki#Documentation), which will serve the final site.
- *Anything else* is actual content for the site (usually in the form of markdown files). - _Anything else_ is actual content for the site (usually in the form of markdown files).
- **styles/** SCSS stylesheets. Anything directly in this directory that doesn't begin with an underscore will be available in the final build. - **styles/** SCSS stylesheets. Anything directly in this directory that doesn't begin with an underscore will be available in the final build.
- **.eleventy.js** Base Eleventy configuration. This is set up so that the correct paths for the selected site (according to the environment variable `SITE`) are selected automatically. - **.eleventy.js** Base Eleventy configuration. This is set up so that the correct paths for the selected site (according to the environment variable `SITE`) are selected automatically.
- **.eleventyignore** Eleventy ignore file. Place paths in here that should be excluded in the final build. - **.eleventyignore** Eleventy ignore file. Place paths in here that should be excluded in the final build.
@ -58,3 +58,17 @@ The flake also contains a second package for building the production output:
```shell ```shell
nix build # Will create an output derivation in 'result' nix build # Will create an output derivation in 'result'
``` ```
## Deployment
Deploy the container from the image automatically by the CI server.
Ask @yrd for the URL.
The container will expose the site under port 80.
Further configuration is available via environment variables.
- `ZAMMAD_URL=https://ticket.z31.it` URL of the Zammad server to use.
- `ZAMMAD_GROUP=` Set this variable to override the group all Zammad tickets go in. If empty (the default), different forms will be sorted into different groups.
- `ZAMMAD_TOKEN` This is the only mandatory option. Set it to a Zammad access token with the `ticket.agent` permission.
See https://codeberg.org/angestoepselt/homepage/issues/6#issuecomment-419104 for details.

View file

@ -137,6 +137,8 @@ ticket_details = collections.OrderedDict()
ticket_details["Kontaktperson"] = contact_name ticket_details["Kontaktperson"] = contact_name
ticket_details["Email"] = contact_email ticket_details["Email"] = contact_email
form_group = "csw-Allgemein"
match request_uri: match request_uri:
case "/kontakt": case "/kontakt":
form_name = "Allgemein" form_name = "Allgemein"
@ -152,6 +154,7 @@ match request_uri:
case "/computer-beantragen/organisation": case "/computer-beantragen/organisation":
form_name = "Computerantrag (Organisation)" form_name = "Computerantrag (Organisation)"
form_group = "csw-Anfragen"
ticket_details["Organisation"] = get_form_value("organization") ticket_details["Organisation"] = get_form_value("organization")
ticket_details["Adresse"] = get_form_value("addressline") ticket_details["Adresse"] = get_form_value("addressline")
ticket_details["PLZ"] = get_form_value("postalcode") ticket_details["PLZ"] = get_form_value("postalcode")
@ -162,6 +165,7 @@ match request_uri:
case "/computer-beantragen/privat": case "/computer-beantragen/privat":
form_name = "Computerantrag (privat)" form_name = "Computerantrag (privat)"
form_group = "csw-Anfragen"
ticket_details["Adresse"] = get_form_value("addressline") ticket_details["Adresse"] = get_form_value("addressline")
ticket_details["PLZ"] = get_form_value("postalcode") ticket_details["PLZ"] = get_form_value("postalcode")
ticket_details["Stadt"] = get_form_value("city") ticket_details["Stadt"] = get_form_value("city")
@ -172,11 +176,13 @@ match request_uri:
case "/hardware-spenden/organisation": case "/hardware-spenden/organisation":
form_name = "Hardwarespende (Organisation)" form_name = "Hardwarespende (Organisation)"
form_group = "csw-Hardwarespenden"
ticket_details["Organisation"] = get_form_value("organization") ticket_details["Organisation"] = get_form_value("organization")
attachment = get_form_value("inventory", cast=bytes) attachment = get_form_value("inventory", cast=bytes)
case "/hardware-spenden/privat/laptop": case "/hardware-spenden/privat/laptop":
form_name = "Laptopspende (privat)" form_name = "Laptopspende (privat)"
form_group = "csw-Hardwarespenden"
ticket_details["Gerätedetails"] = get_form_value("device") ticket_details["Gerätedetails"] = get_form_value("device")
case _: case _:
@ -186,10 +192,12 @@ match request_uri:
ticket_details["Kontaktformular"] = form_name ticket_details["Kontaktformular"] = form_name
# Allow the form group to be overriden using the environment variable (for
# testing).
form_group = os.environ.get("ZAMMAD_GROUP", "") or form_group
ZAMMAD_URL = os.environ.get("ZAMMAD_URL", "").rstrip("/") ZAMMAD_URL = os.environ.get("ZAMMAD_URL", "").rstrip("/")
ZAMMAD_TOKEN = os.environ.get("ZAMMAD_TOKEN", "") ZAMMAD_TOKEN = os.environ.get("ZAMMAD_TOKEN", "")
ZAMMAD_GROUP = os.environ.get("ZAMMAD_GROUP", "")
session = requests.Session() session = requests.Session()
session.headers.update(Authorization=f"Token token={ZAMMAD_TOKEN}") session.headers.update(Authorization=f"Token token={ZAMMAD_TOKEN}")
@ -199,7 +207,7 @@ try:
f"{ZAMMAD_URL}/api/v1/tickets", f"{ZAMMAD_URL}/api/v1/tickets",
json=dict( json=dict(
title=f"Kontaktformular {contact_name} {form_name}", title=f"Kontaktformular {contact_name} {form_name}",
group=ZAMMAD_GROUP, group=form_group,
customer_id=f"guess:{contact_email}", customer_id=f"guess:{contact_email}",
article=dict( article=dict(
type="web", type="web",

View file

@ -59,7 +59,7 @@
# We need to provide these default variables because otherwise # We need to provide these default variables because otherwise
# lighttpd doesn't even parse its configuration file: # lighttpd doesn't even parse its configuration file:
"ZAMMAD_URL=https://ticket.z31.it" "ZAMMAD_URL=https://ticket.z31.it"
"ZAMMAD_GROUP=testgruppe" "ZAMMAD_GROUP="
]; ];
ExposedPorts = { ExposedPorts = {
"80/tcp" = {}; "80/tcp" = {};