From 0e8be00cfec89d1c4db0081b65c5b66265c5b15c Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Wed, 8 Apr 2009 18:21:21 +0200 Subject: [PATCH] Move Guru Meditation javascript code outside --- geekigeeki.py | 33 +++++++++++---------------------- gurumeditation.js | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 gurumeditation.js diff --git a/geekigeeki.py b/geekigeeki.py index 774225b..9f4400f 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -81,6 +81,13 @@ def permalink(s): def emit_header(mime_type="text/html"): print "Content-type: " + mime_type + "; charset=utf-8\n" +def sendfile(dest_file, src_file): + """Efficiently copy file data between file descriptors""" + while 1: + data = src_file.read(65536) + if not data: break + dest_file.write(data) + def send_guru(msg_text, msg_type): if not msg_text: return print '
'
@@ -90,28 +97,10 @@ def send_guru(msg_text, msg_type):
     if msg_type == 'error':
         print '\n      Guru Meditation #DEADBEEF.ABADC0DE'
     print '
' - # FIXME: This little JS snippet is harder to pass than ACID 3.0 - print """ - """ + try: + sendfile(sys.stdout, open('gurumeditation.js', 'rb')) + except IOError, err: + pass def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=False): global title_done diff --git a/gurumeditation.js b/gurumeditation.js new file mode 100644 index 0000000..0f783a9 --- /dev/null +++ b/gurumeditation.js @@ -0,0 +1,25 @@ + -- 2.25.1