- print ' 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>"""
-
-def send_title(name, text="Limbo", msg_text=None, msg_type='error'):
- global title_done
- if title_done: return
-
- # Head
- emit_header()
- print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'
- print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
- print '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'
-
- site_name = globals().get('site_name', 'Unconfigured Site')
- print "<head><title>%s: %s</title>" % (site_name, text)
- print ' <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />'
- if not name:
- print ' <meta name="robots" content="noindex,nofollow" />'
- for css in css_url:
- print ' <link rel="stylesheet" type="text/css" href="%s" />' % relative_url(css)
- print '</head>'
-
- # Body
- if name and privileged_url is not None:
- print '<body ondblclick="location.href=\'' + privileged_path() + '?edit=' + name + '\'">'
- else:
- print '<body>'
-
- title_done = True
- send_guru(msg_text, msg_type)
-
- # Navbar
- print '<div class="nav">'
- if name:
- print ' <b>' + link_tag('?fullsearch=' + name, text, 'navlink') + '</b> '
+ print '\n Guru Meditation #DEADBEEF.ABADC0DE'
+ print('</pre><script type="text/javascript" src="%s" defer="defer"></script>' \
+ % relative_url('sys/GuruMeditation.js'))
+
+def send_httperror(status="403 Not Found", query="", trace=False):
+ print("Status: %s" % status)
+ msg_text = "%s: on query '%s'" % (status, query)
+ if trace:
+ import traceback
+ msg_text += '\n\n' + traceback.format_exc()
+ page = Page()
+ page.send_title(msg_text=msg_text)
+ page.send_footer()
+
+def link_tag(dest, text=None, privileged=False, **kvargs):
+ if text is None:
+ text = humanlink(dest)
+ elif image_re.match(text):
+ text = '<img style="border: 0" src="' + relative_url(text) + '" alt="' + text + '" />'
+
+ link_class = kvargs.get('class', kvargs.get('cssclass', None))
+ if not link_class:
+ if is_external_url(dest):
+ link_class = 'external'
+ elif file_re.match(dest) and Page(dest).exists():
+ link_class = 'wikilink'
+ else:
+ text = config_get('nonexist_pfx', '') + text
+ link_class = 'nonexistent'
+
+ # Prevent crawlers from following links potentially added by spammers or to generated pages
+ nofollow = ''
+ if link_class == 'external' or link_class == 'navlink':
+ nofollow = 'rel="nofollow" '
+
+ return '<a class="%s" %shref="%s">%s</a>' % (link_class, nofollow, relative_url(dest, privileged=privileged), text)
+
+def link_inline(name, descr=None, kvargs={}):
+ if not descr: descr = humanlink(name)
+ url = relative_url(name)
+ if video_re.match(name):
+ return '<video controls="1" src="%s">Your browser does not support HTML5 video</video>' % url
+ elif image_re.match(name):
+ return '<a href="%s"><img border="0" src="%s" alt="%s" /></a>' % (url, url + url_args(kvargs), descr)
+ elif file_re.match(name) and not ext_re.search(name): # FIXME: this guesses a wiki page
+ Page(name).send_naked(kvargs) # FIXME: we should return the page as a string rather than print it
+ return ''