Commit 7ef24005 authored by Lysander Trischler's avatar Lysander Trischler
Browse files

Generate conversation subject URLs

These are ususally the ones I really want to visit, when opening the twt
subject hash tags. The conversation view covers the complete discussion,
including the original twt starting the conversation. The root twt is
missing in the tag search view. In contrast to the search, twts are also
sorted in chronological order in the conversation view, which makes for
a much more convenient user experience, since normal text flow is from
top to bottom.
parent 5f4302c6
......@@ -264,6 +264,8 @@ class TwtsListBox(widgets.VimListBox):
class URLListBox(widgets.VimListBox):
CONV_URL = "https://twtxt.net/conv/%s"
class Mention:
def __init__(self, nick, url, following):
self.nick = nick
......@@ -289,7 +291,7 @@ class URLListBox(widgets.VimListBox):
url = token.url
hint = ""
elif token.hash:
url = "https://twtxt.net/conv/%s" % token.hash
url = self.CONV_URL % token.hash
hint = " (generated this URL)"
else:
continue
......@@ -300,7 +302,17 @@ class URLListBox(widgets.VimListBox):
("link-normal", url),
hint]
items.append(widgets.SelectableAttrMap(urwid.Text(markup), twtxtrenderer.read_normal_map, twtxtrenderer.read_focus_map))
preferred_weighted_indices.append((2, len(self._tokens) - 1))
preferred_weighted_indices.append((3, len(self._tokens) - 1))
if "conv" not in url:
url = self.CONV_URL % token.hash
self._tokens.append(twtxtparser.SubjectHash(token.start_pos, token.end_pos, token.hash, url))
markup = ["%2d: Subject conversation " % len(self._tokens),
("subject-normal", token.hash if token.hash else "unknown subject hash"),
" – ",
("link-normal", url)]
items.append(widgets.SelectableAttrMap(urwid.Text(markup), twtxtrenderer.read_normal_map, twtxtrenderer.read_focus_map))
preferred_weighted_indices.append((2, len(self._tokens) - 1))
elif isinstance(token, twtxtparser.Mention):
if token.nick and token.url:
......@@ -324,7 +336,7 @@ class URLListBox(widgets.VimListBox):
" – ",
("link-normal", url)]
items.append(widgets.SelectableAttrMap(urwid.Text(markup), twtxtrenderer.read_normal_map, twtxtrenderer.read_focus_map))
preferred_weighted_indices.append((4 if following else 3, len(self._tokens) - 1))
preferred_weighted_indices.append((5 if following else 4, len(self._tokens) - 1))
if not items:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment