ATLAS Offline Software
Classes | Functions | Variables
WebPage Namespace Reference

Classes

class  GlobalConfiguration
 
class  HelloWorld
 
class  htmlTable
 
class  WebPage
 
class  WebPageConfigurationError
 

Functions

def sep (s)
 
def htmlDiv (id, contents='', attr='', keepEmptyDiv=True)
 
def htmlText (text, attr='', escapeText=False)
 
def htmlPre (text, attr='', escapeText=False)
 
def htmlPara (text='', attr='', escapeText=False)
 
def htmlLink (text, link, attr='', escapeText=False)
 
def htmlList (contents, attr='', listType='ul')
 
def htmlLI (text, attr='', escapeText=False)
 
def htmlFoldingSection (header, content, isClosed=True, headerClass='section-header', contentClass='section-content')
 
def htmlForm (contents, action='', method='post', attr='')
 
def htmlLabel (labelText, parName, attr='')
 
def htmlSelect (labelText, parName, args, choiceList, hint=None, descriptionSeparator='::', labelAttr='', attr='')
 
def htmlCheckbox (labelText, parName, args, labelAttr='', attr='')
 
def htmlTextInput (labelText, parName, args, size=None, maxLength=None, labelAttr='', attr='')
 
def htmlSubmit (text, parName, attr='', onlyOnce=False)
 

Variables

string __author__ = 'Juerg Beringer'
 
string __version__ = 'WebPage.py atlas/athena'
 
string startPage
 
string endPage
 

Function Documentation

◆ htmlCheckbox()

def WebPage.htmlCheckbox (   labelText,
  parName,
  args,
  labelAttr = '',
  attr = '' 
)
Make a checkbox (including label with text).

Definition at line 206 of file WebPage.py.

206 def htmlCheckbox(labelText, parName, args, labelAttr='', attr=''):
207  """Make a checkbox (including label with text)."""
208  snippet = htmlLabel(labelText,parName,labelAttr)
209  checked = 'checked="checked"' if parName in args else ''
210  snippet += '<input type="checkbox" name="%s"%s%s/>\n' % (parName,sep(checked),sep(attr))
211  return snippet
212 

◆ htmlDiv()

def WebPage.htmlDiv (   id,
  contents = '',
  attr = '',
  keepEmptyDiv = True 
)
Make a named div element containing contents. If
   contents is empty, an empty string is returned,
   unless keepEmtpyDiv is set True.

Definition at line 46 of file WebPage.py.

46 def htmlDiv(id, contents='', attr='', keepEmptyDiv=True):
47  """Make a named div element containing contents. If
48  contents is empty, an empty string is returned,
49  unless keepEmtpyDiv is set True."""
50  if contents or keepEmptyDiv:
51  if id:
52  return '<div id="%s"%s>\n%s</div>\n' % (id,sep(attr),contents)
53  else:
54  return '<div%s>\n%s</div>\n' % (sep(attr),contents)
55  else:
56  return ''
57 

◆ htmlFoldingSection()

def WebPage.htmlFoldingSection (   header,
  content,
  isClosed = True,
  headerClass = 'section-header',
  contentClass = 'section-content' 
)
Generate the html for a folding section using the toggleSection JavaScript utility
   from WebPageUtils.js and CSS classes section-closed, section-open, and hidden.

Definition at line 154 of file WebPage.py.

154 def htmlFoldingSection(header, content, isClosed=True,
155  headerClass='section-header',
156  contentClass='section-content'):
157  """Generate the html for a folding section using the toggleSection JavaScript utility
158  from WebPageUtils.js and CSS classes section-closed, section-open, and hidden."""
159  if isClosed:
160  s = '<div class="section-closed" onclick="toggleSection(this);">'
161  else:
162  s = '<div class="section-open" onclick="toggleSection(this);">'
163  s += '<span class="%s">%s</span></div>\n' % (headerClass,header)
164  h = ' hidden' if isClosed else ''
165  s += '<div class="%s%s">\n%s</div>\n' % (contentClass,h,content)
166  return s
167 

◆ htmlForm()

def WebPage.htmlForm (   contents,
  action = '',
  method = 'post',
  attr = '' 
)

Definition at line 168 of file WebPage.py.

168 def htmlForm(contents, action='', method='post', attr=''):
169  snippet = '<form action="%s" method="%s"%s>\n' % (action,method,sep(attr))
170  snippet += '<fieldset>\n'
171  snippet += contents
172  snippet += '</fieldset>\n</form>\n'
173  return snippet
174 

◆ htmlLabel()

def WebPage.htmlLabel (   labelText,
  parName,
  attr = '' 
)
Make a label for parName. If labelText is None,
   an empty string is returned.

Definition at line 175 of file WebPage.py.

