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:
Sascha Ißbrücker
2025-03-22 19:07:05 +01:00
committed by GitHub
parent 6d9d0e19f1
commit 6bba4f35c8
10 changed files with 300 additions and 10 deletions

View File

@@ -130,11 +130,20 @@ class BookmarkItem:
self.description = bookmark.resolved_description
self.notes = bookmark.notes
self.tag_names = bookmark.tag_names
self.web_archive_snapshot_url = bookmark.web_archive_snapshot_url
if not self.web_archive_snapshot_url:
self.web_archive_snapshot_url = generate_fallback_webarchive_url(
bookmark.url, bookmark.date_added
if bookmark.latest_snapshot_id:
self.snapshot_url = reverse(
"linkding:assets.view", args=[bookmark.latest_snapshot_id]
)
self.snapshot_title = "View latest snapshot"
else:
self.snapshot_url = bookmark.web_archive_snapshot_url
self.snapshot_title = (
"View snapshot on the Internet Archive Wayback Machine"
)
if not self.snapshot_url:
self.snapshot_url = generate_fallback_webarchive_url(
bookmark.url, bookmark.date_added
)
self.favicon_file = bookmark.favicon_file
self.preview_image_file = bookmark.preview_image_file
self.is_archived = bookmark.is_archived