Extra context variables

This commit is contained in:
Martin Mahner 2019-12-07 17:04:44 +01:00
parent 101060e6e5
commit 3de7837ac2
6 changed files with 24 additions and 4 deletions

View File

@ -26,6 +26,15 @@ class dpasteAppConfig(AppConfig):
# """
EXTRA_HEAD_HTML = ""
# HTML content injected in the About page
EXTRA_POST_ABOUT = ""
# HTML content injeted after the "New snippet" form
EXTRA_POST_NEW =""
# HTML content injected at the end of every form
EXTRA_POST_FORM = ""
# Integer. Length of the random slug for each new snippet. In the rare
# case an existing slug is generated again, the length will increase by
# one more character.
@ -629,4 +638,7 @@ class dpasteAppConfig(AppConfig):
return {
"dpaste_application_name": self.APPLICATION_NAME,
"dpaste_extra_head_html": mark_safe(self.EXTRA_HEAD_HTML),
"dpaste_extra_post_about": mark_safe(self.EXTRA_POST_ABOUT),
"dpaste_extra_post_new": mark_safe(self.EXTRA_POST_NEW),
"dpaste_extra_post_form": mark_safe(self.EXTRA_POST_FORM),
}

View File

@ -102,8 +102,11 @@ DATABASES = {
# add that webserver right away.
try:
import django_webserver
INSTALLED_APPS.append('django_webserver')
sys.stdout.write(f'\n🚀 Production webserver installed. Will run on port {env("PORT")}\n')
INSTALLED_APPS.append("django_webserver")
sys.stdout.write(
f'\n🚀 Production webserver installed. Will run on port {env("PORT")}\n'
)
except ImportError:
pass

View File

@ -1,6 +1,7 @@
"""
Settings for the testsuite runs.
"""
import django
from .base import * # noqa
SECRET_KEY = "test-key"
@ -11,6 +12,5 @@ DATABASES = {
# Drop CSP middleware for Django 3.0 until it was fixed upstream
# https://github.com/mozilla/django-csp/issues/129
import django
if django.get_version().startswith("3."):
MIDDLEWARE.remove("csp.middleware.CSPMiddleware")

View File

@ -20,5 +20,7 @@
<a href="https://github.com/bartTC/dpaste">on Github</a>.
</p>
{{ dpaste_extra_post_about }}
</article>
{% endblock %}

View File

@ -31,10 +31,12 @@
</button>
</p>
</div>
<p class="content superenter {% if not object %}autofocus{% endif %} {% if form.content.errors %}error{% endif %}">
<label for="{{ form.content.auto_id }}">{% trans "Content" %}</label>
{{ form.content }}
</p>
{{ dpaste_extra_post_form }}
</form>

View File

@ -11,4 +11,5 @@
{% block page %}
{% include "dpaste/includes/form.html" %}
{{ dpaste_extra_post_new }}
{% endblock %}