Metadata-Version: 2.4
Name: django-freakyfunkyfonts
Version: 1.4.1
Summary: Django middleware for when you want your fonts to get freaky.
Author: Naitsabot
License-Expression: MIT
Project-URL: Homepage, https://github.com/Naitsabot/django-freakyfunkyfonts
Project-URL: Source, https://github.com/Naitsabot/django-freakyfunkyfonts
Project-URL: Issues, https://github.com/Naitsabot/django-freakyfunkyfonts/issues
Keywords: django,middleware,fonts,html
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENCE
Requires-Dist: beautifulsoup4>=4.13.5
Dynamic: license-file

# 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

```bash
pip install django-freakyfunkyfonts
```

### Applying

In the project settings

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

### Configs

Example: 

```toml
[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

```bash
pip install -e .
```
