mirror of https://gitlab.com/bashrc2/epicyon
Simplify css cache
parent
6d42faf737
commit
a5d6d4a7a6
13
daemon.py
13
daemon.py
|
@ -5780,6 +5780,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
get_text_mode_banner(self.server.base_dir)
|
get_text_mode_banner(self.server.base_dir)
|
||||||
self.server.iconsCache = {}
|
self.server.iconsCache = {}
|
||||||
self.server.fontsCache = {}
|
self.server.fontsCache = {}
|
||||||
|
self.server.css_cache = {}
|
||||||
self.server.show_publish_as_icon = \
|
self.server.show_publish_as_icon = \
|
||||||
get_config_param(self.server.base_dir,
|
get_config_param(self.server.base_dir,
|
||||||
'showPublishAsIcon')
|
'showPublishAsIcon')
|
||||||
|
@ -14321,18 +14322,23 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '/' in path:
|
if '/' in path:
|
||||||
path = path.split('/')[-1]
|
path = path.split('/')[-1]
|
||||||
path = base_dir + '/' + path
|
path = base_dir + '/' + path
|
||||||
if os.path.isfile(path):
|
css = None
|
||||||
|
if self.server.css_cache.get(path):
|
||||||
|
css = self.server.css_cache[path]
|
||||||
|
elif os.path.isfile(path):
|
||||||
tries = 0
|
tries = 0
|
||||||
while tries < 5:
|
while tries < 5:
|
||||||
try:
|
try:
|
||||||
css = get_css(self.server.base_dir, path)
|
css = get_css(self.server.base_dir, path)
|
||||||
if css:
|
if css:
|
||||||
|
self.server.css_cache[path] = css
|
||||||
break
|
break
|
||||||
except BaseException as ex:
|
except BaseException as ex:
|
||||||
print('EX: _get_style_sheet ' +
|
print('EX: _get_style_sheet ' + path + ' ' +
|
||||||
str(tries) + ' ' + str(ex))
|
str(tries) + ' ' + str(ex))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tries += 1
|
tries += 1
|
||||||
|
if css:
|
||||||
msg = css.encode('utf-8')
|
msg = css.encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
self._set_headers('text/css', msglen,
|
self._set_headers('text/css', msglen,
|
||||||
|
@ -21012,6 +21018,9 @@ def run_daemon(preferred_podcast_formats: [],
|
||||||
# scan the theme directory for any svg files containing scripts
|
# scan the theme directory for any svg files containing scripts
|
||||||
assert not scan_themes_for_scripts(base_dir)
|
assert not scan_themes_for_scripts(base_dir)
|
||||||
|
|
||||||
|
# caches css files
|
||||||
|
httpd.css_cache = {}
|
||||||
|
|
||||||
# load a list of dogwhistle words
|
# load a list of dogwhistle words
|
||||||
dogwhistles_filename = base_dir + '/accounts/dogwhistles.txt'
|
dogwhistles_filename = base_dir + '/accounts/dogwhistles.txt'
|
||||||
if not os.path.isfile(dogwhistles_filename):
|
if not os.path.isfile(dogwhistles_filename):
|
||||||
|
|
Loading…
Reference in New Issue