moved custom Markdown pages to configurable directory.
This commit is contained in:
parent
79bc9a92be
commit
2f0db972de
4 changed files with 21 additions and 3 deletions
14
README.md
14
README.md
|
|
@ -78,6 +78,16 @@ Create a superuser account
|
|||
|
||||
```
|
||||
|
||||
## Custom pages
|
||||
|
||||
Some pages are specific to your installation. E.g. an imprint.
|
||||
|
||||
Those files are markdown files that are rendered as HTML. You have to supply them and put them into the `MARKDOWN_PAGE_DIR`.
|
||||
|
||||
The following files are expected:
|
||||
|
||||
* `imprint.md` with your imprint information.
|
||||
|
||||
## Settings
|
||||
|
||||
### BACKUP_USER
|
||||
|
|
@ -120,3 +130,7 @@ The secret key used by django for session cookies and other things.
|
|||
### DEBUG
|
||||
|
||||
Django debug setting.
|
||||
|
||||
### MARKDOWN_PAGE_DIR
|
||||
|
||||
`MARKDOWN_PAGE_DIR` is the directory where customized markdown files are put. This directory is required.
|
||||
|
|
|
|||
|
|
@ -19,3 +19,5 @@ SECRET_KEY = "change me!"
|
|||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
# DEBUG = True
|
||||
|
||||
MARKDOWN_PAGE_DIR = Path("./custom_md/")
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ try:
|
|||
assert module.BACKUP_AUTHORIZED_KEYS, (
|
||||
"The BACKUP_AUTHORIZED_KEYS setting is required."
|
||||
)
|
||||
assert module.MARKDOWN_PAGE_DIR, "The MARKDOWN_PAGE_DIR setting is required."
|
||||
|
||||
except ModuleNotFoundError:
|
||||
print(f"could not find configuration file {config_module}")
|
||||
|
|
@ -142,5 +143,6 @@ BACKUP_BORG_DIR = module.BACKUP_BORG_DIR
|
|||
BACKUP_AUTHORIZED_KEYS = module.BACKUP_AUTHORIZED_KEYS
|
||||
DATABASES = module.DATABASES
|
||||
SECRET_KEY = module.SECRET_KEY
|
||||
MARKDOWN_PAGE_DIR = module.MARKDOWN_PAGE_DIR
|
||||
|
||||
DEBUG = getattr(module, "DEBUG", False)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,12 @@ from django.shortcuts import get_object_or_404
|
|||
from django.views.generic.base import TemplateView
|
||||
from django.views.generic import ListView, FormView
|
||||
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
||||
from django.conf import settings
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.forms import BaseUserCreationForm
|
||||
from django.contrib.auth.mixins import UserPassesTestMixin, LoginRequiredMixin
|
||||
|
||||
from django.template.loader import get_template
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
import markdown2
|
||||
|
||||
|
|
@ -36,7 +35,8 @@ class MarkdownView(TemplateView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
source = get_template(self.md).template.source
|
||||
|
||||
source = (settings.MARKDOWN_PAGE_DIR / self.md).read_text()
|
||||
context["markdown_content"] = markdown2.markdown(source)
|
||||
return context
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue