diff --git a/libs/twtxt.php b/libs/twtxt.php index 9eb2003..a3533e8 100644 --- a/libs/twtxt.php +++ b/libs/twtxt.php @@ -16,6 +16,7 @@ class TwtxtFile { public $mainURL = ''; // First found URL public $URLs = []; public $nick = ''; + public $domain = ''; public $avatar = ''; public $emoji = ''; public $description = ''; @@ -456,8 +457,7 @@ function getTwtsFromTwtxtString($url) { } } - // Clean up nick if set to something like `@soren@darch.dk` instead of just `soren` - // mosty for (re)feeds from Mastodon etc. + // Clean up nick if set to something like `@soren@darch.dk` instead of just `soren` - mosty for (re)feeds from Mastodon etc. if (str_contains($twtxtData->nick, "@")) { $str = $twtxtData->nick; $str = ltrim($str, "@"); @@ -465,17 +465,25 @@ function getTwtsFromTwtxtString($url) { } // Fallback for nick and url if not set in twtxt.txt - // TODO: Use nick from local follow list as fallback? if ($twtxtData->nick === "") { $str = parse_url($url, PHP_URL_HOST); $str = str_replace("www.", "", $str); - $str = explode(".", $str)[0]; // take the first [0] from splitting the host at "." + //$str = explode(".", $str)[0]; // take the first [0] from splitting the host at "." $twtxtData->nick = $str; } if ($twtxtData->mainURL === "") { $twtxtData->mainURL = $url; } + // Use only nick as handle if nick and domain is the same + $twtxtData->domain = parse_url($twtxtData->mainURL, PHP_URL_HOST); + + if ($twtxtData->nick === $twtxtData->domain) { + $twtxtData->domain = ""; + } else { + $twtxtData->domain = "@".$twtxtData->domain; + } + if (!str_starts_with($currentLine, '#')) { $explodedLine = explode("\t", $currentLine); @@ -550,6 +558,7 @@ function getTwtsFromTwtxtString($url) { $twt->emoji = $twtxtData->emoji; $twt->nick = $twtxtData->nick; $twt->mainURL = $twtxtData->mainURL; + $twt->domain = $twtxtData->domain; $twtxtData->twts[$timestamp] = $twt; } diff --git a/partials/profile_card.php b/partials/profile_card.php index 1799e6d..dc0635b 100644 --- a/partials/profile_card.php +++ b/partials/profile_card.php @@ -63,7 +63,7 @@ if ($is_gallery) {
=$profile->description?>
diff --git a/partials/timeline.php b/partials/timeline.php index ca4a666..7fb60d4 100644 --- a/partials/timeline.php +++ b/partials/timeline.php @@ -15,7 +15,7 @@