2020-05-17 21:22:04 +03:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
class UnraidCommunityApplicationsBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'Unraid Community Applications';
|
|
|
|
const URI = 'https://forums.unraid.net/topic/38582-plug-in-community-applications/';
|
|
|
|
const DESCRIPTION = 'Fetches the latest fifteen new apps/plugins from Unraid Community Applications';
|
|
|
|
const MAINTAINER = 'Paroleen';
|
|
|
|
const CACHE_TIMEOUT = 3600;
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
const APPSURI = 'https://raw.githubusercontent.com/Squidly271/AppFeed/master/applicationFeed.json';
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
private $apps = [];
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
private function fetchApps()
|
|
|
|
{
|
|
|
|
Debug::log('Fetching all applications/plugins');
|
|
|
|
$this->apps = getContents(self::APPSURI);
|
|
|
|
$this->apps = json_decode($this->apps, true)['applist'];
|
|
|
|
}
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
private function sortApps()
|
|
|
|
{
|
|
|
|
Debug::log('Sorting applications/plugins');
|
|
|
|
usort($this->apps, function ($app1, $app2) {
|
|
|
|
return $app1['FirstSeen'] < $app2['FirstSeen'] ? 1 : -1;
|
|
|
|
});
|
|
|
|
}
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$this->fetchApps();
|
|
|
|
$this->sortApps();
|
|
|
|
foreach ($this->apps as $app) {
|
2022-10-16 21:26:33 +03:00
|
|
|
if (array_key_exists('Language', $app)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$item = [];
|
|
|
|
$item['title'] = $app['Name'];
|
|
|
|
$item['timestamp'] = $app['FirstSeen'];
|
|
|
|
$item['author'] = explode('\'', $app['Repo'])[0];
|
|
|
|
$item['content'] = '';
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-10-16 21:26:33 +03:00
|
|
|
if (isset($app['CategoryList'])) {
|
|
|
|
$item['categories'] = $app['CategoryList'];
|
|
|
|
}
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-10-16 21:26:33 +03:00
|
|
|
if (array_key_exists('Icon', $app)) {
|
|
|
|
$item['content'] .= '<img style="width: 64px" src="'
|
|
|
|
. $app['Icon']
|
|
|
|
. '">';
|
|
|
|
}
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-10-16 21:26:33 +03:00
|
|
|
if (array_key_exists('Overview', $app)) {
|
|
|
|
$item['content'] .= '<p>'
|
|
|
|
. $app['Overview']
|
|
|
|
. '</p>';
|
|
|
|
}
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-10-16 21:26:33 +03:00
|
|
|
if (array_key_exists('Project', $app)) {
|
|
|
|
$item['uri'] = $app['Project'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_key_exists('Registry', $app)) {
|
|
|
|
$item['content'] .= '<br><a href="'
|
|
|
|
. $app['Registry']
|
|
|
|
. '">Docker Hub</a>';
|
|
|
|
}
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-10-16 21:26:33 +03:00
|
|
|
if (array_key_exists('Support', $app)) {
|
|
|
|
$item['content'] .= '<br><a href="'
|
|
|
|
. $app['Support']
|
|
|
|
. '">Support</a>';
|
|
|
|
}
|
2020-05-17 21:22:04 +03:00
|
|
|
|
2022-10-16 21:26:33 +03:00
|
|
|
$this->items[] = $item;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-10-16 21:26:33 +03:00
|
|
|
if (count($this->items) >= 150) {
|
|
|
|
break;
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-17 21:22:04 +03:00
|
|
|
}
|