From eaaeabb959c107e59825233774aec244813844b1 Mon Sep 17 00:00:00 2001 From: Martin Sanders Date: Fri, 3 Jul 2015 09:19:33 +0100 Subject: [PATCH] Calling block.super in extra_js and extra_css. The specific usecase is if you'd globally like to inject css and js then you can via django overextending `wagtailadmin/base.html`. Why not just use the `insert_editor_js` and `insert_editor_css` hooks? - It isn't global across the admin, only on editor pages. - In my opinion, this stuff shouldn't be in python. Why not overextend `wagtailadmin/admin_base.html`? - Can't use super if you need to insert code after loading vendor libs like jquery, bootstrap etc but before extra_js. So you then have to copy-paste a ton of code from the parent - this goes against the open closed principle and should be avoided. So given the current build process for front end admin/dashboard assets in wagtail, this seems like the best solution for now. --- .../wagtailstyleguide/templates/wagtailstyleguide/base.html | 4 ++++ .../wagtailadmin/account/password_reset/complete.html | 2 ++ .../wagtailadmin/account/password_reset/confirm.html | 2 ++ .../templates/wagtailadmin/account/password_reset/done.html | 2 ++ .../templates/wagtailadmin/account/password_reset/form.html | 2 ++ wagtail/wagtailadmin/templates/wagtailadmin/home.html | 2 ++ wagtail/wagtailadmin/templates/wagtailadmin/login.html | 3 +++ wagtail/wagtailadmin/templates/wagtailadmin/pages/copy.html | 1 + wagtail/wagtailadmin/templates/wagtailadmin/pages/create.html | 2 ++ wagtail/wagtailadmin/templates/wagtailadmin/pages/edit.html | 2 ++ wagtail/wagtailadmin/templates/wagtailadmin/pages/index.html | 2 ++ wagtail/wagtailadmin/templates/wagtailadmin/pages/search.html | 2 ++ wagtail/wagtaildocs/templates/wagtaildocs/documents/add.html | 2 ++ wagtail/wagtaildocs/templates/wagtaildocs/documents/edit.html | 2 ++ .../wagtaildocs/templates/wagtaildocs/documents/index.html | 1 + .../templates/wagtailforms/index_submissions.html | 1 + wagtail/wagtailimages/templates/wagtailimages/images/add.html | 2 ++ .../wagtailimages/templates/wagtailimages/images/edit.html | 4 ++++ .../wagtailimages/templates/wagtailimages/images/index.html | 1 + .../templates/wagtailimages/images/url_generator.html | 3 ++- .../wagtailimages/templates/wagtailimages/multiple/add.html | 4 ++++ wagtail/wagtailredirects/templates/wagtailredirects/add.html | 3 ++- wagtail/wagtailredirects/templates/wagtailredirects/edit.html | 3 ++- .../wagtailredirects/templates/wagtailredirects/index.html | 1 + .../templates/wagtailsearch/editorspicks/add.html | 2 ++ .../templates/wagtailsearch/editorspicks/edit.html | 4 +++- .../templates/wagtailsearch/editorspicks/index.html | 3 ++- wagtail/wagtailsites/templates/wagtailsites/create.html | 1 + wagtail/wagtailsites/templates/wagtailsites/edit.html | 1 + .../templates/wagtailsnippets/snippets/create.html | 2 ++ .../templates/wagtailsnippets/snippets/edit.html | 2 ++ .../wagtailusers/templates/wagtailusers/groups/create.html | 4 ++++ wagtail/wagtailusers/templates/wagtailusers/groups/edit.html | 3 +++ wagtail/wagtailusers/templates/wagtailusers/groups/index.html | 1 + wagtail/wagtailusers/templates/wagtailusers/users/index.html | 1 + 35 files changed, 72 insertions(+), 5 deletions(-) diff --git a/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html b/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html index f4e859987..45b6c9f60 100644 --- a/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html +++ b/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html @@ -2,6 +2,8 @@ {% load wagtailadmin_tags compress i18n static gravatar %} {% block extra_css %} + {{ block.super }} + {% compress css %} {% endcompress %} @@ -567,6 +569,8 @@ {% endblock %} {% block extra_js %} + {{ block.super }} + {% include "wagtailadmin/pages/_editor_js.html" %} diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/pages/search.html b/wagtail/wagtailadmin/templates/wagtailadmin/pages/search.html index 989c22aa4..664245408 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/pages/search.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/pages/search.html @@ -3,6 +3,8 @@ {% block titletag %}{% trans 'Search' %}{% endblock %} {% block bodyclass %}menu-search{% endblock %} {% block extra_js %} + {{ block.super }} + {% endcompress %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/wagtail/wagtailimages/templates/wagtailimages/multiple/add.html b/wagtail/wagtailimages/templates/wagtailimages/multiple/add.html index b9fb8e418..436c2cc7d 100644 --- a/wagtail/wagtailimages/templates/wagtailimages/multiple/add.html +++ b/wagtail/wagtailimages/templates/wagtailimages/multiple/add.html @@ -3,6 +3,8 @@ {% block titletag %}{% trans "Add multiple images" %}{% endblock %} {% block bodyclass %}menu-images{% endblock %} {% block extra_css %} + {{ block.super }} + {% compress css %} {% endcompress %} @@ -54,6 +56,8 @@ {% endblock %} {% block extra_js %} + {{ block.super }} + {% compress js %} diff --git a/wagtail/wagtailredirects/templates/wagtailredirects/add.html b/wagtail/wagtailredirects/templates/wagtailredirects/add.html index 5fcf22e08..aee31135f 100644 --- a/wagtail/wagtailredirects/templates/wagtailredirects/add.html +++ b/wagtail/wagtailredirects/templates/wagtailredirects/add.html @@ -18,5 +18,6 @@ {% endblock %} {% block extra_js %} + {{ block.super }} {% include "wagtailadmin/pages/_editor_js.html" %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/wagtail/wagtailredirects/templates/wagtailredirects/edit.html b/wagtail/wagtailredirects/templates/wagtailredirects/edit.html index 88ddc9274..eac85d31d 100644 --- a/wagtail/wagtailredirects/templates/wagtailredirects/edit.html +++ b/wagtail/wagtailredirects/templates/wagtailredirects/edit.html @@ -19,5 +19,6 @@ {% endblock %} {% block extra_js %} + {{ block.super }} {% include "wagtailadmin/pages/_editor_js.html" %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/wagtail/wagtailredirects/templates/wagtailredirects/index.html b/wagtail/wagtailredirects/templates/wagtailredirects/index.html index ef9b349dd..fda83f362 100644 --- a/wagtail/wagtailredirects/templates/wagtailredirects/index.html +++ b/wagtail/wagtailredirects/templates/wagtailredirects/index.html @@ -4,6 +4,7 @@ {% block bodyclass %}menu-redirects{% endblock %} {% block extra_js %} + {{ block.super }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/wagtail/wagtailsearch/templates/wagtailsearch/editorspicks/index.html b/wagtail/wagtailsearch/templates/wagtailsearch/editorspicks/index.html index e8e72f238..b65e71805 100644 --- a/wagtail/wagtailsearch/templates/wagtailsearch/editorspicks/index.html +++ b/wagtail/wagtailsearch/templates/wagtailsearch/editorspicks/index.html @@ -4,6 +4,7 @@ {% block bodyclass %}menu-editorspicks{% endblock %} {% block extra_js %} + {{ block.super }}