mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-29 09:33:54 +01:00
Move preview_settings to wagtail_config template tag
This commit is contained in:
parent
ff8a33733c
commit
87e868d315
@ -9,11 +9,6 @@ function initPreview() {
|
||||
// Preview side panel is not shown if the object does not have any preview modes
|
||||
if (!previewSidePanel) return;
|
||||
|
||||
// Get settings from the preview_settings template tag
|
||||
const settings = JSON.parse(
|
||||
document.getElementById('wagtail-preview-settings').textContent,
|
||||
);
|
||||
|
||||
// The previewSidePanel is a generic container for side panels,
|
||||
// the content of the preview panel itself is in a child element
|
||||
const previewPanel = previewSidePanel.querySelector('[data-preview-panel]');
|
||||
@ -218,7 +213,7 @@ function initPreview() {
|
||||
refreshButton.addEventListener('click', handlePreview);
|
||||
}
|
||||
|
||||
if (settings.WAGTAIL_AUTO_UPDATE_PREVIEW) {
|
||||
if (WAGTAIL_CONFIG.WAGTAIL_AUTO_UPDATE_PREVIEW) {
|
||||
let oldPayload = new URLSearchParams(new FormData(form)).toString();
|
||||
let updateInterval;
|
||||
|
||||
@ -244,7 +239,7 @@ function initPreview() {
|
||||
// Only set the interval while the panel is shown
|
||||
updateInterval = setInterval(
|
||||
checkAndUpdatePreview,
|
||||
settings.WAGTAIL_AUTO_UPDATE_PREVIEW_INTERVAL,
|
||||
WAGTAIL_CONFIG.WAGTAIL_AUTO_UPDATE_PREVIEW_INTERVAL,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
|
||||
{% preview_settings as settings %}
|
||||
{{ settings|json_script:"wagtail-preview-settings" }}
|
||||
{% wagtail_config as settings %}
|
||||
|
||||
<div class="preview-panel preview-panel--mobile" data-preview-panel data-action="{{ preview_url }}">
|
||||
<div class="preview-panel__sizes">
|
||||
|
@ -863,19 +863,6 @@ def get_comments_enabled():
|
||||
return getattr(settings, "WAGTAILADMIN_COMMENTS_ENABLED", True)
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def preview_settings():
|
||||
default_options = {
|
||||
"WAGTAIL_AUTO_UPDATE_PREVIEW": True,
|
||||
"WAGTAIL_AUTO_UPDATE_PREVIEW_INTERVAL": 500,
|
||||
}
|
||||
|
||||
return {
|
||||
option: getattr(settings, option, default)
|
||||
for option, default in default_options.items()
|
||||
}
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def wagtail_config(context):
|
||||
request = context["request"]
|
||||
@ -889,6 +876,17 @@ def wagtail_config(context):
|
||||
},
|
||||
}
|
||||
|
||||
default_settings = {
|
||||
"WAGTAIL_AUTO_UPDATE_PREVIEW": True,
|
||||
"WAGTAIL_AUTO_UPDATE_PREVIEW_INTERVAL": 500,
|
||||
}
|
||||
config.update(
|
||||
{
|
||||
option: getattr(settings, option, default)
|
||||
for option, default in default_settings.items()
|
||||
}
|
||||
)
|
||||
|
||||
return config
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user