mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-08 19:28:29 +02:00
Prefer local snapshot over web archive link in bookmark list links (#1021)
* Prefer local snapshot over web archive link * Update latest snapshot when it is deleted * fix filter in migration * improve migration performance
This commit is contained in:
@@ -43,7 +43,7 @@ class BookmarkListTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
||||
self.assertInHTML(
|
||||
f"""
|
||||
<a href="{url}"
|
||||
title="Show snapshot on the Internet Archive Wayback Machine" target="{link_target}" rel="noopener">
|
||||
title="View snapshot on the Internet Archive Wayback Machine" target="{link_target}" rel="noopener">
|
||||
{label_content}
|
||||
</a>
|
||||
<span>|</span>
|
||||
@@ -559,6 +559,31 @@ class BookmarkListTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
||||
html, "1 week ago", bookmark.web_archive_snapshot_url, link_target="_self"
|
||||
)
|
||||
|
||||
def test_should_render_latest_snapshot_link_if_one_exists(self):
|
||||
bookmark = self.setup_date_format_test(
|
||||
UserProfile.BOOKMARK_DATE_DISPLAY_ABSOLUTE
|
||||
)
|
||||
bookmark.latest_snapshot = self.setup_asset(bookmark)
|
||||
bookmark.save()
|
||||
|
||||
html = self.render_template()
|
||||
formatted_date = formats.date_format(bookmark.date_added, "SHORT_DATE_FORMAT")
|
||||
snapshot_url = reverse(
|
||||
"linkding:assets.view", args=[bookmark.latest_snapshot.id]
|
||||
)
|
||||
|
||||
# Check that the snapshot link is rendered with the correct URL and title
|
||||
self.assertInHTML(
|
||||
f"""
|
||||
<a href="{snapshot_url}"
|
||||
title="View latest snapshot" target="_blank" rel="noopener">
|
||||
{formatted_date}
|
||||
</a>
|
||||
<span>|</span>
|
||||
""",
|
||||
html,
|
||||
)
|
||||
|
||||
def test_should_reflect_unread_state_as_css_class(self):
|
||||
self.setup_bookmark(unread=True)
|
||||
html = self.render_template()
|
||||
|
Reference in New Issue
Block a user