pig.py/serp/utils.py
Russell Ballestrini 7fff500f2f CSS-only side quests: no JS, pure delight
Interactions via CSS animations and SVG:
- Hover logo: 🐷 appears, click: oink!
- Hover body: 'grow food not lawn' rises from below
- Print stylesheet: Sign Maker approves
- Spider descends from nav on hover
- About page: spider-pig SVG descends on hero hover
- Sign Maker's mark ☉ at page end - spins on hover
- ::selection styled in brand colors

Side quest comments scattered: 1/21, 2/21, 3/21...

No JavaScript easter eggs. CSS only. The way it should be.
2026-01-05 20:31:29 -05:00

17 lines
552 B
Python

"""Utility functions for SERP.
# Side quest 2/21: Can he swing from a web? No he can't, he's a pig.
"""
import re
import unicodedata
def slugify(text: str, max_len: int = 60) -> str:
"""Convert text to a safe filename slug."""
# Normalize unicode
text = unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('ascii')
# Lowercase and replace spaces/special chars with hyphens
text = re.sub(r'[^\w\s-]', '', text.lower())
text = re.sub(r'[-\s]+', '-', text).strip('-')
return text[:max_len] if text else ""