Improve interface and subject display (Thanks to the blabber.im group chat).

This commit is contained in:
Schimon Jehudah, Adv. 2024-10-14 12:31:31 +03:00
parent 928f5272e0
commit 26d92eff7c
5 changed files with 145 additions and 61 deletions

83
fasi.py
View file

@ -109,7 +109,9 @@ class HttpInstance:
message = '{}: {} (XEP-0030)'.format(jid_info['text'], jid_info['condition'])
action = 'Connect with'
link_href = 'xmpp:{}'.format(jid_bare)
links.append(['Connect', link_href])
links.append({'name' : 'Connect',
'href' : link_href,
'iden' : 'connect'})
xmpp_uri = jid_bare
elif jid_kind in ('conference', 'server'):
action = 'Discover'
@ -118,7 +120,9 @@ class HttpInstance:
elif jid_kind == 'server':
instance = 'services'
link_href = 'xmpp:{}?disco;type=get;request=items'.format(jid_bare)
links.append(['Discover', link_href])
links.append({'name' : 'Discover',
'href' : link_href,
'iden' : 'discover'})
view_href = '/d/' + jid_bare
xmpp_uri = jid_bare
elif jid_kind in ('mix', 'muc'):
@ -127,7 +131,9 @@ class HttpInstance:
action = 'Join to'
instance = 'participants'
link_href = 'xmpp:{}?join'.format(jid_bare)
links.append(['Join', link_href])
links.append({'name' : 'Join',
'href' : link_href,
'iden' : 'join'})
view_href = '/v/' + jid_bare
xmpp_uri = jid_bare
# room_info = await XmppXep0045.get_room_data(xmpp_instance, jid_bare)
@ -144,21 +150,33 @@ class HttpInstance:
action = 'Browse'
instance = 'nodes'
link_href = 'xmpp:{}?disco;type=get;request=items'.format(jid_bare)
links.append(['Browse', link_href])
links.append({'name' : 'Browse',
'href' : link_href,
'iden' : 'browse'})
view_href = '/d/' + jid_bare
xmpp_uri = jid_bare
else:
action = 'Message'
instance = 'articles'
link_href = 'xmpp:{}?message'.format(jid_bare)
links.append(['Add', 'xmpp:{}?roster'.format(jid_bare)])
links.append(['Message', link_href])
links.append({'name' : 'Add',
'href' : 'xmpp:{}?roster'.format(jid_bare),
'id' : 'add'})
links.append({'name' : 'Message',
'href' : link_href,
'iden' : 'message'})
node_name = 'urn:xmpp:microblog:0'
view_href = '/d/{}/{}'.format(jid_bare, node_name)
xmpp_uri = jid_bare
links.append(['Subscribe', 'xmpp:{}?pubsub;node={};action=subscribe'.format(jid_bare, node_name)])
links.append(['View', 'xmpp:{}?pubsub;node={}'.format(jid_bare, node_name)])
links.append(['vCard', 'xmpp:{}?vcard'.format(jid_bare)])
links.append({'name' : 'Subscribe',
'href' : 'xmpp:{}?pubsub;node={};action=subscribe'.format(jid_bare, node_name),
'iden' : 'subscribe'})
links.append({'name' : 'View',
'href' : 'xmpp:{}?pubsub;node={}'.format(jid_bare, node_name),
'iden' : 'view'})
links.append({'name' : 'vCard',
'href' : 'xmpp:{}?vcard'.format(jid_bare),
'iden' : 'vcard'})
# JID info
# NOTE Group chat of Psi+ Project at jabber.ru has a note in its vCard.
@ -336,7 +354,9 @@ class HttpInstance:
message = '{}: {} (XEP-0030)'.format(jid_info['text'], jid_info['condition'])
action = 'Connect with'
link_href = 'xmpp:{}'.format(jid_bare)
links.append(['Connect', link_href])
links.append({'name' : 'Connect',
'href' : link_href,
'iden' : 'connect'})
xmpp_uri = jid_bare
elif jid_kind in ('conference', 'server'):
action = 'Discover'
@ -345,7 +365,9 @@ class HttpInstance:
elif jid_kind == 'server':
instance = 'services'
link_href = 'xmpp:{}?disco;type=get;request=items'.format(jid_bare)
links.append(['Discover', link_href])
links.append({'name' : 'Discover',
'href' : link_href,
'iden' : 'discover'})
view_href = '/d/' + jid_bare
xmpp_uri = jid_bare
elif jid_kind in ('mix', 'muc'):
@ -354,7 +376,9 @@ class HttpInstance:
action = 'Join to'
instance = 'participants'
link_href = 'xmpp:{}?join'.format(jid_bare)
links.append(['Join', link_href])
links.append({'name' : 'Join',
'href' : link_href,
'iden' : 'join'})
view_href = '/v/' + jid_bare
xmpp_uri = jid_bare
# room_info = await XmppXep0045.get_room_data(xmpp_instance, jid_bare)
@ -371,21 +395,41 @@ class HttpInstance:
action = 'Browse'
instance = 'nodes'
link_href = 'xmpp:{}?disco;type=get;request=items'.format(jid_bare)
links.append(['Browse', link_href])
links.append({'name' : 'Browse',
'href' : link_href,
'iden' : 'browse'})
view_href = '/d/' + jid_bare
xmpp_uri = jid_bare
else:
action = 'Message'
instance = 'articles'
link_href = 'xmpp:{}?message'.format(jid_bare)
links.append(['Add', 'xmpp:{}?roster'.format(jid_bare)])
links.append(['Message', link_href])
links.append({'name' : 'Add',
'href' : 'xmpp:{}?roster'.format(jid_bare),
'iden' : 'add'})
links.append({'name' : 'Add',
'href' : link_href,
'iden' : 'message'})
node_name = 'urn:xmpp:microblog:0'
view_href = '/d/{}/{}'.format(jid_bare, node_name)
xmpp_uri = jid_bare
links.append(['Subscribe', 'xmpp:{}?pubsub;node={};action=subscribe'.format(jid_bare, node_name)])
links.append(['View', 'xmpp:{}?pubsub;node={}'.format(jid_bare, node_name)])
links.append(['vCard', 'xmpp:{}?vcard'.format(jid_bare)])
if item_id:
links.append({'name' : 'Subscribe',
'href' : 'xmpp:{}?pubsub;node={};item={};action=subscribe'.format(jid_bare, node_name, item_id),
'iden' : 'subscribe'})
links.append({'name' : 'View',
'href' : 'xmpp:{}?pubsub;node={};item={}'.format(jid_bare, node_name, item_id),
'iden' : 'view'})
else:
links.append({'name' : 'Subscribe',
'href' : 'xmpp:{}?pubsub;node={};action=subscribe'.format(jid_bare, node_name),
'iden' : 'subscribe'})
links.append({'name' : 'View',
'href' : 'xmpp:{}?pubsub;node={}'.format(jid_bare, node_name),
'iden' : 'view'})
links.append({'name' : 'vCard',
'href' : 'xmpp:{}?vcard'.format(jid_bare),
'iden' : 'vcard'})
# JID info
# NOTE Group chat of Psi+ Project at jabber.ru has a note in its vCard.
@ -410,6 +454,7 @@ class HttpInstance:
}
# Title
# TODO /d/pubsub.nicoco.fr/blog/urn-uuid-53e43061-1962-3112-bb8a-1473dca61719
if '@' in jid_bare and node_name == 'urn:xmpp:microblog:0':
node_title = 'Journal'
else:
@ -1109,7 +1154,7 @@ class Syndication:
instances = '' # TODO Check the Blasta database for instances.
entry = {'content' : content_text,
'link' : link_href,
'href' : link_href,
'published' : published_text,
'summary' : summary_text,
'tags' : tags,