projects
/
geekigeeki.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixup a few errors in the HTML output
[geekigeeki.git]
/
geekigeeki.py
diff --git
a/geekigeeki.py
b/geekigeeki.py
index 5bae68b43b78e972a0b1e987ee29a214130df87a..f6ba26c967419f5c219d98d313bdc19932630883 100755
(executable)
--- a/
geekigeeki.py
+++ b/
geekigeeki.py
@@
-78,7
+78,7
@@
def relative_url(pathname, privileged=False):
else:
url = script_name()
pathname = url + '/' + pathname
else:
url = script_name()
pathname = url + '/' + pathname
- return
pathname
+ return
cgi.escape(pathname, quote=True)
def permalink(s):
return re.sub(' ', '-', re.sub('[^a-z0-9_ ]', '', s.lower()).strip())
def permalink(s):
return re.sub(' ', '-', re.sub('[^a-z0-9_ ]', '', s.lower()).strip())
@@
-87,13
+87,6
@@
def permalink(s):
def emit_header(mime_type="text/html"):
print "Content-type: " + mime_type + "; charset=utf-8\n"
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 + '">'
def send_guru(msg_text, msg_type):
if not msg_text: return
print '<pre id="guru" onclick="this.style.display = \'none\'" class="' + msg_type + '">'
@@
-103,10
+96,8
@@
def send_guru(msg_text, msg_type):
if msg_type == 'error':
print '\n Guru Meditation #DEADBEEF.ABADC0DE'
print '</pre>'
if msg_type == 'error':
print '\n Guru Meditation #DEADBEEF.ABADC0DE'
print '</pre>'
- try:
- sendfile(sys.stdout, open('gurumeditation.js', 'rb'))
- except IOError, err:
- pass
+ print '<script language="JavaScript" type="text/javascript" src="%s" defer="defer"></script>' \
+ % relative_url('sys/GuruMeditation.js')
def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=False):
global title_done
def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=False):
global title_done
@@
-152,7
+143,7
@@
def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal
# Navbar
print '<div class="nav">'
# Navbar
print '<div class="nav">'
- print link_tag('FrontPage',
relative_url(site_icon or 'Home')
, 'navlink')
+ print link_tag('FrontPage',
site_icon or 'Home'
, 'navlink')
if name:
print ' <b>' + link_tag('?fullsearch=' + name, text, 'navlink') + '</b> '
else:
if name:
print ' <b>' + link_tag('?fullsearch=' + name, text, 'navlink') + '</b> '
else:
@@
-189,7
+180,7
@@
def link_tag(params, text=None, link_class=None, privileged=False):
if text is None:
text = params # default
elif img_re.match(text):
if text is None:
text = params # default
elif img_re.match(text):
- text = '<img border="0" src="' + text + '" />'
+ text = '<img border="0" src="' +
relative_url(text) + '" alt="' +
text + '" />'
if not link_class:
if is_external_url(params):
if not link_class:
if is_external_url(params):
@@
-296,9
+287,10
@@
def handle_edit(pagename):
text = form['savetext'].value
pg.send_editor(text)
text = form['savetext'].value
pg.send_editor(text)
+# Used by macros/WordIndex and macros/TitleIndex
def make_index_key():
links = map(lambda ch: '<a href="#%s">%s</a>' % (ch, ch), 'abcdefghijklmnopqrstuvwxyz')
def make_index_key():
links = map(lambda ch: '<a href="#%s">%s</a>' % (ch, ch), 'abcdefghijklmnopqrstuvwxyz')
- return '<p
><center>'+ ' | '.join(links) + '</center>
</p>'
+ return '<p
style="text-align: center">'+ ' | '.join(links) + '
</p>'
def page_list(dirname = None, re = word_re):
return sorted(filter(re.match, os.listdir(dirname or data_dir)))
def page_list(dirname = None, re = word_re):
return sorted(filter(re.match, os.listdir(dirname or data_dir)))
@@
-411,11
+403,13
@@
class WikiFormatter:
return link_inline(name, name)
def _html_repl(self, word):
return link_inline(name, name)
def _html_repl(self, word):
+ if not self.in_html and word.startswith('<div'): word = '</p>' + word
self.in_html += 1
return word; # Pass through
def _htmle_repl(self, word):
self.in_html -= 1
self.in_html += 1
return word; # Pass through
def _htmle_repl(self, word):
self.in_html -= 1
+ if not self.in_html and word.startswith('</div'): word += '<p>'
return word; # Pass through
def _ent_repl(self, s):
return word; # Pass through
def _ent_repl(self, s):