comparison src/plugins/plugin_xep_0277.py @ 770:64dd7c0f4feb

plugin groupblog, XEP-0277: store both published and updated timestamps
author souliane <souliane@mailoo.org>
date Thu, 19 Dec 2013 13:54:40 +0100
parents 812dc38c0094
children bfabeedbf32e
comparison
equal deleted inserted replaced
769:8b6137f7b4e1 770:64dd7c0f4feb
106 microblog_data['content'] = _entry.title.text # FIXME: must use text version of the microblog, or convert XHTML to text if not available 106 microblog_data['content'] = _entry.title.text # FIXME: must use text version of the microblog, or convert XHTML to text if not available
107 else: 107 else:
108 microblog_data['content'] = _entry.title.text 108 microblog_data['content'] = _entry.title.text
109 if len(_entry.authors): 109 if len(_entry.authors):
110 microblog_data['author'] = _entry.authors[0].name.text 110 microblog_data['author'] = _entry.authors[0].name.text
111 microblog_data['timestamp'] = str(int(_entry.updated.tf)) 111 microblog_data['updated'] = str(int(_entry.updated.tf))
112 try:
113 microblog_data['published'] = str(int(_entry.published.tf))
114 except (KeyError, TypeError):
115 microblog_data['published'] = microblog_data['updated']
112 microblog_data['id'] = item['id'] 116 microblog_data['id'] = item['id']
113 for link in _entry.links: 117 for link in _entry.links:
114 try: 118 try:
115 if link.attrs["title"] == "comments": 119 if link.attrs["title"] == "comments":
116 microblog_data['comments'] = link.attrs["href"] 120 microblog_data['comments'] = link.attrs["href"]
170 _entry.title.attrs['type'] = 'text' 174 _entry.title.attrs['type'] = 'text'
171 _entry.title = unicode(content).encode('utf-8') 175 _entry.title = unicode(content).encode('utf-8')
172 176
173 _entry.author = atom.Author() 177 _entry.author = atom.Author()
174 _entry.author.name = data.get('author', self.host.getJidNStream(profile)[0].userhost()).encode('utf-8') 178 _entry.author.name = data.get('author', self.host.getJidNStream(profile)[0].userhost()).encode('utf-8')
175 _entry.updated = float(data.get('timestamp', time())) 179 _entry.updated = float(data.get('updated', time()))
180 _entry.published = float(data.get('published', time()))
176 entry_id = data.get('id', str(_uuid)) 181 entry_id = data.get('id', str(_uuid))
177 _entry.id = entry_id 182 _entry.id = entry_id
178 if 'comments' in data: 183 if 'comments' in data:
179 link = atom.Link() 184 link = atom.Link()
180 link.attrs['href'] = data['comments'] 185 link.attrs['href'] = data['comments']