X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=geekigeeki.py;h=fbf3d93e96b3e1ac322b19055aed56c7d7b3e159;hb=4b7c0eb2e64ba9ac910dd57c545c2a455077632b;hp=79f99efcd292e67034554823a04ca557aa1a19ff;hpb=2048d6cc1d4792f816b2204554984c15fb3d7886;p=geekigeeki.git diff --git a/geekigeeki.py b/geekigeeki.py index 79f99ef..fbf3d93 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -78,26 +78,25 @@ def relative_url(pathname, privileged=False): else: url = script_name() pathname = url + '/' + pathname - return pathname + return cgi.escape(pathname, quote=True) def permalink(s): return re.sub(' ', '-', re.sub('[^a-z0-9_ ]', '', s.lower()).strip()) # Formatting stuff -------------------------------------------------- def emit_header(mime_type="text/html"): - print "Content-type: " + mime_type + "; charset=utf-8\n" + print("Content-type: " + mime_type + "; charset=utf-8\n") def send_guru(msg_text, msg_type): if not msg_text: return - print '
' + print('' \ + % relative_url('sys/GuruMeditation.js')) def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=False): global title_done @@ -105,74 +104,74 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal # Head emit_header() - print '' - print '' + print('') + print('') - print "') if msg_type == 'error': - print ' Software Failure. Press left mouse button to continue.\n' - print msg_text + print(' Software Failure. Press left mouse button to continue.\n') + print(msg_text) if msg_type == 'error': print '\n Guru Meditation #DEADBEEF.ABADC0DE' - print '' - print '' \ - % relative_url('sys/GuruMeditation.js') + print('
' + link_tag(page_name) - print ' . . . . ' + `count` - print ['match', 'matches'][count != 1] - print '
' + link_tag(page_name)) + print(' . . . . ' + `count`) + print(['match', 'matches'][count != 1]) + print('
' + link_tag(filename) + "
' + link_tag(filename) + "
%d hits out of %d pages searched.
" % (hits, searched) + print("%d hits out of %d pages searched.
" % (hits, searched)) def handle_raw(pagename): if not file_re.match(pagename): @@ -287,9 +286,10 @@ def handle_edit(pagename): text = form['savetext'].value pg.send_editor(text) +# Used by macros/WordIndex and macros/TitleIndex def make_index_key(): - links = map(lambda ch: '%s' % (ch, ch), 'abcdefghijklmnopqrstuvwxyz') - return '' + ' | '.join(links) + '
' def page_list(dirname = None, re = word_re): return sorted(filter(re.match, os.listdir(dirname or data_dir))) @@ -299,16 +299,16 @@ def send_footer(mod_string=None): cgi.print_arguments() cgi.print_form(form) cgi.print_environ() - print ''' + print(''' ' + print('last modified %s
' % mod_string) + print('') class WikiFormatter: """Object that turns Wiki markup into HTML. @@ -363,13 +363,13 @@ class WikiFormatter: argv = [name] if m.group(2): argv.extend(m.group(2).split('|')) - argv = map(str.strip, argv) + argv = list(map(str.strip, argv)) macro = globals().get('_macro_' + name) if not macro: try: - execfile("macros/" + name + ".py", globals()) - except IOError, err: + exec(open("macros/" + name + ".py").read(), globals()) + except IOError as err: if err.errno == errno.ENOENT: pass macro = globals().get('_macro_' + name) if macro: @@ -402,11 +402,13 @@ class WikiFormatter: return link_inline(name, name) def _html_repl(self, word): + if not self.in_html and word.startswith('' + print('
') scan_re = re.compile(r"""(?: # Styles and formatting @@ -549,9 +551,9 @@ class WikiFormatter: indent_re = re.compile(r"^\s*") tr_re = re.compile(r"^\s*\|\|") eol_re = re.compile(r"\r?\n") - # For each line, we scan through looking for magic strings, outputting verbatim any intervening text - for self.line in eol_re.split(self.raw.expandtabs()): + #3.0: for self.line in eol_re.split(str(self.raw.expandtabs(), 'utf-8')): + for self.line in eol_re.split(str(self.raw.expandtabs())): # Skip pragmas if self.in_header: if self.line.startswith('#'): @@ -559,23 +561,24 @@ class WikiFormatter: self.in_header = False if self.in_pre: - print re.sub(pre_re, self.replace, self.line) + print(re.sub(pre_re, self.replace, self.line)) else: if self.in_table and not tr_re.match(self.line): self.in_table = False - print '
' + print('
') if blank_re.match(self.line): - print '
' + print('
') else: indent = indent_re.match(self.line) - print self._indent_to(len(indent.group(0))) , - print re.sub(scan_re, self.replace, self.line) + #3.0: print(self._indent_to(len(indent.group(0))), end=' ') + print(self._indent_to(len(indent.group(0)))) + print(re.sub(scan_re, self.replace, self.line)) - if self.in_pre: print '' - if self.in_table: print '
' - print self._undent() - print '
') + print(self._undent()) + print('
Editing ' + self.page_name + print(('
Editing ' + self.page_name + ' for ' + cgi.escape(remote_user()) + ' from ' + cgi.escape(get_hostname(remote_host())) - + '
') - print '