This directory contains maintenance and build utilities for the btdt/ module.
Most utilities in btdt/scripts/ use only Python's standard library and can be
run directly with python3.
The only utility that currently requires a virtual environment is
btdt/scripts/minify.py. Its dependencies are installed in the shared
btdt/scripts/.venv environment so future Python utilities can reuse the same
setup if needed.
Install it with:
python3 -m venv btdt/scripts/.venv
source btdt/scripts/.venv/bin/activate
pip install -r btdt/scripts/requirements.txtAvailable scripts:
add-fonts.pydownload_google_fonts.pyexport-runtime.pyminify.pyminify-allminify-all.pysync-configs.pysync-fonts.py
Utility to export the minimal BTDT runtime asset subset into another directory.
File:
export-runtime.py creates or updates DESTINATION/btdt/ and copies only:
- the project root
README.mdasDESTINATION/btdt/README.md btdt/css/bootstrap.min.cssbtdt/js/bootstrap.bundle.min.jsbtdt/js/btdt.min.jsbtdt/themes/modes/dark.min.cssbtdt/themes/preset/*.min.cssbtdt/fonts/*/*(only fonts used by the selected presets)
It preserves the relative directory structure inside the exported btdt/ folder.
Examples:
# Export all presets and all fonts (full export)
python3 btdt/scripts/export-runtime.py tmp/runtime-export
# Export only specific presets with their required fonts only
python3 btdt/scripts/export-runtime.py tmp/runtime-export --presets nordic-elegance,amber-roar
python3 btdt/scripts/export-runtime.py tmp/runtime-export --presets amber-roar --force
# Dry run to preview what would be copied
python3 btdt/scripts/export-runtime.py tmp/runtime-export --dry-run
python3 btdt/scripts/export-runtime.py tmp/runtime-export --presets amber-roar --dry-run- This script uses only Python's standard library
tmp/is a good default destination for local preview exports because the repo ignores its contents- The destination argument is the parent directory; the script creates
DESTINATION/btdt/ - If
DESTINATION/btdt/already exists, the script does nothing unless--forceis passed - With
--force, existing files in the destination are overwritten only for the exported subset - With
--presets, only the specified presets are exported, and only the fonts they use are included
Utility to download Google Fonts for local hosting with licenses.
File:
download_google_fonts.py downloads individual Google Fonts with all their weights and variants for local hosting. It:
- Fetches font metadata from Google Fonts API
- Downloads all variants (supports variable font ranges like 100..900)
- Saves WOFF2 or TrueType files to
btdt/fonts/[font-slug]/ - Downloads the original OFL license from Google Fonts GitHub repository
- Generates local CSS with @font-face rules
This is typically used when:
- Adding a new font to BTDT for offline/air-gapped environments
- Preparing fonts for production with local file hosting
- Reducing external CDN dependencies
python3 btdt/scripts/download_google_fonts.py "Font Name"Example:
python3 btdt/scripts/download_google_fonts.py "Inter"
python3 btdt/scripts/download_google_fonts.py "Roboto Slab"
python3 btdt/scripts/download_google_fonts.py "Playfair Display"- Fetches CSS from Google Fonts API using variable weight range (100..900)
- Parses @font-face rules for each weight and style
- Downloads font files (WOFF2 or TrueType) from Google Fonts servers
- Saves to
btdt/fonts/[slug]/directory - Downloads OFL license from
github.com/google/fontsrepository - Generates
[slug].csswith local @font-face rules pointing to downloaded files
btdt/fonts/
└── inter/
├── inter-100-normal.woff2
├── inter-400-normal.woff2
├── inter-700-normal.woff2
├── inter.css
└── LICENSE.txt
- This script uses only Python's standard library
- The font name is case-sensitive (use the exact name from Google Fonts)
- Supports both WOFF2 and TrueType formats (detected automatically from CSS)
- Variable font ranges (e.g., 100..900) are expanded to individual weights
- License is downloaded from the official Google Fonts GitHub repository
- If license download fails, a reference file with links is created instead
Utility to synchronize fonts from themes with local font files.
File:
sync-fonts.py scans btdt/themes/fonts/ for font CSS files, checks if corresponding font files exist in btdt/fonts/, and downloads missing fonts using download_google_fonts.py.
This is typically used when:
- Setting up a new development environment
- Synchronizing after adding new fonts to themes
- Updating font files after theme changes
python3 btdt/scripts/sync-fonts.py
python3 btdt/scripts/sync-fonts.py --dry-run- Scans
btdt/themes/fonts/*.cssfor font imports - Supports both old format (Google Fonts CDN) and new format (local files)
- Checks if each font exists in
btdt/fonts/[slug]/ - Downloads missing fonts automatically
- Reports which fonts are already present vs missing
- This script uses only Python's standard library
- Uses
--dry-runto preview what would be downloaded without actually downloading - Automatically imports and uses
download_google_fonts.pyfor downloads - Handles both WOFF2 and TrueType font formats
Utility to add a new font to BTDT system in one step.
File:
add-fonts.py combines downloading font files and creating theme CSS into a single command. It:
- Downloads font files if not already present
- Creates theme CSS file if not already present
- Reports status of each step
This is the recommended way to add new fonts to BTDT.
python3 btdt/scripts/add-fonts.py "Font Name"Example:
python3 btdt/scripts/add-fonts.py "Inter"
python3 btdt/scripts/add-fonts.py "Playfair Display"- Checks if font files exist in
btdt/fonts/[slug]/ - If missing, downloads using
download_google_fonts.py - Checks if theme CSS exists in
btdt/themes/fonts/[slug].css - If missing, creates CSS that imports local font with Bootstrap variable mappings
- Shows next steps (sync-configs.py and minify-all.py)
Adding font: Inter (inter)
✓ Font files already exist: btdt/fonts/inter
✓ Theme CSS already exists: btdt/themes/fonts/inter.css
==================================================
Font added successfully!
Next steps:
1. Run: python3 btdt/scripts/sync-configs.py
2. Run: python3 btdt/scripts/minify-all.py
- This script uses only Python's standard library
- Safe to run multiple times - won't overwrite existing files
- Font name is case-sensitive (use exact name from Google Fonts)
- Automatically imports and uses
download_google_fonts.py
Utility to generate minified assets from source files.
Important
This tool is designed specifically for the BTDT project structure and preset format. It is not intended to be a generic CSS/JS minification or bundling utility.
Files:
minify.py supports two modes:
normal: minifies source.jsand.cssfiles into.min.jsand.min.csspreset: compiles preset CSS files by resolving and embedding their@importdependencies first, then minifies the final bundled result
From the project root:
source btdt/scripts/.venv/bin/activate
pip install -r btdt/scripts/requirements.txtDependencies:
rjsminrcssmin
Run from btdt/scripts/:
source .venv/bin/activate
python minify.py normal <file-or-directory>
python minify.py preset <file-or-directory>Examples:
python btdt/scripts/minify.py normal btdt/js/btdt.js
python btdt/scripts/minify.py normal btdt/themes/styles
python btdt/scripts/minify.py preset btdt/themes/preset/amber-roar.css
python btdt/scripts/minify.py preset btdt/themes/preset- Accepts a single file or a directory
- Processes
.jsand.css - Skips files already ending in
.min.jsor.min.css - Writes minified output next to the source file
- Accepts a single preset CSS file or a directory of preset CSS files
- Only processes
.css - Resolves recursive
@import "..."statements - Embeds imported CSS into one final stylesheet
- Moves any remaining
@importrules to the top of the final stylesheet before minifying - Minifies the bundled result into a
.min.cssfile next to the source preset
- The script skips common non-source directories such as
.git,node_modules,__pycache__, and.venv - In
presetmode, circular imports are detected and reported as an error --helpworks even if dependencies are not installed yetminify-allis the Bash wrapper for running the full BTDT minification passminify-all.pyis the Python wrapper equivalent for running the full BTDT minification pass
Utility to regenerate the BTDT catalog files in btdt/js/ from the actual contents of btdt/themes/.
File:
sync-configs.py rebuilds:
btdt/js/config-colors.jsbtdt/js/config-fonts.jsbtdt/js/config-presets.jsbtdt/js/config-ui.js
It does not rewrite the corresponding .min.js files. Those remain under the minification workflow.
It also emits warnings when it finds mismatches or modules that do not follow the conventions documented in .agents/skills/.
Examples:
python3 btdt/scripts/sync-configs.py
python3 btdt/scripts/sync-configs.py --check- Color modules expose the expected primary, secondary, and accent variables
- Font modules define the required body typography variables
- Presets declare the expected 11 imports and metadata keys
- Style modules follow recognized naming conventions
- Existing config catalogs do not drift away from the files actually present on disk
- This script uses only Python's standard library
--checkvalidates and reports warnings without writing any file- Only the source
config-*.jsfiles are regenerated