Module: check_mk
Branch: master
Commit: cc437176612088cc968d4fb4fdcd9e5e606ac49c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cc437176612088…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 8 18:48:01 2016 +0200
Removed Check_MK GUI specific things to html_mod_python
---
web/htdocs/html_mod_python.py | 54 +++++++++++++++++++++++++++++++++++++++
web/htdocs/htmllib.py | 59 ++++++++-----------------------------------
2 files changed, 65 insertions(+), 48 deletions(-)
diff --git a/web/htdocs/html_mod_python.py b/web/htdocs/html_mod_python.py
index bc8a346..448babf 100644
--- a/web/htdocs/html_mod_python.py
+++ b/web/htdocs/html_mod_python.py
@@ -309,3 +309,57 @@ class html_mod_python(htmllib.html):
if fn.endswith(".css"):
plugin_stylesheets.add(fn)
return plugin_stylesheets
+
+
+ def css_filename_for_browser(self, css):
+ if not defaults.omd_root:
+ return '%s.css' % css
+
+ rel_path = "/share/check_mk/web/htdocs/" + css + ".css"
+ if os.path.exists(defaults.omd_root + rel_path) or \
+ os.path.exists(defaults.omd_root + "/local" + rel_path):
+ return '%s-%s.css' % (css, defaults.check_mk_version)
+
+
+ # 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 detect_icon_path(self, icon_name):
+ # Detect whether or not the icon is available as images/icon_*.png
+ # or images/icons/*.png. When an icon is available as internal icon,
+ # always use this one
+ is_internal = False
+ if defaults.omd_root:
+ rel_path =
"share/check_mk/web/htdocs/images/icon_"+icon_name+".png"
+ if os.path.exists(defaults.omd_root+"/"+rel_path):
+ is_internal = True
+ elif os.path.exists(defaults.omd_root+"/local/"+rel_path):
+ is_internal = True
+ elif
os.path.exists(defaults.web_dir+"/htdocs/images/icon_"+icon_name+".png"):
+ is_internal = True
+
+ if is_internal:
+ return "images/icon_%s.png" % icon_name
+ else:
+ return "images/icons/%s.png" % icon_name
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index a424e02..8fb1605 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -55,7 +55,8 @@ try:
except ImportError:
import json
-from lib import *
+from cmk.exceptions import MKGeneralException
+from lib import MKUserError
# Only parse variable adhering to the following regular expressions
# TODO: Fix this regex. +-\ selects all from + to \, not +, - and \!
@@ -833,24 +834,9 @@ class html(GUITester):
if not self.mobile:
self.write('</label>')
+
def detect_icon_path(self, icon_name):
- # Detect whether or not the icon is available as images/icon_*.png
- # or images/icons/*.png. When an icon is available as internal icon,
- # always use this one
- is_internal = False
- if defaults.omd_root:
- rel_path =
"share/check_mk/web/htdocs/images/icon_"+icon_name+".png"
- if os.path.exists(defaults.omd_root+"/"+rel_path):
- is_internal = True
- elif os.path.exists(defaults.omd_root+"/local/"+rel_path):
- is_internal = True
- elif
os.path.exists(defaults.web_dir+"/htdocs/images/icon_"+icon_name+".png"):
- is_internal = True
-
- if is_internal:
- return "images/icon_%s.png" % icon_name
- else:
- return "images/icons/%s.png" % icon_name
+ raise NotImplementedError()
def icon(self, help, icon, **kwargs):
@@ -1391,15 +1377,9 @@ class html(GUITester):
# Load all specified style sheets and all user style sheets in htdocs/css
for css in self._default_stylesheets + stylesheets + [ 'ie' ]:
- if defaults.omd_root:
- rel_path = "/share/check_mk/web/htdocs/" + css +
".css"
- if os.path.exists(defaults.omd_root + rel_path) or \
- os.path.exists(defaults.omd_root + "/local" +
rel_path):
- fname = '%s-%s.css' % (css, defaults.check_mk_version)
- else:
- continue
- else:
- fname = '%s.css' % css
+ fname = self.css_filename_for_browser(css)
+ if fname == None:
+ continue
if css == 'ie':
self.write('<!--[if IE]>\n')
@@ -1430,33 +1410,16 @@ class html(GUITester):
self.write('<link rel="shortcut icon"
href="images/favicon.ico" type="image/ico">\n')
- # TODO: Rename. Also rename in CMA!
def add_custom_style_sheet(self):
raise NotImplementedError()
- # 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", "" ]
+ def css_filename_for_browser(self, css):
+ raise NotImplementedError()
- 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 javascript_filename_for_browser(self, jsname):
+ raise NotImplementedError()
def html_foot(self):