HTMLTools.py
Go to the documentation of this file.
1 
2 
3 
4 endl = "\n"
5 
6 # HTML Helper functions
7 def title(str):
8  return "<title>" + str + "</title>"
9 def heading1(str):
10  return "<h1>" + str + "</h1>"
11 def heading2(str):
12  return "<h2>" + str + "</h2>"
13 def heading3(str):
14  return "<h3>" + str + "</h3>"
15 def link(text, url, newTab=False):
16  l = '<a href="'+ url + '" '
17  if newTab:
18  l += 'target="_blank"'
19  l += '">' + text + "</a>"
20  return l
21 
22 def paragraph(str):
23  return "<p>" + str + "</p>"
24 def bold(str):
25  return "<b>" + str + "</b>"
26 def entry(str):
27  return "<li>" + str + "</li>"
28 def hrule():
29  return '<hr width="810px" align="left" noshade color="#000000">'
30 
31 def hruleWide():
32  return '<hr align="left" noshade color="#000000">'
33 
34 
35 
36 def img(path, mouseover=""):
37  return '<img src="' + path +'" alt="'+ mouseover +'">'
38 
39 
40 
42  return """
43  <meta http-equiv="cache-control" content="max-age=0" />
44  <meta http-equiv="cache-control" content="no-cache" />
45  <meta http-equiv="expires" content="0" />
46  <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
47  <meta http-equiv="pragma" content="no-cache" />
48  """
49 
50 
51 # Bootstrap stuff
52 
53 def bootStrap():
54  return """
55  <head>
56  <meta charset="utf-8">
57  <meta http-equiv="X-UA-Compatible" content="IE=edge">
58  <meta name="viewport" content="width=device-width, initial-scale=1">
59  <meta name="description" content="">
60  <meta name="author" content="">
61  <link rel="icon" href="../../favicon.ico">
62 
63 
64 
65  <!-- Bootstrap core CSS -->
66  <link href="../static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
67 
68  <!-- Custom styles for this template -->
69  <link href="../static/bootstrap/css/theme.css" rel="stylesheet">
70 
71  """
72 
73 def bodyOpen():
74  return '<body role="document">'
75 
76 def bodyClose():
77  return """
78  <!-- Bootstrap core JavaScript
79  ================================================== -->
80  <!-- Placed at the end of the document so the pages load faster -->
81  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
82  <script src="../static/bootstrap/js/bootstrap.min.js"></script>
83 
84  </body>'
85  """
86 
87 def jumbo(content):
88  t = ' <div class="jumbotron">' + endl
89  t+= " " + content + endl
90  t+= '</div>' + endl
91  return t
92 
93 def panel(title, content):
94  p = """<div class="panel panel-default">
95  <div class="panel-heading">
96  <h3 class="panel-title">""" + title + """</h3>
97  </div>
98  <div class="panel-body">
99  """+content+"""
100  </div>
101  </div>"""
102  return p
103 
104 def button(text, url):
105  b = '<button type="button" class="btn btn-default navbar-btn">'
106  b += link(text, url)
107  b += "</button>"
108  return b
109 
110 def alertDanger(text):
111  return '<div class="alert alert-danger" role="alert">'+text+'</div>'
112 
113 def alertLink(text, url, newTab=False):
114  l ='<a href="'+url+'"'
115  if newTab:
116  l += 'target="_blank"'
117  l += ' class="alert-link">'+text+'</a>'
118  return l
119 
120 
def button(text, url)
Definition: HTMLTools.py:104
def panel(title, content)
Definition: HTMLTools.py:93
def link(text, url, newTab=False)
Definition: HTMLTools.py:15
def preventCaching()
Definition: HTMLTools.py:41
def jumbo(content)
Definition: HTMLTools.py:87
def bold(str)
Definition: HTMLTools.py:24
def paragraph(str)
Definition: HTMLTools.py:22
def bootStrap()
Definition: HTMLTools.py:53
def alertDanger(text)
Definition: HTMLTools.py:110
def heading3(str)
Definition: HTMLTools.py:13
def img(path, mouseover="")
Definition: HTMLTools.py:36
def bodyClose()
Definition: HTMLTools.py:76
def hrule()
Definition: HTMLTools.py:28
def alertLink(text, url, newTab=False)
Definition: HTMLTools.py:113
def bodyOpen()
Definition: HTMLTools.py:73
def title(str)
Definition: HTMLTools.py:7
def heading1(str)
Definition: HTMLTools.py:9
def hruleWide()
Definition: HTMLTools.py:31
def entry(str)
Definition: HTMLTools.py:26
def heading2(str)
Definition: HTMLTools.py:11