Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not load external bootstrap resources for cdn_resources = 'in_line' | 'local' #201

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions notebooks/dot.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,12 @@
<meta charset="utf-8">

<script src="lib/bindings/utils.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="lib/vis-9.1.2/vis-network.min.css"/>
<script src="lib/vis-9.1.2/vis-network.min.js"></script>
<link rel="stylesheet" href="lib/bootstrap/bootstrap.min.css"/>
<script src="lib/bootstrap/bootstrap.bundle.min.js"></script>


<center>
<h1></h1>
</center>

<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"
></script>


<center>
<h1></h1>
Expand Down
32 changes: 14 additions & 18 deletions notebooks/example.html

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions notebooks/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fcd4c1a3d60>"
"<IPython.lib.display.IFrame at 0x7f7dbee76740>"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -112,7 +112,7 @@
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fcd4c147d60>"
"<IPython.lib.display.IFrame at 0x7f7dd87c6c20>"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -212,7 +212,7 @@
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fcd4c1a3af0>"
"<IPython.lib.display.IFrame at 0x7f7dbee8f490>"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -268,7 +268,7 @@
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fcd4c1a3820>"
"<IPython.lib.display.IFrame at 0x7f7dbee8f5e0>"
]
},
"execution_count": 6,
Expand Down Expand Up @@ -323,7 +323,7 @@
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fcd4c6dc3d0>"
"<IPython.lib.display.IFrame at 0x7f7dbee1d6f0>"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -393,7 +393,7 @@
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fccfa516bb0>"
"<IPython.lib.display.IFrame at 0x7f7d928034f0>"
]
},
"execution_count": 8,
Expand Down Expand Up @@ -479,7 +479,7 @@
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fcd2403f280>"
"<IPython.lib.display.IFrame at 0x7f7dbee8f8b0>"
]
},
"execution_count": 9,
Expand Down Expand Up @@ -571,7 +571,7 @@
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7fccfc4d9e80>"
"<IPython.lib.display.IFrame at 0x7f7d9267ce50>"
]
},
"execution_count": 12,
Expand Down Expand Up @@ -644,7 +644,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.10.6"
}
},
"nbformat": 4,
Expand Down
36 changes: 16 additions & 20 deletions notebooks/example2.html

Large diffs are not rendered by default.

36 changes: 16 additions & 20 deletions notebooks/example3.html

Large diffs are not rendered by default.

35 changes: 11 additions & 24 deletions notebooks/example4.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,31 +194,18 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>







<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"
></script>

<center>
<h1></h1>
</center>

<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"
></script>


<center>
<h1></h1>
Expand Down
37 changes: 12 additions & 25 deletions notebooks/example5.html

Large diffs are not rendered by default.

37 changes: 12 additions & 25 deletions notebooks/example6.html

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions notebooks/lib/bootstrap/bootstrap.bundle.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions notebooks/lib/bootstrap/bootstrap.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions notebooks/lib/vis-9.1.2/vis-network.css

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions notebooks/lib/vis-9.1.2/vis-network.min.js

Large diffs are not rendered by default.

35 changes: 11 additions & 24 deletions notebooks/nx.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,34 +194,21 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>






<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tom-select/2.0.0-rc.4/css/tom-select.min.css" integrity="sha512-43fHB3GLgZfz8QXl1RPQ8O66oIgv3po9cJ5erMt1c4QISq9dYb195T3vr5ImnJPXuVroKcGBPXBFKETW8jrPNQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/tom-select/2.0.0-rc.4/js/tom-select.complete.js" integrity="sha512-jeF9CfnvzDiw9G9xiksVjxR2lib44Gnovvkv+3CgCG6NXCD4gqlA5nDAVW5WjpA+i+/zKsUWV5xNEbW1X/HH0Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>


<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"
></script>

<center>
<h1></h1>
</center>

<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"
></script>


