Skip to main content

Provide a view for serving and updating books created with mdBook

Project description

Provides a simple view for mdBooks, allowing them to exist within a Django site. Note that because all requests are proxied through the MdBookView, it will be a bit slower than using Apache or Nginx directly; however, using a Django view allows fine-grained access control.

Example use:

import os.path

from django.contrib.auth.decorators import permission_required
from django.urls import path
from django.views.generic import RedirectView

from django_mdbook.views import MdBookView

directory = os.path.dirname(__file__)

def rel_to_abs(path: str) -> str:
    Given a path relative to this file, give its absolute name
    :param path: a relative path to resolve
    :return: an absolute path
    return os.path.join(directory, path)

urlpatterns = [
        RedirectView.as_view(url='index.html', permanent=True),
            # Note: book_root is the directory with book.toml, not the built directory

Project details

Download files

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

Files for django-mdbook, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size django_mdbook-0.2.0-py3-none-any.whl (3.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-mdbook-0.2.0.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page