175 def htmlLabel(labelText, parName, attr=''):
176  """Make a label for parName. If labelText is None,
177  an empty string is returned."""
178  if labelText!=None:
179  return '<label for="%s"%s>%s</label>' % (parName,sep(attr),labelText)
180  else:
181  return ''
182 

◆ htmlLI()

def WebPage.htmlLI (   text,
  attr = '',
  escapeText = False 
)
Make a list item.  Special HTML characters
   in the text are properly replaced (using escape from cgi) if
   escapeText is set True.

Definition at line 85 of file WebPage.py.

85 def htmlLI(text, attr='', escapeText=False):
86  """Make a list item. Special HTML characters
87  in the text are properly replaced (using escape from cgi) if
88  escapeText is set True."""
89  return '<li%s>%s</li>\n' % (sep(attr), escape(text) if escapeText else text)
90 

◆ htmlLink()

def WebPage.htmlLink (   text,
  link,
  attr = '',
  escapeText = False 
)

Definition at line 77 of file WebPage.py.

77 def htmlLink(text, link, attr='', escapeText=False):
78  return '<a href="%s"%s>%s</a>' % (link,sep(attr),escape(text) if escapeText else text)
79 

◆ htmlList()

def WebPage.htmlList (   contents,
  attr = '',
  listType = 'ul' 
)
Enclose list contents (a string with one or more list items) with
   the proper list tag. The type of the list is given by listType.

Definition at line 80 of file WebPage.py.

80 def htmlList(contents, attr='', listType='ul'):
81  """Enclose list contents (a string with one or more list items) with
82  the proper list tag. The type of the list is given by listType."""
83  return '<%s%s>\n%s</%s>\n' % (listType,sep(attr),contents,listType)
84 

◆ htmlPara()

def WebPage.htmlPara (   text = '',
  attr = '',
  escapeText = False 
)
Make a paragraph.

Definition at line 70 of file WebPage.py.

70 def htmlPara(text='', attr='', escapeText=False):
71  """Make a paragraph."""
72  if text or attr:
73  return '<p%s>%s</p>\n' % (sep(attr), escape(text) if escapeText else text)
74  else:
75  return '<p>\n'
76 

◆ htmlPre()

def WebPage.htmlPre (   text,
  attr = '',
  escapeText = False 
)
Make a preformatted text section. Special HTML characters
   in the text are properly replaced (using escape from cgi) if
   escapeText is set True.

Definition at line 64 of file WebPage.py.

64 def htmlPre(text, attr='', escapeText=False):
65  """Make a preformatted text section. Special HTML characters
66  in the text are properly replaced (using escape from cgi) if
67  escapeText is set True."""
68  return '<pre%s>\n%s\n</pre>\n' % (sep(attr),escape(text) if escapeText else text)
69 

◆ htmlSelect()

def WebPage.htmlSelect (   labelText,
  parName,
  args,
  choiceList,
  hint = None,
  descriptionSeparator = '::',
  labelAttr = '',
  attr = '' 
)
Make a select statement (including label with text).

Definition at line 183 of file WebPage.py.

183 def htmlSelect(labelText, parName, args, choiceList, hint=None, descriptionSeparator='::', labelAttr='', attr=''):
184  """Make a select statement (including label with text)."""
185  snippet = htmlLabel(labelText,parName,labelAttr)
186  default = args[parName] if parName in args else ''
187  if not isinstance(default,list):
188  default = [default]
189  snippet += '<select name="%s"%s>\n' % (parName,sep(attr))
190  if hint:
191  snippet += '<option value="">%s</option>\n' % hint
192  for c in choiceList:
193  p = c.split(descriptionSeparator)
194  if len(p)==2:
195  (desc,val) = p
196  else:
197  (desc,val) = (c,c)
198  if val in default:
199  snippet += '<option selected="yes" value="%s">%s</option>\n' % (val,desc)
200  else:
201  snippet += '<option value="%s">%s</option>\n' % (val,desc)
202  snippet += '</select>\n'
203  return snippet
204 
205 

◆ htmlSubmit()

def WebPage.htmlSubmit (   text,
  parName,
  attr = '',
  onlyOnce = False 
)
Make a submit button. If onlyOnce is true, the button can only
   be clicked once in order to prevent multiple clicking of the
   submit button.

Definition at line 227 of file WebPage.py.

227 def htmlSubmit(text, parName, attr='', onlyOnce=False):
228  """Make a submit button. If onlyOnce is true, the button can only
229  be clicked once in order to prevent multiple clicking of the
230  submit button."""
231  if onlyOnce:
232  # FIXME: this doesn't work yet - it disables submission
233  s = '<input type="button" name="%s" value="%s"' % (parName,text)
234  s += ' onclick="this.form.submit()"'
235  s += '%s />\n' % sep(attr)
236  return s
237  else:
238  return '<input type="submit" name="%s" value="%s"%s />\n' % (parName,text,sep(attr))
239 
240 
241 #
242 # Utility classes
243 #

