Add bookmark to conversation links

merge-requests/30/head
Bob Mottram 2024-05-29 19:33:54 +01:00
parent 3dba69c19a
commit 2d92d6f924
1 changed files with 14 additions and 7 deletions

View File

@ -1338,8 +1338,9 @@ def _announce_unattributed_html(translate: {},
if translate.get(announces_str): if translate.get(announces_str):
announces_str = translate[announces_str] announces_str = translate[announces_str]
post_id = remove_id_ending(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
post_bookmark = '#' + post_id.replace('--', '-')
post_link = '/users/' + nickname + '?convthread=' + \ post_link = '/users/' + nickname + '?convthread=' + \
post_id.replace('--', '/') post_id.replace('--', '/') + post_bookmark
return ' <img loading="lazy" decoding="async" title="' + \ return ' <img loading="lazy" decoding="async" title="' + \
announces_str + '" alt="' + \ announces_str + '" alt="' + \
announces_str + '" src="/icons' + \ announces_str + '" src="/icons' + \
@ -1360,8 +1361,9 @@ def _announce_with_display_name_html(translate: {},
if translate.get(announces_str): if translate.get(announces_str):
announces_str = translate[announces_str] announces_str = translate[announces_str]
post_id = remove_id_ending(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
post_bookmark = '#' + post_id.replace('--', '-')
post_link = '/users/' + nickname + '?convthread=' + \ post_link = '/users/' + nickname + '?convthread=' + \
post_id.replace('--', '/') post_id.replace('--', '/') + post_bookmark
return ' <img loading="lazy" decoding="async" title="' + \ return ' <img loading="lazy" decoding="async" title="' + \
announces_str + '" alt="' + \ announces_str + '" alt="' + \
announces_str + '" src="/' + \ announces_str + '" src="/' + \
@ -1528,8 +1530,9 @@ def _reply_to_unknown_html(translate: {},
""" """
replying_to_str = _replying_to_with_scope(post_json_object, translate) replying_to_str = _replying_to_with_scope(post_json_object, translate)
post_id = get_reply_to(post_json_object['object']) post_id = get_reply_to(post_json_object['object'])
post_bookmark = '#' + post_id.replace('--', '-')
post_link = '/users/' + nickname + '?convthread=' + \ post_link = '/users/' + nickname + '?convthread=' + \
post_id.replace('--', '/') post_id.replace('--', '/') + post_bookmark
return ' <img loading="lazy" decoding="async" title="' + \ return ' <img loading="lazy" decoding="async" title="' + \
replying_to_str + '" alt="' + \ replying_to_str + '" alt="' + \
replying_to_str + '" src="/icons' + \ replying_to_str + '" src="/icons' + \
@ -1558,8 +1561,9 @@ def _reply_with_unknown_path_html(translate: {},
""" """
replying_to_str = _replying_to_with_scope(post_json_object, translate) replying_to_str = _replying_to_with_scope(post_json_object, translate)
post_id = get_reply_to(post_json_object['object']) post_id = get_reply_to(post_json_object['object'])
post_bookmark = '#' + post_id.replace('--', '-')
post_link = '/users/' + nickname + '?convthread=' + \ post_link = '/users/' + nickname + '?convthread=' + \
post_id.replace('--', '/') post_id.replace('--', '/') + post_bookmark
return ' <img loading="lazy" decoding="async" title="' + \ return ' <img loading="lazy" decoding="async" title="' + \
replying_to_str + \ replying_to_str + \
'" alt="' + replying_to_str + \ '" alt="' + replying_to_str + \
@ -1580,8 +1584,9 @@ def _get_reply_html(translate: {},
if not in_reply_to: if not in_reply_to:
return '' return ''
replying_to_str = _replying_to_with_scope(post_json_object, translate) replying_to_str = _replying_to_with_scope(post_json_object, translate)
post_bookmark = '#' + in_reply_to.replace('--', '-')
post_link = '/users/' + nickname + '?convthread=' + \ post_link = '/users/' + nickname + '?convthread=' + \
in_reply_to.replace('--', '/') in_reply_to.replace('--', '/') + post_bookmark
return ' ' + \ return ' ' + \
'<img loading="lazy" decoding="async" title="' + \ '<img loading="lazy" decoding="async" title="' + \
replying_to_str + '" alt="' + \ replying_to_str + '" alt="' + \
@ -1854,8 +1859,9 @@ def _get_footer_with_icons(show_icons: bool,
footer_str += _get_copyright_footer(content_license_url, footer_str += _get_copyright_footer(content_license_url,
translate) translate)
# show the date # show the date
post_bookmark = '#' + published_link.replace('--', '-')
date_link = '/users/' + nickname + '?convthread=' + \ date_link = '/users/' + nickname + '?convthread=' + \
published_link.replace('--', '/') published_link.replace('--', '/') + post_bookmark
footer_str += '<a href="' + date_link + '" class="' + \ footer_str += '<a href="' + date_link + '" class="' + \
time_class + '" tabindex="10"><span itemprop="datePublished">' + \ time_class + '" tabindex="10"><span itemprop="datePublished">' + \
published_str + '</span></a>\n' published_str + '</span></a>\n'
@ -2702,8 +2708,9 @@ def individual_post_as_html(signing_priv_key_pem: str,
if content_license_url and not is_reminder(post_json_object): if content_license_url and not is_reminder(post_json_object):
footer_str += _get_copyright_footer(content_license_url, footer_str += _get_copyright_footer(content_license_url,
translate) translate)
post_bookmark = '#' + published_link.replace('--', '-')
conv_link = '/users/' + nickname + '?convthread=' + \ conv_link = '/users/' + nickname + '?convthread=' + \
published_link.replace('--', '/') published_link.replace('--', '/') + post_bookmark
footer_str += '<a href="' + conv_link + \ footer_str += '<a href="' + conv_link + \
'" class="' + time_class + '" tabindex="10">' + \ '" class="' + time_class + '" tabindex="10">' + \
published_str + '</a>\n' published_str + '</a>\n'