Better CSS support
[geekigeeki.git] / geekigeeki.py
index ec64ca9f42d41eebedeaf7e7f385b77429be360a..116b03b480911485162d8c6bacc49b3cddd1f523 100755 (executable)
@@ -19,7 +19,7 @@
 # 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__ = '$Revision: 1.63+gerry+bernie $'[11:-2]
 
 import cgi, sys, string, os, re, errno, time, stat
 from os import path, environ
@@ -43,7 +43,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 +56,7 @@ def get_hostname(addr):
         from socket import gethostbyaddr
         return gethostbyaddr(addr)[0] + ' (' + addr + ')'
     except:
-        return addr;
+        return addr
 
 # Formatting stuff --------------------------------------------------
 
@@ -62,7 +65,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 '<pre id="guru" onclick="this.style.display = \'none\'" class="' + msg_type + '">'
     if msg_type == 'error':
         print '    Software Failure.  Press left mouse button to continue.\n'
@@ -117,10 +120,11 @@ def send_title(name, text="Limbo", msg=None, msg_type='error'):
     else:
         print '<body>'
 
+    title_done = True
     send_guru(msg, msg_type)
 
     # Navbar
-    print '<div class="navigator">'
+    print '<div class="nav">'
     print '  <b>' + site_name + ': ',
     if name:
         print link_tag('?fullsearch=' + name, text) + '</b> '
@@ -128,10 +132,10 @@ def send_title(name, text="Limbo", msg=None, msg_type='error'):
         print text + '</b> '
     print ' | ' + link_tag('FrontPage', 'Front Page', 'navlink')
     print ' | ' + link_tag('FindPage', 'Find Page', 'navlink')
-    print ' | <a href="/wikigit/wiki.git" class="navlink">Recent Changes</a>'
+    print ' | <a href="' + history_url + '" class="navlink">Recent Changes</a>'
 
     if name:
-        print ' | <a href="/wikigit/wiki.git?a=history;f=' + name + '" class="navlink">Page History</a>'
+        print ' | <a href="' + history_url + '?a=history;f=' + name + '" class="navlink">Page History</a>'
         print ' | ' + link_tag('?raw=' + name, 'Raw Text', 'navlink')
         if privileged_url is not None:
             print ' | ' + link_tag('?edit=' + name, 'Edit Page', 'navlink', authentication=True)
@@ -140,11 +144,9 @@ def send_title(name, text="Limbo", msg=None, msg_type='error'):
 
     user = remote_user()
     if user != 'AnonymousCoward':
-        print ' | <i>logged in as <b>' + cgi.escape(user) + '</b></i>'
-
-    print '</div>'
+        print ' | <span class="login"><i>logged in as <b>' + cgi.escape(user) + '</b></i></span>'
 
-    title_done = True
+    print '<hr /></div>'
 
 def link_tag(params, text=None, ss_class=None, authentication=False):
     if text is None:
@@ -253,9 +255,10 @@ def send_footer(name, mod_string=None):
         cgi.print_arguments()
         cgi.print_form(cgi.FieldStorage())
         cgi.print_environ()
-    print '<div class="footer">'
+    print '<div id="footer"><hr />'
+    print '<p class="copyright">Powered by <a href="http://www.codewiz.org/wiki/GeekiGeeki">GeekiGeeki</a></p>'
     if mod_string:
-        print "last modified %s" % mod_string
+        print '<p class="modified">last modified %s</p>' % mod_string
     print '</div></body></html>'
 
 
@@ -354,7 +357,7 @@ class PageFormatter:
         else:
             self.h_level = len(word) - 1
             result = "<h%d>" % self.h_level
-        return result;
+        return result
 
     def _rule_repl(self, word):
         s = self._undent()
@@ -685,6 +688,7 @@ try:
     data_dir = '/home/bernie/public_html/wiki'
     text_dir = path.join(data_dir, 'text')
     css_url = '../wikidata/geekigeeki.css'  # optional stylesheet link
+    history_url = '../wikigit/wiki.git'
     post_edit_hook = './post_edit_hook.sh'
     datetime_fmt = '%a %d %b %Y %I:%M %p'
     allow_edit = True                       # Is it possible to edit pages?