* Added a first FAQ

* Added atom feeds
This commit is contained in:
Stefan Ritter 2009-03-24 20:37:21 +01:00
parent 44b517e5b4
commit 6bfd0d4bde
2 changed files with 187 additions and 136 deletions

5
FAQ Normal file
View File

@ -0,0 +1,5 @@
1) I edited an entry, now it is listed first on the page... wtf?
Unix don't know a creation time for a file, so i had to use the last
changed time for entries. You can use 'touch' to edit the timestamp.
Syntax is 'touch foo.txt -t YYMMDDhhmm'.

View File

@ -15,6 +15,7 @@ import time
import glob import glob
import re import re
import ConfigParser import ConfigParser
import md5
configuration = ConfigParser.ConfigParser() configuration = ConfigParser.ConfigParser()
configuration.read('configuration') configuration.read('configuration')
@ -38,10 +39,12 @@ month_display = action.getvalue('m')
post_display = action.getvalue('p') post_display = action.getvalue('p')
static_display = action.getvalue('s') static_display = action.getvalue('s')
allentries_display = action.getvalue('a') allentries_display = action.getvalue('a')
feed_display = action.getvalue('feed')
if not month_display: month_display = "" if not month_display: month_display = ""
if not post_display: post_display = "" if not post_display: post_display = ""
if not static_display: static_display = "" if not static_display: static_display = ""
if not allentries_display: allentries_display = "" if not allentries_display: allentries_display = ""
if not feed_display: feed_display = ""
# Commentstuff # Commentstuff
ctitle = action.getvalue('ctitle') ctitle = action.getvalue('ctitle')
@ -75,20 +78,7 @@ if cname and ctext and ctitle:
content.write("." + line + "\n") content.write("." + line + "\n")
content.close() content.close()
print 'Content-type: text/html\n' # Read entries and store their title and timestamp
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'
print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">'
print ' <head>'
print ' <title>' + blog_title + '</title>'
print ' <meta http-equiv="content-type" content="text/html; charset=utf-8" />'
print ' <meta name="keywords" content="' + keywords + '" />'
print ' <meta name="description" content="' + blog_title + '" />'
print ' <link rel="stylesheet" type="text/css" href="styles/' + style + '" />'
print ' </head>'
print ' <body>'
print ' <div class="title"><a href="?" class="title">' + blog_title + '</a></div>'
entries = [] entries = []
entries_list = glob.glob(entries_dir + '*.' + entries_suffix) entries_list = glob.glob(entries_dir + '*.' + entries_suffix)
@ -103,10 +93,66 @@ if newest_first:
else: else:
entries.sort() entries.sort()
print ' <div class="screen"><div class="sidebar">' # Generate atom feed
if feed_display == "atom":
title = str(entries[0][1]).replace('entries/', '', 1).replace('.' + entries_suffix, '')
date = entries[0][0]
# Sidebar: Staticpages print 'Content-type: text/html\n'
if staticpages == "True": print '<?xml version="1.0" encoding="utf-8"?>'
print '<feed xmlns="http://www.w3.org/2005/Atom">'
print ' <author>'
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 ' <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="http://www.thehappy.de/~xeno/"/>'
print ' <id>urn:uuid:' + title_md5sum_1 + '-' + title_md5sum_2 + '-' + title_md5sum_3 + '-' + title_md5sum_4 + '-' + title_md5sum_5 + '</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>'
# Generate regular page
else:
print 'Content-type: text/html\n'
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'
print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">'
print ' <head>'
print ' <title>' + blog_title + '</title>'
print ' <meta http-equiv="content-type" content="text/html; charset=utf-8" />'
print ' <meta name="keywords" content="' + keywords + '" />'
print ' <meta name="description" content="' + blog_title + '" />'
print ' <link rel="stylesheet" type="text/css" href="styles/' + style + '" />'
print ' </head>'
print ' <body>'
print ' <div class="title"><a href="?" class="title">' + blog_title + '</a></div>'
print ' <div class="screen"><div class="sidebar">'
# Sidebar: Staticpages
if staticpages == "True":
staticpages = [] staticpages = []
staticpages_list = glob.glob(staticpages_dir + '*') staticpages_list = glob.glob(staticpages_dir + '*')
staticpages_list.sort() staticpages_list.sort()
@ -124,8 +170,8 @@ if staticpages == "True":
if monthlist == "True": print ' <br />' if monthlist == "True": print ' <br />'
print ' </div>' print ' </div>'
# Sidebar: Monthlist # Sidebar: Monthlist
if monthlist == "True": if monthlist == "True":
olddate = "" olddate = ""
print ' <div class="sidebarentry">' print ' <div class="sidebarentry">'
print ' <small>months</small><br />' print ' <small>months</small><br />'
@ -138,8 +184,8 @@ if monthlist == "True":
if linklist == "True": print ' <br />' if linklist == "True": print ' <br />'
print ' </div>' print ' </div>'
# Sidebar: Linklist # Sidebar: Linklist
if linklist == "True": if linklist == "True":
print ' <div class="sidebarentry">' print ' <div class="sidebarentry">'
print ' <small>links</small><br />' print ' <small>links</small><br />'
content = open("linklist", "r") content = open("linklist", "r")
@ -151,10 +197,10 @@ if linklist == "True":
content.close() content.close()
print ' </div>' print ' </div>'
print ' </div>' print ' </div>'
print ' <div class="content">' print ' <div class="content">'
if static_display != "": # Show Staticpage if static_display != "": # Show Staticpage
content = open(staticpages_dir + static_display, "r") content = open(staticpages_dir + static_display, "r")
print ' <div class="entrytitle">' + re.sub('\d+?-', '', static_display) + '</div>' print ' <div class="entrytitle">' + re.sub('\d+?-', '', static_display) + '</div>'
print ' <div class="entry"><p>' print ' <div class="entry"><p>'
@ -162,14 +208,14 @@ if static_display != "": # Show Staticpage
print ' ' + line.strip() + '<br />' print ' ' + line.strip() + '<br />'
print ' </p></div>' print ' </p></div>'
content.close() content.close()
else: # Show regular entry else: # Show regular entry
entry_counter = 0 entry_counter = 0
for entry in entries: for entry in entries:
date = time.strftime("%c", entry[0]) date = time.strftime("%c", entry[0])
date_to_compare = time.strftime("%m%Y", entry[0]) # Needed for permalinks date_to_compare = time.strftime("%m%Y", entry[0]) # Needed for permalinks
entry = entry[1] entry = entry[1]
title = entry.replace('entries/', '', 1) title = entry.replace('entries/', '', 1)
title = title.replace('.txt', '') title = title.replace('.' + entries_suffix, '')
if month_display == date_to_compare or not month_display: if month_display == date_to_compare or not month_display:
if post_display == title or not post_display: if post_display == title or not post_display:
@ -234,8 +280,8 @@ else: # Show regular entry
if not month_display and not post_display and not allentries_display and entry_counter == entries_per_page: # Display pagelist if not month_display and not post_display and not allentries_display and entry_counter == entries_per_page: # Display pagelist
print ' <div class="entry"><a href=?a=1>View all entries...</a></div>' print ' <div class="entry"><a href=?a=1>View all entries...</a></div>'
print ' </div></div>' print ' </div></div>'
print ' </body>' print ' </body>'
print '</html>' print '</html>'
# vim: set tw=0 ts=4: # vim: set tw=0 ts=4: