turn followlist into an app

This commit is contained in:
nobody 2020-11-01 19:33:48 -08:00
parent 89776640e7
commit b64874b0d6
4 changed files with 43 additions and 1 deletions

View file

@ -322,6 +322,7 @@ class Apps {
'Report Bug' => t('Report Bug'),
'View Bookmarks' => t('View Bookmarks'),
'Chatrooms' => t('Chatrooms'),
'Followlist' => t('Followlist'),
'Content Import' => t('Content Import'),
'Connections' => t('Connections'),
'Expire Posts' => t('Expire Posts'),

View file

@ -5,7 +5,7 @@ use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\ASCollection;
use Zotlabs\Lib\Connect;
use Zotlabs\Lib\Apps;
class Followlist extends Controller {
@ -15,6 +15,10 @@ class Followlist extends Controller {
return;
}
if (! Apps::system_app_installed(local_channel(),'Followlist')) {
return;
}
$max_records = get_config('system','max_imported_channels',1000);
$importer = App::get_channel();
$url = $_GET['url'];
@ -43,12 +47,42 @@ class Followlist extends Controller {
function get() {
$desc = t('This app allows you to connect to everybody in a pre-defined ActivityPub collection, such as follower/following lists. Install the app and revisit this page to input the source URL.');
$text = '<div class="section-content-info-wrapper">' . $desc . '</div>';
$max_records = get_config('system','max_imported_channels',1000);
// check service class limits
$r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ",
intval(local_channel())
);
if ($r) {
$total_channels = $r[0]['total'];
}
$sc = service_class_fetch(local_channel(),'total_channels');
if ($sc !== false) {
$allowed = intval($sc) - $total_channels;
if ($allowed < $max_records) {
$max_records = $allowed;
}
}
if (! local_channel()) {
return login();
}
if (! Apps::system_app_installed(local_channel(),'Followlist')) {
return $text;
}
return replace_macros(get_markup_template('followlist.tpl'), [
'$page_title' => t('Followlist'),
'$limits' => sprintf( t('You may import up to %d records'), $max_records),
'$notes' => t('Enter the URL of an ActivityPub followers/following collection to import'),
'$url' => [ 'url', t('URL of followers/following list'), '', '' ],
'$submit' => t('Submit')

6
app/followlist.apd Normal file
View file

@ -0,0 +1,6 @@
version: 1
url: $baseurl/followlist
requires: local_channel
name: Followlist
photo: icon:users
categories: Networking

View file

@ -1,5 +1,6 @@
<h3>{{$page_title}}</h3>
<div class="descriptive-text">{{$notes}}</div>
<div class="descriptive-text">{{$limits}}</div>
<form action="followlist" method="post">
{{include file="field_input.tpl" field=$url}}
<input type="submit" name="submit" value="{{$submit}}" >