* Added a first FAQ
* Added atom feeds
This commit is contained in:
parent
44b517e5b4
commit
6bfd0d4bde
5
FAQ
Normal file
5
FAQ
Normal 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'.
|
314
blogthon.cgi
314
blogthon.cgi
@ -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,139 +93,195 @@ 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"?>'
|
||||||
staticpages = []
|
print '<feed xmlns="http://www.w3.org/2005/Atom">'
|
||||||
staticpages_list = glob.glob(staticpages_dir + '*')
|
print ' <author>'
|
||||||
staticpages_list.sort()
|
print ' <name>' + blog_title + '</name>'
|
||||||
print ' <div class="sidebarentry">'
|
print ' </author>'
|
||||||
print ' <small>pages</small><br />'
|
print ' <title>' + blog_title + '</title>'
|
||||||
for staticpage in staticpages_list:
|
|
||||||
title = re.sub('\w+?\/\d+?-', '', staticpage)
|
|
||||||
link = re.sub('\w+?\/', '', staticpage)
|
|
||||||
# The ultimative lookshe-hack *g*
|
|
||||||
if title == "lookshe":
|
|
||||||
print ' <a href="?s=' + link + '">/me</a> <br />'
|
|
||||||
else:
|
|
||||||
print ' <a href="?s=' + link + '">' + title + '</a> <br />'
|
|
||||||
|
|
||||||
if monthlist == "True": print ' <br />'
|
blog_title_md5sum = md5.new(blog_title).hexdigest()
|
||||||
print ' </div>'
|
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]
|
||||||
|
|
||||||
# Sidebar: Monthlist
|
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>'
|
||||||
if monthlist == "True":
|
print ' <updated>' + str(date[0]) + '-' + str(date[1]) + '-' + str(date[2]) + 'T' + str(date[3]) + ':' + str(date[4]) + ':' + str(date[5]) + 'Z</updated>'
|
||||||
olddate = ""
|
print ''
|
||||||
print ' <div class="sidebarentry">'
|
print ' <entry>'
|
||||||
print ' <small>months</small><br />'
|
|
||||||
for entry in entries:
|
|
||||||
date = time.strftime("%m%Y", entry[0])
|
|
||||||
date_display = time.strftime("%h %Y", entry[0])
|
|
||||||
if not olddate == date:
|
|
||||||
print ' <a href="?m=' + date + '">' + date_display + '</a> <br />'
|
|
||||||
olddate = date
|
|
||||||
if linklist == "True": print ' <br />'
|
|
||||||
print ' </div>'
|
|
||||||
|
|
||||||
# Sidebar: Linklist
|
title_md5sum = md5.new(title).hexdigest()
|
||||||
if linklist == "True":
|
title_md5sum_1 = title_md5sum[0:8]
|
||||||
print ' <div class="sidebarentry">'
|
title_md5sum_2 = title_md5sum[8:12]
|
||||||
print ' <small>links</small><br />'
|
title_md5sum_3 = title_md5sum[12:16]
|
||||||
content = open("linklist", "r")
|
title_md5sum_4 = title_md5sum[16:20]
|
||||||
for line in content:
|
title_md5sum_5 = title_md5sum[20:32]
|
||||||
if line.strip() is "":
|
|
||||||
print ' <br />'
|
|
||||||
else:
|
|
||||||
print ' <a href="' + line.split(" ")[0] + '" target="_blank">' + line.split(" ", 1)[1].strip() + '</a> <br />'
|
|
||||||
content.close()
|
|
||||||
print ' </div>'
|
|
||||||
|
|
||||||
print ' </div>'
|
print ' <title>' + title + '</title>'
|
||||||
print ' <div class="content">'
|
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>'
|
||||||
|
|
||||||
if static_display != "": # Show Staticpage
|
# Generate regular page
|
||||||
content = open(staticpages_dir + static_display, "r")
|
else:
|
||||||
print ' <div class="entrytitle">' + re.sub('\d+?-', '', static_display) + '</div>'
|
|
||||||
print ' <div class="entry"><p>'
|
|
||||||
for line in content:
|
|
||||||
print ' ' + line.strip() + '<br />'
|
|
||||||
print ' </p></div>'
|
|
||||||
content.close()
|
|
||||||
else: # Show regular entry
|
|
||||||
entry_counter = 0
|
|
||||||
for entry in entries:
|
|
||||||
date = time.strftime("%c", entry[0])
|
|
||||||
date_to_compare = time.strftime("%m%Y", entry[0]) # Needed for permalinks
|
|
||||||
entry = entry[1]
|
|
||||||
title = entry.replace('entries/', '', 1)
|
|
||||||
title = title.replace('.txt', '')
|
|
||||||
|
|
||||||
if month_display == date_to_compare or not month_display:
|
print 'Content-type: text/html\n'
|
||||||
if post_display == title or not post_display:
|
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'
|
||||||
if allentries_display == "1" or entry_counter < entries_per_page:
|
print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
||||||
content = open(entry, "r")
|
print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">'
|
||||||
if permalinks: # Title as permalink...
|
print ' <head>'
|
||||||
print ' <div class="entrytitle"><a href="?p=' + title + '" class="entrytitle">' + title + ' <small>(' + date + ')</small></a></div>'
|
print ' <title>' + blog_title + '</title>'
|
||||||
else: # ... or not
|
print ' <meta http-equiv="content-type" content="text/html; charset=utf-8" />'
|
||||||
print ' <div class="entrytitle">' + title + ' <small>(' + date + ')</small></div>'
|
print ' <meta name="keywords" content="' + keywords + '" />'
|
||||||
print ' <div class="entry">'
|
print ' <meta name="description" content="' + blog_title + '" />'
|
||||||
for line in content:
|
print ' <link rel="stylesheet" type="text/css" href="styles/' + style + '" />'
|
||||||
print ' ' + line.strip() + '<br />'
|
print ' </head>'
|
||||||
|
print ' <body>'
|
||||||
|
print ' <div class="title"><a href="?" class="title">' + blog_title + '</a></div>'
|
||||||
|
|
||||||
# Comments are shown when post_display and comments_file
|
print ' <div class="screen"><div class="sidebar">'
|
||||||
comments_file = glob.glob(entries_dir + title + '.comments')
|
|
||||||
if post_display:
|
|
||||||
if comments_file:
|
|
||||||
print ' <br /><hr />'
|
|
||||||
comments_file = glob.glob(entries_dir + title + '.comments')
|
|
||||||
comments_content = open(comments_file[0], "r")
|
|
||||||
for line in comments_content:
|
|
||||||
if line.split(".", 1)[0] == "-":
|
|
||||||
print ' <br />'
|
|
||||||
print ' <b><i>' + line.split(".", 1)[1].strip() + '</i><small> wrote at '
|
|
||||||
elif line.split(".", 1)[0] == "+":
|
|
||||||
print ' ' + line.split(".", 1)[1].strip() + ':</small></b><br />'
|
|
||||||
else:
|
|
||||||
line = line.split(".", 1)[1]
|
|
||||||
print ' ' + line.strip() + '<br />'
|
|
||||||
comments_content.close()
|
|
||||||
|
|
||||||
# Form for adding comments
|
# Sidebar: Staticpages
|
||||||
print ' <br /><br /><br />'
|
if staticpages == "True":
|
||||||
print ' <form action="" method="post">'
|
staticpages = []
|
||||||
print ' <input type="hidden" name="ctitle" value="' + title + '" />'
|
staticpages_list = glob.glob(staticpages_dir + '*')
|
||||||
print ' <label for="cname">name:</label><input type="text" id="cname" name="cname" />'
|
staticpages_list.sort()
|
||||||
print ' <br /><label for="ctext">text:</label><textarea rows="5" cols="80" id="ctext" name="ctext"></textarea>'
|
print ' <div class="sidebarentry">'
|
||||||
print ' <br /><input type="submit" id="submit" value="post comment" />'
|
print ' <small>pages</small><br />'
|
||||||
print ' </form>'
|
for staticpage in staticpages_list:
|
||||||
|
title = re.sub('\w+?\/\d+?-', '', staticpage)
|
||||||
|
link = re.sub('\w+?\/', '', staticpage)
|
||||||
|
# The ultimative lookshe-hack *g*
|
||||||
|
if title == "lookshe":
|
||||||
|
print ' <a href="?s=' + link + '">/me</a> <br />'
|
||||||
|
else:
|
||||||
|
print ' <a href="?s=' + link + '">' + title + '</a> <br />'
|
||||||
|
|
||||||
if comments == "True":
|
if monthlist == "True": print ' <br />'
|
||||||
|
print ' </div>'
|
||||||
|
|
||||||
|
# Sidebar: Monthlist
|
||||||
|
if monthlist == "True":
|
||||||
|
olddate = ""
|
||||||
|
print ' <div class="sidebarentry">'
|
||||||
|
print ' <small>months</small><br />'
|
||||||
|
for entry in entries:
|
||||||
|
date = time.strftime("%m%Y", entry[0])
|
||||||
|
date_display = time.strftime("%h %Y", entry[0])
|
||||||
|
if not olddate == date:
|
||||||
|
print ' <a href="?m=' + date + '">' + date_display + '</a> <br />'
|
||||||
|
olddate = date
|
||||||
|
if linklist == "True": print ' <br />'
|
||||||
|
print ' </div>'
|
||||||
|
|
||||||
|
# Sidebar: Linklist
|
||||||
|
if linklist == "True":
|
||||||
|
print ' <div class="sidebarentry">'
|
||||||
|
print ' <small>links</small><br />'
|
||||||
|
content = open("linklist", "r")
|
||||||
|
for line in content:
|
||||||
|
if line.strip() is "":
|
||||||
|
print ' <br />'
|
||||||
|
else:
|
||||||
|
print ' <a href="' + line.split(" ")[0] + '" target="_blank">' + line.split(" ", 1)[1].strip() + '</a> <br />'
|
||||||
|
content.close()
|
||||||
|
print ' </div>'
|
||||||
|
|
||||||
|
print ' </div>'
|
||||||
|
print ' <div class="content">'
|
||||||
|
|
||||||
|
if static_display != "": # Show Staticpage
|
||||||
|
content = open(staticpages_dir + static_display, "r")
|
||||||
|
print ' <div class="entrytitle">' + re.sub('\d+?-', '', static_display) + '</div>'
|
||||||
|
print ' <div class="entry"><p>'
|
||||||
|
for line in content:
|
||||||
|
print ' ' + line.strip() + '<br />'
|
||||||
|
print ' </p></div>'
|
||||||
|
content.close()
|
||||||
|
else: # Show regular entry
|
||||||
|
entry_counter = 0
|
||||||
|
for entry in entries:
|
||||||
|
date = time.strftime("%c", entry[0])
|
||||||
|
date_to_compare = time.strftime("%m%Y", entry[0]) # Needed for permalinks
|
||||||
|
entry = entry[1]
|
||||||
|
title = entry.replace('entries/', '', 1)
|
||||||
|
title = title.replace('.' + entries_suffix, '')
|
||||||
|
|
||||||
|
if month_display == date_to_compare or not month_display:
|
||||||
|
if post_display == title or not post_display:
|
||||||
|
if allentries_display == "1" or entry_counter < entries_per_page:
|
||||||
|
content = open(entry, "r")
|
||||||
|
if permalinks: # Title as permalink...
|
||||||
|
print ' <div class="entrytitle"><a href="?p=' + title + '" class="entrytitle">' + title + ' <small>(' + date + ')</small></a></div>'
|
||||||
|
else: # ... or not
|
||||||
|
print ' <div class="entrytitle">' + title + ' <small>(' + date + ')</small></div>'
|
||||||
|
print ' <div class="entry">'
|
||||||
|
for line in content:
|
||||||
|
print ' ' + line.strip() + '<br />'
|
||||||
|
|
||||||
|
# Comments are shown when post_display and comments_file
|
||||||
comments_file = glob.glob(entries_dir + title + '.comments')
|
comments_file = glob.glob(entries_dir + title + '.comments')
|
||||||
if not comments_file and not post_display:
|
if post_display:
|
||||||
print ' <div class="comment">'
|
if comments_file:
|
||||||
print ' <ul><li><a href="?p=' + title + '" class="comment">no comments</a></li></ul>'
|
print ' <br /><hr />'
|
||||||
print ' </div>'
|
comments_file = glob.glob(entries_dir + title + '.comments')
|
||||||
elif comments_file and not post_display:
|
comments_content = open(comments_file[0], "r")
|
||||||
comments_content = open(comments_file[0], "r")
|
for line in comments_content:
|
||||||
comments_counter = 0
|
if line.split(".", 1)[0] == "-":
|
||||||
for line in comments_content:
|
print ' <br />'
|
||||||
if line.split(".", 1)[0] == "-": comments_counter += 1
|
print ' <b><i>' + line.split(".", 1)[1].strip() + '</i><small> wrote at '
|
||||||
print ' <div class="comment">'
|
elif line.split(".", 1)[0] == "+":
|
||||||
print ' <ul><li><a href="?p=' + title + '" class="comment">comments (' + str(comments_counter) + ')</a></li></ul>'
|
print ' ' + line.split(".", 1)[1].strip() + ':</small></b><br />'
|
||||||
print ' </div>'
|
else:
|
||||||
comments_content.close()
|
line = line.split(".", 1)[1]
|
||||||
|
print ' ' + line.strip() + '<br />'
|
||||||
|
comments_content.close()
|
||||||
|
|
||||||
print ' </div>'
|
# Form for adding comments
|
||||||
print ' <br /><br />'
|
print ' <br /><br /><br />'
|
||||||
content.close()
|
print ' <form action="" method="post">'
|
||||||
entry_counter += 1
|
print ' <input type="hidden" name="ctitle" value="' + title + '" />'
|
||||||
|
print ' <label for="cname">name:</label><input type="text" id="cname" name="cname" />'
|
||||||
|
print ' <br /><label for="ctext">text:</label><textarea rows="5" cols="80" id="ctext" name="ctext"></textarea>'
|
||||||
|
print ' <br /><input type="submit" id="submit" value="post comment" />'
|
||||||
|
print ' </form>'
|
||||||
|
|
||||||
if not month_display and not post_display and not allentries_display and entry_counter == entries_per_page: # Display pagelist
|
if comments == "True":
|
||||||
print ' <div class="entry"><a href=?a=1>View all entries...</a></div>'
|
comments_file = glob.glob(entries_dir + title + '.comments')
|
||||||
|
if not comments_file and not post_display:
|
||||||
|
print ' <div class="comment">'
|
||||||
|
print ' <ul><li><a href="?p=' + title + '" class="comment">no comments</a></li></ul>'
|
||||||
|
print ' </div>'
|
||||||
|
elif comments_file and not post_display:
|
||||||
|
comments_content = open(comments_file[0], "r")
|
||||||
|
comments_counter = 0
|
||||||
|
for line in comments_content:
|
||||||
|
if line.split(".", 1)[0] == "-": comments_counter += 1
|
||||||
|
print ' <div class="comment">'
|
||||||
|
print ' <ul><li><a href="?p=' + title + '" class="comment">comments (' + str(comments_counter) + ')</a></li></ul>'
|
||||||
|
print ' </div>'
|
||||||
|
comments_content.close()
|
||||||
|
|
||||||
print ' </div></div>'
|
print ' </div>'
|
||||||
print ' </body>'
|
print ' <br /><br />'
|
||||||
print '</html>'
|
content.close()
|
||||||
|
entry_counter += 1
|
||||||
|
|
||||||
|
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></div>'
|
||||||
|
print ' </body>'
|
||||||
|
print '</html>'
|
||||||
|
|
||||||
# vim: set tw=0 ts=4:
|
# vim: set tw=0 ts=4:
|
||||||
|
Loading…
Reference in New Issue
Block a user