Clean message before displaying it in the buffers or the post dialogue
This commit is contained in:
parent
9b20fca1e5
commit
b1b154c282
@ -43,7 +43,7 @@ class postController(object):
|
|||||||
self.dialog.set_title(title)
|
self.dialog.set_title(title)
|
||||||
message = u""
|
message = u""
|
||||||
if self.post.has_key("text"):
|
if self.post.has_key("text"):
|
||||||
message = self.post["text"]
|
message = utils.clean_text(self.post["text"])
|
||||||
if self.post.has_key("attachment"):
|
if self.post.has_key("attachment"):
|
||||||
print self.post["attachment"].keys()
|
print self.post["attachment"].keys()
|
||||||
message = message+session.add_attachment(self.post["attachment"])
|
message = message+session.add_attachment(self.post["attachment"])
|
||||||
|
@ -51,9 +51,9 @@ def add_text(status):
|
|||||||
message = ""
|
message = ""
|
||||||
if status.has_key("text"):
|
if status.has_key("text"):
|
||||||
if len(status["text"]) < 140:
|
if len(status["text"]) < 140:
|
||||||
message = status["text"]
|
message = utils.clean_text(status["text"])
|
||||||
else:
|
else:
|
||||||
message = status["text"][:139]
|
message = utils.clean_text(status["text"][:139])
|
||||||
return message
|
return message
|
||||||
|
|
||||||
def compose_new(status, session):
|
def compose_new(status, session):
|
||||||
@ -88,7 +88,6 @@ def compose_status(status, session):
|
|||||||
created_at = original_date.humanize(locale=languageHandler.getLanguage())
|
created_at = original_date.humanize(locale=languageHandler.getLanguage())
|
||||||
if status.has_key("copy_owner_id"):
|
if status.has_key("copy_owner_id"):
|
||||||
user = _(u"{0} has shared the {1}'s post").format(user, session.get_user_name(status["copy_owner_id"]))
|
user = _(u"{0} has shared the {1}'s post").format(user, session.get_user_name(status["copy_owner_id"]))
|
||||||
print status.keys()
|
|
||||||
if status["post_type"] == "post" or status["post_type"] == "copy":
|
if status["post_type"] == "post" or status["post_type"] == "copy":
|
||||||
message += add_text(status)
|
message += add_text(status)
|
||||||
if status.has_key("attachment") and len(status["attachment"]) > 0:
|
if status.has_key("attachment") and len(status["attachment"]) > 0:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
""" Some utilities. I no have idea how I should put these, so..."""
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
@ -51,3 +52,8 @@ def download_file(url, local_filename, window):
|
|||||||
window.change_status(msg)
|
window.change_status(msg)
|
||||||
window.change_status(_(u"Ready"))
|
window.change_status(_(u"Ready"))
|
||||||
return local_filename
|
return local_filename
|
||||||
|
|
||||||
|
def clean_text(text):
|
||||||
|
""" Replaces all HTML entities and put the plain text equivalent if it's possible."""
|
||||||
|
text = text.replace("<br>", "\n")
|
||||||
|
return text
|
Loading…
Reference in New Issue
Block a user