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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-mdbook-0.2.0.tar.gz.
File metadata
- Download URL: django-mdbook-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e5b7811ff5b3fe5599c1b40c9e4b775f2ad9d861bbea01547c7ca86dffdd238
|
|
| MD5 |
e98ce3f2b2b5326ea76192d5ac286689
|
|
| BLAKE2b-256 |
06975c7a8413d4db33d1c7975418bd3ff3026119e1d679861e2a879dbff46462
|
File details
Details for the file django_mdbook-0.2.0-py3-none-any.whl.
File metadata
- Download URL: django_mdbook-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e039dc8f72d8ffc0c1cf2a99db5547cb8e2c3c750d22c140d07c9c7c44a9f8b
|
|
| MD5 |
0ceefdecff5b4b9a0a9e3e634113b0fd
|
|
| BLAKE2b-256 |
fc8d57031d866ea1ca064565b7ce8a9861485444d56015cc096c148dcb8cc215
|