Add signals global_html_head, global_html_page_header, and global_html_footer

This commit is contained in:
Raphael Michel
2020-07-29 18:29:44 +02:00
parent 80b6a3d27d
commit 4c77e2f16e
3 changed files with 46 additions and 2 deletions

View File

@@ -12,7 +12,10 @@ from pretix.helpers.i18n import (
get_javascript_format_without_seconds, get_moment_locale,
)
from .signals import footer_link, html_footer, html_head, html_page_header
from .signals import (
footer_link, global_html_footer, global_html_head, global_html_page_header,
html_footer, html_head, html_page_header,
)
logger = logging.getLogger(__name__)
@@ -56,12 +59,18 @@ def _default_context(request):
ctx['footer_text'] = str(text)
if hasattr(request, 'event') and get_scope():
for receiver, response in global_html_head.send(None, request=request):
_html_head.append(response)
for receiver, response in html_head.send(request.event, request=request):
_html_head.append(response)
for receiver, response in global_html_page_header.send(None, request=request):
_html_page_header.append(response)
for receiver, response in html_page_header.send(request.event, request=request):
_html_page_header.append(response)
for receiver, response in html_footer.send(request.event, request=request):
_html_foot.append(response)
for receiver, response in global_html_footer.send(None, request=request):
_html_foot.append(response)
for receiver, response in footer_link.send(request.event, request=request):
if isinstance(response, list):
_footer += response

View File

@@ -1,5 +1,40 @@
from django.dispatch import Signal
from pretix.base.signals import EventPluginSignal
global_html_head = Signal(
providing_args=["request"]
)
"""
This signal allows you to put code inside the HTML ``<head>`` tag
of every page in the frontend. You will get the request as the keyword argument
``request`` and are expected to return plain HTML.
This signal is called regardless of whether your plugin is active for all pages of the system.
"""
global_html_page_header = Signal(
providing_args=["request"]
)
"""
This signal allows you to put code right in the beginning of the HTML ``<body>`` tag
of every page in the frontend. You will get the request as the keyword argument
``request`` and are expected to return plain HTML.
This signal is called regardless of whether your plugin is active for all pages of the system.
"""
global_html_footer = Signal(
providing_args=["request"]
)
"""
This signal allows you to put code before the end of the HTML ``<body>`` tag
of every page in the frontend. You will get the request as the keyword argument
``request`` and are expected to return plain HTML.
This signal is called regardless of whether your plugin is active for all pages of the system.
"""
html_head = EventPluginSignal(
providing_args=["request"]
)