From 473676a5f5a6d746fbb76551ee25348d584476de Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Sun, 31 Mar 2019 18:20:20 +0200
Subject: [PATCH] Add option to get bootstrap and jquery from a cdn

---
 configproxy.py        |  5 +++++
 templates/layout.html | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/configproxy.py b/configproxy.py
index f8acbe0..28c95d8 100755
--- a/configproxy.py
+++ b/configproxy.py
@@ -472,6 +472,11 @@ CONFIG_SECTIONS = [
                 required=False, internal=False,
                 description="Protocol used by this website. "
                             "Either 'http' or 'https'."),
+            ConfigEntry(
+                name="CDN_URL",
+                default=None,
+                required=False, internal=False,
+                description="URL to get bootstrap and jQuery from.")
         ],
         check=check_server_name,
         description="Where is the website hosted"),
diff --git a/templates/layout.html b/templates/layout.html
index 4054fa4..c0a2e89 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -5,7 +5,11 @@
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <meta name="description" content="Protokollsystem" />
-    <link rel="stylesheet" href="{{url_for("static", filename="css/bootstrap.min.css")}}">
+    {% if config.CDN_URL is defined %}
+      <link rel="stylesheet" href="{{[config.CDN_URL, "bootstrap/css/bootstrap.min.css"]|join("/")}}">
+    {% else %}
+      <link rel="stylesheet" href="{{url_for("static", filename="css/bootstrap.min.css")}}">
+    {% endif %}
     <link rel="stylesheet" href="{{url_for("static", filename="css/style.css")}}" />
     {% block additional_js %}
     {% endblock %}
@@ -73,6 +77,11 @@ Diese Seite ist leer.
 {% endblock %}
 
 </div>
-<script src="{{url_for("static", filename="js/jquery.min.js")}}"></script>
-<script src="{{url_for("static", filename="js/bootstrap.min.js")}}"></script>
+{% if config.CDN_URL is defined %}
+  <script src="{{[config.CDN_URL, "jquery/jquery.min.js"]|join("/")}}"></script>
+  <script src="{{[config.CDN_URL, "bootstrap/js/bootstrap.min.js"]|join("/")}}"></script>
+{% else %}
+  <script src="{{url_for("static", filename="js/jquery.min.js")}}"></script>
+  <script src="{{url_for("static", filename="js/bootstrap.min.js")}}"></script>
+{% endif %}
 </body>
-- 
GitLab