Module: check_mk
Branch: master
Commit: c29e54b46ca922336b592ca4c314ce2275056493
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c29e54b46ca922…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 12 11:59:26 2015 +0100
Fixed possible javascript caching issues after updates for wato.js and search.js
---
web/htdocs/htmllib.py | 46 +++++++++++++++++++++++------------------
web/htdocs/wato.py | 3 +--
web/plugins/sidebar/search.py | 2 +-
3 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 417464d..65502fb 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -823,27 +823,8 @@ class html:
self.add_custom_style_sheet()
- # Load specified javascript files. We have some special handling here:
- # a) files which can not be found shal not be loaded
- # b) in OMD environments, add the Check_MK version to the version (prevents
update problems)
- # c) load the minified javascript when not in debug mode
for js in [ "checkmk", "graphs" ] + javascripts:
- filename_for_browser = None
- if defaults.omd_root:
- rel_path = "/share/check_mk/web/htdocs/js"
- if self.enable_debug:
- min_parts = [ "", "_min" ]
- else:
- min_parts = [ "_min", "" ]
-
- for min_part in min_parts:
- path_pattern = defaults.omd_root + "%s" + rel_path +
"/" + js + min_part + ".js"
- if os.path.exists(path_pattern % "") or
os.path.exists(path_pattern % "/local"):
- filename_for_browser = '%s%s-%s' % (js, min_part,
defaults.check_mk_version)
- break
- else:
- filename_for_browser = js
-
+ filename_for_browser = self.javascript_filename_for_browser(js)
if filename_for_browser:
self.javascript_file(filename_for_browser)
@@ -856,6 +837,31 @@ class html:
self.write("</head>\n")
self.header_sent = True
+
+ # Make the browser load specified javascript files. We have some special handling
here:
+ # a) files which can not be found shal not be loaded
+ # b) in OMD environments, add the Check_MK version to the version (prevents update
problems)
+ # c) load the minified javascript when not in debug mode
+ def javascript_filename_for_browser(self, jsname):
+ if not defaults.omd_root:
+ return jsname
+
+ filename_for_browser = None
+ rel_path = "/share/check_mk/web/htdocs/js"
+ if self.enable_debug:
+ min_parts = [ "", "_min" ]
+ else:
+ min_parts = [ "_min", "" ]
+
+ for min_part in min_parts:
+ path_pattern = defaults.omd_root + "%s" + rel_path + "/"
+ jsname + min_part + ".js"
+ if os.path.exists(path_pattern % "") or os.path.exists(path_pattern
% "/local"):
+ filename_for_browser = '%s%s-%s' % (jsname, min_part,
defaults.check_mk_version)
+ break
+
+ return filename_for_browser
+
+
def html_foot(self):
self.write("</html>\n")
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 1742ca6..54d336c 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -278,8 +278,7 @@ def page_handler():
html.add_user_error(None, e.reason)
# Title
- html.header(modefunc("title"), stylesheets = wato_styles)
- html.write("<script type='text/javascript'
src='js/wato.js'></script>")
+ html.header(modefunc("title"), javascripts=["wato"],
stylesheets=wato_styles)
html.write("<div class=wato>\n")
try:
diff --git a/web/plugins/sidebar/search.py b/web/plugins/sidebar/search.py
index 9f1a677..fa821b0 100644
--- a/web/plugins/sidebar/search.py
+++ b/web/plugins/sidebar/search.py
@@ -29,7 +29,7 @@ def render_searchform():
html.write('<input id="mk_side_search_field" type="text"
name="search" autocomplete="off" />\n')
html.icon_button("#", _("Search"), "quicksearch",
onclick="mkSearchButton();")
html.write('</div>\n<div id=mk_side_clear></div>\n')
- html.write("<script type='text/javascript'
src='js/search.js'></script>\n")
+ html.javascript_file(html.javascript_filename_for_browser("search"))
sidebar_snapins["search"] = {
"title": _("Quicksearch"),