Comments:

* Comments are now shown under the entry when you click the permalink or the
  comments link
This commit is contained in:
Stefan Ritter 2009-03-07 15:57:49 +01:00
parent 622aec5bad
commit de59842011
1 changed files with 24 additions and 6 deletions

View File

@ -132,26 +132,44 @@ else: # Show regular entry
if post_display == title or not post_display: if post_display == title or not post_display:
if allentries_display == "1" or entry_counter < entries_per_page: if allentries_display == "1" or entry_counter < entries_per_page:
content = open(entry, "r") content = open(entry, "r")
if permalinks: if permalinks: # Title as permalink...
print ' <div class="entrytitle"><a href="?p=' + title + '" class="entrytitle">' + title + ' <small>(' + date + ')</small></a></div>' print ' <div class="entrytitle"><a href="?p=' + title + '" class="entrytitle">' + title + ' <small>(' + date + ')</small></a></div>'
else: else: # ... or not
print ' <div class="entrytitle">' + title + ' <small>(' + date + ')</small></div>' print ' <div class="entrytitle">' + title + ' <small>(' + date + ')</small></div>'
print ' <div class="entry"><p>' print ' <div class="entry"><p>'
for line in content: for line in content:
print ' ' + line.strip() + '<br />' print ' ' + line.strip() + '<br />'
# Comments are shown when post_display and comments_file
comments_file = glob.glob(entries_dir + title + '.comments')
if comments_file and post_display:
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 ' <i>' + line.split(".", 1)[1] + '</i><small> wrote at '
elif line.split(".", 1)[0] == "+":
print ' ' + line.split(".", 1)[1] + ':</small><br />'
else:
line = line.split(".", 1)[1]
print ' &nbsp;&nbsp;' + line.strip() + '<br />'
comments_content.close()
if comments == "True": if comments == "True":
comments_file = glob.glob(entries_dir + title + '.comments') comments_file = glob.glob(entries_dir + title + '.comments')
if not comments_file: if not comments_file and not post_display:
print ' <div class="comment">' print ' <div class="comment">'
print ' <ul><li><a href=? class="comment">no comments</a></li></ul>' print ' <ul><li><a href="?p=' + title + '" class="comment">no comments</a></li></ul>'
print ' </div><br />' print ' </div><br />'
else: elif comments_file and not post_display:
comments_content = open(comments_file[0], "r") comments_content = open(comments_file[0], "r")
comments_counter = 0 comments_counter = 0
for line in comments_content: for line in comments_content:
if line.split(".", 1)[0] == "-": comments_counter += 1 if line.split(".", 1)[0] == "-": comments_counter += 1
print ' <div class="comment">' print ' <div class="comment">'
print ' <ul><li><a href=? class="comment">comments (' + str(comments_counter) + ')</a></li></ul>' print ' <ul><li><a href="?p=' + title + '" class="comment">comments (' + str(comments_counter) + ')</a></li></ul>'
print ' </div><br />' print ' </div><br />'
comments_content.close() comments_content.close()