diff --git a/src/plugins/plugin_misc_groupblog.py b/src/plugins/plugin_misc_groupblog.py
index 91995223..8b891c2e 100755
--- a/src/plugins/plugin_misc_groupblog.py
+++ b/src/plugins/plugin_misc_groupblog.py
@@ -28,7 +28,6 @@ from sat.core import exceptions
from wokkel import disco, data_form, iwokkel
from wokkel import rsm
from zope.interface import implements
-from feed import date
# import uuid
try:
@@ -116,11 +115,6 @@ class GroupBlog(object):
method=self.getGroupBlogsWithComments,
async=True)
- host.bridge.addMethod("getGroupBlogsAtom", ".plugin",
- in_sign='sa{ss}s', out_sign='s',
- method=self.getGroupBlogsAtom,
- async=True)
-
# host.bridge.addMethod("getMassiveGroupBlogs", ".plugin",
# in_sign='sasa{ss}s', out_sign='a{s(aa{ss}a{ss})}',
# method=self._getMassiveGroupBlogs,
@@ -616,47 +610,6 @@ class GroupBlog(object):
assert max_comments > 0 # otherwise the return signature is not the same
return self._getGroupBlogs(pub_jid_s, item_ids=item_ids, rsm_data=rsm_data, max_comments=max_comments, profile_key=profile_key)
- def getGroupBlogsAtom(self, pub_jid_s, rsm_data=None, profile_key=C.PROF_KEY_NONE):
- """Get the atom feed of the last published microblogs
- @param pub_jid: jid of the publisher
- @param profile_key: profile key
- @return: a deferred unicode (atom XML feed)
- """
- pub_jid = jid.JID(pub_jid_s)
-
- def removeAllURIs(element):
- """Recursively remove the URIs of the element and its children.
- Without that, the entry would still be valid but not displayed
- by Firefox nor Thunderbird (and probably more readers)"""
- element.uri = element.defaultUri = None
- for child in element.children:
- if isinstance(child, Element):
- removeAllURIs(child)
-
- def items2feed(items, pub_jid, client):
- feed = """
-
- %(user)s's blogposts
-
-
- %(id)s
- %(date)s\n""" % {'user': pub_jid.user,
- 'feed': 'http://%s/blog/%s/atom.xml' % (client.jid.host, pub_jid.user),
- 'blog': 'http://%s/blog/%s' % (client.jid.host, pub_jid.user),
- 'id': self.getNodeName(pub_jid),
- 'date': date.rfc3339.timestamp_from_tf(date.rfc3339.tf_utc())}
- for item in items:
- entry = item.firstChildElement()
- removeAllURIs(entry)
- feed += " " + entry.toXml() + "\n"
- return feed + ""
-
- def cb(items, client):
- return items2feed(items, pub_jid, client)
-
- d = DeferredItems(self, cb, lambda dummy: [''], profile_key).get(self.getNodeName(pub_jid), rsm_data=rsm_data)
- return d.addCallback(lambda res: res[0])
-
# def _getMassiveGroupBlogs(self, publishers_type, publishers, rsm_data=None, profile_key=C.PROF_KEY_NONE):
# if publishers_type == 'JID':
# publishers_jids = [jid.JID(publisher) for publisher in publishers]
diff --git a/src/plugins/plugin_xep_0277.py b/src/plugins/plugin_xep_0277.py
index 447c58ac..df89e2d0 100755
--- a/src/plugins/plugin_xep_0277.py
+++ b/src/plugins/plugin_xep_0277.py
@@ -96,7 +96,10 @@ class XEP_0277(object):
method=self._mbGetFromMany)
host.bridge.addMethod("mbGetFromManyWithCommentsRTResult", ".plugin", in_sign='ss', out_sign='(ua(sssa(a{ss}a(sssaa{ss}a{ss}))a{ss}))',
method=self._mbGetFromManyWithCommentsRTResult, async=True)
- host.bridge.addMethod("mbGetFromManyWithComments", ".plugin", in_sign='sasiia{ss}a{ss}s', out_sign='s', method=self._mbGetFromManyWithComments)
+ host.bridge.addMethod("mbGetFromManyWithComments", ".plugin", in_sign='sasiia{ss}a{ss}s', out_sign='s',
+ method=self._mbGetFromManyWithComments)
+ host.bridge.addMethod("mbGetAtom", ".plugin", in_sign='ssiasa{ss}s', out_sign='s',
+ method=self._mbGetAtom, async=True)
## plugin management methods ##
@@ -498,14 +501,15 @@ class XEP_0277(object):
@defer.inlineCallbacks
def mbGet(self, service_jid, node=None, max_items=None, item_ids=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE):
- """Get the last published microblogs
+ """Get some microblogs
@param service_jid(jid.JID): jid of the publisher
@param node(unicode, None): node to get (or microblog node if None)
@param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
@param item_ids (list[unicode]): list of item IDs
@param rsm_request (rsm.RSMRequest): RSM request data
- @param profile_key: profile key
+ @param extra (dict): extra data
+ @param profile_key: %(doc_profile_key)s
@return: a deferred couple with the list of items and metadatas.
"""
@@ -815,3 +819,67 @@ class XEP_0277(object):
d.addErrback(lambda failure: (unicode(failure.value), ([],{})))
return self.rt_sessions.newSession(deferreds, client.profile)
+
+ # atom feed
+
+ def _mbGetAtom(self, service_jid_s, node="", max_items=10, item_ids=None, extra_dict=None, profile_key=C.PROF_KEY_NONE):
+ """Get the atom feed of the last published microblogs
+
+ @param service_jid(jid.JID): jid of the publisher
+ @param node(unicode, None): node to get (or microblog node if None)
+ @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
+ @param item_ids (list[unicode]): list of item IDs
+ @param rsm_request (rsm.RSMRequest): RSM request data
+ @param extra (dict): extra data
+ @param profile_key: %(doc_profile_key)s
+ @return: a deferred unicode (atom XML feed)
+ """
+ max_items = None if max_items == C.NO_LIMIT else max_items
+ extra = self._p.parseExtra(extra_dict)
+ return self.mbGetAtom(jid.JID(service_jid_s), node or None, max_items, item_ids, extra.rsm_request, extra.extra, profile_key)
+
+ @defer.inlineCallbacks
+ def mbGetAtom(self, service_jid, node=None, max_items=None, item_ids=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE):
+ """Get the atom feed of the last published microblogs
+
+ @param service_jid(jid.JID): jid of the publisher
+ @param node(unicode, None): node to get (or microblog node if None)
+ @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
+ @param item_ids (list[unicode]): list of item IDs
+ @param rsm_request (rsm.RSMRequest): RSM request data
+ @param extra (dict): extra data
+ @param profile_key: %(doc_profile_key)s
+
+ @return: a deferred couple with the list of items and metadatas.
+ """
+ if node is None:
+ node = NS_MICROBLOG
+ items, metadata = yield self._p.getItems(service_jid, node, max_items=max_items, item_ids=item_ids, rsm_request=rsm_request, extra=extra, profile_key=profile_key)
+
+ feed = """
+
+ %(user)s's blogposts
+
+
+ %(id)s
+ %(date)s\n""" % {'user': service_jid.user,
+ 'feed': 'http://%s/blog/%s/atom.xml' % (service_jid.host, service_jid.user),
+ 'blog': 'http://%s/blog/%s' % (service_jid.host, service_jid.user),
+ 'id': node,
+ 'date': rfc3339.timestamp_from_tf(rfc3339.tf_utc())}
+
+ def removeAllURIs(element):
+ """Recursively remove the URIs of the element and its children.
+ Without that, the entry would still be valid but not displayed
+ by Firefox nor Thunderbird (and probably more readers)"""
+ element.uri = element.defaultUri = None
+ for child in element.children:
+ if isinstance(child, domish.Element):
+ removeAllURIs(child)
+
+ for item in items:
+ entry = item.firstChildElement()
+ removeAllURIs(entry)
+ feed += " " + entry.toXml() + "\n"
+ defer.returnValue(feed + "")
+