X-Git-Url: https://codewiz.org/gitweb?p=geekigeeki.git;a=blobdiff_plain;f=geekigeeki.py;h=12b6b7cdaec57d05e14baadd381c17a6431029bb;hp=e7001abc60ce63edd26aa03c838c6208816b53ec;hb=75836706224e9f6b8ede6c59deea646e31672924;hpb=76a9e7542e0ed64a3054882db2cf4ae18e4f558e
diff --git a/geekigeeki.py b/geekigeeki.py
index e7001ab..12b6b7c 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,12 +17,13 @@
# 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
-from socket import gethostbyaddr
-from time import localtime, strftime
# Regular expression defining a WikiWord
# (but this definition is also assumed in other places)
@@ -35,24 +34,39 @@ url_re = re.compile(r"^[a-z]{3,8}://[^\s'\"]+\S$")
title_done = False
-def emit_header(type="text/html"):
- print "Content-type: " + type + "; charset=utf-8"
- print
-
-# Formatting stuff --------------------------------------------------
+# CGI stuff ---------------------------------------------------------
-def get_scriptname():
+def script_name():
return environ.get('SCRIPT_NAME', '')
+def privileged_path():
+ return privileged_url or script_name()
+
+def remote_user():
+ 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', '')
+
def get_hostname(addr):
try:
+ from socket import gethostbyaddr
return gethostbyaddr(addr)[0] + ' (' + addr + ')'
except:
- return addr;
+ return addr
+
+# Formatting stuff --------------------------------------------------
+
+def emit_header(type="text/html"):
+ print "Content-type: " + type + "; charset=utf-8"
+ print
def send_guru(msg, msg_type):
- if msg is None or len(msg) == 0: return
+ if msg is None or msg == '': return
print '
'
if msg_type == 'error':
print ' Software Failure. Press left mouse button to continue.\n'
@@ -60,7 +74,7 @@ def send_guru(msg, msg_type):
if msg_type == 'error':
print ' Guru Meditation #DEADBEEF.ABADC0DE'
print '
'
- # FIXME: This simple JS code is harder to pass than ACID 3.0
+ # FIXME: This simple JS snippet is harder to pass than ACID 3.0
print """
"""
-def send_title(name, text="Limbo", msg=None, msg_type = 'error'):
+def send_title(name, text="Limbo", msg=None, msg_type='error'):
global title_done
if title_done: return
# Head
emit_header()
- print """
-
-"""
+ print ''
+ print ''
+
+ site_name = globals().get('site_name', 'Unconfigured Site')
print "%s: %s" % (site_name, text)
- print ' '
+ print ' '
if not name:
- print ' '
- if css_url:
+ print ' '
+ if globals().has_key('css_url'):
print ' ' % css_url
print ''
# Body
- if name and allow_edit:
- print ''
+ if name and privileged_url is not None:
+ print ''
else:
print ''
+ title_done = True
send_guru(msg, msg_type)
# Navbar
- print '