Skip to content

Commit

Permalink
Finish CDN migration
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Sep 21, 2022
1 parent 18d2215 commit 8cecad4
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 15 deletions.
6 changes: 3 additions & 3 deletions panel/_templates/convert_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
}
</script>
{% endif %}
<script type="module" src="https://unpkg.com/@microsoft/fast-colors@5.1.0"></script>
<script type="module" src="https://unpkg.com/@microsoft/fast-components@1.13.0"></script>
<script type="module" src="{{ npm_cdn|default('https://cdn.jsdelivr.net/npm', true) }}/@microsoft/fast-colors@5.1.0"></script>
<script type="module" src="{{ npm_cdn|default('https://cdn.jsdelivr.net/npm', true) }}/@microsoft/fast-components@1.13.0"></script>
<script type="text/javascript">
function setParamsFromSearch(text){
function setParamsFromSearch(text) {
const params = new URLSearchParams(location.search);
if (text===""){
params.delete("search")
Expand Down
4 changes: 2 additions & 2 deletions panel/_templates/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<link rel="manifest" href="{{base_url|default("", true) }}static/extensions/panel/images/site.webmanifest">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<script type="module" src="https://unpkg.com/@microsoft/fast-colors@5.1.0"></script>
<script type="module" src="https://unpkg.com/@microsoft/fast-components@1.13.0"></script>
<script type="module" src="{{ npm_cdn|default('https://cdn.jsdelivr.net/npm', true) }}/@microsoft/fast-colors@5.1.0"></script>
<script type="module" src="{{ npm_cdn|default('https://cdn.jsdelivr.net/npm', true) }}/@microsoft/fast-components@1.13.0"></script>
<style>
html {
height:100%;
Expand Down
4 changes: 2 additions & 2 deletions panel/_templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<link rel="manifest" href="{{base_url|default("", true) }}static/extensions/panel/images/site.webmanifest">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<script type="module" src="https://unpkg.com/@microsoft/fast-colors@5.1.0"></script>
<script type="module" src="https://unpkg.com/@microsoft/fast-components@1.13.0"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@microsoft/fast-colors@5.1.0"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@microsoft/fast-components@1.13.0"></script>
<script type="text/javascript">
function setParamsFromSearch(text){
const params = new URLSearchParams(location.search);
Expand Down
1 change: 1 addition & 0 deletions panel/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ async def get(self):
)
self.set_header("Content-Type", 'text/html')
self.write(self._error_template.render(
npm_cdn=config.npn_cdn,
title='Panel: Authentication Error',
error_type='Authentication Error',
error=error,
Expand Down
2 changes: 1 addition & 1 deletion panel/io/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def make_index(files, title=None, manifest=True):
items = {label: './'+os.path.basename(f) for label, f in sorted(files.items())}
return INDEX_TEMPLATE.render(
items=items, manifest=manifest, apple_icon=apple_icon,
favicon=favicon, title=title
favicon=favicon, title=title, npm_cdn=config.npm_cdn
)

def build_pwa_manifest(files, title=None, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions panel/io/jupyter_server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from tornado.ioloop import PeriodicCallback
from tornado.web import StaticFileHandler

from ..config import config
from ..util import edit_readonly
from .resources import (
DIST_DIR, ERROR_TEMPLATE, Resources, _env,
Expand Down Expand Up @@ -403,6 +404,7 @@ async def get(self, path=None):
except (TimeoutError, RuntimeError) as e:
await self.kernel_manager.shutdown_kernel(kernel_id, now=True)
html = ERROR_TEMPLATE.render(
npm_cdn=config.npn_cdn,
base_url=root_url,
error_type="Kernel error",
error="Failed to start kernel",
Expand Down
1 change: 1 addition & 0 deletions panel/io/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ async def get(self, *args, **kwargs):
else:
template = ERROR_TEMPLATE
page = template.render(
npm_cdn=config.npn_cdn,
title='Panel: Authorization Error',
error_type='Authorization Error',
error='User is not authorized.',
Expand Down
5 changes: 3 additions & 2 deletions panel/template/fast/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import param

from ...config import config
from ...io.state import state
from ..base import BasicTemplate
from ..react import ReactTemplate
Expand Down Expand Up @@ -65,8 +66,8 @@ class FastBaseTemplate(BasicTemplate):

_resources = {
'js_modules': {
'fast-colors': 'https://unpkg.com/@microsoft/fast-colors@5.1.4',
'fast': 'https://unpkg.com/@microsoft/fast-components@1.21.8'
'fast-colors': f'{config.npm_cdn}/@microsoft/fast-colors@5.1.4',
'fast': f'{config.npm_cdn}/@microsoft/fast-components@1.21.8'
},
'bundle': False
}
Expand Down
5 changes: 3 additions & 2 deletions panel/template/material/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from bokeh.themes import Theme as _BkTheme

from ...config import config
from ...layout import Card
from ..base import BasicTemplate, TemplateActions
from ..theme import DarkTheme, DefaultTheme
Expand Down Expand Up @@ -49,10 +50,10 @@ class MaterialTemplate(BasicTemplate):

_resources = {
'css': {
'material': "https://unpkg.com/material-components-web@7.0.0/dist/material-components-web.min.css",
'material': f"{config.npm_cdn}/material-components-web@7.0.0/dist/material-components-web.min.css",
},
'js': {
'material': "https://unpkg.com/material-components-web@7.0.0/dist/material-components-web.min.js"
'material': f"{config.npm_cdn}/material-components-web@7.0.0/dist/material-components-web.min.js"
}
}

Expand Down
7 changes: 4 additions & 3 deletions panel/template/react/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import param

from ...config import config
from ...depends import depends
from ...io.resources import CSS_URLS
from ...layout import Card, GridSpec
Expand Down Expand Up @@ -51,9 +52,9 @@ class ReactTemplate(BasicTemplate):

_resources = {
'js': {
'react': "https://unpkg.com/react@16/umd/react.development.js",
'react-dom': "https://unpkg.com/react-dom@16/umd/react-dom.development.js",
'babel': "https://unpkg.com/babel-standalone@latest/babel.min.js",
'react': f"{config.npm_cdn}/react@16/umd/react.development.js",
'react-dom': f"{config.npm_cdn}/react-dom@16/umd/react-dom.development.js",
'babel': f"{config.npm_cdn}/babel-standalone@latest/babel.min.js",
'react-grid': "https://cdnjs.cloudflare.com/ajax/libs/react-grid-layout/1.1.1/react-grid-layout.min.js"
},
'css': {
Expand Down

0 comments on commit 8cecad4

Please sign in to comment.