Mercurial > libervia-web
diff browser_side/panels.py @ 58:4fa3d57f72f8
browser side: microblog entries caching
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 29 May 2011 17:57:02 +0200 |
parents | e552a67b933d |
children | 12e889a683ce |
line wrap: on
line diff
--- a/browser_side/panels.py Sun May 29 16:07:46 2011 +0200 +++ b/browser_side/panels.py Sun May 29 17:57:02 2011 +0200 @@ -112,7 +112,7 @@ Project page: <a href="http://wiki.goffi.org/wiki/Salut_à_Toi"target="_blank">http://wiki.goffi.org/wiki/Salut_à_Toi</a><br /> <br /> Any help welcome :) -<p style='font-size:x-small;text-align:center'>This project is dedicated to Roger Poisson</p> +<p style='font-size:small;text-align:center'>This project is dedicated to Roger Poisson</p> """) _dialog = dialog.GenericDialog("About", _about) _dialog.show() @@ -276,12 +276,14 @@ if item_type=="GROUP": _new_panel = MicroblogPanel(self.host, item) _new_panel.setAcceptedGroup(item) + self.host.FillMicroblogPanel(_new_panel) elif item_type=="CONTACT": _contact = JID(item) _new_panel = ChatPanel(self.host, _contact) _new_panel.historyPrint() elif item_type=="CONTACT_TITLE": _new_panel = MicroblogPanel(self.host, accept_all=True) + self.host.FillMicroblogPanel(_new_panel) else: return self.host.mpanels.remove(self) @@ -465,15 +467,15 @@ class MicroblogEntry(SimplePanel): - def __init__(self, body, author, timestamp): + def __init__(self, mblog_entry): SimplePanel.__init__(self) - _datetime = datetime.fromtimestamp(timestamp) + _datetime = datetime.fromtimestamp(mblog_entry.timestamp) panel = HTMLPanel("<div class='mb_entry_header'><span class='mb_entry_author'>%(author)s</span> on <span class='mb_entry_timestamp'>%(timestamp)s</span></div><div class='mb_entry_body'>%(body)s</div>" % - {"author": html_sanitize(author), + {"author": html_sanitize(mblog_entry.author), "timestamp": _datetime, - "body": html_sanitize(body)} + "body": html_sanitize(mblog_entry.content)} ) panel.setStyleName('microblogEntry') self.add(panel) @@ -490,6 +492,7 @@ self.accept_all = accept_all title=html_sanitize(title) self.accepted_groups = [] + self.entries = {} _class = ['mb_panel_header'] if title == ' ': _class.append('empty_header') @@ -499,12 +502,16 @@ self.setStyleName('microblogPanel') self.setWidget(self.vpanel) - def addEntry(self, text, author=None, timestamp=None): + def addEntry(self, mblog_entry): """Add an entry to the panel @param text: main text of the entry + @param id: unique id of the entry @param author: who wrote the entry @param date: when the entry was written""" - _entry = MicroblogEntry(text, author, timestamp) + if mblog_entry.id in self.entries: + return + _entry = MicroblogEntry(mblog_entry) + self.entries[mblog_entry.id] = _entry self.vpanel.insert(_entry,1) def setAcceptedGroup(self, group):