aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Ritter <xeno@thehappy.de>2009-03-28 14:30:02 +0100
committerStefan Ritter <xeno@thehappy.de>2009-03-28 14:30:02 +0100
commit117a6de1d1641e5320d316c48aff4731352dcf6d (patch)
treead0a80f17f191c5644ea23e864d3e5474e0c29dc
parent2181865ca33b182e6cbb32ed1123f243ad6d1820 (diff)
Several changes:
* Do the atom uuid stuff in a function * Added some comments
-rwxr-xr-xblogthon.cgi42
1 files changed, 18 insertions, 24 deletions
diff --git a/blogthon.cgi b/blogthon.cgi
index 9f4f66b..33aa7e9 100755
--- a/blogthon.cgi
+++ b/blogthon.cgi
@@ -9,14 +9,21 @@
# Author: Stefan Ritter <xeno@thehappy.de>
# Description: A simple blogging software
-import cgi
-import os
-import time
-import glob
-import re
+import cgi, os, time, glob, re, md5
import ConfigParser
-import md5
+def generate_uuid(string):
+ string_md5sum = md5.new(string).hexdigest()
+ string_md5sum_1 = string_md5sum[0:8]
+ string_md5sum_2 = string_md5sum[8:12]
+ string_md5sum_3 = string_md5sum[12:16]
+ string_md5sum_4 = string_md5sum[16:20]
+ string_md5sum_5 = string_md5sum[20:32]
+ string = string_md5sum_1 + '-' + string_md5sum_2 + '-' + string_md5sum_3 + '-' + string_md5sum_4 + '-' + string_md5sum_5
+ return string
+
+
+# Read configuration. TODO: a human readable errorhandler
configuration = ConfigParser.ConfigParser()
configuration.read('configuration')
@@ -35,6 +42,7 @@ permalinks = configuration.get('look', 'permalinks')
comments = configuration.get('look', 'comments')
newest_first = configuration.get('look', 'newest_first')
+# Read POST Variables
action = cgi.FieldStorage()
month_display = action.getvalue('m')
post_display = action.getvalue('p')
@@ -98,6 +106,8 @@ else:
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)
print 'Content-type: text/html\n'
print '<?xml version="1.0" encoding="utf-8"?>'
@@ -106,29 +116,13 @@ if feed_display == "atom":
print ' <name>' + blog_title + '</name>'
print ' </author>'
print ' <title>' + blog_title + '</title>'
-
- blog_title_md5sum = md5.new(blog_title).hexdigest()
- blog_title_md5sum_1 = blog_title_md5sum[0:8]
- blog_title_md5sum_2 = blog_title_md5sum[8:12]
- blog_title_md5sum_3 = blog_title_md5sum[12:16]
- blog_title_md5sum_4 = blog_title_md5sum[16:20]
- blog_title_md5sum_5 = blog_title_md5sum[20:32]
-
- print ' <id>urn:uuid:' + blog_title_md5sum_1 + '-' + blog_title_md5sum_2 + '-' + blog_title_md5sum_3 + '-' + blog_title_md5sum_4 + '-' + blog_title_md5sum_5 + '</id>'
+ print ' <id>urn:uuid:' + blog_title_md5sum + '</id>'
print ' <updated>' + str(date[0]) + '-' + str(date[1]) + '-' + str(date[2]) + 'T' + str(date[3]) + ':' + str(date[4]) + ':' + str(date[5]) + 'Z</updated>'
print ''
print ' <entry>'
-
- title_md5sum = md5.new(title).hexdigest()
- title_md5sum_1 = title_md5sum[0:8]
- title_md5sum_2 = title_md5sum[8:12]
- title_md5sum_3 = title_md5sum[12:16]
- title_md5sum_4 = title_md5sum[16:20]
- title_md5sum_5 = title_md5sum[20:32]
-
print ' <title>' + title + '</title>'
print ' <link href="' + blog_url + '/?p=' + title + '"/>'
- print ' <id>urn:uuid:' + title_md5sum_1 + '-' + title_md5sum_2 + '-' + title_md5sum_3 + '-' + title_md5sum_4 + '-' + title_md5sum_5 + '</id>'
+ print ' <id>urn:uuid:' + title_md5sum + '</id>'
print ' <updated>' + str(date[0]) + '-' + str(date[1]) + '-' + str(date[2]) + 'T' + str(date[3]) + ':' + str(date[4]) + ':' + str(date[5]) + 'Z</updated>'
print ' </entry>'
print '</feed>'