X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=geekigeeki.py;h=7193d5520b50af8bb709453f3cb53f721d9c7efd;hb=e3f54bfe72a742afbe81e363bacc1869959f50c9;hp=e7001abc60ce63edd26aa03c838c6208816b53ec;hpb=76a9e7542e0ed64a3054882db2cf4ae18e4f558e;p=geekigeeki.git
diff --git a/geekigeeki.py b/geekigeeki.py
index e7001ab..7193d55 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,12 +18,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 +35,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
+# CGI stuff ---------------------------------------------------------
-# Formatting 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 +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 '