Comments:

* You can now add comments
This commit is contained in:
Stefan Ritter 2009-03-08 19:17:59 +01:00
parent 5d2010c6e1
commit 6b30c4447e

View File

@ -43,6 +43,32 @@ if not post_display: post_display = ""
if not static_display: static_display = "" if not static_display: static_display = ""
if not allentries_display: allentries_display = "" if not allentries_display: allentries_display = ""
# Commentstuff
ctitle = action.getvalue('ctitle')
cname = action.getvalue('cname')
ctext = action.getvalue('ctext')
if not ctitle: ctitle = ""
if not cname: cname = ""
if not ctext: ctext = ""
# Comment to commit?
if cname and ctext and ctitle:
# Prevent XSS hacks
cname = cname.replace("<", "&lt;")
cname = cname.replace(">", "&gt;")
cname = cname.replace("\"", "&quot;")
ctext = ctext.replace("<", "&lt;")
ctext = ctext.replace(">", "&gt;")
ctext = ctext.replace("\"", "&quot;")
# Add comment
comments_file = glob.glob(entries_dir + ctitle + '.comments')
content = open(comments_file[0], "a+")
content.write("-." + cname + "\n")
content.write("+." + time.asctime() + "\n")
content.write("." + ctext + "\n")
content.close()
print 'Content-type: text/html\n' print 'Content-type: text/html\n'
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
@ -159,9 +185,10 @@ else: # Show regular entry
# Form for adding comments # Form for adding comments
print ' <br /><br /><br />' print ' <br /><br /><br />'
print ' <form action=# method=get>' print ' <form method="post">'
print ' <label for="name">name:</label><input type="text" id="name" name="name">' print ' <input type="hidden" name="ctitle" value="' + title + '">'
print ' <br /><label for="text">text:</label><textarea rows="5" id="text" name="text"></textarea>' print ' <label for="cname">name:</label><input type="text" id="cname" name="cname">'
print ' <br /><label for="ctext">text:</label><textarea rows="5" id="ctext" name="ctext" wrap="hard"></textarea>'
print ' <br /><input type="submit" id="submit" value="post comment">' print ' <br /><input type="submit" id="submit" value="post comment">'
print ' </form>' print ' </form>'