Skip to content

Commit

Permalink
Fix inline resources when saving (#1956)
Browse files Browse the repository at this point in the history
* Fix inline resources when saving

* Fix flake
  • Loading branch information
philippjfr authored Feb 3, 2021
1 parent 6c89b6b commit 48da910
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions panel/io/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from urllib.parse import urljoin

from bokeh.resources import Resources
from bokeh.settings import settings
from jinja2 import Environment, Markup, FileSystemLoader

with open(Path(__file__).parent.parent / 'package.json') as f:
Expand Down Expand Up @@ -39,9 +38,8 @@ def css_raw(self):
css_txt = f.read()
if css_txt not in raw:
raw.append(css_txt)
resources = settings.resources(default='server')
for cssf in glob.glob(str(DIST_DIR / 'css' / '*.css')):
if resources != 'inline':
if self.mode != 'inline':
break
with open(cssf, encoding='utf-8') as f:
css_txt = f.read()
Expand All @@ -56,8 +54,7 @@ def js_files(self):

# Load requirejs last to avoid interfering with other libraries
require_index = [i for i, jsf in enumerate(js_files) if 'require' in jsf]
resources = settings.resources(default='server')
if resources == 'server':
if self.mode == 'server':
dist_dir = urljoin(self.root_url, LOCAL_DIST)
else:
dist_dir = CDN_DIST
Expand All @@ -78,13 +75,12 @@ def css_files(self):
if os.path.isfile(cssf) or cssf in files:
continue
files.append(cssf)
resources = settings.resources(default='server')
if resources == 'server':
if self.mode == 'server':
dist_dir = urljoin(self.root_url, LOCAL_DIST)
else:
dist_dir = CDN_DIST
for cssf in glob.glob(str(DIST_DIR / 'css' / '*.css')):
if resources == 'inline':
if self.mode == 'inline':
break
files.append(dist_dir + f'css/{os.path.basename(cssf)}')
return files
Expand Down

0 comments on commit 48da910

Please sign in to comment.