|
|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
#!/usr/bin/python |
|
|
|
|
|
|
|
|
|
import os,os.path, sys |
|
|
|
|
import urllib, cgi |
|
|
|
|
import urllib, cgi,time |
|
|
|
|
|
|
|
|
|
import cgitb |
|
|
|
|
cgitb.enable() |
|
|
|
|
@ -12,7 +12,7 @@ from datetime import datetime |
|
|
|
|
from pylog_action import * |
|
|
|
|
import pylog_config as cfg |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__version = "v0.1-(2012-03-15)" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def header(): |
|
|
|
|
@ -162,8 +162,59 @@ def get_valid_path(path): |
|
|
|
|
return cfg.contentdir |
|
|
|
|
return os.path.normpath(path) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print 'Content-type: text/html\n\n' |
|
|
|
|
if not 'rss' in form: |
|
|
|
|
sys.stdout.write('Content-type: text/html\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) |
|
|
|
|
|
|
|
|
|
print '''<?xml version="1.0"?> |
|
|
|
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> |
|
|
|
|
<channel> |
|
|
|
|
<atom:link href="'''+cfg.topurl+script+'?rss=1'+'" rel="self" type="application/rss+xml" />' |
|
|
|
|
|
|
|
|
|
print " <title>"+cfg.blogtitle+"</title>" |
|
|
|
|
print " <description>"+cfg.subtitle+"</description>" |
|
|
|
|
print " <link>"+cfg.topurl+script+"</link>" |
|
|
|
|
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>" |
|
|
|
|
|
|
|
|
|
for k in keys: |
|
|
|
|
date=datetime.fromtimestamp(int(k)).strftime("%a, %d %b %Y %H:%M:%S ") |
|
|
|
|
for f in files[k]: |
|
|
|
|
if '.' in os.path.basename(f): |
|
|
|
|
typ = f[f.rindex('.')+1:] |
|
|
|
|
name = os.path.basename(f)[:-(len(typ)+1)] |
|
|
|
|
else: |
|
|
|
|
typ = '' |
|
|
|
|
name = os.path.basename(f) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print " <item>" |
|
|
|
|
print " <title>"+name+"</title>" |
|
|
|
|
|
|
|
|
|
link = ET.Element("link") |
|
|
|
|
link.text = cfg.topurl+script+'?'+urllib.urlencode({'path': os.path.normpath(os.path.dirname(f)),'disp':os.path.normpath(f)}) |
|
|
|
|
print " ", |
|
|
|
|
ET.dump(link) |
|
|
|
|
link.tag="guid" |
|
|
|
|
print " ", |
|
|
|
|
ET.dump(link) |
|
|
|
|
|
|
|
|
|
print " <pubDate>"+date+tz+"</pubDate>" |
|
|
|
|
print " </item>" |
|
|
|
|
|
|
|
|
|
print "</channel>" |
|
|
|
|
print "</rss>" |
|
|
|
|
|
|
|
|
|
sys.exit(0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
path = cfg.contentdir |
|
|
|
|
|