Django-Spellbook

Version 0.1.11

Released: April 19, 2025

This release brings major architectural improvements, URL prefix customization, and enhanced error handling, making Django Spellbook more robust, flexible, and maintainable.

New Features

Customizable URL Prefixes

You can now customize URL prefixes for your markdown content, both for single and multiple source configurations:

# Single source with custom URL prefix
SPELLBOOK_MD_PATH = BASE_DIR / "docs"
SPELLBOOK_MD_APP = "docs_app"
SPELLBOOK_MD_URL_PREFIX = "documentation"  # Content at /documentation/
# Multiple sources with custom URL prefixes
SPELLBOOK_MD_PATH = [BASE_DIR / "docs", BASE_DIR / "blog"]
SPELLBOOK_MD_APP = ["docs_app", "blog_app"]
SPELLBOOK_MD_URL_PREFIX = ["docs", "articles"]  # At /docs/ and /articles/

If no URL prefix is specified:

  • Single app configurations use an empty prefix (root URL)
  • Multiple app configurations give the first app an empty prefix, and use app names for others

Enhanced Error Handling

The command now provides better error messages and diagnostic information when things go wrong:

  • Clear identification of the source of errors (settings, file discovery, processing)
  • Helpful suggestions for resolving common issues
  • Improved logging of error details
  • New --continue-on-error flag to process as many files as possible even when some fail

Architecture Improvements

Modular Command Structure

The spellbook_md command has been refactored into a modular architecture:

django_spellbook/
├── management/
│   ├── commands/
│   │   ├── command_utils.py          # Shared utilities
│   │   ├── spellbook_md.py           # Main command
│   │   └── spellbook_md_p/           # Command components
│   │       ├── processor.py          # Markdown processing
│   │       ├── discovery.py          # File/block discovery
│   │       └── exceptions.py         # Specialized exceptions

Benefits of this new architecture:

  • Improved maintainability with focused modules
  • Better testability with clear component boundaries
  • Easier extensibility for future features
  • Enhanced error handling and reporting

Customizable Base Templates Per Source

You can now specify different base templates for each markdown source, allowing for tailored layouts across your content:

# Single source with custom base template
SPELLBOOK_MD_PATH = BASE_DIR / "docs"
SPELLBOOK_MD_APP = "docs_app"
SPELLBOOK_MD_BASE_TEMPLATE = "docs/base.html"  # Custom base template
# Multiple sources with different base templates
SPELLBOOK_MD_PATH = [BASE_DIR / "docs", BASE_DIR / "blog"]
SPELLBOOK_MD_APP = ["docs_app", "blog_app"]
SPELLBOOK_MD_BASE_TEMPLATE = ["docs/base.html", "blog/base.html"]  # Different templates

If a single base template is provided with multiple sources, it will be applied to all sources:

# Shared base template across multiple sources
SPELLBOOK_MD_PATH = [BASE_DIR / "docs", BASE_DIR / "blog"]
SPELLBOOK_MD_APP = ["docs_app", "blog_app"]
SPELLBOOK_MD_BASE_TEMPLATE = "shared_base.html"  # Same template for all sources

If no base template is specified (or set to None), the default behavior remains unchanged:

# Default template behavior
SPELLBOOK_MD_PATH = [BASE_DIR / "docs", BASE_DIR / "blog"]
SPELLBOOK_MD_APP = ["docs_app", "blog_app"]
SPELLBOOK_MD_BASE_TEMPLATE = None  # Default template for all sources

Enhanced Template Validation

The template system now includes improved validation:

  • Verification that base template configurations match source configurations
  • Path validation to prevent template path traversal vulnerabilities
  • Helpful error messages for template-related configuration issues

Summary Report Generation

The command now produces a comprehensive summary after processing:

  • Total files processed across all sources
  • Success rate for each source-destination pair
  • Detailed information about any failures
  • Processing statistics
ℹ️

We're committed to continuous improvement. If you have feedback or feature requests for future versions, please open an issue on GitHub.