[kommentointi Panu Kalliokoski **20090826124117] { hunk ./piki.py 44 +def norm_ws( string ): + return string.replace( '\r\n', '\n' ).rstrip() + '\n' hunk ./piki.py 191 +def do_comment(pagename): + Page(pagename).send_comment_editor() hunk ./piki.py 248 +def do_save(pg, savetext, oldtext): + pagename = pg.page_name + status_map = { None: 'no', False: 'ok', True: 'confl' } + save_status = status_map[pg.save_text( savetext, oldtext )] + redir_url = '%s%s?saved=%s' % \ + (get_scriptname(), urlquote( pagename ), save_status) + emit_http_header() + print """Talletettu %s + +

Muutoksesi talletettu.

Katso + tänne""" % (pagename, redir_url, redir_url) + hunk ./piki.py 262 - status_map = { None: 'no', False: 'ok', True: 'confl' } - def norm_ws( string ): - return string.replace( '\r\n', '\n' ).rstrip() + '\n' hunk ./piki.py 274 + do_save(pg, savetext, oldtext) hunk ./piki.py 276 - save_status = status_map[pg.save_text( savetext, oldtext )] - - redir_url = '%s%s?saved=%s' % \ - (get_scriptname(), urlquote( pagename ), save_status) - emit_http_header() - print """Talletettu %s - -

Muutoksesi talletettu.

Katso - tänne""" % (pagename, redir_url, redir_url) - +def do_savecomment(pagename): + global form + pg = Page(pagename) + try: + nick = form['nick'].value + comment = norm_ws( form['commenttext'].value ) + except KeyError: problem = "Fix your calibration." + else: + oldtext = pg.get_raw_body() + savetext = '%s\n[%s]: %s' % (oldtext, nick, comment) + problem = suspicious_change(savetext, oldtext, oldtext) + if problem: + emit_http_header() + print "

Boo! %s

" % problem + return + do_save(pg, savetext, oldtext) hunk ./piki.py 307 - if mod_string: print "
(viimeksi muutettu %s)" % mod_string + print "
" + if editable: print link_tag("?comment=" + urlquote(name), "kommentoi") + if mod_string: print " (viimeksi muutettu %s)" % mod_string hunk ./piki.py 721 + def send_comment_editor(self): + send_title('Kommentoitavana ' + self.split_title()) + print_formatted('editor-pre') + print '
' % (get_scriptname()) + print '' % (self.page_name) + print 'Nimimerkkisi:
' + print """""" + print """
""" + print "
" + print_formatted('editor-post') + send_normal_footer(self.page_name, 0, self.last_modified()) + hunk ./piki.py 762 + 'comment': do_comment, hunk ./piki.py 767 + 'savecomment': do_savecomment, }