X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=geekigeeki.py;h=e110d8dafe256395a021980b7d8813eb0fa5d58c;hb=1549a288ad7fa65066b0b52739618c011898d2a3;hp=e6cfeca70ef5501177e27af3711418b1636cb81c;hpb=05e3e729c0e20765f418c5efd35ab4426afb2fb7;p=geekigeeki.git
diff --git a/geekigeeki.py b/geekigeeki.py
index e6cfeca..e110d8d 100755
--- a/geekigeeki.py
+++ b/geekigeeki.py
@@ -1,10 +1,8 @@
#! /usr/bin/env python
-"""Quick-quick implementation of WikiWikiWeb in Python
-"""
#
-# Copyright (C) 1999, 2000 Martin Pool
-# This version includes additional changes by Gerardo Poggiali (2002)
-# This version includes additional changes by Bernardo Innocenti (2007)
+# Copyright 1999, 2000 Martin Pool
+# Copyright 2002 Gerardo Poggiali
+# Copyright 2007 Bernardo 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
@@ -19,9 +17,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-__version__ = '$Id$'[3:-2]
+__version__ = '$Id$'[4:12]
-import cgi, sys, string, os, re, errno, time, stat
+from time import clock
+start_time = clock()
+
+import cgi, sys, string, os, re, errno, stat
from os import path, environ
# Regular expression defining a WikiWord
@@ -102,15 +103,16 @@ def send_title(name, text="Limbo", msg=None, msg_type='error'):
# Head
emit_header()
- print """
-
-"""
+ print ''
+ print ''
+
+ site_name = globals().get('site_name', 'Unconfigured Site')
print "%s: %s" % (site_name, text)
print ' '
if not name:
print ' '
- if css_url:
+ if globals().has_key('css_url'):
print ' ' % css_url
print ''
@@ -132,10 +134,12 @@ def send_title(name, text="Limbo", msg=None, msg_type='error'):
print text + ' '
print ' | ' + link_tag('FrontPage', 'Front Page', 'navlink')
print ' | ' + link_tag('FindPage', 'Find Page', 'navlink')
- print ' | Recent Changes'
+ if globals().has_key('history_url'):
+ print ' | Recent Changes'
+ if name:
+ print ' | Page History'
if name:
- print ' | Page History'
print ' | ' + link_tag('?raw=' + name, 'Raw Text', 'navlink')
if privileged_url is not None:
print ' | ' + link_tag('?edit=' + name, 'Edit Page', 'navlink', authentication=True)
@@ -186,13 +190,12 @@ def do_fullsearch(needle):
for (count, page_name) in hits:
print '
'
print ""
print_search_stats(len(hits), len(all_pages))
-
def do_titlesearch(needle):
# TODO: check needle is legal -- but probably we can just accept any RE
send_title(None, "Title search for \"" + needle + '"')
@@ -208,10 +211,10 @@ def do_titlesearch(needle):
print_search_stats(len(hits), len(all_pages))
-
def print_search_stats(hits, searched):
print "
%d hits out of %d pages searched.
" % (hits, searched)
+#TODO: merge into do_savepage()
def do_edit(pagename):
Page(pagename).send_editor()
@@ -241,26 +244,23 @@ def make_index_key():
s = s + '
'
return s
-
def page_list():
return filter(word_re.match, os.listdir(text_dir))
-
def send_footer(name, mod_string=None):
- if debug_cgi:
+ if globals().get('debug_cgi', False):
cgi.print_arguments()
cgi.print_form(cgi.FieldStorage())
cgi.print_environ()
global __version__
print ''
-
# ----------------------------------------------------------
# Macros
def _macro_TitleSearch(*vargs):
@@ -294,7 +294,7 @@ def _macro_WordIndex(*vargs):
# set title
for word in all_words:
letter = string.lower(word[0])
- if letter <> last_letter:
+ if letter != last_letter:
s = s + ';
' % (letter, letter)
last_letter = letter
@@ -316,7 +316,7 @@ def _macro_TitleIndex(*vargs):
current_letter = None
for name in pages:
letter = string.lower(name[0])
- if letter <> current_letter:
+ if letter != current_letter:
s = s + '