Several changes:
* Do the atom uuid stuff in a function * Added some comments
This commit is contained in:
parent
2181865ca3
commit
117a6de1d1
42
blogthon.cgi
42
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>'
|
||||
|
Loading…
Reference in New Issue
Block a user