# HG changeset patch # User Goffi # Date 1499973215 -7200 # Node ID dad500e7ae509aab3207954e329a770da5f28fef # Parent 91a14dab924dc73f2c4ed5c0df52f8b71e0e9f9c jp (blog/get): added "url" key, which compute xmpp: URL of items diff -r 91a14dab924d -r dad500e7ae50 frontends/src/jp/cmd_blog.py --- a/frontends/src/jp/cmd_blog.py Thu Jul 13 21:12:46 2017 +0200 +++ b/frontends/src/jp/cmd_blog.py Thu Jul 13 21:13:35 2017 +0200 @@ -24,6 +24,7 @@ from sat_frontends.jp import common from sat.tools.common.ansi import ANSI as A from sat.tools.common import data_objects +from sat.tools.common import uri from sat.tools import config from ConfigParser import NoSectionError, NoOptionError import json @@ -53,6 +54,7 @@ URL_REDIRECT_PREFIX = 'url_redirect_' INOTIFY_INSTALL = '"pip install inotify"' MB_KEYS = (u"id", + u"url", u"atom_id", u"updated", u"published", @@ -66,7 +68,8 @@ u"content", u"content_xhtml", u"title", - u"title_xhtml") + u"title_xhtml", + ) OUTPUT_OPT_NO_HEADER = u'no-header' @@ -143,6 +146,13 @@ def format_published(self, item, keys): return self.format_time(item['published']) + def format_url(self, item, keys): + return uri.buildXMPPUri(u'pubsub', + subtype=u'microblog', + path=self.metadata[u'service'], + node=self.metadata[u'node'], + item=item[u'id']) + def get_keys(self): """return keys to display according to verbosity or explicit key request""" verbosity = self.args.verbose @@ -165,7 +175,7 @@ def default_output(self, data): """simple key/value output""" - items, metadata = data + items, self.metadata = data keys = self.get_keys() # k_cb use format_[key] methods for complex formattings