Allow retrieving the script path
[geekigeeki.git] / geekigeeki.py
index 4569894255a653ab73d6312e6a7f62354808ed0d..5b26b553da7b344af20ce8d416693d95449f80de 100755 (executable)
@@ -36,6 +36,9 @@ def config_get(key, default=None):
 def script_name():
     return os.environ.get('SCRIPT_NAME', '')
 
+def script_path():
+    return os.path.split(os.environ.get('SCRIPT_FILENAME', ''))[0]
+
 def query_string():
     path_info = os.environ.get('PATH_INFO', '')
     if len(path_info) and path_info[0] == '/':
@@ -345,7 +348,7 @@ def send_footer(mtime=None):
         cgi.print_form(form)
         cgi.print_environ()
     link_inline("sys/footer", kvargs = {
-        'LAST_MODIFIED': strftime(config_get(datetime_fmt, '%a %d %b %Y %I:%M %p'), localtime(mtime))
+        'LAST_MODIFIED': strftime(config_get('datetime_fmt', '%a %d %b %Y %I:%M %p'), localtime(mtime))
     })
     print("</body></html>")
 
@@ -418,7 +421,7 @@ class WikiFormatter:
                 macro = globals().get('_macro_' + args[0])
             return macro(*args, **kvargs)
         except Exception, e:
-            msg = cgi.escape(word) + ": " + cgi.escape(e.message)
+            msg = cgi.escape(word) + ": " + cgi.escape(str(e))
             if not self.in_html:
                 msg = '<strong class="error">' + msg + '</strong>'
             return msg
@@ -671,7 +674,7 @@ class Page:
  
         for filename in page_list(self._filename(), file_re):
             if image_re.match(filename):
-                maxwidth = config_get(image_maxwidth, '')
+                maxwidth = config_get('image_maxwidth', '400')
                 if maxwidth:
                     maxwidth = ' | maxwidth=' + str(maxwidth)
                 out += '{{' + self.page_name + '/' + filename + ' | ' + humanlink(filename) + maxwidth + ' | class=thumbleft}}\n'
@@ -784,7 +787,7 @@ class Page:
             except OSError, err:
                 if err.errno != errno.ENOENT: raise err
         path = os.path.split(name)[0]
-        if not os.path.exists(path):
+        if path and not os.path.exists(path):
             os.makedirs(path)
         os.rename(tmp_filename, name)