diff options
author | Stefan Ritter <xeno@thehappy.de> | 2009-03-08 19:39:52 +0100 |
---|---|---|
committer | Stefan Ritter <xeno@thehappy.de> | 2009-03-08 19:39:52 +0100 |
commit | eb925c903778dd9bde5e4c54b6bea3af19e972ad (patch) | |
tree | cfe2441e4c4cfe90eabc82b2f139fde5e82a1cb9 /blogthon.cgi | |
parent | 6b30c4447eb0b90c4bc656b317cec262b549ccfc (diff) |
Comments:
* Fixed a bug when the commentsfile is not existing
Diffstat (limited to 'blogthon.cgi')
-rwxr-xr-x | blogthon.cgi | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/blogthon.cgi b/blogthon.cgi index 15e1fe5..a4616cf 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -63,6 +63,10 @@ if cname and ctext and ctitle: # Add comment 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.write("-." + cname + "\n") content.write("+." + time.asctime() + "\n") @@ -168,20 +172,21 @@ else: # Show regular entry # 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 ' <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() + 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 print ' <br /><br /><br />' |