Generate your chaos badges today!
  • Python 83.5%
  • HTML 10.9%
  • CSS 5.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-08 16:39:01 +01:00
events/jetzt14 fix missing role text 2026-11-08 16:39:01 +01:00
scripts initial commit 2026-11-08 15:59:47 +01:00
static initial commit 2026-11-08 15:59:47 +01:00
templates initial commit 2026-11-08 15:59:47 +01:00
.gitignore initial commit 2026-11-08 15:59:47 +01:00
.python-version initial commit 2026-11-08 15:59:47 +01:00
badgeconfig.py initial commit 2026-11-08 15:59:47 +01:00
LICENSE add license 2026-11-08 16:22:47 +01:00
lucon.ttf initial commit 2026-11-08 15:59:47 +01:00
main.py make it runnable properly 2026-11-08 16:22:10 +01:00
pyproject.toml make it runnable properly 2026-11-08 16:22:10 +01:00
README.md make it runnable properly 2026-11-08 16:22:10 +01:00
render.py initial commit 2026-11-08 15:59:47 +01:00
start.sh make it runnable properly 2026-11-08 16:22:10 +01:00

ChaosBadger

Generates event badges from Photoshop templates.

uv run main.py                                   # production (Waitress), http://127.0.0.1:9400
uv run flask --app main run --debug --port 9400  # development, auto-reloads on changes

HOST and PORT environment variables override the defaults. Set HOST=0.0.0.0 to accept connections from other machines, or keep 127.0.0.1 and put a reverse proxy (nginx, Caddy) in front.

URLs are /<event-slug>/<badge-slug>. /<event-slug> redirects to the event's first badge.

Adding an event

Each event is a folder under events/. The folder name is the event slug.

events/
  my-event/
    event.toml
    attendee.psd
    speaker.psd
    fonts/
      Brand-Bold.otf

Templates (PSD)

  • The canvas size is the output size. Wider than tall = horizontal badge, taller than wide = vertical badge. There's no other orientation setting.
  • Every text field has a placeholder layer, named after the field key or set with layer = "...". There are two kinds:
    • Point-text layer (the usual Photoshop text tool): the value is drawn on the same baseline and anchor point, aligned the same way (left, center or right) as in Photoshop. Set max_width so the app knows how far the text may extend before it has to shrink.
    • Any other layer (a rectangle, a pixel layer, paragraph text): its bounds are a box the text is fitted into, using align and valign.
  • Placeholder layers are never drawn. Everything else visible in the PSD is the badge artwork.
  • Placeholder layer names must be unique within the PSD. Groups are never placeholders, so a group may share a field's layer name.
  • Text that's part of the artwork but must change per language or badge type (box labels, the role) can be a placeholder too, filled with a fixed text.
  • Fonts aren't read from the PSD. Copy size, tracking and colour from Photoshop's Character panel into the config. Sizes are in pixels; this matched Photoshop exactly for the jetzt14 template.

event.toml

name = "My Event 2026"     # shown in the dropdown as "name (short_name)"
short_name = "ME26"        # optional; without it the dropdown shows just the name

[fonts]                    # path relative to the event folder, or a system font file
heading = "fonts/Brand-Bold.otf"
body = "fonts/Brand-Regular.otf"

[styles.name]              # optional reusable styles
font = "heading"
size = 140
min_size = 60
transform = "upper"

# Badges show in the dropdown in this order; the first is the default.
[badges.attendee]
name = "Attendee"
template = "attendee.psd"  # optional, defaults to "<slug>.psd"
fields = [
  { key = "name", style = "name", required = true },
  { key = "company", font = "body", size = 64, color = "#4a5568" },
]

Several badge types on one template

Put the template and fields in a [layouts.x] table and point badges at it. A field with text isn't shown on the form. {badge} in it becomes the badge type's name, and {event} the event name:

[layouts.main]
template = "badge.psd"
fields = [
  { key = "name", style = "value", required = true },
  { key = "role", style = "value", text = "{badge}" },
]

[badges.attendee]
layout = "main"
name = "Attendee"

[badges.speaker]
layout = "main"
name = "Speaker"

Languages

languages = { en = "English", de = "Deutsch" }   # first is the default

Badge name, field label, default and text can then be either a plain string (same in every language) or a table with every language: name = { en = "Attendee", de = "Teilnehmer*in" }. A missing translation stops the app at startup. Events with more than one language get a Language dropdown, and the language is kept in the URL as ?lang=de.

Field options

Any of these except key, label, layer, box, required, default and text can also live in a [styles.x] table.

key default meaning
key (required) form field name, and the default placeholder layer name
label from key label shown on the form
layer key PSD layer whose bounds are the text box
box none [x, y, width, height] in pixels, used instead of a layer
required false form won't generate without it
text none fixed text instead of a form input. Supports {badge} and {event}
default "" text used when the field is left empty
font (required) key into [fonts]
size 48 font size in template pixels
min_size size shrink toward this to fit. Goes lower only as a last resort, with a warning
color #000000 any CSS-style colour
tracking 0 letter spacing in 1/1000 em, same as Photoshop's tracking
max_width none point-text placeholders only, and required for them: max text width in pixels
align layer's / center left, center, right. Point text defaults to the layer's own alignment
valign middle top, middle, bottom (box placeholders only)
max_lines 1 above 1, text word-wraps
line_spacing 1.15 multiple of font size
transform none upper, lower, title
rotate 0 90, 180, 270, counter-clockwise. Box placeholders only. For vertical text the box is still the layer bounds

Config is checked at startup, so typos fail loudly. Missing placeholder layers are reported the first time that badge is rendered.

Sample templates

The PSDs in events/event-* are throwaway samples generated by uv run scripts/make_sample_templates.py. They use Windows system fonts.