|
|
|
|
@ -42,7 +42,84 @@ def disp_txt(path): |
|
|
|
|
print markdown.markdown(txt,extensions=cfg.markdown_extensions).encode(cfg.encoding) |
|
|
|
|
f.close() |
|
|
|
|
print '</div>' |
|
|
|
|
|
|
|
|
|
def disp_python(path): |
|
|
|
|
disp_source(path,"python",True) |
|
|
|
|
|
|
|
|
|
def disp_c(path): |
|
|
|
|
disp_source(path,"c",True) |
|
|
|
|
|
|
|
|
|
def disp_source(path,lang,line_numbers): |
|
|
|
|
print '<div class="entrytext">' |
|
|
|
|
f = codecs.open(path, mode="r", encoding=cfg.encoding) |
|
|
|
|
if line_numbers: |
|
|
|
|
txt="\t#!"+lang+'\n' |
|
|
|
|
else: |
|
|
|
|
txt="\t:::"+lang+'\n' |
|
|
|
|
for line in f.read().split('\n'): |
|
|
|
|
txt += "\t"+line+'\n' |
|
|
|
|
print markdown.markdown(txt,extensions=cfg.markdown_extensions).encode(cfg.encoding) |
|
|
|
|
f.close() |
|
|
|
|
print '</div>' |
|
|
|
|
|
|
|
|
|
def disp(path): |
|
|
|
|
print '<div class="entrytext">' |
|
|
|
|
f = codecs.open(path, mode="r", encoding=cfg.encoding)(path) |
|
|
|
|
print f.read().encode(cfg.encoding) |
|
|
|
|
f.close() |
|
|
|
|
print '</div>' |
|
|
|
|
|
|
|
|
|
def get_n_words(fi,n): |
|
|
|
|
i=0 |
|
|
|
|
txt="" |
|
|
|
|
c=" " |
|
|
|
|
space=False |
|
|
|
|
while i<40 and len(c)==1: |
|
|
|
|
c = fi.read(1) |
|
|
|
|
txt+=c |
|
|
|
|
if c==" " and not space: |
|
|
|
|
i+=1 |
|
|
|
|
space=True |
|
|
|
|
else: |
|
|
|
|
space=False |
|
|
|
|
|
|
|
|
|
if i==40: |
|
|
|
|
return (txt,True) |
|
|
|
|
return (txt,False) |
|
|
|
|
|
|
|
|
|
def prev(path): |
|
|
|
|
fi = codecs.open(path, mode="r", encoding=cfg.encoding) |
|
|
|
|
txt=get_n_words(fi,40) |
|
|
|
|
print '<div class="preview">'+txt[0].encode(cfg.encoding) |
|
|
|
|
if txt[1]: |
|
|
|
|
print '<i> ...</i>' |
|
|
|
|
print '</div>' |
|
|
|
|
fi.close() |
|
|
|
|
|
|
|
|
|
def prev_txt(path): |
|
|
|
|
fi = codecs.open(path, mode="r", encoding=cfg.encoding) |
|
|
|
|
txt=get_n_words(fi,40) |
|
|
|
|
print '<div class="preview">'+markdown.markdown(txt[0],extensions=cfg.markdown_extensions).encode(cfg.encoding) |
|
|
|
|
if txt[1]: |
|
|
|
|
print '<i> ...</i>' |
|
|
|
|
print '</div>' |
|
|
|
|
fi.close() |
|
|
|
|
|
|
|
|
|
def prev_source(path): |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Legacy code ------------------------ |
|
|
|
|
# using vim for syntax highlighting,could be usefull, |
|
|
|
|
# old disp_source using vim |
|
|
|
|
#def disp_source(path): |
|
|
|
|
# print '<div class="sourcecode">' |
|
|
|
|
# print get_source_html(path).encode(cfg.encoding) |
|
|
|
|
# #print source |
|
|
|
|
# print '</div>' |
|
|
|
|
class BodyParser(HTMLParser): |
|
|
|
|
body=False |
|
|
|
|
src='' |
|
|
|
|
@ -69,14 +146,6 @@ class BodyParser(HTMLParser): |
|
|
|
|
if self.body: |
|
|
|
|
self.src += '&'+ref+';' |
|
|
|
|
|
|
|
|
|
# Legacy code used vim for syntax highlighting, as this could be usefull, |
|
|
|
|
# I'll keep it here |
|
|
|
|
# old disp_source using vim |
|
|
|
|
#def disp_source(path): |
|
|
|
|
# print '<div class="sourcecode">' |
|
|
|
|
# print get_source_html(path).encode(cfg.encoding) |
|
|
|
|
# #print source |
|
|
|
|
# print '</div>' |
|
|
|
|
def get_source_html(path): |
|
|
|
|
tmpdir = os.path.join(tempfile.gettempdir(),"pylog") |
|
|
|
|
cache=False |
|
|
|
|
@ -125,69 +194,4 @@ def get_source_html(path): |
|
|
|
|
if not cache: |
|
|
|
|
os.remove(tmpfile) |
|
|
|
|
return src |
|
|
|
|
|
|
|
|
|
def disp_python(path): |
|
|
|
|
disp_source(path,"python",True) |
|
|
|
|
|
|
|
|
|
def disp_c(path): |
|
|
|
|
disp_source(path,"c",True) |
|
|
|
|
|
|
|
|
|
def disp_source(path,lang,line_numbers): |
|
|
|
|
print '<div class="entrytext">' |
|
|
|
|
f = codecs.open(path, mode="r", encoding=cfg.encoding) |
|
|
|
|
if line_numbers: |
|
|
|
|
txt="\t#!"+lang+'\n' |
|
|
|
|
else: |
|
|
|
|
txt="\t:::"+lang+'\n' |
|
|
|
|
for line in f.read().split('\n'): |
|
|
|
|
txt += "\t"+line+'\n' |
|
|
|
|
print markdown.markdown(txt,extensions=cfg.markdown_extensions).encode(cfg.encoding) |
|
|
|
|
f.close() |
|
|
|
|
print '</div>' |
|
|
|
|
|
|
|
|
|
def disp(path): |
|
|
|
|
print '<div class="entrytext">' |
|
|
|
|
f = codecs.open(path, mode="r", encoding=cfg.encoding)(path) |
|
|
|
|
print f.read().encode(cfg.encoding) |
|
|
|
|
f.close() |
|
|
|
|
print '</div>' |
|
|
|
|
|
|
|
|
|
def get_n_words(fi,n): |
|
|
|
|
i=0 |
|
|
|
|
txt="" |
|
|
|
|
c=" " |
|
|
|
|
space=False |
|
|
|
|
while i<40 and len(c)==1: |
|
|
|
|
c = fi.read(1) |
|
|
|
|
txt+=c |
|
|
|
|
if c==" " and not space: |
|
|
|
|
i+=1 |
|
|
|
|
space=True |
|
|
|
|
else: |
|
|
|
|
space=False |
|
|
|
|
|
|
|
|
|
if i==40: |
|
|
|
|
return (txt,True) |
|
|
|
|
return (txt,False) |
|
|
|
|
|
|
|
|
|
def prev(path): |
|
|
|
|
fi = codecs.open(path, mode="r", encoding=cfg.encoding) |
|
|
|
|
txt=get_n_words(fi,40) |
|
|
|
|
print '<div class="preview">'+txt[0].encode(cfg.encoding) |
|
|
|
|
if txt[1]: |
|
|
|
|
print '<i> ...</i>' |
|
|
|
|
print '</div>' |
|
|
|
|
fi.close() |
|
|
|
|
|
|
|
|
|
def prev_txt(path): |
|
|
|
|
fi = codecs.open(path, mode="r", encoding=cfg.encoding) |
|
|
|
|
txt=get_n_words(fi,40) |
|
|
|
|
print '<div class="preview">'+markdown.markdown(txt[0],extensions=cfg.markdown_extensions).encode(cfg.encoding) |
|
|
|
|
if txt[1]: |
|
|
|
|
print '<i> ...</i>' |
|
|
|
|
print '</div>' |
|
|
|
|
fi.close() |
|
|
|
|
|
|
|
|
|
def prev_source(path): |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|