From e95c6781419e8aa158c9c51790ffbf3bb7d1ee00 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 9 Jul 2023 14:15:01 +0000 Subject: [PATCH] Improve display of quoted posts --- src/Content/Item.php | 3 +-- src/Content/Text/BBCode.php | 5 +++-- src/Model/Item.php | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Content/Item.php b/src/Content/Item.php index bd3c6d774b..bfbf0795d2 100644 --- a/src/Content/Item.php +++ b/src/Content/Item.php @@ -677,7 +677,6 @@ class Item if ($item['network'] == Protocol::FEED) { return PageInfo::getFooterFromUrl($item['plink']); } elseif (!in_array($item['network'] ?? '', Protocol::FEDERATED)) { - $item['guid'] = ''; $item['uri'] = ''; } @@ -695,7 +694,7 @@ class Item // If it is a reshared post then reformat it to avoid display problems with two share elements if (!empty($shared)) { - if (!empty($shared['guid']) && ($encapsulated_share = $this->createSharedPostByGuid($shared['guid'], true))) { + if (($item['network'] != Protocol::BLUESKY) && !empty($shared['guid']) && ($encapsulated_share = $this->createSharedPostByGuid($shared['guid'], true))) { if (!empty(BBCode::fetchShareAttributes($item['body']))) { $item['body'] = preg_replace("/\[share.*?\](.*)\[\/share\]/ism", $encapsulated_share, $item['body']); } else { diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index e321b13e70..3635ba874c 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -64,7 +64,8 @@ class BBCode const ACTIVITYPUB = 9; const BLUESKY = 10; - const TOP_ANCHOR = '
'; + const SHARED_ANCHOR = '
'; + const TOP_ANCHOR = '
'; const BOTTOM_ANCHOR = '
'; const PREVIEW_NONE = 0; @@ -930,7 +931,7 @@ class BBCode $network = $contact['network'] ?? Protocol::PHANTOM; $tpl = Renderer::getMarkupTemplate('shared_content.tpl'); - $text .= Renderer::replaceMacros($tpl, [ + $text .= BBCode::SHARED_ANCHOR . Renderer::replaceMacros($tpl, [ '$profile' => $attributes['profile'], '$avatar' => $attributes['avatar'], '$author' => $attributes['author'], diff --git a/src/Model/Item.php b/src/Model/Item.php index e31009753b..425ba12ec1 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -3217,6 +3217,12 @@ class Item $body = BBCode::removeSharedData($body); } + $pos = strpos($s, BBCode::SHARED_ANCHOR); + if ($pos) { + $shared_html = substr($s, $pos + strlen(BBCode::SHARED_ANCHOR)); + $s = substr($s, 0, $pos); + } + $s = self::addGallery($s, $attachments, $item['uri-id']); $s = self::addVisualAttachments($attachments, $item, $s, false); $s = self::addLinkAttachment($item['uri-id'], $attachments, $body, $s, false, $shared_links); @@ -3237,6 +3243,10 @@ class Item $s = preg_replace('|(]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s); } + if (!empty($shared_html)) { + $s .= $shared_html; + } + $s = HTML::applyContentFilter($s, $filter_reasons); $hook_data = ['item' => $item, 'html' => $s]; -- 2.39.5