add followers/following to directory

This commit is contained in:
Mike Macgirvin 2024-06-28 22:25:21 +10:00
parent 31fa60f6eb
commit 6fce212780
3 changed files with 20 additions and 7 deletions

View file

@ -459,6 +459,10 @@ class Directory extends Controller
'keywords' => $out, 'keywords' => $out,
'ignlink' => $suggest ? z_root() . '/directory?ignore=' . $rr['hash'] : '', 'ignlink' => $suggest ? z_root() . '/directory?ignore=' . $rr['hash'] : '',
'ignore_label' => t('Don\'t suggest'), '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_friends' => (($common[$rr['hash']]) ? intval($common[$rr['hash']]) : ''),
'common_label' => t('Suggestion ranking:'), 'common_label' => t('Suggestion ranking:'),
'common_count' => intval($common[$rr['hash']]), 'common_count' => intval($common[$rr['hash']]),

View file

@ -4,6 +4,7 @@ namespace Code\Module;
use App; use App;
use Code\Lib\Time; use Code\Lib\Time;
use Code\Lib\XConfig;
use Code\Web\Controller; use Code\Web\Controller;
// This is the primary endpoint for communicating with Zot directory services. // This is the primary endpoint for communicating with Zot directory services.
@ -203,12 +204,6 @@ class Dirsearch extends Controller
if ($sort_order == 'normal') { if ($sort_order == 'normal') {
$order = " order by xchan_name asc "; $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') { } elseif ($sort_order == 'reverse') {
$order = " order by xchan_name desc "; $order = " order by xchan_name desc ";
} elseif ($sort_order == 'reversedate') { } elseif ($sort_order == 'reversedate') {
@ -268,6 +263,7 @@ class Dirsearch extends Controller
continue; continue;
} }
$follows = explode('/', XConfig::Get($rr['xchan_hash'], 'activitypub', 'follows', 'unset/unset'));
$entry = []; $entry = [];
@ -295,7 +291,8 @@ class Dirsearch extends Controller
$entry['homepage'] = $rr['xprof_homepage']; $entry['homepage'] = $rr['xprof_homepage'];
$entry['hometown'] = $rr['xprof_hometown']; $entry['hometown'] = $rr['xprof_hometown'];
$entry['keywords'] = $rr['xprof_keywords']; $entry['keywords'] = $rr['xprof_keywords'];
$entry['followers'] = $follows[0];
$entry['following'] = $follows[1];
$entries[] = $entry; $entries[] = $entry;
} }

View file

@ -33,6 +33,18 @@
</div> </div>
{{/if}} {{/if}}
{{if $entry.followers}}
<div class="contact-info-element">
<span class="contact-info-label">{{$entry.followers_label}}</span> {{$entry.followers}}
</div>
{{/if}}
{{if $entry.following}}
<div class="contact-info-element">
<span class="contact-info-label">{{$entry.following_label}}</span> {{$entry.following}}
</div>
{{/if}}
{{if $entry.common_friends}} {{if $entry.common_friends}}
<div id="dir-common" class="contact-info-element"> <div id="dir-common" class="contact-info-element">
<span class="contact-info-label">{{$entry.common_label}}</span> {{$entry.common_count}} <span class="contact-info-label">{{$entry.common_label}}</span> {{$entry.common_count}}