- s = '<p><center>'
- links = map(lambda ch: '<a href="#%s">%s</a>' % (ch, ch),
- string.lowercase)
- s = s + string.join(links, ' | ')
- s = s + '</center></p>'
- return s
-
-def page_list():
- return filter(word_re.match, os.listdir(data_dir))
-
-def send_footer(name, mod_string=None):
- if globals().get('debug_cgi', False):
- cgi.print_arguments()
- cgi.print_form(cgi.FieldStorage())
- cgi.print_environ()
- global __version__
- print '<div id="footer"><hr />'
- print ('<p class="copyright"><span class="benchmark">generated in %0.3fs</span>' +
- ' by <a href="http://www.codewiz.org/wiki/GeekiGeeki">GeekiGeeki</a>' +
- ' version %s</p>') % (clock() - start_time, __version__)
- if mod_string:
- print '<p class="modified">last modified %s</p>' % mod_string
- print '</div></body></html>'
-
-# ----------------------------------------------------------
-# 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
+ links = ['<a href="#%s">%s</a>' % (ch, ch) for ch in 'abcdefghijklmnopqrstuvwxyz']
+ return '<p style="text-align: center">' + ' | '.join(links) + '</p>'
+
+def page_list(dirname=None, search_re=None):
+ if search_re is None:
+ # FIXME: WikiWord is too restrictive now!
+ search_re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$")
+ return sorted(filter(search_re.match, os.listdir(dirname or '.')))