mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Add signals html_page_header, sass_preamble, sass_postamble
This commit is contained in:
@@ -8,7 +8,7 @@ from pretix.helpers.i18n import (
|
||||
get_javascript_format_without_seconds, get_moment_locale,
|
||||
)
|
||||
|
||||
from .signals import footer_link, html_footer, html_head
|
||||
from .signals import footer_link, html_footer, html_head, html_page_header
|
||||
|
||||
|
||||
def contextprocessor(request):
|
||||
@@ -23,6 +23,7 @@ def contextprocessor(request):
|
||||
'DEBUG': settings.DEBUG,
|
||||
}
|
||||
_html_head = []
|
||||
_html_page_header = []
|
||||
_html_foot = []
|
||||
_footer = []
|
||||
|
||||
@@ -45,6 +46,8 @@ def contextprocessor(request):
|
||||
if hasattr(request, 'event'):
|
||||
for receiver, response in html_head.send(request.event, request=request):
|
||||
_html_head.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 footer_link.send(request.event, request=request):
|
||||
@@ -71,6 +74,7 @@ def contextprocessor(request):
|
||||
|
||||
ctx['html_head'] = "".join(_html_head)
|
||||
ctx['html_foot'] = "".join(_html_foot)
|
||||
ctx['html_page_header'] = "".join(_html_page_header)
|
||||
ctx['footer'] = _footer
|
||||
ctx['site_url'] = settings.SITE_URL
|
||||
|
||||
|
||||
@@ -11,6 +11,17 @@ of every page in the frontend. You will get the request as the keyword argument
|
||||
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
||||
"""
|
||||
|
||||
html_page_header = EventPluginSignal(
|
||||
providing_args=["request"]
|
||||
)
|
||||
"""
|
||||
This signal allows you to put code right in the beginnong 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.
|
||||
|
||||
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
||||
"""
|
||||
|
||||
html_footer = EventPluginSignal(
|
||||
providing_args=["request"]
|
||||
)
|
||||
@@ -22,6 +33,33 @@ of every page in the frontend. You will get the request as the keyword argument
|
||||
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
||||
"""
|
||||
|
||||
sass_preamble = EventPluginSignal(
|
||||
providing_args=["filename"]
|
||||
)
|
||||
"""
|
||||
This signal allows you to put SASS code at the beginning of the event-specific
|
||||
stylesheet. Keep in mind that this will only be called/rebuilt when the user changes
|
||||
display settings or pretix gets updated. You will get the filename that is being
|
||||
generated (usually "main.scss" or "widget.scss"). This SASS code will be loaded *after*
|
||||
setting of user-defined variables like colors and fonts but *before* pretix' SASS
|
||||
code.
|
||||
|
||||
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
||||
"""
|
||||
|
||||
sass_postamble = EventPluginSignal(
|
||||
providing_args=["filename"]
|
||||
)
|
||||
"""
|
||||
This signal allows you to put SASS code at the end of the event-specific
|
||||
stylesheet. Keep in mind that this will only be called/rebuilt when the user changes
|
||||
display settings or pretix gets updated. You will get the filename that is being
|
||||
generated (usually "main.scss" or "widget.scss"). This SASS code will be loaded *after*
|
||||
all of pretix' SASS code.
|
||||
|
||||
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
||||
"""
|
||||
|
||||
footer_link = EventPluginSignal(
|
||||
providing_args=["request"]
|
||||
)
|
||||
|
||||
@@ -16,6 +16,7 @@ from pretix.base.models import Event, Event_SettingsStore, Organizer
|
||||
from pretix.base.services.tasks import ProfiledTask
|
||||
from pretix.celery_app import app
|
||||
from pretix.multidomain.urlreverse import get_domain
|
||||
from pretix.presale.signals import sass_postamble, sass_preamble
|
||||
|
||||
logger = logging.getLogger('pretix.presale.style')
|
||||
affected_keys = ['primary_font', 'primary_color']
|
||||
@@ -54,8 +55,16 @@ def compile_scss(object, file="main.scss", fonts=True):
|
||||
font
|
||||
))
|
||||
|
||||
if isinstance(object, Event):
|
||||
for recv, resp in sass_preamble.send(object, filename=file):
|
||||
sassrules.append(resp)
|
||||
|
||||
sassrules.append('@import "{}";'.format(file))
|
||||
|
||||
if isinstance(object, Event):
|
||||
for recv, resp in sass_postamble.send(object, filename=file):
|
||||
sassrules.append(resp)
|
||||
|
||||
cf = dict(django_libsass.CUSTOM_FUNCTIONS)
|
||||
cf['static'] = static
|
||||
css = sass.compile(
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
<meta name="theme-color" content="{{ settings.primary_color|default:"#3b1c4a" }}">
|
||||
</head>
|
||||
<body class="nojs" data-locale="{{ request.LANGUAGE_CODE }}" data-now="{% now "U.u" %}" data-datetimeformat="{{ js_datetime_format }}" data-timeformat="{{ js_time_format }}" data-dateformat="{{ js_date_format }}" data-datetimelocale="{{ js_locale }}">
|
||||
{{ html_page_header|safe }}
|
||||
{% block above %}
|
||||
{% endblock %}
|
||||
<div class="container">
|
||||
|
||||
Reference in New Issue
Block a user