diff --git a/doc/development/api/general.rst b/doc/development/api/general.rst index 72bcba527..d16c8541d 100644 --- a/doc/development/api/general.rst +++ b/doc/development/api/general.rst @@ -33,7 +33,7 @@ Frontend -------- .. automodule:: pretix.presale.signals - :members: html_head, html_footer, footer_link, front_page_top, front_page_bottom, front_page_bottom_widget, fee_calculation_for_cart, contact_form_fields, question_form_fields, checkout_confirm_messages, checkout_confirm_page_content, checkout_all_optional, html_page_header, sass_preamble, sass_postamble, render_seating_plan, checkout_flow_steps, position_info, position_info_top, item_description + :members: html_head, html_footer, footer_link, front_page_top, front_page_bottom, front_page_bottom_widget, fee_calculation_for_cart, contact_form_fields, question_form_fields, checkout_confirm_messages, checkout_confirm_page_content, checkout_all_optional, html_page_header, sass_preamble, sass_postamble, render_seating_plan, checkout_flow_steps, position_info, position_info_top, item_description, global_html_head, globla_html_footer, global_html_page_header .. automodule:: pretix.presale.signals diff --git a/src/pretix/presale/context.py b/src/pretix/presale/context.py index d40977360..77e7ea2b7 100644 --- a/src/pretix/presale/context.py +++ b/src/pretix/presale/context.py @@ -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 diff --git a/src/pretix/presale/signals.py b/src/pretix/presale/signals.py index b352223a4..eba269aea 100644 --- a/src/pretix/presale/signals.py +++ b/src/pretix/presale/signals.py @@ -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 ```` 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 ```` 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 ```` 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"] )