friendship ended with social-app. php is my new best friend

fix video, make popovers prettier yey

Changed files
+49 -11
css
lib
+26
css/main.scss
···
justify-content: space-between;
margin-top: 10px;
}
}
···
justify-content: space-between;
margin-top: 10px;
}
+
}
+
+
[popover] {
+
max-height: calc(100% - 40px);
+
max-width: calc(100% - 40px);
+
display: none;
+
grid-template-rows: 1fr auto;
+
border: 1px var(--border-color) solid;
+
background-color: var(--background-color);
+
+
&:popover-open {
+
display: grid;
+
}
+
+
img {
+
object-fit: contain;
+
}
+
+
.alt {
+
padding: 10px;
+
}
+
}
+
+
::backdrop {
+
backdrop-filter: blur(5px);
+
background-color: color-mix(in srgb-linear, var(--background-color), rgba(0,0,0,.35) 20%);
}
+23 -11
lib/bskyOperations.php
···
<?php
namespace Smallnest\BskyOps;
require_once('vendor/autoload.php');
require_once('lib/bskyProvider.php');
···
$embeds = $this->renderEmbeds($post->embedType, $post->embeds, $post);
$imageEmbedClass = $post->embedType === "images" ? " img-".count($post->embeds) : "";
echo <<<EOD
-
<div class="post">
<div class="postHeader">
<div class="avatar">
<a href="$profileLink"><img src="$post->avatar" /></a>
···
function renderEmbeds($type, $embeds, $context) {
$ret = "";
-
print_r($embeds);
if ($type === 'images') {
$imageCount = count($embeds);
foreach ($embeds as $embed) {
···
} else if ($type === 'video') {
$thumb = $embeds[0]->thumb;
$vid = $embeds[0]->video;
$ret .= <<<EOD
<div class="video">
-
<video poster="$thumb" src="$vid" controls type="application/x-mpegURL" />
</div>
EOD;
} else if ($type === 'external') {
$ret .= <<<EOD
<div class="externalLink">
-
<a href="$embeds[0]->uri" rel="external" target="_blank">
<div class="externalLinkImage">
-
<img src="$embeds[0]->thumb" alt="$embeds[0]->title" />
</div>
<div class="externalLinkInfo">
-
<div class="externalLinkTitle">$embeds[0]->title</div>
-
<div class="externalLinkDesc">$embeds[0]->description</div>
-
<div class="externalLinkUri">$embeds[0]->uri</div>
</div>
</a>
</div>
···
}
$feedData = json_decode(file_get_contents($this->bskyApiBase.$this->apiEndpoints['getFeed']."?feed=".$atUri));
-
$feed = array_map(function($f) {
$post = $f->post;
preg_match('/\/([a-z0-9]+)$/', $post->uri, $postIdRegex);
$pid = $postIdRegex[1];
···
$embedType = 'images';
} elseif ($post->embed->{'$type'} === 'app.bsky.embed.video#view') {
$embeds = [(object) [
-
"video" => $post->embed->playlist,
"thumb" => $post->embed->thumbnail
]];
$embedType = 'video';
···
return (object) [
'displayName' => $post->author->displayName,
'handle' => $post->author->handle,
'postId' => $pid,
'avatar' => $post->author->avatar,
'content' => $post->record->text,
···
'quoteCount' => $post->quoteCount,
'createdAt' => $post->record->createdAt,
'embedType' => $embedType,
-
'embeds' => $embeds
];
}, $feedData->feed);
return $feed;
···
<?php
namespace Smallnest\BskyOps;
+
require_once('config.php');
require_once('vendor/autoload.php');
require_once('lib/bskyProvider.php');
···
$embeds = $this->renderEmbeds($post->embedType, $post->embeds, $post);
$imageEmbedClass = $post->embedType === "images" ? " img-".count($post->embeds) : "";
echo <<<EOD
+
<div class="post" data-cursor="$post->cursor">
<div class="postHeader">
<div class="avatar">
<a href="$profileLink"><img src="$post->avatar" /></a>
···
function renderEmbeds($type, $embeds, $context) {
$ret = "";
if ($type === 'images') {
$imageCount = count($embeds);
foreach ($embeds as $embed) {
···
} else if ($type === 'video') {
$thumb = $embeds[0]->thumb;
$vid = $embeds[0]->video;
+
$author = $context->did;
+
$pds = DEFAULT_PDS;
$ret .= <<<EOD
<div class="video">
+
<video
+
src="$pds/xrpc/com.atproto.sync.getBlob?did=$author&cid=$vid"
+
controls
+
></video>
</div>
EOD;
} else if ($type === 'external') {
+
$title = $embeds[0]->title;
+
$uri = $embeds[0]->uri;
+
$thumb = $embeds[0]->thumb;
+
$desc = $embeds[0]->description;
$ret .= <<<EOD
<div class="externalLink">
+
<a href="$uri" rel="external" target="_blank">
<div class="externalLinkImage">
+
<img src="$thumb" alt="$title" />
</div>
<div class="externalLinkInfo">
+
<div class="externalLinkTitle">$title</div>
+
<div class="externalLinkDesc">$desc</div>
+
<div class="externalLinkUri">$uri</div>
</div>
</a>
</div>
···
}
$feedData = json_decode(file_get_contents($this->bskyApiBase.$this->apiEndpoints['getFeed']."?feed=".$atUri));
+
$cursor = $feedData->cursor;
+
$feed = array_map(function($f) use ($cursor) {
$post = $f->post;
preg_match('/\/([a-z0-9]+)$/', $post->uri, $postIdRegex);
$pid = $postIdRegex[1];
···
$embedType = 'images';
} elseif ($post->embed->{'$type'} === 'app.bsky.embed.video#view') {
$embeds = [(object) [
+
"video" => $post->embed->cid,
"thumb" => $post->embed->thumbnail
]];
$embedType = 'video';
···
return (object) [
'displayName' => $post->author->displayName,
'handle' => $post->author->handle,
+
'did' => $post->author->did,
'postId' => $pid,
'avatar' => $post->author->avatar,
'content' => $post->record->text,
···
'quoteCount' => $post->quoteCount,
'createdAt' => $post->record->createdAt,
'embedType' => $embedType,
+
'embeds' => $embeds,
+
'cursor' => $cursor
];
}, $feedData->feed);
return $feed;