const TWITTER = 8;
const BACKLINK = 8;
const ACTIVITYPUB = 9;
+ const BLUESKY = 10;
- const TOP_ANCHOR = '<br class="top-anchor">';
+ const SHARED_ANCHOR = '<hr class="shared-anchor">';
+ const TOP_ANCHOR = '<br class="top-anchor">';
const BOTTOM_ANCHOR = '<br class="button-anchor">';
const PREVIEW_NONE = 0;
break;
case 'title':
- $value = self::convert(html_entity_decode($value, ENT_QUOTES, 'UTF-8'), false, true);
+ $value = self::convertForUriId(0, html_entity_decode($value, ENT_QUOTES, 'UTF-8'), BBCode::EXTERNAL);
$value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
$value = str_replace(['[', ']'], ['[', ']'], $value);
$data['title'] = $value;
// Remove attachment
$text = self::replaceAttachment($text);
- $naked_text = HTML::toPlaintext(self::convert($text, false, 0, true), 0, !$keep_urls);
+ $naked_text = HTML::toPlaintext(self::convert($text, false, BBCode::EXTERNAL, true), 0, !$keep_urls);
DI::profiler()->stopRecording();
return $naked_text;
*/
private static function convertUrlForActivityPub(string $url): string
{
- return sprintf('<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>', $url, self::getStyledURL($url));
- }
-
- /**
- * Converts an URL in a nicer format (without the scheme and possibly shortened)
- *
- * @param string $url URL that is about to be reformatted
- * @return string reformatted link
- */
- private static function getStyledURL(string $url): string
- {
- $parts = parse_url($url);
- $scheme = $parts['scheme'] . '://';
- $styled_url = str_replace($scheme, '', $url);
-
- if (strlen($styled_url) > 30) {
- $styled_url = substr($styled_url, 0, 30) . "…";
- }
-
- return $styled_url;
+ return sprintf('<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>', $url, Strings::getStyledURL($url));
}
/*
$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'],
$text
);
- if (in_array($simple_html, [self::OSTATUS, self::TWITTER])) {
+ if (in_array($simple_html, [self::OSTATUS, self::TWITTER, self::BLUESKY])) {
$text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", [self::class, 'expandLinksCallback'], $text);
//$text = preg_replace("/[^#@!]\[url\=([^\]]*)\](.*?)\[\/url\]/ism", ' $2 [url]$1[/url]', $text);
$text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", ' $2 [url]$1[/url]', $text);
// Convert it to HTML - don't try oembed
if ($for_diaspora) {
- $text = self::convert($text, false, self::DIASPORA);
+ $text = self::convertForUriId(0, $text, self::DIASPORA);
// Add all tags that maybe were removed
if (preg_match_all("/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/ism", $original_text, $tags)) {
$text = $text . ' ' . $tagline;
}
} else {
- $text = self::convert($text, false, self::CONNECTORS);
+ $text = self::convertForUriId(0, $text, self::CONNECTORS);
}
// If a link is followed by a quote then there should be a newline before it