From d857eb58c5302c470c722bf8487b427dbc69a195 Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Thu, 30 Jul 2026 12:48:28 +1000 Subject: [PATCH] Add bookmarks --- agents.md | 28 ++ links/api_urls.py | 2 + links/bookmark_views.py | 230 ++++++++++ .../management/commands/import_x_bookmarks.py | 94 ++++ links/migrations/0050_bookmark.py | 49 ++ links/models.py | 64 +++ links/search_backend.py | 58 ++- links/search_views.py | 53 ++- links/serializers.py | 123 ++++- links/signals.py | 21 +- links/templates/links/bookmark_detail.html | 57 +++ links/templates/links/bookmark_list.html | 238 ++++++++++ .../links/includes/bookmark_list_items.html | 123 +++++ links/templates/links/search_react.html | 2 +- links/templatetags/bookmark_extras.py | 83 ++++ links/urls.py | 5 + static/dist/jsx-runtime-COXMab3W.js | 8 + static/dist/search.js | 2 +- static/openapi.yaml | 425 ++++++++++++++++++ static_src/search.jsx | 178 +++++--- templates/base.html | 8 + tests/test_bookmarks_api.py | 116 +++++ 22 files changed, 1895 insertions(+), 72 deletions(-) create mode 100644 links/bookmark_views.py create mode 100644 links/management/commands/import_x_bookmarks.py create mode 100644 links/migrations/0050_bookmark.py create mode 100644 links/templates/links/bookmark_detail.html create mode 100644 links/templates/links/bookmark_list.html create mode 100644 links/templates/links/includes/bookmark_list_items.html create mode 100644 links/templatetags/bookmark_extras.py create mode 100644 static/dist/jsx-runtime-COXMab3W.js create mode 100644 tests/test_bookmarks_api.py diff --git a/agents.md b/agents.md index ebc6795..df5c289 100644 --- a/agents.md +++ b/agents.md @@ -81,6 +81,25 @@ Bookmarked pages with auto-extracted metadata: #### Tag Hierarchical tagging system: + +#### Bookmark +Archived social-media posts (originally x.com / Twitter bookmarks), each saved with full preview data so a viewer page renders offline without further x.com API calls: +- **tweet_id**: Source post id (unique, indexed) +- **url**: Canonical x.com post URL +- **author_screen_name / author_name / author_profile_image_url**: Denormalised author +- **text**: Full post text (searchable) +- **summary**: Optional human/agent-written summary (writable via API `PATCH`) +- **tweet_created_at / bookmark_created_at**: Parsed source dates (indexed) +- **view_count / favorite_count / retweet_count / reply_count / bookmark_count / quote_count**: Engagement counters +- **has_video / has_photo / has_card / is_quote / is_retweet**: Indexed boolean flags for fast filter pages +- **media**: JSON list of media objects (photo URL variants; video/animated_gif with `poster`, `best_mp4`, `duration_ms`, `variants[]`) +- **card_data**: JSON link-preview card (title/description/site/image/url) +- **quoted_data**: JSON nested quoted post (recursive shape) +- **data**: The complete original normalised export object (kept for round-tripping / the offline viewer) +- UI: `/ui/bookmarks/` (list, `BookmarkListView`) + `/ui/bookmarks//` (detail). Top-menu item "Bookmarks" in `templates/base.html`. +- Import: `python manage.py import_x_bookmarks [--clear]` (loads `x-bookmarks-exporter` JSON) or `POST /api/bookmarks/import`. +- **No `