summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorUlrike Uhlig <u@451f.org>2014-09-15 19:19:11 +0000
committerUlrike Uhlig <u@451f.org>2014-09-15 19:19:11 +0000
commit4263759ab3aaba01a12be658f899bad36f4376bc (patch)
treec650f52c5c071b1f6c80cc02a2f3b764d1fa7242 /lib
parent4b894c5634c409a2e9265cd2d5f450910d934ad1 (diff)
use nav element for menu on homepage. add some css for nav and pre elements, improve h1.
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@28803 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'lib')
-rw-r--r--lib/python/web_support.py44
1 files changed, 23 insertions, 21 deletions
diff --git a/lib/python/web_support.py b/lib/python/web_support.py
index d5cef51228..2eabfaae1e 100644
--- a/lib/python/web_support.py
+++ b/lib/python/web_support.py
@@ -1,16 +1,16 @@
# web_support.py -- simple HTTP generation framework
# Copyright (C) 2005 Florian Weimer <fw@deneb.enyo.de>
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -114,7 +114,7 @@ class Service:
self.handle(cli, env, data, result)
client.sendall(result.getvalue())
client.close()
-
+
except ServinvokeError:
client.close()
pass
@@ -126,7 +126,7 @@ class Service:
target = cStringIO.StringIO()
traceback.print_exc(None, target)
self.log("%s", target.getvalue())
-
+
def handle(args, environ, data):
"""Invoke by run to handle a single request. Should
return the data to be sent back to the client."""
@@ -146,7 +146,7 @@ class URLFactory:
This factory class handles the case where a script wants to
generate URLs which reference to itself (see scriptRelative)."""
-
+
def __init__(self, server_name, script_name, path_info='',
params={}, secure=False):
self.server_name = server_name or 'localhost'
@@ -177,15 +177,15 @@ class URLFactory:
while arg[:1] == '/':
arg = arg[1:]
return arg
-
+
def absolute(self, url, **args):
"""Creates an absolute URL, with optional arguments to pass."""
-
+
return URL(url + self._convertArgs(args))
def absoluteDict(self, url, args):
"""Creates an absolute URL, with arguments to pass."""
-
+
return URL(url + self._convertArgs(args))
def scriptRelative(self, path, **args):
@@ -195,7 +195,7 @@ class URLFactory:
return URL("/%s%s%s" % (self.script_name,
self._stripSlashes(path),
self._convertArgs(args)))
-
+
def scriptRelativeFull(self, path, **args):
"""Like scriptRelative, but returns an absolute URL, including
the http:// prefix."""
@@ -235,7 +235,7 @@ del _initStringToHTML
def escapeHTML(str):
'''Replaces the characters <>&" in the passed strings with their
HTML entities.'''
-
+
result = []
append = result.append
for ch in str:
@@ -263,7 +263,7 @@ class HTMLBase:
class VerbatimHTML(HTMLBase):
"""Creates verbatim HTML from a string object. Mainly used for
optimizing recurring HTML snippets."""
-
+
def __init__(self, contents):
self.__contents = contents
@@ -288,13 +288,13 @@ class Compose(HTMLBase):
def compose(*contents):
"""Concatenates several HTML objects."""
return Compose(contents)
-
+
class Tag(HTMLBase):
"""Base class for HTML tags."""
-
+
re_name = re.compile(r'\A_?[a-zA-Z][a-zA-Z0-9]*\Z')
-
+
def __init__(self, name, contents, attribs={}):
self._check(name)
self.__name = name
@@ -342,7 +342,7 @@ class Tag(HTMLBase):
pass
raise
write(closing)
-
+
else:
write("<%s%s/>" % (self.__name, self.__attribs))
@@ -356,7 +356,7 @@ class Tag(HTMLBase):
def tag(__name, __contents, **__attribs):
"""Creates a new tag object.
-
+
name - name of the tag
contents - a sequence objet (or iterator) for the enclosed contents
attribs - keyword arguments froming forming attributes
@@ -429,6 +429,8 @@ def HEADER(*__contents, **__attribs):
return Tag('header', __contents, __attribs)
def FOOTER(*__contents, **__attribs):
return Tag('footer', __contents, __attribs)
+def NAV(*__contents, **__attribs):
+ return Tag('nav', __contents, __attribs)
def _linkify(match):
extra = match.group(2)
@@ -555,7 +557,7 @@ class PathRouter:
'wildcard ** in the middle of path'
m['**'] = value
return
-
+
m_new = {}
m[element] = m_new
m = m_new
@@ -734,7 +736,7 @@ class WebServiceBase:
def pre_dispatch(self, url):
"""Invoked by handle prior to calling the registered handler."""
pass
-
+
class WebService(Service, WebServiceBase):
"CGI service implemented using servinvoke"
def __init__(self, socket_name):
@@ -778,7 +780,7 @@ class WebServiceHTTP(WebServiceBase):
self.lock = threading.Lock()
self.__parse_base_url(base_url)
-
+
service_self = self
class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
@@ -839,7 +841,7 @@ class WebServiceHTTP(WebServiceBase):
self.secure = m.group(1) == "https"
self.server_name = m.group(2)
self.script_name = m.group(3)
-
+
def __test():
assert str(URL("")) == ""

© 2014-2024 Faster IT GmbH | imprint | privacy policy