Skip to main content

Django middleware for when you want your fonts to get freaky.

Project description

Freaky Funky Fonts Middleware (Django)

For when you feel the funk that freaks you fonts

What it this?

Freaky Funky Fonts Middleware is essentially a Django “font chaos” middleware package with configurable behaviour.

It intercespts the html of Djangos reponses, and applies random fonts to each and every peice of text in html documents.

Usage

  • Install the package.
  • Apply the middleare in your Django project settings as middleware.
  • (Optional but recommended) Configure in your freakyfunkyfonts.toml (or .ini for versions before python 3.11).

Installing

pip install django-freakyfunkyfonts

Applying

In the project settings

MIDDLEWARE = [
    # ...
    "freakyfunkyfonts.middleware.FreakyFunkyFontsMiddleware",
]

Configs

Example:

[fonts]
# List of fonts to randomly pick from
pool = [
  "Times New Roman",
  "Georgia",
  "Merriweather",
  "Lora"
]

[inject]
# Extra tags to inject into <head> (Like a link tag to google fonts)
# More than one tag can be applied, just append to the list
# Make sure that the fonts in the pool are convered
tags = [
  '<link href="https://fonts.googleapis.com/css2?family=Merriweather&family=Lora&display=swap" rel="stylesheet">'
]

[behaviour]
# Scopes to operate on: "all" (If it should work on the whole html document), "body", or any tag names (article, main)
scopes = ["body", "article", "main"]

# HTML tags to skip completely
skip_tags = ['head', 'title', 'meta', 'link', 'style', 'script'] 

[date_ranges]
# List of date ranges with optional time ranges
# You can use full dates (YYYY-MM-DD:YYYY-MM-DD) or year-agnostic month-day ranges (MM-DD:MM-DD)
# A range "2025-12-24:2025-12-26" will apply on December 24, 25, and 26. 
# The same applies to month-day ranges like "12-24:12-26".
include = [
  { range = "2025-10-01:2025-10-10", temporal = ["08:00-18:00"] },
  { range = "2025-12-24:2025-12-26", temporal = ["00:00-23:59"] },
  { range = "12-24:12-26", temporal = ["00:00-23:59"] } # applies every year
]
exclude = [
  { range = "2025-12-31:2026-01-01", temporal = ["00:00-23:59"] }
]

# The middleware will only apply during the included date/time ranges, and will be skipped during excluded ranges.
# If no temporal is specified, the range applies for the whole day
# If no ranges are defined, the middleware is always applied
# You can use MM-DD:MM-DD for recurring yearly ranges.

[paths]
# URL path patterns (RegEx) to include or exclude
include = ["^/funky/", "^/blog/"]
exclude = ["^/admin/", "^/api/"]

# The middleware will only apply to included paths and will be skipped for excluded paths.
# If no paths are defined, the middleware is applied to all URLs.

Dev

Installing

pip install -e .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_freakyfunkyfonts-1.4.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_freakyfunkyfonts-1.4.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file django_freakyfunkyfonts-1.4.0.tar.gz.

File metadata

  • Download URL: django_freakyfunkyfonts-1.4.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for django_freakyfunkyfonts-1.4.0.tar.gz
Algorithm Hash digest
SHA256 9bf4480909051051fb4903770112766c1dbf4ac9f5e358d969e8948a9c360ff4
MD5 669d4c3add73f1b6d876903a5d782415
BLAKE2b-256 65edc68f0bdff4ee26b8f40bd97924261ee5fa21419e22818e87c9fce8226ff2

See more details on using hashes here.

File details

Details for the file django_freakyfunkyfonts-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_freakyfunkyfonts-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cee83168db517a6eaa625af61d12936f8a06ad2ed39bbd5407e0bbb79d90c056
MD5 80e50770b09c83d862911f5fe9388ebe
BLAKE2b-256 ebdda586405a76b59b30e7f9200c69b677ef1d81fdcf2f297c1339473294f2d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page