diff --git a/zephyr/models.py b/zephyr/models.py index ad029fd4a2..7e5f0c6cc1 100644 --- a/zephyr/models.py +++ b/zephyr/models.py @@ -168,7 +168,7 @@ class Zephyr(models.Model): 'display_recipient': get_display_recipient(self.recipient), 'recipient_id' : self.recipient.id, 'instance' : self.instance, - 'content' : md_engine.convert(self.content), + 'content' : md_engine.convert(self.content.decode("utf-8")), 'timestamp' : calendar.timegm(self.pub_date.timetuple()), 'gravatar_hash' : hashlib.md5(self.sender.user.email.lower()).hexdigest(), } diff --git a/zephyr/zephyr_mirror.py b/zephyr/zephyr_mirror.py index 9d0f13245d..0c1b612154 100644 --- a/zephyr/zephyr_mirror.py +++ b/zephyr/zephyr_mirror.py @@ -11,6 +11,12 @@ import time import subprocess import optparse import os +import markdown +md_engine = markdown.Markdown( + extensions = ['fenced_code', 'codehilite'], + safe_mode = True, + output_format = 'xhtml' ) + zephyr.init() parser = optparse.OptionParser() @@ -72,12 +78,10 @@ def send_humbug(zeph): humbug_data = [] for key in zeph.keys(): - try: val = zeph[key].decode("utf-8").encode("utf-8") - except: - try: - val = zeph[key].encode("utf-8") - except: - print "wtf!", zeph[key] + if isinstance(zeph[key], unicode): + val = zeph[key].encode("utf-8") + elif isinstance(zeph[key], str): + val = zeph[key].decode("utf-8") humbug_data.append((key, val)) browser.open("https://app.humbughq.com/forge_zephyr/", urllib.urlencode(humbug_data))