jp (blog/get): added "url" key, which compute xmpp: URL of items
This commit is contained in:
parent
da75f58453
commit
c05a0028b6
1 changed files with 12 additions and 2 deletions
|
|
@ -24,6 +24,7 @@ from sat_frontends.jp.constants import Const as C
|
|||
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 @@ KEY_TO_REMOVE_METADATA = ('id','content', 'content_xhtml', 'comments_node', 'com
|
|||
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 @@ MB_KEYS = (u"id",
|
|||
u"content",
|
||||
u"content_xhtml",
|
||||
u"title",
|
||||
u"title_xhtml")
|
||||
u"title_xhtml",
|
||||
)
|
||||
OUTPUT_OPT_NO_HEADER = u'no-header'
|
||||
|
||||
|
||||
|
|
@ -143,6 +146,13 @@ class Get(base.CommandBase, BlogCommon):
|
|||
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 @@ class Get(base.CommandBase, BlogCommon):
|
|||
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue