X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=geekigeeki.py;h=56d71f156f6b62984397e1b91d66ce73427b658e;hb=a2b12762880b05790a30c3996a0468ce69dd7f89;hp=190964478d979134e3c699776a5656923f0ed183;hpb=01057766514a73e0df07470e71c94b0508b2e5bf;p=geekigeeki.git
diff --git a/geekigeeki.py b/geekigeeki.py
index 1909644..56d71f1 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
@@ -36,11 +38,17 @@ title_done = False
# 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():
- 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', '')
@@ -50,7 +58,7 @@ def get_hostname(addr):
from socket import gethostbyaddr
return gethostbyaddr(addr)[0] + ' (' + addr + ')'
except:
- return addr;
+ return addr
# Formatting stuff --------------------------------------------------
@@ -59,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 '
'
if msg_type == 'error':
print ' Software Failure. Press left mouse button to continue.\n'
@@ -67,7 +75,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 ' ' % css_url
+ print ' '
+ for css in css_url:
+ print ' ' % css
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 '