X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=geekigeeki.py;h=64333eaf0605d79abdc674eb9a5042fed05e5050;hb=8b1c9ab129dd6bb01fb0675e146394e7ca547f43;hp=764f3665de6fff91f4e773fc918cdae5adb65a7a;hpb=99acd9376fc3cdaf9dfe9218c78aede47c54968c;p=geekigeeki.git diff --git a/geekigeeki.py b/geekigeeki.py index 764f366..64333ea 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) +img_re = re.compile(r"^.*\.(png|gif|jpg|jpeg|bmp|ico)$", re.IGNORECASE) url_re = re.compile(r"^[a-z]{3,8}://[^\s'\"]+\S$") +link_re = re.compile("(?:\[\[|{{)([^\s\|]+)(?:\s*\|\s*([^\]]+)|)(?:\]\]|}})") title_done = False @@ -70,8 +71,10 @@ def relative_url(pathname, privileged=False): pathname = url + '/' + pathname return pathname -# Formatting stuff -------------------------------------------------- +def permalink(s): + return re.sub(' ', '-', re.sub('[^a-z0-9_ ]', '', s.lower()).strip()) +# Formatting stuff -------------------------------------------------- def emit_header(mime_type="text/html"): print "Content-type: " + mime_type + "; charset=utf-8\n" @@ -107,7 +110,7 @@ def send_guru(msg_text, msg_type): } """ -def send_title(name, text="Limbo", msg_text=None, msg_type='error'): +def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=False): global title_done if title_done: return @@ -122,12 +125,23 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error'): print ' ' if not name: print ' ' - for css in css_url: - print ' ' % relative_url(css) + + for link in link_urls: + rel, href = link + print ' ' % (rel, relative_url(href)) + + if name and writable and privileged_url is not None: + print ' ' \ + % (privileged_path() + '?edit=' + name) + + if history_url is not None: + print ' ' \ + % relative_url(history_url + '?a=rss') + print '' # Body - if name and privileged_url is not None: + if name and writable and privileged_url is not None: print '' else: print '' @@ -137,22 +151,25 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error'): # Navbar print '