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 = [
    path('doc/foo/',
        RedirectView.as_view(url='index.html', permanent=True),
        name='foo_doc_index'),
    path('doc/foo/<path:path>',
        permission_required('doc.foo_documentation')(
            # Note: book_root is the directory with book.toml, not the built directory
            MdBookView.as_view(book_root=rel_to_abs('foo'))),
        name='foo_docs')
]

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-mdbook-0.1.0.tar.gz (2.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_mdbook-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file django-mdbook-0.1.0.tar.gz.

File metadata

  • Download URL: django-mdbook-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

File hashes

Hashes for django-mdbook-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a83b8f03613fdd6ef6663a3fbf249f51ae8bb81f6d3ac15bf2408c653a80ecb
MD5 aecdb2019667829ae6909d361a2d94c3
BLAKE2b-256 74b61a3834c358456727fe6b12be66c54228f4addafe94e5f63e8189513c9025

See more details on using hashes here.

File details

Details for the file django_mdbook-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_mdbook-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

File hashes

Hashes for django_mdbook-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5e58f4bcba1f9ed5e8f14d90dbfc25d55ea6369e74f025a7012df66254a3d0b
MD5 ee61fbad16fcc68a6ed206ff965dd0fa
BLAKE2b-256 987282e3fabfacb3d6084c5873c7b60fb651b3ec4b32f4ef9b2f0092e345b021

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