From 117a6de1d1641e5320d316c48aff4731352dcf6d Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Sat, 28 Mar 2009 14:30:02 +0100 Subject: Several changes: * Do the atom uuid stuff in a function * Added some comments --- blogthon.cgi | 42 ++++++++++++++++++------------------------ 1 file 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 # 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 '' @@ -106,29 +116,13 @@ if feed_display == "atom": print ' ' + blog_title + '' print ' ' print ' ' + blog_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 ' urn:uuid:' + blog_title_md5sum_1 + '-' + blog_title_md5sum_2 + '-' + blog_title_md5sum_3 + '-' + blog_title_md5sum_4 + '-' + blog_title_md5sum_5 + '' + print ' urn:uuid:' + blog_title_md5sum + '' print ' ' + str(date[0]) + '-' + str(date[1]) + '-' + str(date[2]) + 'T' + str(date[3]) + ':' + str(date[4]) + ':' + str(date[5]) + 'Z' print '' print ' ' - - 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 + '' print ' ' - print ' urn:uuid:' + title_md5sum_1 + '-' + title_md5sum_2 + '-' + title_md5sum_3 + '-' + title_md5sum_4 + '-' + title_md5sum_5 + '' + print ' urn:uuid:' + title_md5sum + '' print ' ' + str(date[0]) + '-' + str(date[1]) + '-' + str(date[2]) + 'T' + str(date[3]) + ':' + str(date[4]) + ':' + str(date[5]) + 'Z' print ' ' print '' -- cgit v1.2.3