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 '<pre id="guru" onclick="this.style.display = \'none\'" class="' + msg_type + '">'
if msg_type == 'error':
print '\n Guru Meditation #DEADBEEF.ABADC0DE'
print '</pre>'
- # FIXME: This little JS snippet is harder to pass than ACID 3.0
- print """
- <script language="JavaScript" type="text/javascript">
- var guru = document.getElementById('guru');
- // Firefox 2.0 doesn't take border-color, but returns border-top-color fine
- var color = document.defaultView.getComputedStyle(guru,null).getPropertyValue('border-top-color');
-
- function guruOn() {
- guru.style.setProperty('border-color', color, '');
- setTimeout('guruOff()', 1000);
- }
- function guruOff() {
- guru.style.setProperty('border-color', '#000000', '');
- setTimeout('guruOn()', 1000);
- }
- // Safari 2.0 returns this rgba crap
- // Konqueror 3.5.6 doesn't seem to support computed properties
- if (color && color != 'rgba(0, 0, 0, 0)') {
- //window.alert("enabled! color='" + color + "'");
- guruOn();
- }
- </script>"""
+ 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
--- /dev/null
+<script language="JavaScript" type="text/javascript">
+// Copyright 2008, 2009 Bernie Innocenti <bernie@codewiz.org>
+//
+// FIXME: The following JS snippet is harder to pass than ACID 3
+
+var guru = document.getElementById('guru');
+
+// Firefox 2.0 doesn't take border-color, but returns border-top-color fine
+var color = document.defaultView.getComputedStyle(guru,null).getPropertyValue('border-top-color');
+
+function guruOn() {
+ guru.style.setProperty('border-color', color, '');
+ setTimeout('guruOff()', 1000);
+}
+function guruOff() {
+ guru.style.setProperty('border-color', '#000000', '');
+ setTimeout('guruOn()', 1000);
+}
+// Safari 2.0 returns this rgba crap
+// Konqueror 3.5.6 doesn't seem to support computed properties
+if (color && color != 'rgba(0, 0, 0, 0)') {
+ //window.alert("enabled! color='" + color + "'");
+ guruOn();
+}
+</script>