Merge pull request #13166 from annando/getstylesurl

"getStyledURL" is now public
This commit is contained in:
Hypolite Petovan 2023-05-26 10:30:06 -04:00 committed by GitHub
commit 68c0408af5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 47 deletions

View file

@ -508,26 +508,7 @@ class BBCode
*/ */
private static function convertUrlForActivityPub(string $url): string private static function convertUrlForActivityPub(string $url): string
{ {
return sprintf('<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>', $url, self::getStyledURL($url)); return sprintf('<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>', $url, Strings::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;
} }
/* /*

View file

@ -561,4 +561,22 @@ class Strings
return $shorthand; return $shorthand;
} }
/**
* 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
*/
public 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;
}
} }

View file

@ -6,9 +6,9 @@
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2023.05-rc\n" "Project-Id-Version: 2023.09-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-05-21 17:30+0000\n" "POT-Creation-Date: 2023-05-26 07:34+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -1614,7 +1614,7 @@ msgstr ""
msgid "show more" msgid "show more"
msgstr "" msgstr ""
#: src/Content/Item.php:327 src/Model/Item.php:2927 #: src/Content/Item.php:327 src/Model/Item.php:2931
msgid "event" msgid "event"
msgstr "" msgstr ""
@ -1622,7 +1622,7 @@ msgstr ""
msgid "status" msgid "status"
msgstr "" msgstr ""
#: src/Content/Item.php:336 src/Model/Item.php:2929 #: src/Content/Item.php:336 src/Model/Item.php:2933
#: src/Module/Post/Tag/Add.php:123 #: src/Module/Post/Tag/Add.php:123
msgid "photo" msgid "photo"
msgstr "" msgstr ""
@ -2028,8 +2028,8 @@ msgid ""
"<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s" "<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:956 src/Model/Item.php:3645 #: src/Content/Text/BBCode.php:956 src/Model/Item.php:3649
#: src/Model/Item.php:3651 src/Model/Item.php:3652 #: src/Model/Item.php:3655 src/Model/Item.php:3656
msgid "Link to source" msgid "Link to source"
msgstr "" msgstr ""
@ -3203,76 +3203,76 @@ msgstr ""
msgid "Detected languages in this post:\\n%s" msgid "Detected languages in this post:\\n%s"
msgstr "" msgstr ""
#: src/Model/Item.php:2931 #: src/Model/Item.php:2935
msgid "activity" msgid "activity"
msgstr "" msgstr ""
#: src/Model/Item.php:2933 #: src/Model/Item.php:2937
msgid "comment" msgid "comment"
msgstr "" msgstr ""
#: src/Model/Item.php:2936 src/Module/Post/Tag/Add.php:123 #: src/Model/Item.php:2940 src/Module/Post/Tag/Add.php:123
msgid "post" msgid "post"
msgstr "" msgstr ""
#: src/Model/Item.php:3105
#, php-format
msgid "%s is blocked"
msgstr ""
#: src/Model/Item.php:3107
#, php-format
msgid "%s is ignored"
msgstr ""
#: src/Model/Item.php:3109 #: src/Model/Item.php:3109
#, php-format #, php-format
msgid "Content from %s is collapsed" msgid "%s is blocked"
msgstr ""
#: src/Model/Item.php:3111
#, php-format
msgid "%s is ignored"
msgstr "" msgstr ""
#: src/Model/Item.php:3113 #: src/Model/Item.php:3113
#, php-format #, php-format
msgid "Content from %s is collapsed"
msgstr ""
#: src/Model/Item.php:3117
#, php-format
msgid "Content warning: %s" msgid "Content warning: %s"
msgstr "" msgstr ""
#: src/Model/Item.php:3557 #: src/Model/Item.php:3561
msgid "bytes" msgid "bytes"
msgstr "" msgstr ""
#: src/Model/Item.php:3588 #: src/Model/Item.php:3592
#, php-format #, php-format
msgid "%2$s (%3$d%%, %1$d vote)" msgid "%2$s (%3$d%%, %1$d vote)"
msgid_plural "%2$s (%3$d%%, %1$d votes)" msgid_plural "%2$s (%3$d%%, %1$d votes)"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:3590 #: src/Model/Item.php:3594
#, php-format #, php-format
msgid "%2$s (%1$d vote)" msgid "%2$s (%1$d vote)"
msgid_plural "%2$s (%1$d votes)" msgid_plural "%2$s (%1$d votes)"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:3595 #: src/Model/Item.php:3599
#, php-format #, php-format
msgid "%d voter. Poll end: %s" msgid "%d voter. Poll end: %s"
msgid_plural "%d voters. Poll end: %s" msgid_plural "%d voters. Poll end: %s"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:3597 #: src/Model/Item.php:3601
#, php-format #, php-format
msgid "%d voter." msgid "%d voter."
msgid_plural "%d voters." msgid_plural "%d voters."
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:3599 #: src/Model/Item.php:3603
#, php-format #, php-format
msgid "Poll end: %s" msgid "Poll end: %s"
msgstr "" msgstr ""
#: src/Model/Item.php:3633 src/Model/Item.php:3634 #: src/Model/Item.php:3637 src/Model/Item.php:3638
msgid "View on separate page" msgid "View on separate page"
msgstr "" msgstr ""