From 6fce2127808ce49b1d53e921332c755bb70fa7ed Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Fri, 28 Jun 2024 22:25:21 +1000 Subject: [PATCH] add followers/following to directory --- src/Module/Directory.php | 4 ++++ src/Module/Dirsearch.php | 11 ++++------- view/tpl/direntry.tpl | 12 ++++++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Module/Directory.php b/src/Module/Directory.php index da2b04b55..5f312bebe 100644 --- a/src/Module/Directory.php +++ b/src/Module/Directory.php @@ -459,6 +459,10 @@ class Directory extends Controller 'keywords' => $out, 'ignlink' => $suggest ? z_root() . '/directory?ignore=' . $rr['hash'] : '', 'ignore_label' => t('Don\'t suggest'), + 'followers_label' => t('Followers:'), + 'following_label' => t('Following:'), + 'followers' => (($rr['followers'] === 'unset') ? '' : $rr['followers']), + 'following' => (($rr['following'] === 'unset') ? '' : $rr['following']), 'common_friends' => (($common[$rr['hash']]) ? intval($common[$rr['hash']]) : ''), 'common_label' => t('Suggestion ranking:'), 'common_count' => intval($common[$rr['hash']]), diff --git a/src/Module/Dirsearch.php b/src/Module/Dirsearch.php index 77511205e..b95cbf2df 100644 --- a/src/Module/Dirsearch.php +++ b/src/Module/Dirsearch.php @@ -4,6 +4,7 @@ namespace Code\Module; use App; use Code\Lib\Time; +use Code\Lib\XConfig; use Code\Web\Controller; // This is the primary endpoint for communicating with Zot directory services. @@ -203,12 +204,6 @@ class Dirsearch extends Controller if ($sort_order == 'normal') { $order = " order by xchan_name asc "; - - // Start the alphabetic search at 'A' - // This will make a handful of channels whose names begin with - // punctuation un-searchable in this mode - - $safesql .= " and ascii(substring(xchan_name FROM 1 FOR 1)) > 64 "; } elseif ($sort_order == 'reverse') { $order = " order by xchan_name desc "; } elseif ($sort_order == 'reversedate') { @@ -268,6 +263,7 @@ class Dirsearch extends Controller continue; } + $follows = explode('/', XConfig::Get($rr['xchan_hash'], 'activitypub', 'follows', 'unset/unset')); $entry = []; @@ -295,7 +291,8 @@ class Dirsearch extends Controller $entry['homepage'] = $rr['xprof_homepage']; $entry['hometown'] = $rr['xprof_hometown']; $entry['keywords'] = $rr['xprof_keywords']; - + $entry['followers'] = $follows[0]; + $entry['following'] = $follows[1]; $entries[] = $entry; } diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl index 58b0a8a5e..2f4044a52 100755 --- a/view/tpl/direntry.tpl +++ b/view/tpl/direntry.tpl @@ -33,6 +33,18 @@ {{/if}} + {{if $entry.followers}} +
+ {{$entry.followers_label}} {{$entry.followers}} +
+ {{/if}} + + {{if $entry.following}} +
+ {{$entry.following_label}} {{$entry.following}} +
+ {{/if}} + {{if $entry.common_friends}}
{{$entry.common_label}} {{$entry.common_count}}