superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccwilli...@apache.org
Subject [incubator-superset] branch master updated: [bugfix] De-dup <script> tags. #5883 (#5890)
Date Wed, 19 Sep 2018 00:50:36 GMT
This is an automated email from the ASF dual-hosted git repository.

ccwilliams pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 325e7c0  [bugfix] De-dup <script> tags. #5883 (#5890)
325e7c0 is described below

commit 325e7c03b8e533b5394ae1dc253e5688eb266244
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Tue Sep 18 17:50:30 2018 -0700

    [bugfix] De-dup <script> tags. #5883 (#5890)
    
    * Fix adding duplicate script tags.
    
    * add more empty lines
    
    * rename function
---
 superset/__init__.py                                  |  9 +++++++++
 superset/templates/superset/base.html                 |  6 +++---
 superset/templates/superset/basic.html                | 10 +++++-----
 superset/templates/superset/partials/_script_tag.html |  2 +-
 4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/superset/__init__.py b/superset/__init__.py
index 5ec3c94..ce98dc2 100644
--- a/superset/__init__.py
+++ b/superset/__init__.py
@@ -69,12 +69,21 @@ def get_css_manifest_files(filename):
     return entry_files.get('css', [])
 
 
+def get_unloaded_chunks(files, loaded_chunks):
+    filtered_files = [f for f in files if f not in loaded_chunks]
+    for f in filtered_files:
+        loaded_chunks.add(f)
+    return filtered_files
+
+
 parse_manifest_json()
 
 
 @app.context_processor
 def get_manifest():
     return dict(
+        loaded_chunks=set(),
+        get_unloaded_chunks=get_unloaded_chunks,
         js_manifest=get_js_manifest_files,
         css_manifest=get_css_manifest_files,
     )
diff --git a/superset/templates/superset/base.html b/superset/templates/superset/base.html
index f974348..b4397f5 100644
--- a/superset/templates/superset/base.html
+++ b/superset/templates/superset/base.html
@@ -3,21 +3,21 @@
   {% block head_css %}
     {{super()}}
     <link rel="icon" type="image/png" href="/static/assets/images/favicon.png">
-    {% for entry in css_manifest('theme') %}
+    {% for entry in get_unloaded_chunks(css_manifest('theme'), loaded_chunks) %}
       <link rel="stylesheet" type="text/css" href="{{ entry }}" />
     {% endfor %}
   {% endblock %}
 
   {% block head_js %}
     {{super()}}
-    {% for entry in js_manifest('theme') %}
+    {% for entry in get_unloaded_chunks(js_manifest('theme'), loaded_chunks) %}
       <script src="{{ entry }}"></script>
     {% endfor %}
   {% endblock %}
 
   {% block tail_js %}
     {{super()}}
-    {% for entry in js_manifest('common') %}
+    {% for entry in get_unloaded_chunks(js_manifest('common'), loaded_chunks) %}
       <script src="{{ entry }}"></script>
     {% endfor %}
   {% endblock %}
diff --git a/superset/templates/superset/basic.html b/superset/templates/superset/basic.html
index 802f14a..a5e72f3 100644
--- a/superset/templates/superset/basic.html
+++ b/superset/templates/superset/basic.html
@@ -16,23 +16,23 @@
       <link rel="stylesheet" type="text/css" href="/static/appbuilder/css/flags/flags16.css"
/>
       <link rel="stylesheet" type="text/css" href="/static/appbuilder/css/font-awesome.min.css">
 
-      {% for entry in css_manifest('theme') %}
+      {% for entry in get_unloaded_chunks(css_manifest('theme'), loaded_chunks) %}
         <link rel="stylesheet" type="text/css" href="{{ entry }}" />
       {% endfor %}
 
       {% if entry %}
         {% set entry_files = css_manifest(entry) %}
-        {% for entry in entry_files %}
+        {% for entry in get_unloaded_chunks(entry_files, loaded_chunks) %}
           <link rel="stylesheet" type="text/css" href="{{ entry }}" />
         {% endfor %}
       {% endif %}
 
     {% endblock %}
 
-    {% for entry in js_manifest('theme') %}
+    {% for entry in get_unloaded_chunks(js_manifest('theme'), loaded_chunks) %}
       <script src="{{ entry }}"></script>
     {% endfor %}
-    {% for entry in js_manifest('common') %}
+    {% for entry in get_unloaded_chunks(js_manifest('common'), loaded_chunks) %}
       <script src="{{ entry }}"></script>
     {% endfor %}
 
@@ -80,7 +80,7 @@
     {% block tail_js %}
       {% if entry %}
         {% set entry_files = js_manifest(entry) %}
-        {% for entry in entry_files %}
+        {% for entry in get_unloaded_chunks(entry_files, loaded_chunks) %}
           <script src="{{ entry }}"></script>
         {% endfor %}
       {% endif %}
diff --git a/superset/templates/superset/partials/_script_tag.html b/superset/templates/superset/partials/_script_tag.html
index fd049a7..f530c7b 100644
--- a/superset/templates/superset/partials/_script_tag.html
+++ b/superset/templates/superset/partials/_script_tag.html
@@ -1,5 +1,5 @@
 {% block tail_js %}
-  {% for entry in js_manifest(filename) %}
+  {% for entry in get_unloaded_chunks(js_manifest(filename), loaded_chunks) %}
     <script src="{{ entry }}"></script>
   {% endfor %}
 {% endblock %}


Mime
View raw message