Module: check_mk
Branch: master
Commit: 8929403fb1c98e52652888ce7ed6c655ef7468a8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8929403fb1c98e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 26 12:58:56 2016 +0200
Minor cleanup
---
web/htdocs/htmllib.py | 60 +++++++++++++++++++++++++++++++------------------
1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 0885ee1..04bd1aa 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -258,12 +258,6 @@ class html(GUITester):
self.flush()
self.plugged = False
- def heading(self, text):
- self.write("<h2>%s</h2>\n" % text)
-
- def rule(self):
- self.write("<hr/>")
-
def age_text(self, timedif):
timedif = int(timedif)
if timedif < 120:
@@ -345,22 +339,6 @@ class html(GUITester):
self.write('<br>'.join(self.user_errors.values()))
self.write('</div>\n')
-
- def hidden_field(self, *args, **kwargs):
- self.write(self.render_hidden_field(*args, **kwargs))
-
-
- def render_hidden_field(self, var, value, id=None, add_var=False):
- if value == None:
- return ""
-
- if add_var:
- self.add_form_var(var)
-
- id = id and ' id="%s"' % self.attrencode(id) or ''
- return "<input type=\"hidden\" name=\"%s\"
value=\"%s\"%s />" % \
- (self.attrencode(var), self.attrencode(value), id)
-
# Beware: call this method just before end_form(). It will
# add all current non-underscored HTML variables as hiddedn
# field to the form - *if* they are not used in any input
@@ -411,6 +389,43 @@ class html(GUITester):
def makeactionuri_contextless(self, addvars, filename=None):
return self.makeuri_contextless(addvars + [("_transid",
self.get_transid())], filename=filename)
+
+ #
+ # Generic HTML rendering and writing functions
+ #
+
+ def heading(self, text):
+ self.write("<h2>%s</h2>\n" % text)
+
+
+ def rule(self):
+ self.write("<hr/>")
+
+
+ def p(self, content):
+ self.write("<p>%s</p>" % self.attrencode(content))
+
+
+ #
+ # HTML form rendering
+ #
+
+
+ def hidden_field(self, *args, **kwargs):
+ self.write(self.render_hidden_field(*args, **kwargs))
+
+
+ def render_hidden_field(self, var, value, id=None, add_var=False):
+ if value == None:
+ return ""
+
+ if add_var:
+ self.add_form_var(var)
+
+ id = id and ' id="%s"' % self.attrencode(id) or ''
+ return "<input type=\"hidden\" name=\"%s\"
value=\"%s\"%s />" % \
+ (self.attrencode(var), self.attrencode(value), id)
+
def image_button(self, varname, title, cssclass = '', style=None):
if not self.mobile:
self.write('<label for="%s"
class="image_button"%s>' %
@@ -419,6 +434,7 @@ class html(GUITester):
if not self.mobile:
self.write('</label>')
+
def button(self, *args, **kwargs):
self.image_button(*args, **kwargs)