X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=geekigeeki.py;h=79dda63e2c463df56b6e9790985b4005d727f2b4;hb=46efe19f353d79e0be12da32980ef1457a97d749;hp=4569894255a653ab73d6312e6a7f62354808ed0d;hpb=2776ec9d104a0cd3fefb2ebb09bf32f4f13cc80a;p=geekigeeki.git diff --git a/geekigeeki.py b/geekigeeki.py index 4569894..79dda63 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -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] == '/': @@ -143,7 +146,7 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal editable = name and writable and config_get('privileged_url') is not None if editable: print(' ' \ - % (privileged_path() + '?a=edit&q=' + name)) + % relative_url('?a=edit&q=' + name, privileged=True)) history = config_get('history_url') if history is not None: @@ -154,7 +157,7 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal # Body if editable: - print('
') + print('') else: print('') @@ -234,10 +237,13 @@ def link_inline(name, descr=None, kvargs={}): % (url, url, name) def link_inline_glob(pattern, descr=None, kvargs={}): - s = '' - for name in glob.glob(pattern): - s += link_inline(name, descr, kvargs) - return s + if not url_re.match(pattern) and bool(set(pattern) & set('?*[')): + s = '' + for name in glob.glob(pattern): + s += link_inline(name, descr, kvargs) + return s + else: + return link_inline(pattern, descr, kvargs) # Search --------------------------------------------------- @@ -345,7 +351,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("") @@ -367,7 +373,7 @@ class WikiFormatter: self.h_level = 0 self.in_pre = self.in_html = self.in_table = self.in_li = False self.in_header = True - self.list_indents = [] + self.list_indents = [] # a list of pairs (indent_level, list_type) to track nested lists self.tr_cnt = 0 self.styles = { #wiki html enabled? @@ -405,7 +411,7 @@ class WikiFormatter: return '' return s - def _undent(self): - res = '
' - res += ''
- self.list_indents = []
- return res
-
def replace(self, match):
for rule, hit in list(match.groupdict().items()):
if hit:
@@ -588,7 +589,7 @@ class WikiFormatter:
| (?P
') else: indent = indent_re.match(self.line) - #3.0: print(self._indent_to(len(indent.group(0))), end=' ') - print(self._indent_to(len(indent.group(0)))) + print(self._indent_to(len(indent.group(1)), indent.group(2))) + # Stand back! Here we apply the monster regex that does all the parsing print(re.sub(scan_re, self.replace, self.line)) if self.in_pre: print('') if self.in_table: print('
') - print(self._undent()) + print(self._indent_to(0)) print('
') class Page: @@ -665,13 +666,13 @@ class Page: out = '== ' pathname = '' for dirname in self.page_name.strip('/').split('/'): - pathname = (pathname + '/' + dirname) if pathname else dirname + pathname = (pathname and pathname + '/' ) + dirname out += '[[' + pathname + '|' + dirname + ']]/' out += ' ==\n' 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 +785,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)