diff options
author | Pascal Turbing <pascal@turbing.de> | 2009-12-03 22:19:56 +0100 |
---|---|---|
committer | Pascal Turbing <pascal@turbing.de> | 2009-12-03 22:19:56 +0100 |
commit | 6c4970adff15fe709a25c559501678ad4dde44d3 (patch) | |
tree | 391f72eeb1429d95886408a55d7fe8e09030e7b4 | |
parent | 6f50460edaed24d04faba990c717f72790b07e26 (diff) |
Feeds:
* Added Preview of Blogpost in Atom/RSS Feeds
* Added feed_preview in configuration to set the length of BlogPostPreview in Lines
Diffstat (limited to '')
-rwxr-xr-x | blogthon.cgi | 40 | ||||
-rw-r--r-- | configuration | 5 |
2 files changed, 36 insertions, 9 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>' diff --git a/configuration b/configuration index c7b3a2a..234f1ed 100644 --- a/configuration +++ b/configuration @@ -14,10 +14,13 @@ staticpages: True monthlist: True linklist: True permalinks: True -comments: True +comments: newest_first: True [smtp] new_comment_mail: False mail_to: please@change.me!!! smtp_host: localhost + +[feed] +feed_preview: 10 |