X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=geekigeeki.py;h=cd92c54edffbd737d1d6affdbe7e94f83faf3a2b;hb=9f2fe21749316eaf332c37b6f6fbbc12237dd1cf;hp=ec64ca9f42d41eebedeaf7e7f385b77429be360a;hpb=2d4c364b47b01894842b7ae21535ea00cf420722;p=geekigeeki.git
diff --git a/geekigeeki.py b/geekigeeki.py
index ec64ca9..cd92c54 100755
--- a/geekigeeki.py
+++ b/geekigeeki.py
@@ -1,10 +1,9 @@
-#! /usr/bin/env python
-"""Quick-quick implementation of WikiWikiWeb in Python
-"""
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
#
-# 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 +18,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-__version__ = '$Revision: 1.63+gerry+bernie $'[11:-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
@@ -43,7 +45,10 @@ def privileged_path():
return privileged_url or script_name()
def remote_user():
- return environ.get('REMOTE_USER', 'AnonymousCoward')
+ user = environ.get('REMOTE_USER', '')
+ if user is None or user == '' or user == 'anonymous':
+ user = 'AnonymousCoward'
+ return user
def remote_host():
return environ.get('REMOTE_ADDR', '')
@@ -53,7 +58,7 @@ def get_hostname(addr):
from socket import gethostbyaddr
return gethostbyaddr(addr)[0] + ' (' + addr + ')'
except:
- return addr;
+ return addr
# Formatting stuff --------------------------------------------------
@@ -62,7 +67,7 @@ def emit_header(type="text/html"):
print
def send_guru(msg, msg_type):
- if msg is None or len(msg) == 0: return
+ if msg is None or msg == '': return
print '
'
def link_tag(params, text=None, ss_class=None, authentication=False):
if text is None:
@@ -152,8 +159,7 @@ def link_tag(params, text=None, ss_class=None, authentication=False):
classattr = ''
if ss_class:
classattr += 'class="%s" ' % ss_class
- # Prevent crawlers from following links to generated pages
- # and links added by potential spammers
+ # Prevent crawlers from following links potentially added by spammers or to generated pages
if ss_class == 'external' or ss_class == 'navlink':
classattr += 'rel="nofollow" '
if authentication:
@@ -185,13 +191,12 @@ def do_fullsearch(needle):
for (count, page_name) in hits:
print '