diff options
Diffstat (limited to '')
-rwxr-xr-x | blogthon.cgi | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/blogthon.cgi b/blogthon.cgi index 714948f..48a9dee 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -9,6 +9,7 @@ # Authors: Stefan Ritter <xeno@thehappy.de> # Adrian Vondendriesch <disco-stu@disco-stu.de> +# Pascal Turbing <pascal@turbing.de> # Description: A simple blogging software import cgi, os, time, glob, re, md5, sys, random, smtplib @@ -116,6 +117,9 @@ except: errorpage('"mail_to" is missing in configuration!') try: smtp_host = configuration.get('smtp', 'smtp_host') except: errorpage('"smtp_host" is missing in configuration!') +try: feed_preview = configuration.get('feed', 'feed_preview') +except: errorpage('"feed_preview" is missing or empty in configuration') + # Read POST Variables action = cgi.FieldStorage() month_display = action.getvalue('m') @@ -197,10 +201,8 @@ else: # Generate atom feed if feed_display == "atom": - title = str(entries[0][1]).replace('entries/', '', 1).replace('.' + entries_suffix, '') date = entries[0][0] blog_title_md5sum = generate_uuid(blog_title) - title_md5sum = generate_uuid(title) # Append 0 to the beginning if len of integer is 1 (value<10) month = '%(#)02d' % {'#': int(date[1])} @@ -218,12 +220,26 @@ if feed_display == "atom": print ' <id>urn:uuid:' + blog_title_md5sum + '</id>' print ' <updated>' + str(date[0]) + '-' + month + '-' + day + 'T' + hour + ':' + min + ':' + sec + 'Z</updated>' print '' - print ' <entry>' - print ' <title>' + title + '</title>' - print ' <link href="' + blog_url + '"/>' - print ' <id>urn:uuid:' + title_md5sum + '</id>' - print ' <updated>' + str(date[0]) + '-' + month + '-' + day + 'T' + hour + ':' + min + ':' + sec + 'Z</updated>' - print ' </entry>' + j = len(entries) + if j > 10: j = 10 + for i in xrange(0, j): + title = str(entries[i][1]).replace('entries/', '', 1).replace('.' + entries_suffix, '') + date = time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime(time.mktime(entries[i][0]))) + title_md5sum = generate_uuid(title) + print ' <entry>' + print ' <title>' + title + '</title>' + print ' <link href="' + blog_url + '?p=' + title + '"/>' + print ' <id>urn:uuid:' + title_md5sum + '</id>' + print ' <updated>' + date + '</updated>' + print ' <summary>' + content = open(str(entries[i][1]), 'r') + for h in xrange(0, int(feed_preview)): + rss_line = content.readline().strip() + if rss_line != '': + print ' ' + rss_line + content.close() + print ' </summary>' + print ' </entry>' print '</feed>' # Generate rss 2.0 feed @@ -247,6 +263,14 @@ elif feed_display == "rss": print ' <link>' + blog_url + '?p=' + title + '</link>' print ' <guid>' + title_md5sum + '</guid>' print ' <pubDate>' + date + '</pubDate>' + print ' <description>' + content = open(str(entries[i][1]), 'r') + for h in xrange(0, int(feed_preview)): + rss_line = content.readline().strip() + if rss_line != '': + print ' ' + rss_line + content.close() + print ' </description>' print ' </item>' print ' </channel>' print '</rss>' |