-
-# ----------------------------------------------------------
-# Macros
-def _macro_TitleSearch(*vargs):
- return _macro_search("titlesearch")
-
-def _macro_FullSearch(*vargs):
- return _macro_search("fullsearch")
-
-def _macro_search(type):
- if form.has_key('value'):
- default = form["value"].value
- else:
- default = ''
- return """<form method="get"><input name="%s" size="30" value="%s" /><input type="submit" value="Search" /></form>""" % (type, default)
-
-def _macro_WordIndex(*vargs):
- s = make_index_key()
- pages = list(page_list())
- map = {}
- word_re = re.compile('[A-Z][a-z]+')
- for name in pages:
- for word in word_re.findall(name):
- try:
- map[word].append(name)
- except KeyError:
- map[word] = [name]
-
- all_words = map.keys()
- all_words.sort()
- last_letter = None
- # set title
- for word in all_words:
- letter = string.lower(word[0])
- if letter <> last_letter:
- s = s + '; <a name="%s"><h3>%s</h3></a>' % (letter, letter)
- last_letter = letter
-
- s = s + '<b>%s</b><ul>' % word
- links = map[word]
- links.sort()
- last_page = None
- for name in links:
- if name == last_page: continue
- s = s + '<li>' + Page(name).link_to()
- s = s + '</ul>'
- return s
-
-
-def _macro_TitleIndex(*vargs):
- s = make_index_key()
- pages = list(page_list())
- pages.sort()
- current_letter = None
- for name in pages:
- letter = string.lower(name[0])
- if letter <> current_letter:
- s = s + '<a name="%s"><h3>%s</h3></a>' % (letter, letter)
- current_letter = letter
- else:
- s = s + '<br />'
- s = s + Page(name).link_to()
- return s
-
-
-# ----------------------------------------------------------
-class PageFormatter: