mirror of https://gitlab.com/bashrc2/epicyon
Tab index for post links
parent
b7b23b9816
commit
9593092c8f
17
content.py
17
content.py
|
@ -616,8 +616,8 @@ def add_web_links(content: str) -> str:
|
||||||
# the word contains a prefix
|
# the word contains a prefix
|
||||||
if wrd.endswith('.') or wrd.endswith(';'):
|
if wrd.endswith('.') or wrd.endswith(';'):
|
||||||
wrd = wrd[:-1]
|
wrd = wrd[:-1]
|
||||||
markup = '<a href="' + wrd + \
|
markup = '<a href="' + wrd + '" tabindex="10" ' + \
|
||||||
'" rel="nofollow noopener noreferrer" target="_blank">'
|
'rel="nofollow noopener noreferrer" target="_blank">'
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
if wrd.startswith(prefix):
|
if wrd.startswith(prefix):
|
||||||
markup += '<span class="invisible">' + prefix + '</span>'
|
markup += '<span class="invisible">' + prefix + '</span>'
|
||||||
|
@ -768,7 +768,7 @@ def _add_mention(word_str: str, http_prefix: str, following: str,
|
||||||
replace_mentions[word_str] = \
|
replace_mentions[word_str] = \
|
||||||
"<span class=\"h-card\"><a href=\"" + http_prefix + \
|
"<span class=\"h-card\"><a href=\"" + http_prefix + \
|
||||||
"://" + replace_domain + "/@" + possible_nickname + \
|
"://" + replace_domain + "/@" + possible_nickname + \
|
||||||
"\" class=\"u-url mention\">@<span>" + \
|
"\" tabindex=\"10\" class=\"u-url mention\">@<span>" + \
|
||||||
possible_nickname + "</span></a></span>"
|
possible_nickname + "</span></a></span>"
|
||||||
return True
|
return True
|
||||||
# try replacing petnames with mentions
|
# try replacing petnames with mentions
|
||||||
|
@ -795,7 +795,8 @@ def _add_mention(word_str: str, http_prefix: str, following: str,
|
||||||
replace_mentions[word_str] = \
|
replace_mentions[word_str] = \
|
||||||
"<span class=\"h-card\"><a href=\"" + http_prefix + \
|
"<span class=\"h-card\"><a href=\"" + http_prefix + \
|
||||||
"://" + replace_domain + "/@" + replace_nickname + \
|
"://" + replace_domain + "/@" + replace_nickname + \
|
||||||
"\" class=\"u-url mention\">@<span>" + \
|
"\" tabindex=\"10\" " + \
|
||||||
|
"class=\"u-url mention\">@<span>" + \
|
||||||
replace_nickname + "</span></a></span>"
|
replace_nickname + "</span></a></span>"
|
||||||
return True
|
return True
|
||||||
follow_ctr += 1
|
follow_ctr += 1
|
||||||
|
@ -827,8 +828,8 @@ def _add_mention(word_str: str, http_prefix: str, following: str,
|
||||||
replace_mentions[word_str] = \
|
replace_mentions[word_str] = \
|
||||||
"<span class=\"h-card\"><a href=\"" + http_prefix + \
|
"<span class=\"h-card\"><a href=\"" + http_prefix + \
|
||||||
"://" + possible_domain + "/@" + possible_nickname + \
|
"://" + possible_domain + "/@" + possible_nickname + \
|
||||||
"\" class=\"u-url mention\">@<span>" + possible_nickname + \
|
"\" tabindex=\"10\" class=\"u-url mention\">@<span>" + \
|
||||||
"</span></a></span>"
|
possible_nickname + "</span></a></span>"
|
||||||
return True
|
return True
|
||||||
# @nick@domain
|
# @nick@domain
|
||||||
if not (possible_domain == 'localhost' or '.' in possible_domain):
|
if not (possible_domain == 'localhost' or '.' in possible_domain):
|
||||||
|
@ -845,8 +846,8 @@ def _add_mention(word_str: str, http_prefix: str, following: str,
|
||||||
replace_mentions[word_str] = \
|
replace_mentions[word_str] = \
|
||||||
"<span class=\"h-card\"><a href=\"" + http_prefix + \
|
"<span class=\"h-card\"><a href=\"" + http_prefix + \
|
||||||
"://" + possible_domain + "/@" + possible_nickname + \
|
"://" + possible_domain + "/@" + possible_nickname + \
|
||||||
"\" class=\"u-url mention\">@<span>" + possible_nickname + \
|
"\" tabindex=\"10\" class=\"u-url mention\">@<span>" + \
|
||||||
"</span></a></span>"
|
possible_nickname + "</span></a></span>"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
28
tests.py
28
tests.py
|
@ -3583,10 +3583,15 @@ def _test_web_links():
|
||||||
example_text = \
|
example_text = \
|
||||||
'This post has a web links https://somesite.net\n\nAnd some other text'
|
'This post has a web links https://somesite.net\n\nAnd some other text'
|
||||||
linked_text = add_web_links(example_text)
|
linked_text = add_web_links(example_text)
|
||||||
assert \
|
expected_text = \
|
||||||
'<a href="https://somesite.net" rel="nofollow noopener noreferrer"' + \
|
'<a href="https://somesite.net" tabindex="10" ' + \
|
||||||
|
'rel="nofollow noopener noreferrer"' + \
|
||||||
' target="_blank"><span class="invisible">https://' + \
|
' target="_blank"><span class="invisible">https://' + \
|
||||||
'</span><span class="ellipsis">somesite.net</span></a' in linked_text
|
'</span><span class="ellipsis">somesite.net</span></a'
|
||||||
|
if expected_text not in linked_text:
|
||||||
|
print(expected_text + '\n')
|
||||||
|
print(linked_text)
|
||||||
|
assert expected_text in linked_text
|
||||||
|
|
||||||
example_text = \
|
example_text = \
|
||||||
'This post has a very long web link\n\nhttp://' + \
|
'This post has a very long web link\n\nhttp://' + \
|
||||||
|
@ -4613,11 +4618,15 @@ def _test_reply_to_public_post(base_dir: str) -> None:
|
||||||
low_bandwidth, content_license_url,
|
low_bandwidth, content_license_url,
|
||||||
languages_understood)
|
languages_understood)
|
||||||
# print(str(reply))
|
# print(str(reply))
|
||||||
assert reply['object']['content'] == \
|
expected_str = \
|
||||||
'<p><span class=\"h-card\">' + \
|
'<p><span class=\"h-card\">' + \
|
||||||
'<a href=\"https://rat.site/@ninjarodent\" ' + \
|
'<a href=\"https://rat.site/@ninjarodent\" tabindex="10" ' + \
|
||||||
'class=\"u-url mention\">@<span>ninjarodent</span>' + \
|
'class=\"u-url mention\">@<span>ninjarodent</span>' + \
|
||||||
'</a></span> This is a test.</p>'
|
'</a></span> This is a test.</p>'
|
||||||
|
if reply['object']['content'] != expected_str:
|
||||||
|
print(expected_str + '\n')
|
||||||
|
print(reply['object']['content'])
|
||||||
|
assert reply['object']['content'] == expected_str
|
||||||
reply['object']['contentMap'][system_language] = reply['object']['content']
|
reply['object']['contentMap'][system_language] = reply['object']['content']
|
||||||
assert reply['object']['tag'][0]['type'] == 'Mention'
|
assert reply['object']['tag'][0]['type'] == 'Mention'
|
||||||
assert reply['object']['tag'][0]['name'] == '@ninjarodent@rat.site'
|
assert reply['object']['tag'][0]['name'] == '@ninjarodent@rat.site'
|
||||||
|
@ -5541,17 +5550,22 @@ def _test_links_within_post(base_dir: str) -> None:
|
||||||
low_bandwidth, content_license_url,
|
low_bandwidth, content_license_url,
|
||||||
languages_understood)
|
languages_understood)
|
||||||
|
|
||||||
assert post_json_object['object']['content'] == \
|
expected_str = \
|
||||||
'<p>This is a test post with links.<br><br>' + \
|
'<p>This is a test post with links.<br><br>' + \
|
||||||
'<a href="ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/v4/" ' + \
|
'<a href="ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/v4/" ' + \
|
||||||
|
'tabindex="10" ' + \
|
||||||
'rel="nofollow noopener noreferrer" target="_blank">' + \
|
'rel="nofollow noopener noreferrer" target="_blank">' + \
|
||||||
'<span class="invisible">ftp://</span>' + \
|
'<span class="invisible">ftp://</span>' + \
|
||||||
'<span class="ellipsis">' + \
|
'<span class="ellipsis">' + \
|
||||||
'ftp.ncdc.noaa.gov/pub/data/ghcn/v4/</span>' + \
|
'ftp.ncdc.noaa.gov/pub/data/ghcn/v4/</span>' + \
|
||||||
'</a><br><br><a href="https://libreserver.org" ' + \
|
'</a><br><br><a href="https://libreserver.org" tabindex="10" ' + \
|
||||||
'rel="nofollow noopener noreferrer" target="_blank">' + \
|
'rel="nofollow noopener noreferrer" target="_blank">' + \
|
||||||
'<span class="invisible">https://</span>' + \
|
'<span class="invisible">https://</span>' + \
|
||||||
'<span class="ellipsis">libreserver.org</span></a></p>'
|
'<span class="ellipsis">libreserver.org</span></a></p>'
|
||||||
|
if post_json_object['object']['content'] != expected_str:
|
||||||
|
print(expected_str + '\n')
|
||||||
|
print(post_json_object['object']['content'])
|
||||||
|
assert post_json_object['object']['content'] == expected_str
|
||||||
assert post_json_object['object']['content'] == \
|
assert post_json_object['object']['content'] == \
|
||||||
post_json_object['object']['contentMap'][system_language]
|
post_json_object['object']['contentMap'][system_language]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue