mirror of
https://github.com/sorenpeter/timeline.git
synced 2026-03-11 12:42:17 +00:00
fallback nick and url if not set in txt
This commit is contained in:
parent
ccf39b7c91
commit
2b553bceb9
5 changed files with 81 additions and 54 deletions
|
|
@ -144,7 +144,7 @@ a.author {
|
|||
|
||||
.profile {
|
||||
padding: 0 1rem;
|
||||
margin-bottom: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.profile-grid {
|
||||
|
|
|
|||
|
|
@ -334,6 +334,7 @@ function getTwtsFromTwtxtString($url) {
|
|||
}
|
||||
|
||||
if (str_starts_with($currentLine, '#')) {
|
||||
|
||||
// Check if comments (starting with #) have some metadata
|
||||
if (!is_null(getSingleParameter('url', $currentLine))) {
|
||||
$currentURL = getSingleParameter('url', $currentLine);
|
||||
|
|
@ -364,6 +365,18 @@ function getTwtsFromTwtxtString($url) {
|
|||
}
|
||||
}
|
||||
|
||||
// Fallback for nick and url if not set in twtxt.txt
|
||||
if ($twtxtData->nick === "") {
|
||||
$host_to_nick = parse_url($url, PHP_URL_HOST);
|
||||
$host_to_nick = str_replace("www.", "", $host_to_nick);
|
||||
$host_to_nick = explode(".", $host_to_nick)[0];
|
||||
$twtxtData->nick = $host_to_nick;
|
||||
}
|
||||
if ($twtxtData->mainURL === "") {
|
||||
$twtxtData->mainURL = $url;
|
||||
}
|
||||
|
||||
|
||||
if (!str_starts_with($currentLine, '#')) {
|
||||
$explodedLine = explode("\t", $currentLine);
|
||||
if (count($explodedLine) >= 2) {
|
||||
|
|
|
|||
|
|
@ -23,11 +23,19 @@ $twt_posts = array_filter($twts, function ($twt) use ($pattern) {
|
|||
return !preg_match($pattern, $twt->originalTwtStr);
|
||||
});
|
||||
|
||||
$twt_gallery = array_filter($twts, function ($twt) {
|
||||
return preg_match('/!\[(.*?)\]\((.*?)\)/', $twt->originalTwtStr);
|
||||
//return preg_match('/(<img[^>]+>)/i', $twt->content);
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Get active view/filter
|
||||
$is_gallery = str_contains(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), "gallery");
|
||||
$is_replies = str_contains(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), "replies");
|
||||
|
||||
if ($is_gallery) {
|
||||
//$twts = $twt_gallery;
|
||||
$posts_active = "";
|
||||
$replies_active = "";
|
||||
$gallery_artive = "class='active'";
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ if (!empty($_GET['search'])) {
|
|||
$pattern = preg_quote($search, '/');
|
||||
$pattern = "/^.*$pattern.*\$/mi";
|
||||
|
||||
// TODO: Make into a genral function in twtxt.php since i use it so much in profile.php and potentialle other places
|
||||
$twts = array_filter($twts, function ($twt) use ($pattern) {
|
||||
return preg_match($pattern, $twt->content);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
// Base on code from: https://social.dfaria.eu/search
|
||||
|
||||
// Add all tags to one array
|
||||
$tags = [];
|
||||
|
||||
foreach ($twts as $twt) {
|
||||
$tag_array = getTagsFromTwt($twt->content);
|
||||
|
||||
|
|
@ -12,6 +14,8 @@ foreach ($twts as $twt) {
|
|||
}
|
||||
}
|
||||
|
||||
if(!empty($tags)) {
|
||||
|
||||
natcasesort($tags);
|
||||
$tag_count = array_count_values($tags);
|
||||
//arsort($tag_count, SORT_STRING);
|
||||
|
|
@ -75,3 +79,4 @@ foreach ($solo_tags as $tag => $count) {
|
|||
echo "</details>";
|
||||
*/
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue