* Add some comments

* Parts of new comment mail now in blog_locale[]
This commit is contained in:
Stefan Ritter 2011-07-14 12:12:43 +02:00
parent 7bf8b5659f
commit 25e7cc7a09
1 changed files with 33 additions and 10 deletions

View File

@ -44,14 +44,16 @@ no_break = re.compile("^\s*(<ul|</ul>|<li|</li>|<ol|</ol>|<table|</table>|<tr|</
line_start_hyphen = re.compile("^-.*$")
line_start_plus = re.compile("^\+.*$")
# Indention
# HTML indention
ind = "\t"
# Generate md5sum for feeds
def generate_uuid(string):
string_md5sum = md5(string.encode("utf-8")).hexdigest()
string = str.join("-", (string_md5sum[0:8], string_md5sum[8:12], string_md5sum[12:16], string_md5sum[16:20], string_md5sum[20:32]))
return string
# Custom errorpage
def errorpage(string):
document_header("html")
print("<head>")
@ -67,6 +69,7 @@ def errorpage(string):
print("</html>")
sys.exit()
# Header for html, atom and rss
def document_header(string):
if string == "html":
print("Content-type: text/html\n")
@ -145,7 +148,19 @@ if not os.path.exists("linklist"):
errorpage("File \"linklist\" does not exist!")
if language == "de":
blog_locale = ("Seiten", "Monate", "Links", "Keine Kommentare", "Kommentare", "Alle Einträge anzeigen...", "Name", "Text", "Absenden")
blog_locale = (
"Seiten",
"Monate",
"Links",
"Keine Kommentare",
"Kommentare",
"Alle Einträge anzeigen...",
"Name",
"Text",
"Absenden",
"Neuer Kommentar zu",
"Jemand hat einen Kommentar zu diesem Beitrag verfasst:"
)
locales_de = ("de_DE.UTF-8", "de_DE.@euro", "de_DE")
for i in locales_de:
try:
@ -157,7 +172,17 @@ if language == "de":
locale.setlocale(locale.LC_TIME, None)
else:
blog_locale = ("pages", "months", "links", "no comments", "comments", "View all entries...", "name", "text", "commit")
blog_locale = (
"pages",
"months",
"links",
"no comments",
"comments",
"View all entries...",
"name", "text",
"commit", "New comment on",
"Someone wrote a comment to this entry:"
)
locales_en = ("en_US.UTF-8", "en_US.ISO-8859-15", "en_US")
for i in locales_en:
try:
@ -168,7 +193,7 @@ else:
else:
locale.setlocale(locale.LC_TIME, None)
# Read POST Variables
# Read POST variables
action = FieldStorage()
month_display = action.getvalue("m")
@ -198,7 +223,6 @@ if not allentries_display:
if not feed_display:
feed_display = ""
# Commentstuff
ctitle = action.getvalue("ctitle")
cname = action.getvalue("cname")
ctext = action.getvalue("ctext")
@ -216,15 +240,14 @@ if not cquiz:
if not cquizv:
cquizv = ""
# Comment to commit?
# Commit comment
if cname and ctext and ctitle:
# Prevent XSS hacks
cname = cname.replace("<", "&lt;").replace(">", "&gt;").replace("\'", "&quot;")
ctext = ctext.replace("<", "&lt;").replace(">", "&gt;").replace("\'", "&quot;")
# Add comment
if not cquiz == cquizv:
errorpage("Brainmode")
errorpage("Brainmode") # Captcha not solved
else:
comments_file = os.path.join(entries_dir, ctitle + ".comments")
if not os.path.exists(comments_file):
@ -245,9 +268,9 @@ if cname and ctext and ctitle:
content.write("." + line + "\n")
content.close()
# Send mail?
# Send mail
if not new_comment_mail == "False":
msg = "From: Blogthon\nTo: %s\nSubject: New comment on %s\n\nSomeone wrote a comment to this entry: %s?p=%s" % (mail_to, blog_title, blog_url, ctitle.replace(" ", "-"))
msg = "From: Blogthon\nTo: %s\nSubject: %s %s\n\n%s %s?p=%s" % (mail_to, blog_locale[9], blog_title, blog_locale[10], blog_url, ctitle.replace(" ", "-"))
smtp = SMTP(smtp_host)
smtp.starttls()
smtp.sendmail(blog_title, mail_to, msg)