#
# Copyright 1999, 2000 Martin Pool <mbp@humbug.org.au>
# Copyright 2002 Gerardo Poggiali
-# Copyright 2007, 2008 Bernie Innocenti <bernie@codewiz.org>
+# Copyright 2007, 2008, 2009 Bernie Innocenti <bernie@codewiz.org>
#
# 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
title_done = False
-
# CGI stuff ---------------------------------------------------------
-
def script_name():
return os.environ.get('SCRIPT_NAME', '')
+def query_string():
+ path_info = os.environ.get('PATH_INFO', '')
+ if len(path_info) and path_info[0] == '/':
+ return path_info[1:] or 'FrontPage'
+ else:
+ return os.environ.get('QUERY_STRING', '') or 'FrontPage'
+
def privileged_path():
return privileged_url or script_name()
# Navbar
print '<div class="nav">'
+ print link_tag('FrontPage', relative_url(site_icon or 'Home'), 'navlink')
if name:
print ' <b>' + link_tag('?fullsearch=' + name, text, 'navlink') + '</b> '
else:
print ' <b>' + text + '</b> '
- print ' | ' + link_tag('FrontPage', 'Home', 'navlink')
print ' | ' + link_tag('FindPage', 'Find Page', 'navlink')
if 'history_url' in globals():
print ' | <a href="' + relative_url(history_url) + '" class="navlink">Recent Changes</a>'
user = remote_user()
if user != 'AnonymousCoward':
- print ' | <span class="login"><i>logged in as <b>' + cgi.escape(user) + '</b></i></span>'
+ print ' | <span class="login"><i><b>' + link_tag('User/' + user, user) + '</b></i></span>'
print '<hr /></div>'
return '<a %shref="%s">%s</a>' % (classattr, relative_url(params, privileged=privileged), text)
+def link_inline(name, descr=None, args=''):
+ if not descr: descr = name
+ if video_re.match(name):
+ return '<video src="%s">Your browser does not support the HTML5 video tag</video>' % name
+ else:
+ return '<a href="%s"><img border="0" src="%s" alt="%s" /></a>' % (name, name + args, descr)
+
# Search ---------------------------------------------------
def handle_fullsearch(needle):
self.styles = {
#wiki html enabled?
"//": ["em", False],
- "''": ["em", False],
"**": ["b", False],
- "'''": ["b", False],
"##": ["tt", False],
- "``": ["tt", False],
"__": ["u", False],
"^^": ["sup", False],
- ",,": ["sub", False]
+ ",,": ["sub", False],
+ "''": ["em", False], # LEGACY
+ "'''": ["b", False], # LEGACY
+ "``": ["tt", False], # LEGACY
}
def _b_repl(self, word):
if macro:
return macro(argv)
else:
- return '<strong class="error"><<' + '|'.join(argv) + '>></strong>'
+ msg = '<<' + '|'.join(argv) + '>>'
+ if not self.in_html:
+ msg = '<strong class="error">' + msg + '</strong>'
+ return msg
def _hurl_repl(self, word):
m = link_re.match(word)
return link_tag(m.group(1), m.group(2))
- def _url_repl(self, word):
- return link_tag(word)
-
- def _word_repl(self, word):
- return link_tag(word)
-
def _inl_repl(self, word):
m = link_re.match(word)
name = relative_url(m.group(1))
args = '?' + '&'.join(argv)
# The "extthumb" nonsense works around a limitation of the HTML block model
- return '<div class="extthumb"><div class="thumb"><a href="%s"><img border="0" src="%s" alt="%s" /></a><div class="caption">%s</div></div></div>' \
- % (name, name + args, descr, descr)
- elif video_re.match(name):
- return '<video src="%s">Your browser does not support the HTML5 video tag</video>' % name
+ return '<div class="extthumb"><div class="thumb">' \
+ + link_inline(name, descr, args) \
+ + '<div class="caption">' + descr + '</div></div></div>'
else:
- return '<a href="%s"><img border="0" src="%s" /></a>' % (name, name)
-
- def _img_repl(self, word):
- return self._inl_repl('{{' + word + '}}')
-
- def _email_repl(self, word):
- return '<a href="mailto:%s">%s</a>' % (word, word)
+ return link_inline(name, name)
def _html_repl(self, word):
self.in_html += 1
return word; # Pass through
+ def _htmle_repl(self, word):
+ self.in_html -= 1
+ return word; # Pass through
+
def _ent_repl(self, s):
- if self.in_html and s == '>':
- self.in_html -= 1
- return '>'
+ if self.in_html:
+ return s; # Pass through
return {'&': '&',
'<': '<',
'>': '>'}[s]
+ def _img_repl(self, word): # LEGACY
+ return self._inl_repl('{{' + word + '}}')
+
+ def _word_repl(self, word): # LEGACY
+ if self.in_html: return word # pass through
+ return link_tag(word)
+
+ def _url_repl(self, word): # LEGACY
+ if self.in_html: return word # pass through
+ return link_tag(word)
+
+ def _email_repl(self, word): # LEGACY
+ if self.in_html: return word # pass through
+ return '<a href="mailto:%s">%s</a>' % (word, word)
+
def _li_repl(self, match):
if self.in_li:
return '</li><li>'
| (?P<tit> \={2,6})
| (?P<br> \\\\)
| (?P<rule> ^-{3,})
- | (?P<hi> \b(FIXME|TODO|DONE)\b)
+ | (?P<hi> \b( FIXME | TODO | DONE )\b )
# Links
| (?P<macro> \<\<([^\s\|\>]+)(?:\s*\|\s*([^\>]+)|)\>\>)
| (?P<hurl> \[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\])
# Inline HTML
- | (?P<html> <(/|)(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])[^>]*>)
- | (?P<ent> [<>&])
+ | (?P<html> <(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])\b )
+ | (?P<htmle> ( /\s*> | </(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])> ) )
+ | (?P<ent> [<>&] )
# Auto links (LEGACY)
| (?P<img> \b[a-zA-Z0-9_/-]+\.(png|gif|jpg|jpeg|bmp|ico|ogm|ogg|mkv|mpg|mpeg|mp4|avi|asf|flv|wmv|qt))
handler(form[cmd].value)
break
else:
- path_info = os.environ.get('PATH_INFO', '')
- if len(path_info) and path_info[0] == '/':
- query = path_info[1:] or 'FrontPage'
- else:
- query = os.environ.get('QUERY_STRING', '') or 'FrontPage'
-
+ query = query_string()
if file_re.match(query):
if word_re.match(query):
Page(query).format()