comparison frontends/src/quick_frontend/quick_chat.py @ 2078:3a0a7e5cef49

quick frontend (chat): added Message.main_message_xhtml property to get XHTML content
author Goffi <goffi@goffi.org>
date Sun, 25 Sep 2016 16:07:44 +0200
parents 529a6d7f7f6a
children 0931b5a6213c
comparison
equal deleted inserted replaced
2077:95ad70ad815c 2078:3a0a7e5cef49
89 except AttributeError: 89 except AttributeError:
90 return False 90 return False
91 91
92 @property 92 @property
93 def main_message(self): 93 def main_message(self):
94 """Return currently displayed message""" 94 """currently displayed message"""
95 if self.parent.lang in self.message: 95 if self.parent.lang in self.message:
96 self.selected_lang = self.parent.lang 96 self.selected_lang = self.parent.lang
97 return self.message[self.parent.lang] 97 return self.message[self.parent.lang]
98 try: 98 try:
99 self.selected_lang = '' 99 self.selected_lang = ''
104 self.selected_lang = lang 104 self.selected_lang = lang
105 return mess 105 return mess
106 except StopIteration: 106 except StopIteration:
107 log.error(u"Can't find message for uid {}".format(self.uid)) 107 log.error(u"Can't find message for uid {}".format(self.uid))
108 return '' 108 return ''
109
110 @property
111 def main_message_xhtml(self):
112 """rich message"""
113 xhtml = {k:v for k,v in self.extra.iteritems() if 'html' in k}
114 if xhtml:
115 # FIXME: we only return first found value for now
116 return next(xhtml.itervalues())
117
109 118
110 @property 119 @property
111 def time_text(self): 120 def time_text(self):
112 """Return timestamp in a nicely formatted way""" 121 """Return timestamp in a nicely formatted way"""
113 # if the message was sent before today, we print the full date 122 # if the message was sent before today, we print the full date