<center>
<h1></h1>
Expand Down
7 changes: 7 additions & 0 deletions pyvis/lib/bootstrap/bootstrap.bundle.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions pyvis/lib/bootstrap/bootstrap.min.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pyvis/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ def write_html(self, name, local=True, notebook=False,open_browser=False):
shutil.copytree(f"{os.path.dirname(__file__)}/templates/lib/tom-select", "lib/tom-select")
if not os.path.exists(os.getcwd()+"/lib/vis-9.1.2"):
shutil.copytree(f"{os.path.dirname(__file__)}/templates/lib/vis-9.1.2", "lib/vis-9.1.2")
if not os.path.exists("lib/bootstrap"):
shutil.copytree(f"{os.path.dirname(__file__)}/templates/lib/bootstrap", "lib/bootstrap")
with open(getcwd_name, "w+") as out:
out.write(self.html)
elif self.cdn_resources == "in_line" or self.cdn_resources == "remote":
Expand Down
7 changes: 7 additions & 0 deletions pyvis/templates/lib/bootstrap/bootstrap.bundle.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions pyvis/templates/lib/bootstrap/bootstrap.min.css

Large diffs are not rendered by default.

43 changes: 17 additions & 26 deletions pyvis/templates/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<meta charset="utf-8">
{% if cdn_resources=="local" %}
<script src="lib/bindings/utils.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="lib/vis-9.1.2/vis-network.min.css"/>
<script src="lib/vis-9.1.2/vis-network.min.js"></script>
<link rel="stylesheet" href="lib/bootstrap/bootstrap.min.css"/>
<script src="lib/bootstrap/bootstrap.bundle.min.js"></script>
{% if select_menu or filter_menu %}
<link href="lib/tom-select/tom-select.css" rel="stylesheet">
<script src="lib/tom-select/tom-select.complete.min.js"></script>
Expand All @@ -17,39 +19,28 @@
<style>{% include 'lib/tom-select/tom-select.css' %}</style>
<script>{% include 'lib/tom-select/tom-select.complete.min.js' %}</script>
{% endif %}
<style>{% include 'lib/bootstrap/bootstrap.min.css' %}</style>
<script>{% include 'lib/bootstrap/bootstrap.bundle.min.js' %}</script>
{% elif cdn_resources=="remote" %}
<script>{% include 'lib/bindings/utils.js' %}</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
{# <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.0.4/dist/dist/vis-network.min.css" integrity="sha512-+5tJeVsSE2tSnmKB5SWOD0GsYA5dOP0B/FSv7I2GYhdOcyjJq81Q1St3qgJgInwreAdNuw0KGJ0FOaxOJ0E4yw==" crossorigin="anonymous" referrerpolicy="no-referrer" />#}
{# <script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.0.4/dist/vis-network.js"#}
{# integrity="sha512-CEbUhbSq35hCqBH8ckfAkH1Tcua5NEywtEzwiJ+BUC4EIZkC7vyta3ivZu/WqJhK1qHTurO3hwHsErU3HHjwIA=="#}
{# crossorigin="anonymous"#}
{# referrerpolicy="no-referrer"></script>#}
{% if select_menu or filter_menu %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tom-select/2.0.0-rc.4/css/tom-select.min.css" integrity="sha512-43fHB3GLgZfz8QXl1RPQ8O66oIgv3po9cJ5erMt1c4QISq9dYb195T3vr5ImnJPXuVroKcGBPXBFKETW8jrPNQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/tom-select/2.0.0-rc.4/js/tom-select.complete.js" integrity="sha512-jeF9CfnvzDiw9G9xiksVjxR2lib44Gnovvkv+3CgCG6NXCD4gqlA5nDAVW5WjpA+i+/zKsUWV5xNEbW1X/HH0Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
{% endif %}

<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"
></script>
{% endif %}
<center>
<h1>{{heading}}</h1>
</center>

<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
crossorigin="anonymous"
></script>


<center>
<h1>{{heading}}</h1>
Expand Down