# ----------------------------------------------------------
# Macros
-def _macro_TitleSearch():
+def _macro_TitleSearch(*vargs):
return _macro_search("titlesearch")
-def _macro_FullSearch():
+def _macro_FullSearch(*vargs):
return _macro_search("fullsearch")
def _macro_search(type):
default = form["value"].value
else:
default = ''
- return """<form method="get"><input name="%s" size="30" value="%s"><input type="submit" value="Go" /></form>""" % (type, default)
+ return """<form method="get"><input name="%s" size="30" value="%s" /><input type="submit" value="Search" /></form>""" % (type, default)
-def _macro_WordIndex():
+def _macro_WordIndex(*vargs):
s = make_index_key()
pages = list(page_list())
map = {}
return s
-def _macro_TitleIndex():
+def _macro_TitleIndex(*vargs):
s = make_index_key()
pages = list(page_list())
pages.sort()
return Page(word).link_to()
def _img_repl(self, word):
- return '<img border="0" src="%s/%s" />' % (script_name(), word)
+ path = script_name() + '/' + word;
+ return '<a href="%s"><img border="0" src="%s" /></a>' % (path, path)
def _url_repl(self, word):
if img_re.match(word):
- return '<img border="0" src="%s" />' % word
+ return '<a href="%s"><img border="0" src="%s" /></a>' % (word, word)
else:
return '<a href="%s" rel="nofollow" class="external">%s</a>' % (word, word)
def _hurl_repl(self, word):
- m = re.compile("\[\[(\S+)\ (.+)\]\]").match(word)
- anchor = m.group(1)
- descr = m.group(2)
- if img_re.match(anchor):
- return '<img border="0" src="%s" alt="%s" />' % (anchor, descr)
- elif url_re.match(anchor):
- return '<a href="%s" rel="nofollow" class="external">%s</a>' % (anchor, descr)
- elif anchor.startswith('/'):
- return '<a href="%s">%s</a>' % (anchor, descr)
+ m = re.compile("\[\[(\S+)([^\]]*)\]\]").match(word)
+ name = m.group(1)
+ descr = m.group(2).strip() or name
+
+ macro = globals().get('_macro_' + name)
+ if macro:
+ return apply(macro, (name, descr))
+ elif img_re.match(name):
+ return '<a href="%s"><img border="0" src="%s" alt="%s" /></a>' % (name, name, descr)
+ elif url_re.match(name):
+ return '<a href="%s" rel="nofollow" class="external">%s</a>' % (name, descr)
+ elif name.startswith('/'):
+ return '<a href="%s">%s</a>' % (name, descr)
else:
- return link_tag(anchor, descr)
+ return link_tag(name, descr)
def _email_repl(self, word):
return '<a href="mailto:%s">%s</a>' % (word, word)
return '</td><td>'
return ''
- def _macro_repl(self, word):
- macro_name = word[2:-2]
- # TODO: Somehow get the default value into the search field
- return apply(globals()['_macro_' + macro_name], ())
-
def _indent_level(self):
return len(self.list_indents) and self.list_indents[-1]
# Links
+ r"|(?P<img>\b[a-zA-Z0-9_-]+\.(png|gif|jpg|jpeg|bmp))"
+ r"|(?P<word>\b(?:[A-Z][a-z]+){2,}\b)"
- + r"|(?P<hurl>\[\[\S+\s+.+\]\])"
- + r"|(?P<url>(http|ftp|nntp|news|mailto)\:[^\s'\"]+\S)"
+ + r"|(?P<hurl>\[\[\S+[^\]]*\]\])"
+ + r"|(?P<url>(http|https|ftp|mailto)\:[^\s'\"]+\S)"
+ r"|(?P<email>[-\w._+]+\@[\w.-]+)"
# Lists, divs, spans
+ r"|(?P<tr>^\s*\|\|\s*)"
+ r"|(?P<tre>\s*\|\|\s*$)"
+ r"|(?P<td>\s*\|\|\s*)"
-
- # Macros
- + r"|(?P<macro>\[\[(TitleSearch|FullSearch|WordIndex|TitleIndex)\]\])"
+ r")")
pre_re = re.compile(
r"(?:"