Mercurial > libervia-backend
changeset 2327:dad500e7ae50
jp (blog/get): added "url" key, which compute xmpp: URL of items
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 13 Jul 2017 21:13:35 +0200 |
parents | 91a14dab924d |
children | f9adda22a2e1 |
files | frontends/src/jp/cmd_blog.py |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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