From: Bernardo Innocenti Date: Tue, 12 Feb 2008 05:05:28 +0000 (+1000) Subject: Add upload support X-Git-Tag: v3.0~33 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=8219f46aeb18e422f05e561493f3dad023ce2585;p=geekigeeki.git Add upload support --- diff --git a/geekigeeki.py b/geekigeeki.py index 764f366..eef3d6c 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -144,7 +144,7 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error'): print text + ' ' print ' | ' + link_tag('FrontPage', 'Front Page', 'navlink') print ' | ' + link_tag('FindPage', 'Find Page', 'navlink') - if globals().has_key('history_url'): + if 'history_url' in globals(): print ' | Recent Changes' if name: print ' | Page History' @@ -227,17 +227,21 @@ def do_raw(pagename): def do_edit(pagename): pg = Page(pagename) - if 'preview' in form: - pg.send_editor(form['savetext'].value) - elif 'save' in form: - pg.save_text(form['savetext'].value) + if 'save' in form: + if form['file'].value: + pg.save(form['file'].file.read()) + else: + pg.save(form['savetext'].value.replace('\r\n', '\n')) pg.send_page() elif 'cancel' in form: pg.msg_text = 'Editing canceled' pg.msg_type = 'notice' pg.send_page() else: - pg.send_editor() + text = None + if 'preview' in form: + text = form['savetext'].value + pg.send_editor(text) def make_index_key(): links = map(lambda ch: '%s' % (ch, ch), 'abcdefghijklmnopqrstuvwxyz') @@ -249,7 +253,7 @@ def page_list(): def send_footer(name, mod_string=None): if globals().get('debug_cgi', False): cgi.print_arguments() - cgi.print_form(cgi.FieldStorage()) + cgi.print_form(form) cgi.print_environ() print '