Rewrite session Part 2

This commit is contained in:
Stefan Ritter 2009-05-18 17:27:03 +02:00
parent 0002b915cd
commit b1fc650b1b

View File

@ -285,17 +285,27 @@ else:
print ' </div>'
print ''
print ' <div class="content">'
if static_display != "": # Show Staticpage
# Staticpage
if static_display != "":
content = open(staticpages_dir + static_display, "r")
print ' <div class="entrytitle">' + re.sub('\d+?-', '', static_display) + '</div>'
print ' <div class="entry"><p>'
print ' <div class="entry">'
print ' <div class="entry_title">' + re.sub('\d+?-', '', static_display) + '</div>'
print ' <div class="entry_content">'
print ' <p>'
for line in content:
print ' ' + line.strip() + '<br />'
print ' </p></div>'
print ' </p>'
print ' </div>'
print ' <div class="entry_footer"></div>'
print ' <div class="entry_comments"></div>'
print ' <div class="entry_border_left"></div>'
print ' <div class="entry_border_right"></div>'
print ' <div class="entry_border_top"></div>'
print ' <div class="entry_border_bottom"></div>'
print ' </div>'
content.close()
else: # Show regular entry
# Entry
else:
entry_counter = 0
for entry in entries:
date = time.strftime("%c", entry[0])
@ -308,72 +318,82 @@ else:
if post_display == title or not post_display:
if allentries_display == "1" or entry_counter < entries_per_page:
content = open(entry, "r")
print ' <div class="entry">'
if permalinks:
print ' <div class="entrytitle"><a href="?p=' + title + '" class="entrytitle">' + title + ' <small>(' + date + ')</small></a></div>'
print ' <div class="entry_title"><a href="?p=' + title + '" class="entry_title">' + title + '</a></div>'
else:
print ' <div class="entrytitle">' + title + ' <small>(' + date + ')</small></div>'
print ' <div class="entry">'
print ' <div class="entry_title">' + title + '</div>'
print ' <div class="entry_content">'
for line in content:
print ' ' + line.strip() + '<br />'
# Comments are shown when post_display and comments_file
print ' </div>'
print ' <div class="entry_footer"></div>'
print ' <div class="entry_comments"></div>'
print ' <div class="entry_border_left"></div>'
print ' <div class="entry_border_right"></div>'
print ' <div class="entry_border_top"></div>'
print ' <div class="entry_border_bottom"></div>'
print ' </div>'
print ''
# Comments...
# ... are shown when post_display and comments_file isn't false
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")
print ' <div class="comments">'
for line in comments_content:
if line.split(".", 1)[0] == "-":
print ' <br />'
print ' <b><i>' + line.split(".", 1)[1].strip() + '</i><small> wrote at '
print ' <div class="comments_author">' + line.split(".", 1)[1].strip() + '</div>'
elif line.split(".", 1)[0] == "+":
print ' ' + line.split(".", 1)[1].strip() + ':</small></b><br />'
print ' <div class="comments_date">' + line.split(".", 1)[1].strip() + '</div>'
else:
line = line.split(".", 1)[1]
print ' &nbsp;&nbsp;' + line.strip() + '<br />'
print ' <div class="comments_content">'
print ' ' + line.strip() + '<br />'
print ' </div>'
print ' </div>'
print ''
comments_content.close()
# Form for adding comments
random_int_a = random.randint(1,9)
random_int_b = random.randint(1,9)
cquizv = random_int_a + random_int_b
print ' <br /><br /><br />'
print ' <form action="" method="post">'
print ' <input type="hidden" name="ctitle" value="' + title + '" />'
print ' <input type="hidden" name="cquizv" value="' + str(cquizv) + '" />'
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 /><label for="cquiz">' + str(random_int_a) + '+' + str(random_int_b) + '=</label><input type="text" id="cquiz" name="cquiz" />'
print ' <br /><input type="submit" id="submit" value="post comment" />'
print ' </form>'
print ' <form action="" method="post">'
print ' <input type="hidden" name="ctitle" value="' + title + '" />'
print ' <input type="hidden" name="cquizv" value="' + str(cquizv) + '" />'
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 /><label for="cquiz">' + str(random_int_a) + '+' + str(random_int_b) + '=</label><input type="text" id="cquiz" name="cquiz" />'
print ' <br /><input type="submit" id="submit" value="post comment" />'
print ' </form>'
if comments == "True":
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>'
print ' <div class="entry_comments">'
print ' <a href="?p=' + title + '" class="entry_comments">no comments</a>'
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>'
print ' <div class="entry_comments">'
print ' <a href="?p=' + title + '" class="entry_comments">comments (' + str(comments_counter) + ')</a>'
print ' </div>'
comments_content.close()
print ' </div>'
print ' <br /><br />'
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 ''
print ' </body>'
print '</html>'