Comments:
* Fixed a bug when the commentsfile is not existing
This commit is contained in:
parent
6b30c4447e
commit
eb925c9037
33
blogthon.cgi
33
blogthon.cgi
@ -63,6 +63,10 @@ if cname and ctext and ctitle:
|
|||||||
|
|
||||||
# Add comment
|
# Add comment
|
||||||
comments_file = glob.glob(entries_dir + ctitle + '.comments')
|
comments_file = glob.glob(entries_dir + ctitle + '.comments')
|
||||||
|
if not comments_file:
|
||||||
|
content = open(entries_dir + ctitle + '.comments', "w")
|
||||||
|
content.close()
|
||||||
|
comments_file = glob.glob(entries_dir + ctitle + '.comments')
|
||||||
content = open(comments_file[0], "a+")
|
content = open(comments_file[0], "a+")
|
||||||
content.write("-." + cname + "\n")
|
content.write("-." + cname + "\n")
|
||||||
content.write("+." + time.asctime() + "\n")
|
content.write("+." + time.asctime() + "\n")
|
||||||
@ -168,20 +172,21 @@ else: # Show regular entry
|
|||||||
|
|
||||||
# Comments are shown when post_display and comments_file
|
# 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 comments_file and post_display:
|
if post_display:
|
||||||
print ' <br /><hr>'
|
if comments_file:
|
||||||
comments_file = glob.glob(entries_dir + title + '.comments')
|
print ' <br /><hr>'
|
||||||
comments_content = open(comments_file[0], "r")
|
comments_file = glob.glob(entries_dir + title + '.comments')
|
||||||
for line in comments_content:
|
comments_content = open(comments_file[0], "r")
|
||||||
if line.split(".", 1)[0] == "-":
|
for line in comments_content:
|
||||||
print ' <br />'
|
if line.split(".", 1)[0] == "-":
|
||||||
print ' <b><i>' + line.split(".", 1)[1].strip() + '</i><small> wrote at '
|
print ' <br />'
|
||||||
elif line.split(".", 1)[0] == "+":
|
print ' <b><i>' + line.split(".", 1)[1].strip() + '</i><small> wrote at '
|
||||||
print ' ' + line.split(".", 1)[1].strip() + ':</small></b><br />'
|
elif line.split(".", 1)[0] == "+":
|
||||||
else:
|
print ' ' + line.split(".", 1)[1].strip() + ':</small></b><br />'
|
||||||
line = line.split(".", 1)[1]
|
else:
|
||||||
print ' ' + line.strip() + '<br />'
|
line = line.split(".", 1)[1]
|
||||||
comments_content.close()
|
print ' ' + line.strip() + '<br />'
|
||||||
|
comments_content.close()
|
||||||
|
|
||||||
# Form for adding comments
|
# Form for adding comments
|
||||||
print ' <br /><br /><br />'
|
print ' <br /><br /><br />'
|
||||||
|
Loading…
Reference in New Issue
Block a user