From 79b970652044d72ed8e5568673399300bfc9543c Mon Sep 17 00:00:00 2001 From: Pascal Repond Date: Mon, 7 Sep 2026 11:03:33 +0200 Subject: [PATCH] perf: bundle frontend libraries locally * Closes #1171. Co-Authored-by: Pascal Repond --- sonar/config.py | 14 ------ .../documents/templates/documents/record.html | 17 ++----- .../modules/pdf_extractor/templates/test.html | 1 + sonar/theme/assets/js/sonar/bootstrap.js | 7 +++ sonar/theme/assets/js/sonar/katex.js | 10 +++++ sonar/theme/templates/sonar/macros/macro.html | 2 +- sonar/theme/templates/sonar/page.html | 7 --- sonar/theme/templates/sonar/page_wiki.html | 2 +- .../templates/sonar/projects/detail.html | 1 + sonar/theme/webpack.py | 8 +++- tests/ui/test_views.py | 45 +++++++++++++++++++ 11 files changed, 76 insertions(+), 38 deletions(-) create mode 100644 sonar/theme/assets/js/sonar/bootstrap.js create mode 100644 sonar/theme/assets/js/sonar/katex.js diff --git a/sonar/config.py b/sonar/config.py index 9916be21e..126413312 100644 --- a/sonar/config.py +++ b/sonar/config.py @@ -233,30 +233,18 @@ def _(x): "'self'", "'unsafe-inline'", "'unsafe-eval'", - "https://code.jquery.com", - "https://cdnjs.cloudflare.com", - "https://stackpath.bootstrapcdn.com", "https://www.googletagmanager.com", "https://www.google-analytics.com", - "https://cdn.jsdelivr.net", ], "style-src": [ "'self'", "'unsafe-inline'", - "https://cdnjs.cloudflare.com", - "https://fonts.googleapis.com", - "https://maxcdn.bootstrapcdn.com", - "https://cdn.jsdelivr.net", ], "font-src": [ "'self'", "data:", "blob:", "'unsafe-inline'", - "https://cdnjs.cloudflare.com", - "https://fonts.gstatic.com", - "https://maxcdn.bootstrapcdn.com", - "https://cdn.jsdelivr.net", ], "img-src": [ "'self'", @@ -898,8 +886,6 @@ def _(x): # WIKI # ==== -# Serve the Bootstrap assets from the package, the wiki base template loads them. -BOOTSTRAP_SERVE_LOCAL = True WIKI_CONTENT_DIR = "./data/wiki" WIKI_INDEX_DIR = "./data/wiki/_index" WIKI_URL_PREFIX = "//help" diff --git a/sonar/modules/documents/templates/documents/record.html b/sonar/modules/documents/templates/documents/record.html index 086d1f05e..eed3874d1 100644 --- a/sonar/modules/documents/templates/documents/record.html +++ b/sonar/modules/documents/templates/documents/record.html @@ -16,7 +16,7 @@ {{ schema_org_data | safe }} - +{{ webpack['sonar-katex.css'] }} {{ webpack[get_specific_theme()] }} - - - {%- endblock css %} {%- endblock head %} diff --git a/sonar/theme/templates/sonar/page_wiki.html b/sonar/theme/templates/sonar/page_wiki.html index a043b5633..8e69bbf44 100644 --- a/sonar/theme/templates/sonar/page_wiki.html +++ b/sonar/theme/templates/sonar/page_wiki.html @@ -30,6 +30,6 @@ {%- block javascript %} {{ super() }} -{{ bootstrap.load_js() }} +{{ webpack['sonar-bootstrap.js'] }} {%- endblock javascript %} diff --git a/sonar/theme/templates/sonar/projects/detail.html b/sonar/theme/templates/sonar/projects/detail.html index b6ae8b90c..9e0676d5f 100644 --- a/sonar/theme/templates/sonar/projects/detail.html +++ b/sonar/theme/templates/sonar/projects/detail.html @@ -95,6 +95,7 @@

{{ _('Linked documents') }}

{% block javascript %} {{super()}} +{{ webpack['sonar-bootstrap.js'] }}