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

styling for external links and embedded records, some bugfixes

+120 -26
+1 -1
README.md
··· 37 37 * [ ] Posting box 38 38 * [X] Figure out how to run Constellation server despite build time for rocksdb being FOREVER 39 39 * [ ] More color themes? (i have priorities) 40 - * [ ] Figure out why pages cut off loading halfway (why) 40 + * [X] Figure out why pages cut off loading halfway (why) 41 41 42 42 ## thanks to 43 43
+50
css/_partials/_feed.scss
··· 11 11 &:hover { 12 12 opacity: 1; 13 13 } 14 + } 15 + 16 + .feedHeader { 17 + text-align: left; 18 + padding: 10px; 19 + display: grid; 20 + grid-template-areas: "avatar heading" 21 + "spacer description" 22 + "spacer info"; 23 + gap: 10px; 24 + grid-template-columns: 64px 1fr; 25 + border-bottom: 1px var(--border-color) solid; 26 + 27 + img { 28 + width: 64px; 29 + height: 64px; 30 + border-radius: 100%; 31 + grid-area: avatar; 32 + } 33 + 34 + h2 { 35 + text-align: left; 36 + grid-area: heading; 37 + margin: 0; 38 + 39 + small { 40 + display: block; 41 + margin-top: .5em; 42 + font-size: .5em; 43 + opacity: 0.75; 44 + 45 + &:hover { 46 + opacity: 1; 47 + } 48 + } 49 + } 50 + 51 + .description { 52 + grid-area: description; 53 + } 54 + 55 + .info { 56 + grid-area: info; 57 + } 58 + 59 + ul { 60 + list-style: none; 61 + margin: 1em 0 0; 62 + padding: 0; 63 + } 14 64 }
+33
css/_partials/_post.scss
··· 24 24 img { 25 25 width: 48px; 26 26 height: 48px; 27 + object-fit: cover; 27 28 } 28 29 } 29 30 ··· 112 113 grid-template-columns: repeat(2, 1fr); 113 114 grid-template-rows: repeat(2, 1fr); 114 115 } 116 + 117 + .record { 118 + border: 1px var(--border-color) solid; 119 + } 120 + 121 + .externalLink { 122 + border: 1px var(--border-color) solid; 123 + 124 + .externalLinkImage { 125 + width: 100%; 126 + border-bottom: 1px var(--border-color) solid; 127 + 128 + img { 129 + border: none; 130 + } 131 + } 132 + 133 + .externalLinkInfo { 134 + padding: 10px; 135 + } 136 + 137 + .externalLinkTitle { 138 + font-size: 1.5em; 139 + margin-bottom: 0.5em; 140 + } 141 + 142 + a { 143 + color: inherit; 144 + text-decoration: none; 145 + } 146 + } 115 147 } 116 148 117 149 .postFooter { ··· 140 172 141 173 #interactions { 142 174 border-bottom: 1px var(--border-color) solid; 175 + padding: 10px; 143 176 } 144 177 145 178 #replies {
+27 -19
lib/bskyToucher.php
··· 77 77 } 78 78 } 79 79 80 - function getSlingshotData($repo, $collection, $rkey): object|bool { 80 + function getSlingshotData(string $repo, string $collection, string $rkey, bool $reverse = false): object|bool { 81 + $query = [ 82 + 'collection' => $collection, 83 + 'repo' => $repo, 84 + 'rkey' => $rkey 85 + ]; 86 + if ($reverse) { 87 + $query['reverse'] = true; 88 + } 81 89 $ret = $this->makeRequest("GET", $this->slingshotBase."com.atproto.repo.getRecord", [ 82 - 'query' => [ 83 - 'collection' => $collection, 84 - 'repo' => $repo, 85 - 'rkey' => $rkey 86 - ] 90 + 'query' => $query 87 91 ]); 88 92 89 93 if ($ret && $ret->getReasonPhrase() === 'OK') { ··· 93 97 return false; 94 98 } 95 99 96 - function getSlingshotIdentityMiniDoc($handle): object|bool { 100 + function getSlingshotIdentityMiniDoc(string $handle): object|bool { 97 101 $ret = $this->makeRequest("GET", $this->slingshotBase."com.bad-example.identity.resolveMiniDoc", [ 98 102 'query' => [ 99 103 'identifier' => $handle ··· 107 111 return false; 108 112 } 109 113 110 - function getConstellationLinkData($target, $collection, $path, $limit = 50, $offset = 0, $endpoint = ''):object|bool { 114 + function getConstellationLinkData(string $target, string $collection, string $path, int $limit = 50, int $offset = 0, string $endpoint = ''): object|bool { 111 115 $ret = $this->makeRequest("GET", $this->constellationBase.$endpoint, [ 112 116 'query' => [ 113 117 'target' => $target, ··· 306 310 $ret = $this->getSlingshotData($identifier, "app.bsky.feed.post", $rkey); 307 311 if (!$ret) return false; 308 312 $post = $this->sanitizePost($ret, true); 309 - \updatePostCache($post->postId, $post->did, $post->content, $post->embedType, json_encode($post->embeds)); 313 + \updatePostCache($post->postId, $post->author->did, $post->content, $post->embedType, json_encode($post->embeds)); 310 314 return $post; 311 315 } 312 316 ··· 319 323 } 320 324 321 325 function getLikeUsers(string $post):array { 322 - $ret = $this->getConstellationLinkData($post, "app.bsky.feed.like", ".subject.uri", 50, "/distinct-dids"); 326 + $ret = $this->getConstellationLinkData($post, "app.bsky.feed.like", ".subject.uri", 50, 0, "/distinct-dids"); 327 + print_r($ret); 323 328 if ($ret) { 324 - return $this->sanitizeUserList($ret->linking_records); 329 + //return $this->sanitizeUserList($ret->linking_records); 325 330 } 326 331 return []; 327 332 } ··· 335 340 } 336 341 337 342 function getRepostUsers(string $post):array { 338 - $ret = $this->getConstellationLinkData($post, "app.bsky.feed.repost", ".subject.uri", 50, "/distinct-dids"); 343 + $ret = $this->getConstellationLinkData($post, "app.bsky.feed.repost", ".subject.uri", 50, 0, "/distinct-dids"); 339 344 if ($ret) { 340 - return $this->sanitizeUserList($ret->linking_records); 345 + return array_map(function($user) { 346 + return $this->getUserInfo($user, 'did'); 347 + }, $ret->linking_dids); 348 + //return $this->sanitizeUserList($ret->linking_records); 341 349 } 342 350 return []; 343 351 } ··· 370 378 $ret = $this->getConstellationLinkData($post, "app.bsky.feed.post", ".reply.root.uri"); 371 379 if ($ret) { 372 380 return array_map(function ($rec) { 373 - $slingshotRecord = $this->getSlingshotData($rec->did, $rec->collection, $rec->rkey); 381 + $slingshotRecord = $this->getSlingshotData($rec->did, $rec->collection, $rec->rkey, true); 374 382 return $this->sanitizePost($slingshotRecord, true); 375 383 }, $ret->linking_records); 376 384 } ··· 388 396 if (!$postData) return false; 389 397 $postData = array_map(function($p) { 390 398 $uriComponents = $this->splitAtUri($p->uri); 399 + print_r($uriComponents); 391 400 $cache = \requestPostCache($uriComponents->rkey); 392 401 if ($cache) return $this->sanitizeCachedPost($cache); 402 + $post = $this->getPost($uriComponents->did, $uriComponents->rkey, true); 403 + return $this->sanitizePost($post, true); 393 404 }, $postData->records); 394 - 395 - if (!$postData) return false; 396 - 397 405 return $postData; 398 406 } 399 407 ··· 426 434 if (!$uriComponents) return false; 427 435 $feedData = $this->getSlingshotData($uriComponents->did, $uriComponents->collection, $uriComponents->rkey); 428 436 $authorInfo = $this->getUserInfo($uriComponents->did, 'did'); 429 - \updateFeedCache($atUri, $feedData->value->displayName, $feedData->value->description, $feedData->value->avatar->ref->{'$link'}, $uriComponents->did); 437 + \updateFeedCache($atUri, $feedData->value->displayName, $feedData->value->description, $this->getMediaUrl($authorInfo->pds, $uriComponents->did, $feedData->value->avatar->ref->{'$link'}), $uriComponents->did); 430 438 return (object) [ 431 439 'title' => $feedData->value->displayName, 432 440 'url' => '/f/'.$uriComponents->did.'/'.$uriComponents->rkey, ··· 614 622 'uri' => $embeds->external->uri, 615 623 'title' => $embeds->external->title, 616 624 'description' => $embeds->external->description, 617 - 'thumb' => $this->getMediaUrl($authorData->pds, $authorData->did, $embeds->external->thumb->ref->{'$link'}) 625 + 'thumb' => property_exists($embeds->external, 'thumb') ? $this->getMediaUrl($authorData->pds, $authorData->did, $embeds->external->thumb->ref->{'$link'}) : null 618 626 ] 619 627 ]; 620 628 }
+1 -1
templates/_partials/embed_link.latte
··· 1 1 <div class="postEmbeds"> 2 2 <div class="externalLink"> 3 3 <a href="{$embed->uri}" rel="external" target="_blank"> 4 - <div class="externalLinkImage"> 4 + <div class="externalLinkImage" n:if="$embed->thumb"> 5 5 <img src="{$embed->thumb}" alt="{$embed->title}" /> 6 6 </div> 7 7 <div class="externalLinkInfo">
+8 -5
templates/_partials/embed_record.latte
··· 1 - <div class="embeds"> 1 + <div class="postEmbeds"> 2 2 <div class="record post"> 3 3 <div class="postHeader"> 4 4 <div class="avatar"> 5 - <a href="{$embed->profileLink}"><img src="{$embed->avatar}" alt="{$embed->displayName}'s user icon" /></a> 5 + <a href="{$embed->post->author->profileLink}"><img src="{$embed->post->author->avatar}" alt="{$embed->post->author->displayName}'s user icon" /></a> 6 6 </div> 7 - <div class="displayName"><a href="{$embed->profileLink}">{$embed->displayName}</a></div> 8 - <div class="handle"><a href="{$embed->profileLink}">{$embed->handle}</a></div> 9 - <div class="timeAgo"><a href="{$embed->postLink}">{$embed->createdAt}</a></div> 7 + <div class="displayName"><a href="{$embed->post->author->profileLink}">{$embed->post->author->displayName}</a></div> 8 + <div class="handle"><a href="{$embed->post->author->profileLink}">{$embed->post->author->handle}</a></div> 9 + <div class="timeAgo"><a href="{$embed->post->postLink}">{$embed->post->createdAt}</a></div> 10 + </div> 11 + <div class="content"> 12 + {$embed->post->content|noescape} 10 13 </div> 11 14 </div> 12 15 </div>