◆ htmlText()

def WebPage.htmlText (   text,
  attr = '',
  escapeText = False 
)
Make a text consisting of an unnamed div. Special HTML characters
   in the text are properly replaced (using escape from cgi) if
   escapeText is set True.

Definition at line 58 of file WebPage.py.

58 def htmlText(text, attr='', escapeText=False):
59  """Make a text consisting of an unnamed div. Special HTML characters
60  in the text are properly replaced (using escape from cgi) if
61  escapeText is set True."""
62  return '<div%s>%s</div>\n' % (sep(attr),escape(text) if escapeText else text)
63 

◆ htmlTextInput()

def WebPage.htmlTextInput (   labelText,
  parName,
  args,
  size = None,
  maxLength = None,
  labelAttr = '',
  attr = '' 
)
Make a text input area (including label with text). Special HTML
   characters in any default text are properly replaced.

Definition at line 213 of file WebPage.py.

213 def htmlTextInput(labelText, parName, args, size=None, maxLength = None, labelAttr='', attr=''):
214  """Make a text input area (including label with text). Special HTML
215  characters in any default text are properly replaced."""
216  snippet = htmlLabel(labelText,parName,labelAttr)
217  snippet += '<input type="text" name="%s"' % parName
218  if parName in args:
219  snippet += ' value="%s"' % escape(args[parName],True)
220  if size!=None:
221  snippet += ' size="%s"' % size
222  if maxLength!=None:
223  snippet += ' maxlength="%s"' % maxLength
224  snippet += '%s/>\n' % sep(attr)
225  return snippet
226 

◆ sep()

def WebPage.sep (   s)
Add separator to string s unless s is empty.

Definition at line 42 of file WebPage.py.

42 def sep(s):
43  """Add separator to string s unless s is empty."""
44  return ' '+s if s else s
45 

Variable Documentation

◆ __author__

string WebPage.__author__ = 'Juerg Beringer'
private

Definition at line 9 of file WebPage.py.

◆ __version__

string WebPage.__version__ = 'WebPage.py atlas/athena'
private

Definition at line 10 of file WebPage.py.

◆ endPage

string WebPage.endPage
Initial value:
1 = """\
2 </body>
3 </html>\
4 """

Definition at line 33 of file WebPage.py.

◆ startPage

string WebPage.startPage
Initial value:
1 = """\
2 %(contentType)s<?xml version="1.0" encoding="UTF-8"?>
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7 <title>%(pageTitle)s</title>
8 <link href="%(cssName)s" rel="stylesheet" type="text/css" />
9 %(pageHeaderSnippets)s\
10 </head>
11 <body>
12 """

Definition at line 20 of file WebPage.py.

WebPage.htmlLink
def htmlLink(text, link, attr='', escapeText=False)
Definition: WebPage.py:77
WebPage.htmlForm
def htmlForm(contents, action='', method='post', attr='')
Definition: WebPage.py:168
WebPage.htmlPara
def htmlPara(text='', attr='', escapeText=False)
Definition: WebPage.py:70
WebPage.htmlTextInput
def htmlTextInput(labelText, parName, args, size=None, maxLength=None, labelAttr='', attr='')
Definition: WebPage.py:213
WebPage.htmlCheckbox
def htmlCheckbox(labelText, parName, args, labelAttr='', attr='')
Definition: WebPage.py:206
WebPage.htmlDiv
def htmlDiv(id, contents='', attr='', keepEmptyDiv=True)
Definition: WebPage.py:46
WebPage.sep
def sep(s)
Definition: WebPage.py:42
WebPage.htmlList
def htmlList(contents, attr='', listType='ul')
Definition: WebPage.py:80
WebPage.htmlLI
def htmlLI(text, attr='', escapeText=False)
Definition: WebPage.py:85
WebPage.htmlText
def htmlText(text, attr='', escapeText=False)
Definition: WebPage.py:58
WebPage.htmlSelect
def htmlSelect(labelText, parName, args, choiceList, hint=None, descriptionSeparator='::', labelAttr='', attr='')
Definition: WebPage.py:183
WebPage.htmlLabel
def htmlLabel(labelText, parName, attr='')
Definition: WebPage.py:175
WebPage.htmlFoldingSection
def htmlFoldingSection(header, content, isClosed=True, headerClass='section-header', contentClass='section-content')
Definition: WebPage.py:154
WebPage.htmlPre
def htmlPre(text, attr='', escapeText=False)
Definition: WebPage.py:64
WebPage.htmlSubmit
def htmlSubmit(text, parName, attr='', onlyOnce=False)
Definition: WebPage.py:227