diff --git a/README.md b/README.md index e312f0b..691e313 100644 --- a/README.md +++ b/README.md @@ -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. - **sites/** – Each site gets a subdirectory here containing its content. - **<name>** - - **_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/). - - **_images/** – Place images that should be rendered by the build system in some way here. + - **\_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/). + - **\_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. - - *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. - **.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. @@ -58,3 +58,17 @@ The flake also contains a second package for building the production output: ```shell 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. diff --git a/cgi-bin/form.py b/cgi-bin/form.py index ddb8694..c7faa9a 100755 --- a/cgi-bin/form.py +++ b/cgi-bin/form.py @@ -137,6 +137,8 @@ ticket_details = collections.OrderedDict() ticket_details["Kontaktperson"] = contact_name ticket_details["Email"] = contact_email +form_group = "csw-Allgemein" + match request_uri: case "/kontakt": form_name = "Allgemein" @@ -152,6 +154,7 @@ match request_uri: case "/computer-beantragen/organisation": form_name = "Computerantrag (Organisation)" + form_group = "csw-Anfragen" ticket_details["Organisation"] = get_form_value("organization") ticket_details["Adresse"] = get_form_value("addressline") ticket_details["PLZ"] = get_form_value("postalcode") @@ -162,6 +165,7 @@ match request_uri: case "/computer-beantragen/privat": form_name = "Computerantrag (privat)" + form_group = "csw-Anfragen" ticket_details["Adresse"] = get_form_value("addressline") ticket_details["PLZ"] = get_form_value("postalcode") ticket_details["Stadt"] = get_form_value("city") @@ -172,11 +176,13 @@ match request_uri: case "/hardware-spenden/organisation": form_name = "Hardwarespende (Organisation)" + form_group = "csw-Hardwarespenden" ticket_details["Organisation"] = get_form_value("organization") attachment = get_form_value("inventory", cast=bytes) case "/hardware-spenden/privat/laptop": form_name = "Laptopspende (privat)" + form_group = "csw-Hardwarespenden" ticket_details["Gerätedetails"] = get_form_value("device") case _: @@ -186,10 +192,12 @@ match request_uri: 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_TOKEN = os.environ.get("ZAMMAD_TOKEN", "") -ZAMMAD_GROUP = os.environ.get("ZAMMAD_GROUP", "") session = requests.Session() session.headers.update(Authorization=f"Token token={ZAMMAD_TOKEN}") @@ -199,7 +207,7 @@ try: f"{ZAMMAD_URL}/api/v1/tickets", json=dict( title=f"Kontaktformular {contact_name} – {form_name}", - group=ZAMMAD_GROUP, + group=form_group, customer_id=f"guess:{contact_email}", article=dict( type="web", diff --git a/flake.nix b/flake.nix index eaa58f1..8671177 100644 --- a/flake.nix +++ b/flake.nix @@ -59,7 +59,7 @@ # We need to provide these default variables because otherwise # lighttpd doesn't even parse its configuration file: "ZAMMAD_URL=https://ticket.z31.it" - "ZAMMAD_GROUP=testgruppe" + "ZAMMAD_GROUP=" ]; ExposedPorts = { "80/tcp" = {};