X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=geekigeeki.py;h=b00838ae923d45ac5320579096b7d6f1cebb1b8d;hb=2bb00b8d6473a767cba8616e18d587f98c773354;hp=4569894255a653ab73d6312e6a7f62354808ed0d;hpb=2776ec9d104a0cd3fefb2ebb09bf32f4f13cc80a;p=geekigeeki.git
diff --git a/geekigeeki.py b/geekigeeki.py
index 4569894..b00838a 100755
--- a/geekigeeki.py
+++ b/geekigeeki.py
@@ -1,16 +1,16 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
-# Copyright 1999, 2000 Martin Pool '
+ text = '
'
link_class = kvargs.get('class', kvargs.get('cssclass', None))
if not link_class:
@@ -234,10 +239,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 ---------------------------------------------------
@@ -299,7 +307,7 @@ def handle_edit(pagename, form):
send_httperror("403 Forbidden", pagename)
return
- pg = Page(form['q'].value)
+ pg = Page(form['q'].value)
if 'save' in form:
if form['file'].value:
pg.save(form['file'].file.read(), form['changelog'].value)
@@ -339,14 +347,15 @@ def page_list(dirname=None, search_re=None):
search_re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$")
return sorted(filter(search_re.match, os.listdir(dirname or '.')))
-def send_footer(mtime=None):
+def send_footer(mtime=None, footer="sys/footer"):
if config_get('debug_cgi', False):
cgi.print_arguments()
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))
- })
+ if footer != "off":
+ link_inline(footer, kvargs = {
+ 'LAST_MODIFIED': strftime(config_get('datetime_fmt', '%a %d %b %Y %I:%M %p'), localtime(mtime))
+ })
print("")
def _macro_ELAPSED_TIME(*args, **kvargs):
@@ -367,7 +376,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?
@@ -380,7 +389,6 @@ class WikiFormatter:
",,": ["sub", False],
"''": ["em", False], # LEGACY
"'''": ["b", False], # LEGACY
- "``": ["tt", False], # LEGACY
}
def _b_repl(self, word):
@@ -405,7 +413,7 @@ class WikiFormatter:
return '
'
def _rule_repl(self, word):
- return self._undent() + '\n
\n' % (len(word) - 2)
+ return '\n
\n' % (len(word) - 2)
def _macro_repl(self, word):
try:
@@ -418,7 +426,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 = '' + msg + ''
return msg
@@ -512,31 +520,26 @@ class WikiFormatter:
return ''
def _indent_level(self):
- return len(self.list_indents) and self.list_indents[-1]
+ return len(self.list_indents) and self.list_indents[-1][0]
- def _indent_to(self, new_level):
+ def _indent_to(self, new_level, list_type=''):
if self._indent_level() == new_level:
return ''
s = '
' 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:
@@ -549,7 +552,7 @@ class WikiFormatter:
scan_re = re.compile(r"""(?:
# Styles and formatting ("--" must cling to a word to disambiguate it from the dash)
- (?P \*\* | // | \#\# | __ | --\b | \b-- | \^\^ | ,, | ''' | '' | `` )
+ (?P \*\* | // | \#\# | __ | --\b | \b-- | \^\^ | ,, | ''' | '' )
| (?P
\\\\)
| (?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: def __init__(self, page_name): - self.page_name = page_name + self.page_name = page_name.rstrip('/'); self.msg_text = '' self.msg_type = 'error' @@ -665,19 +668,20 @@ 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' + images_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' + images_out += '{{' + self.page_name + '/' + filename + ' | ' + humanlink(filename) + maxwidth + ' | class=thumbleft}}\n' else: out += ' * [[' + self.page_name + '/' + filename + ']]\n' - return out + return out + images_out def pragmas(self): if not '_pragmas' in self.__dict__: @@ -693,7 +697,7 @@ class Page: #print "bernie: pragmas[" + m.group(1) + "] = " + m.group(2) + "