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
Release history Release notifications | RSS feed
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.0.1.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for django_mdbook-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 366c6704f69c54b9bfe9a00f938d5787eb0a52dc8167dafb02a910a93be46cc2 |
|
MD5 | 15c9e1cf6caf61c5a70a63ebb45b477c |
|
BLAKE2b-256 | a270139b41574072c32d64bcc1db9cb2fa92dcbe0b0391bc627f1e0fc600b262 |