diff --git a/FAQ b/FAQ new file mode 100644 index 0000000..3a88302 --- /dev/null +++ b/FAQ @@ -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'. diff --git a/blogthon.cgi b/blogthon.cgi index 2acc7f5..983aa99 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -15,6 +15,7 @@ import time import glob import re import ConfigParser +import md5 configuration = ConfigParser.ConfigParser() configuration.read('configuration') @@ -38,10 +39,12 @@ month_display = action.getvalue('m') post_display = action.getvalue('p') static_display = action.getvalue('s') allentries_display = action.getvalue('a') +feed_display = action.getvalue('feed') if not month_display: month_display = "" if not post_display: post_display = "" if not static_display: static_display = "" if not allentries_display: allentries_display = "" +if not feed_display: feed_display = "" # Commentstuff ctitle = action.getvalue('ctitle') @@ -75,20 +78,7 @@ if cname and ctext and ctitle: content.write("." + line + "\n") content.close() -print 'Content-type: text/html\n' -print '' -print '' -print ' ' -print ' ' + blog_title + '' -print ' ' -print ' ' -print ' ' -print ' ' -print ' ' -print ' ' -print '
' + blog_title + '
' - +# Read entries and store their title and timestamp entries = [] entries_list = glob.glob(entries_dir + '*.' + entries_suffix) @@ -103,139 +93,195 @@ if newest_first: else: entries.sort() -print '
' -print '
' +# Generate regular page +else: -if static_display != "": # Show Staticpage - content = open(staticpages_dir + static_display, "r") - print '
' + re.sub('\d+?-', '', static_display) + '
' - print '

' - for line in content: - print ' ' + line.strip() + '
' - print '

' - 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', '') + print 'Content-type: text/html\n' + print '' + print '' + print ' ' + print ' ' + blog_title + '' + print ' ' + print ' ' + print ' ' + print ' ' + print ' ' + print ' ' + print ' ' - 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 ' ' - else: # ... or not - print '
' + title + ' (' + date + ')
' - print '
' - for line in content: - print ' ' + line.strip() + '
' - - # Comments are shown when post_display and comments_file - comments_file = glob.glob(entries_dir + title + '.comments') - if post_display: - if comments_file: - print '

' - 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 '
' - print ' ' + line.split(".", 1)[1].strip() + ' wrote at ' - elif line.split(".", 1)[0] == "+": - print ' ' + line.split(".", 1)[1].strip() + ':
' - else: - line = line.split(".", 1)[1] - print '   ' + line.strip() + '
' - comments_content.close() + print '
' + print '
' + + if static_display != "": # Show Staticpage + content = open(staticpages_dir + static_display, "r") + print '
' + re.sub('\d+?-', '', static_display) + '
' + print '

' + for line in content: + print ' ' + line.strip() + '
' + print '

' + 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 ' ' + else: # ... or not + print '
' + title + ' (' + date + ')
' + print '
' + for line in content: + print ' ' + line.strip() + '
' + + # Comments are shown when post_display and comments_file comments_file = glob.glob(entries_dir + title + '.comments') - if not comments_file and not post_display: - print '
' - print ' ' - print '
' - 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 ' ' - comments_content.close() - - print '
' - print '

' - content.close() - entry_counter += 1 + if post_display: + if comments_file: + print '

' + 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 '
' + print ' ' + line.split(".", 1)[1].strip() + ' wrote at ' + elif line.split(".", 1)[0] == "+": + print ' ' + line.split(".", 1)[1].strip() + ':
' + else: + line = line.split(".", 1)[1] + print '   ' + line.strip() + '
' + comments_content.close() - if not month_display and not post_display and not allentries_display and entry_counter == entries_per_page: # Display pagelist - print '
View all entries...
' + # Form for adding comments + print '


' + print '
' + print ' ' + print ' ' + print '
' + print '
' + print '
' -print '
' -print ' ' -print '' + if comments == "True": + comments_file = glob.glob(entries_dir + title + '.comments') + if not comments_file and not post_display: + print '
' + print ' ' + print '
' + 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 ' ' + comments_content.close() + + print '
' + print '

' + 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 '
View all entries...
' + + print '
' + print ' ' + print '' # vim: set tw=0 ts=4: