projects
/
geekigeeki.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add benchmark.
[geekigeeki.git]
/
geekigeeki.py
diff --git
a/geekigeeki.py
b/geekigeeki.py
index 0c1423a97d7534e64d9e9da53cf64e3578e641a5..ad4fc5dd0683fd99b62fd6a5df85903cb4fa1da9 100755
(executable)
--- a/
geekigeeki.py
+++ b/
geekigeeki.py
@@
-1,10
+1,8
@@
#! /usr/bin/env python
#! /usr/bin/env python
-"""Quick-quick implementation of WikiWikiWeb in Python
-"""
#
#
-# Copyright
(C)
1999, 2000 Martin Pool <mbp@humbug.org.au>
-#
This version includes additional changes by Gerardo Poggiali (2002)
-#
This version includes additional changes by Bernardo Innocenti (2007)
+# Copyright 1999, 2000 Martin Pool <mbp@humbug.org.au>
+#
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
#
# 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 <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-__version__ = '$Revision: 1.63+gerry+bernie $'[11:-2]
+__version__ = '$Id$'[4:12]
+
+from time import clock
+start_time = clock()
-import cgi, sys, string, os, re, errno,
time,
stat
+import cgi, sys, string, os, re, errno, stat
from os import path, environ
# Regular expression defining a WikiWord
from os import path, environ
# Regular expression defining a WikiWord
@@
-192,7
+193,6
@@
def do_fullsearch(needle):
print_search_stats(len(hits), len(all_pages))
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 + '"')
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,7
+208,6
@@
def do_titlesearch(needle):
print_search_stats(len(hits), len(all_pages))
print_search_stats(len(hits), len(all_pages))
-
def print_search_stats(hits, searched):
print "<p>%d hits out of %d pages searched.</p>" % (hits, searched)
def print_search_stats(hits, searched):
print "<p>%d hits out of %d pages searched.</p>" % (hits, searched)
@@
-241,23
+240,23
@@
def make_index_key():
s = s + '</center></p>'
return s
s = s + '</center></p>'
return s
-
def page_list():
return filter(word_re.match, os.listdir(text_dir))
def page_list():
return filter(word_re.match, os.listdir(text_dir))
-
def send_footer(name, mod_string=None):
if debug_cgi:
cgi.print_arguments()
cgi.print_form(cgi.FieldStorage())
cgi.print_environ()
def send_footer(name, mod_string=None):
if debug_cgi:
cgi.print_arguments()
cgi.print_form(cgi.FieldStorage())
cgi.print_environ()
+ global __version__
print '<div id="footer"><hr />'
print '<div id="footer"><hr />'
- print '<p class="copyright">Powered by <a href="http://www.codewiz.org/wiki/GeekiGeeki">GeekiGeeki</a></p>'
+ 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>'
if mod_string:
print '<p class="modified">last modified %s</p>' % mod_string
print '</div></body></html>'
-
# ----------------------------------------------------------
# Macros
def _macro_TitleSearch(*vargs):
# ----------------------------------------------------------
# Macros
def _macro_TitleSearch(*vargs):
@@
-584,10
+583,7
@@
class Page:
if self.exists():
return link_tag(word, word, 'wikilink')
else:
if self.exists():
return link_tag(word, word, 'wikilink')
else:
- if nonexist_qm:
- return link_tag(word, '?', 'nonexistent') + word
- else:
- return link_tag(word, word, 'nonexistent')
+ return link_tag(word, nonexist_pfx + word, 'nonexistent')
def get_raw_body(self):
try:
def get_raw_body(self):
try:
@@
-754,7
+750,7
@@
try:
datetime_fmt = '%a %d %b %Y %I:%M %p'
allow_edit = True # Is it possible to edit pages?
show_hosts = True # show hostnames?
datetime_fmt = '%a %d %b %Y %I:%M %p'
allow_edit = True # Is it possible to edit pages?
show_hosts = True # show hostnames?
- nonexist_
qm = False # show '?' for nonexistent?
+ nonexist_
pfx = '' # prefix before nonexistent link (usually '?')
debug_cgi = False # Set to True for CGI var dump
form = cgi.FieldStorage()
debug_cgi = False # Set to True for CGI var dump
form = cgi.FieldStorage()