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

styling for external links and embedded records, some bugfixes

Changed files
+120 -26
css
lib
templates
+1 -1
README.md
···
* [ ] Posting box
* [X] Figure out how to run Constellation server despite build time for rocksdb being FOREVER
* [ ] More color themes? (i have priorities)
-
* [ ] Figure out why pages cut off loading halfway (why)
+
* [X] Figure out why pages cut off loading halfway (why)
## thanks to
+50
css/_partials/_feed.scss
···
&:hover {
opacity: 1;
}
+
}
+
+
.feedHeader {
+
text-align: left;
+
padding: 10px;
+
display: grid;
+
grid-template-areas: "avatar heading"
+
"spacer description"
+
"spacer info";
+
gap: 10px;
+
grid-template-columns: 64px 1fr;
+
border-bottom: 1px var(--border-color) solid;
+
+
img {
+
width: 64px;
+
height: 64px;
+
border-radius: 100%;
+
grid-area: avatar;
+
}
+
+
h2 {
+
text-align: left;
+
grid-area: heading;
+
margin: 0;
+
+
small {
+
display: block;
+
margin-top: .5em;
+
font-size: .5em;
+
opacity: 0.75;
+
+
&:hover {
+
opacity: 1;
+
}
+
}
+
}
+
+
.description {
+
grid-area: description;
+
}
+
+
.info {
+
grid-area: info;
+
}
+
+
ul {
+
list-style: none;
+
margin: 1em 0 0;
+
padding: 0;
+
}
}
+33
css/_partials/_post.scss
···
img {
width: 48px;
height: 48px;
+
object-fit: cover;
}
}
···
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(2, 1fr);
}
+
+
.record {
+
border: 1px var(--border-color) solid;
+
}
+
+
.externalLink {
+
border: 1px var(--border-color) solid;
+
+
.externalLinkImage {
+
width: 100%;
+
border-bottom: 1px var(--border-color) solid;
+
+
img {
+
border: none;
+
}
+
}
+
+
.externalLinkInfo {
+
padding: 10px;
+
}
+
+
.externalLinkTitle {
+
font-size: 1.5em;
+
margin-bottom: 0.5em;
+
}
+
+
a {
+
color: inherit;
+
text-decoration: none;
+
}
+
}
}
.postFooter {
···
#interactions {
border-bottom: 1px var(--border-color) solid;
+
padding: 10px;
}
#replies {
+27 -19
lib/bskyToucher.php
···
}
}
-
function getSlingshotData($repo, $collection, $rkey): object|bool {
+
function getSlingshotData(string $repo, string $collection, string $rkey, bool $reverse = false): object|bool {
+
$query = [
+
'collection' => $collection,
+
'repo' => $repo,
+
'rkey' => $rkey
+
];
+
if ($reverse) {
+
$query['reverse'] = true;
+
}
$ret = $this->makeRequest("GET", $this->slingshotBase."com.atproto.repo.getRecord", [
-
'query' => [
-
'collection' => $collection,
-
'repo' => $repo,
-
'rkey' => $rkey
-
]
+
'query' => $query
]);
if ($ret && $ret->getReasonPhrase() === 'OK') {
···
return false;
}
-
function getSlingshotIdentityMiniDoc($handle): object|bool {
+
function getSlingshotIdentityMiniDoc(string $handle): object|bool {
$ret = $this->makeRequest("GET", $this->slingshotBase."com.bad-example.identity.resolveMiniDoc", [
'query' => [
'identifier' => $handle
···
return false;
}
-
function getConstellationLinkData($target, $collection, $path, $limit = 50, $offset = 0, $endpoint = ''):object|bool {
+
function getConstellationLinkData(string $target, string $collection, string $path, int $limit = 50, int $offset = 0, string $endpoint = ''): object|bool {
$ret = $this->makeRequest("GET", $this->constellationBase.$endpoint, [
'query' => [
'target' => $target,
···
$ret = $this->getSlingshotData($identifier, "app.bsky.feed.post", $rkey);
if (!$ret) return false;
$post = $this->sanitizePost($ret, true);
-
\updatePostCache($post->postId, $post->did, $post->content, $post->embedType, json_encode($post->embeds));
+
\updatePostCache($post->postId, $post->author->did, $post->content, $post->embedType, json_encode($post->embeds));
return $post;
}
···
}
function getLikeUsers(string $post):array {
-
$ret = $this->getConstellationLinkData($post, "app.bsky.feed.like", ".subject.uri", 50, "/distinct-dids");
+
$ret = $this->getConstellationLinkData($post, "app.bsky.feed.like", ".subject.uri", 50, 0, "/distinct-dids");
+
print_r($ret);
if ($ret) {
-
return $this->sanitizeUserList($ret->linking_records);
+
//return $this->sanitizeUserList($ret->linking_records);
}
return [];
}
···
}
function getRepostUsers(string $post):array {
-
$ret = $this->getConstellationLinkData($post, "app.bsky.feed.repost", ".subject.uri", 50, "/distinct-dids");
+
$ret = $this->getConstellationLinkData($post, "app.bsky.feed.repost", ".subject.uri", 50, 0, "/distinct-dids");
if ($ret) {
-
return $this->sanitizeUserList($ret->linking_records);
+
return array_map(function($user) {
+
return $this->getUserInfo($user, 'did');
+
}, $ret->linking_dids);
+
//return $this->sanitizeUserList($ret->linking_records);
}
return [];
}
···
$ret = $this->getConstellationLinkData($post, "app.bsky.feed.post", ".reply.root.uri");
if ($ret) {
return array_map(function ($rec) {
-
$slingshotRecord = $this->getSlingshotData($rec->did, $rec->collection, $rec->rkey);
+
$slingshotRecord = $this->getSlingshotData($rec->did, $rec->collection, $rec->rkey, true);
return $this->sanitizePost($slingshotRecord, true);
}, $ret->linking_records);
}
···
if (!$postData) return false;
$postData = array_map(function($p) {
$uriComponents = $this->splitAtUri($p->uri);
+
print_r($uriComponents);
$cache = \requestPostCache($uriComponents->rkey);
if ($cache) return $this->sanitizeCachedPost($cache);
+
$post = $this->getPost($uriComponents->did, $uriComponents->rkey, true);
+
return $this->sanitizePost($post, true);
}, $postData->records);
-
-
if (!$postData) return false;
-
return $postData;
}
···
if (!$uriComponents) return false;
$feedData = $this->getSlingshotData($uriComponents->did, $uriComponents->collection, $uriComponents->rkey);
$authorInfo = $this->getUserInfo($uriComponents->did, 'did');
-
\updateFeedCache($atUri, $feedData->value->displayName, $feedData->value->description, $feedData->value->avatar->ref->{'$link'}, $uriComponents->did);
+
\updateFeedCache($atUri, $feedData->value->displayName, $feedData->value->description, $this->getMediaUrl($authorInfo->pds, $uriComponents->did, $feedData->value->avatar->ref->{'$link'}), $uriComponents->did);
return (object) [
'title' => $feedData->value->displayName,
'url' => '/f/'.$uriComponents->did.'/'.$uriComponents->rkey,
···
'uri' => $embeds->external->uri,
'title' => $embeds->external->title,
'description' => $embeds->external->description,
-
'thumb' => $this->getMediaUrl($authorData->pds, $authorData->did, $embeds->external->thumb->ref->{'$link'})
+
'thumb' => property_exists($embeds->external, 'thumb') ? $this->getMediaUrl($authorData->pds, $authorData->did, $embeds->external->thumb->ref->{'$link'}) : null
]
];
}
+1 -1
templates/_partials/embed_link.latte
···
<div class="postEmbeds">
<div class="externalLink">
<a href="{$embed->uri}" rel="external" target="_blank">
-
<div class="externalLinkImage">
+
<div class="externalLinkImage" n:if="$embed->thumb">
<img src="{$embed->thumb}" alt="{$embed->title}" />
</div>
<div class="externalLinkInfo">
+8 -5
templates/_partials/embed_record.latte
···
-
<div class="embeds">
+
<div class="postEmbeds">
<div class="record post">
<div class="postHeader">
<div class="avatar">
-
<a href="{$embed->profileLink}"><img src="{$embed->avatar}" alt="{$embed->displayName}'s user icon" /></a>
+
<a href="{$embed->post->author->profileLink}"><img src="{$embed->post->author->avatar}" alt="{$embed->post->author->displayName}'s user icon" /></a>
</div>
-
<div class="displayName"><a href="{$embed->profileLink}">{$embed->displayName}</a></div>
-
<div class="handle"><a href="{$embed->profileLink}">{$embed->handle}</a></div>
-
<div class="timeAgo"><a href="{$embed->postLink}">{$embed->createdAt}</a></div>
+
<div class="displayName"><a href="{$embed->post->author->profileLink}">{$embed->post->author->displayName}</a></div>
+
<div class="handle"><a href="{$embed->post->author->profileLink}">{$embed->post->author->handle}</a></div>
+
<div class="timeAgo"><a href="{$embed->post->postLink}">{$embed->post->createdAt}</a></div>
+
</div>
+
<div class="content">
+
{$embed->post->content|noescape}
</div>
</div>
</div>