|
|
|
|
@ -16,11 +16,9 @@ __version = "v0.1-(2012-03-15)" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def header(): |
|
|
|
|
script = sys.argv[0][sys.argv[0].rindex('/')+1:] |
|
|
|
|
print '<head>' |
|
|
|
|
print '<meta charset="UTF-8">' |
|
|
|
|
print '<title>'+cfg.title+'</title>' |
|
|
|
|
print '<h1 id="blogtitle"><a href="'+script+'">'+cfg.blogtitle+'</a></h1>' |
|
|
|
|
print '<h2 id="subtitle">'+cfg.subtitle+'</h2>' |
|
|
|
|
print cfg.header |
|
|
|
|
print '</head>' |
|
|
|
|
|
|
|
|
|
@ -48,7 +46,7 @@ def file_entry(f,path,depth,hidden): |
|
|
|
|
def process_dirs(path='.',disppath='.',depth=0,hidden=False): |
|
|
|
|
dirlist = os.listdir(path) |
|
|
|
|
if len(dirlist)!=0: |
|
|
|
|
dir_begin(disppath,hidden) |
|
|
|
|
dir_begin(disppath,hidden,depth) |
|
|
|
|
dirs = [] |
|
|
|
|
files = [] |
|
|
|
|
for f in dirlist: |
|
|
|
|
@ -70,7 +68,7 @@ def process_dirs(path='.',disppath='.',depth=0,hidden=False): |
|
|
|
|
else: |
|
|
|
|
file_entry(f,disppath,depth,hidden) |
|
|
|
|
|
|
|
|
|
dir_end(disppath,hidden) |
|
|
|
|
dir_end(disppath,hidden,depth) |
|
|
|
|
|
|
|
|
|
def disp_list(path): |
|
|
|
|
if path==cfg.contentdir: |
|
|
|
|
@ -105,7 +103,7 @@ def disp_file_dict(d,keys): |
|
|
|
|
if typ in prev_actions and not os.path.isdir(f): |
|
|
|
|
sys.stdout.write('<h1><a class="entryheader" href="'+script+'?') |
|
|
|
|
sys.stdout.write(urllib.urlencode({'path': os.path.normpath(os.path.dirname(f)), \ |
|
|
|
|
'disp':os.path.normpath(f)})+'">') |
|
|
|
|
'disp':os.path.normpath(f)}).replace('&','&')+'">') |
|
|
|
|
print name+'</a> - <span class="entrydate">', |
|
|
|
|
print datetime.fromtimestamp(int(k)).strftime(cfg.datefmt), |
|
|
|
|
print '</span></h1>' |
|
|
|
|
@ -163,14 +161,16 @@ def get_valid_path(path): |
|
|
|
|
return os.path.normpath(path) |
|
|
|
|
|
|
|
|
|
if not 'rss' in form: |
|
|
|
|
sys.stdout.write('Content-type: text/html\n\n') |
|
|
|
|
sys.stdout.write('Content-type: text/html; charset=utf-8\n\n') |
|
|
|
|
else: |
|
|
|
|
import xml.etree.ElementTree as ET |
|
|
|
|
sys.stdout.write('Content-type: text/xml\n\n') |
|
|
|
|
|
|
|
|
|
script = sys.argv[0][sys.argv[0].rindex('/')+1:] |
|
|
|
|
files,keys=get_newest(cfg.numofposts) |
|
|
|
|
tz = str(time.timezone) |
|
|
|
|
tz = time.timezone |
|
|
|
|
tzHHMM = "%03d%02d" % (tz/3600,abs((tz%3600)/60)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '''<?xml version="1.0"?> |
|
|
|
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> |
|
|
|
|
@ -183,7 +183,7 @@ else: |
|
|
|
|
print " <generator>Pylog"+__version+"</generator>" |
|
|
|
|
if len(keys)>0: |
|
|
|
|
date=datetime.fromtimestamp(int(keys[0])).strftime("%a, %d %b %Y %H:%M:%S ") |
|
|
|
|
print " <lastBuildDate>"+date+tz+"</lastBuildDate>" |
|
|
|
|
print " <lastBuildDate>"+date+tzHHMM+"</lastBuildDate>" |
|
|
|
|
|
|
|
|
|
for k in keys: |
|
|
|
|
date=datetime.fromtimestamp(int(k)).strftime("%a, %d %b %Y %H:%M:%S ") |
|
|
|
|
@ -207,7 +207,7 @@ else: |
|
|
|
|
print " ", |
|
|
|
|
ET.dump(link) |
|
|
|
|
|
|
|
|
|
print " <pubDate>"+date+tz+"</pubDate>" |
|
|
|
|
print " <pubDate>"+date+tzHHMM+"</pubDate>" |
|
|
|
|
print " </item>" |
|
|
|
|
|
|
|
|
|
print "</channel>" |
|
|
|
|
@ -217,16 +217,19 @@ else: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
script = sys.argv[0][sys.argv[0].rindex('/')+1:] |
|
|
|
|
path = cfg.contentdir |
|
|
|
|
if 'path' in form: |
|
|
|
|
path=form['path'].value |
|
|
|
|
|
|
|
|
|
path=get_valid_path(path) |
|
|
|
|
|
|
|
|
|
print '<!DOCTYPE html>' |
|
|
|
|
print '<html>' |
|
|
|
|
header() |
|
|
|
|
print '<body>' |
|
|
|
|
|
|
|
|
|
print '<h1 id="blogtitle"><a href="'+script+'">'+cfg.blogtitle+'</a></h1>' |
|
|
|
|
print '<h2 id="subtitle">'+cfg.subtitle+'</h2>' |
|
|
|
|
print '<div id="menu">' |
|
|
|
|
process_dirs(cfg.contentdir,path) |
|
|
|
|
print '</div>' |
|
|
|
|
|