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, re=None):
- if re is None:
+def page_list(dirname=None, search_re=None):
+ if search_re is None:
# FIXME: WikiWord is too restrictive now!
- re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$")
- return sorted(filter(re.match, os.listdir(dirname or data_dir)))
+ 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 '.')))
- def send_footer(mod_string=None):
+ def send_footer(mtime=None):
- if globals().get('debug_cgi', False):
+ if config_get('debug_cgi', False):
cgi.print_arguments()
cgi.print_form(form)
cgi.print_environ()
- link_inline("sys/footer", kvargs = { 'LAST_MODIFIED': mod_string })
- #FIXME link_inline("sys/footer")
- print('''
-<div id="footer"><hr />
-<p class="copyright">
-<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img class="license" alt="Creative Commons License" src="%s" /></a>
-<span class="benchmark">generated in %0.3fs</span> by <a href="http://www.codewiz.org/wiki/GeekiGeeki">GeekiGeeki</a> version %s
-</p>
-''' % (relative_url('sys/cc-by-sa.png'), clock() - start_time, __version__))
- if mtime:
- print('<p class="modified">last modified %s</p>' % strftime(datetime_fmt, localtime(mtime)))
- print('</div></body></html>')
++ link_inline("sys/footer", kvargs = {
++ 'LAST_MODIFIED': strftime(config_get(datetime_fmt, '%a %d %b %Y %I:%M %p'), localtime(mtime))
++ })
+ print("</body></html>")
+
+def _macro_ELAPSED_TIME(*args, **kvargs):
+ return "%03f" % (clock() - start_time)
+
+def _macro_VERSION(*args, **kvargs):
+ return __version__
class WikiFormatter:
"""Object that turns Wiki markup into HTML.
return re.sub('([a-z])([A-Z])', r'\1 \2', self.page_name)
def _filename(self):
- return os.path.join(data_dir, self.page_name)
+ return self.page_name
def _tmp_filename(self):
- return os.path.join(data_dir, ('#' + self.page_name.replace('/','_') + '.' + str(os.getpid()) + '#'))
+ return self.page_name + '.tmp' + str(os.getpid()) + '#'
- def exists(self):
+ def _mtime(self):
try:
- os.stat(self._filename())
- return True
+ return os.stat(self._filename()).st_mtime
except OSError, err:
if err.errno == errno.ENOENT:
- return False
+ return None
raise err
+ def exists(self):
+ if self._mtime():
+ return True
+ return False
+
def get_raw_body(self, default=None):
try:
return open(self._filename(), 'rb').read()