Show the domain in mentions

pull/20/head
Thomas Sileo 2019-04-10 23:39:30 +02:00
rodzic 4518bfbb39
commit 4efec8e74c
1 zmienionych plików z 7 dodań i 2 usunięć

Wyświetl plik

@ -37,7 +37,7 @@ def hashtagify(content: str) -> Tuple[str, List[Dict[str, str]]]:
return content, tags
def mentionify(content: str) -> Tuple[str, List[Dict[str, str]]]:
def mentionify(content: str, hide_domain: bool = False) -> Tuple[str, List[Dict[str, str]]]:
tags = []
for mention in re.findall(MENTION_REGEX, content):
_, username, domain = mention.split("@")
@ -47,7 +47,12 @@ def mentionify(content: str) -> Tuple[str, List[Dict[str, str]]]:
continue
p = get_backend().fetch_iri(actor_url)
tags.append(dict(type="Mention", href=p["id"], name=mention))
link = f'<span class="h-card"><a href="{p["url"]}" class="u-url mention">@<span>{username}</span></a></span>'
d = f"@<span>{domain}</span>"
if hide_domain:
d = ""
link = f'<span class="h-card"><a href="{p["url"]}" class="u-url mention">@<span>{username}</span>{d}</a></span>'
content = content.replace(mention, link)
return content, tags