X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=geekigeeki.py;h=d7e1a5a9e0d28a466e8f40b5704df5d4ea77148f;hb=ff74de7a49cc2bfa936503a4b37fc5c8a650a5fc;hp=cf69d55e013c25335643290af2dde44b8820f91a;hpb=e8b84c43bb30331bdca8f81b9fb9bdc5c3ea8521;p=geekigeeki.git
diff --git a/geekigeeki.py b/geekigeeki.py
index cf69d55..d7e1a5a 100755
--- a/geekigeeki.py
+++ b/geekigeeki.py
@@ -3,7 +3,7 @@
#
# Copyright 1999, 2000 Martin Pool
# Copyright 2002 Gerardo Poggiali
-# Copyright 2007, 2008 Bernardo Innocenti
+# Copyright 2007, 2008 Bernie Innocenti
#
# 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
@@ -28,11 +28,12 @@ from os import path, environ
# Regular expression defining a WikiWord
# (but this definition is also assumed in other places)
-word_re = re.compile(r"^\b((([A-Z][a-z]+){2,}/)*([A-Z][a-z]+){2,})\b$")
+word_re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$")
# FIXME: we accept stuff like foo/../bar and we shouldn't
file_re = re.compile(r"^\b([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)\b$")
img_re = re.compile(r"^.*\.(png|gif|jpg|jpeg)$", re.IGNORECASE)
url_re = re.compile(r"^[a-z]{3,8}://[^\s'\"]+\S$")
+link_re = re.compile("(?:\[\[|{{)([^\s\|]+)(?:\s*\|\s*([^\]]+)|)(?:\]\]|}})")
title_done = False
@@ -233,11 +234,11 @@ def handle_edit(pagename):
pg.save(form['file'].file.read())
else:
pg.save(form['savetext'].value.replace('\r\n', '\n'))
- pg.send_page()
+ pg.format()
elif 'cancel' in form:
pg.msg_text = 'Editing canceled'
pg.msg_type = 'notice'
- pg.send_page()
+ pg.format()
else: # preview or edit
text = None
if 'preview' in form:
@@ -248,8 +249,8 @@ def make_index_key():
links = map(lambda ch: '%s' % (ch, ch), 'abcdefghijklmnopqrstuvwxyz')
return ''+ ' | '.join(links) + '
'
-def page_list():
- return filter(word_re.match, os.listdir(data_dir))
+def page_list(dir = None, re = word_re):
+ return filter(re.match, os.listdir(dir or data_dir))
def send_footer(name, mod_string=None):
if globals().get('debug_cgi', False):
@@ -264,68 +265,7 @@ def send_footer(name, mod_string=None):
print 'last modified %s
' % mod_string
print '