Just looked at this, and was wondering if we could do something like:
User enters:
PHP Code:
<bsky>3ldhirk3zcc2c</bsky>
The BBCode transforms that to
PHP Code:
<div class=bsky bskyid="3ldhirk3zcc2c"/>
Then at the bottom (along with the twitter code) you add:
PHP Code:
<script>
var bskys = document.querySelectorAll("div.bsky");
bskys.forEach (
function(bsky) {
var id = bsky.getAttribute("bskyid");
var req = new XMLHttpRequest();
req.onreadystatechange=function() {
if (this.readyState==4&&this.status=200) {
document.querySelectorAll( '[bskyid='+id+']').innerHTML=req.response.html
};
req.open("GET","https://embed.bsky.app/oembed?url=https://bsky.app/profile/aoc.bsky.social/post/3ldhirk3zcc2c",true);
req.send();
}
);
</script>
That javascript code should loop through all div.bsky elements on the page, make the request for the json for each, then replace the contents of the div with the html that is returned in the json. That html includes the blockquote along with the javascript to convert to a bluesky post.
None of this is tested - just read through the thread and thought this might be a possible solution. It is basically the same as the twitter embed, but requires the extra step of first making a call to transforming the tag to the bluesky blockquote, which will then transform itself into the bluesky.
I am curious what the behaviour will be if the same bluesky post shows up multiple times on a page. The embedded javascript that comes with the blockquote will be repeated. Should be ok as long as those scripts don't run in parallel which can cause a race condition. If it causes an issue, we can look at extracting that javascript from the json response, and posting it once at the bottom of the page after all the bsky requests have completed.