Migrate from client-side unfurl to server-side link preview system#3355
Merged
Conversation
…ards - Queue link metadata fetching via async queue when a status is saved with a URL, storing OG/meta data directly on the entity as link_preview - Render cached link previews server-side in Status view template, eliminating per-page-load AJAX unfurl requests - Redesign preview card with clean Medium-style layout: full-width image, title, description, and domain indicator - Fall back to JS-based unfurl only when no cached preview exists yet - Keep real-time preview in edit form via existing Unfurl.unfurl() flow - Remove debug console.log from Unfurl.getUrls() https://claude.ai/code/session_01EgfJke6iWTtt67VeQJz5DX
Delete the JS-based Unfurl system that fetched link previews via AJAX on every page load: - Delete js/src/classes/Unfurl.js and remove from Grunt build - Delete /service/web/unfurl/ and /service/web/unfurl/remove/ routes, along with UrlUnfurl.php and RemovePreview.php service pages - Delete content/unfurl.tpl.php and entity/UnfurledUrl.tpl.php templates - Delete _unfurl.scss and remove from SCSS imports - Remove unfurl JS calls from Status edit template - Remove generic URL unfurl fallback from content/embed.tpl.php (known media embeds like YouTube/Vimeo still work) - Remove legacy unfurled-url CSS from compiled stylesheet Link previews are now handled entirely server-side: metadata is fetched via the async queue on save and cached on the entity, then rendered directly in the Status view template using LinkPreviewCard.tpl.php. https://claude.ai/code/session_01EgfJke6iWTtt67VeQJz5DX
Move link preview fetching out of the Status plugin into a new
Idno\Core\LinkPreview component so any plugin can benefit from it:
- Create Idno/Core/LinkPreview.php extending Component, with:
- extractFirstUrl() static helper for URL extraction
- buildPreviewFromData() static helper for normalizing OG metadata
- 'published' event listener that auto-enqueues preview fetching
for any entity with a body containing a URL
- 'linkpreview/fetch' async handler that fetches metadata via
UnfurledUrl and caches it on the entity as link_preview
- Register LinkPreview in start.php alongside other core components
- Remove all link preview logic from Status plugin (Main.php event
handler, Status.php queue call and extractFirstUrl method)
Any plugin can now use link previews by:
1. Having a text `body` property on its entity
2. Rendering entity/LinkPreviewCard in its view template when
$entity->link_preview is populated
https://claude.ai/code/session_01EgfJke6iWTtt67VeQJz5DX
The link preview styles were removed from idno.css, which meant the card rendered unstyled across all templates. Add them back and regenerate the minified CSS. https://claude.ai/code/session_01EgfJke6iWTtt67VeQJz5DX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here's what I fixed or added:
Replaced the client-side URL unfurling system with a server-side link preview system that:
New LinkPreview component (
Idno/Core/LinkPreview.php):publishedevent on entitieslink_previewNew LinkPreviewCard template (
templates/default/entity/LinkPreviewCard.tpl.php):Updated styling (
css/idno.css):Removed client-side unfurl system:
js/src/classes/Unfurl.jsand related JavaScriptIdno/Pages/Service/Web/UrlUnfurl.phpendpointIdno/Pages/Service/Web/RemovePreview.phpendpointUpdated build configuration:
Here's why I did it:
Checklist:
https://claude.ai/code/session_01EgfJke6iWTtt67VeQJz5DX