From 36fc4822dd3824518911b7e7e6c0d7c6c849ca03 Mon Sep 17 00:00:00 2001 From: Paroleen <48787191+Paroleen@users.noreply.github.com> Date: Sun, 17 May 2020 20:22:04 +0200 Subject: [PATCH] [UnraidCommunityApplicationsBridge] Add new bridge (#1534) * [UnraidCommunityApplicationsBridge] Add new bridge --- bridges/UnraidCommunityApplicationsBridge.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 bridges/UnraidCommunityApplicationsBridge.php diff --git a/bridges/UnraidCommunityApplicationsBridge.php b/bridges/UnraidCommunityApplicationsBridge.php new file mode 100644 index 00000000..1ab06e3c --- /dev/null +++ b/bridges/UnraidCommunityApplicationsBridge.php @@ -0,0 +1,71 @@ +apps = getContents(self::APPSURI) + or returnServerError('Could not fetch JSON for apps.'); + $this->apps = json_decode($this->apps, true)['applist']; + } + + private function sortApps() { + Debug::log('Sorting applications/plugins'); + usort($this->apps, function($app1, $app2) { + return $app1['FirstSeen'] < $app2['FirstSeen'] ? 1 : -1; + }); + } + + public function collectData() { + $this->fetchApps(); + $this->sortApps(); + + Debug::log('Building RSS feed'); + foreach($this->apps as $app) { + if(!array_key_exists('Language', $app)) { + $item = array(); + $item['title'] = $app['Name']; + $item['timestamp'] = $app['FirstSeen']; + $item['author'] = explode('\'', $app['Repo'])[0]; + $item['categories'] = explode(' ', $app['Category']); + $item['content'] = ''; + + if(array_key_exists('Icon', $app)) + $item['content'] .= ''; + + if(array_key_exists('Overview', $app)) + $item['content'] .= '

' + . $app['Overview'] + . '

'; + + if(array_key_exists('Project', $app)) + $item['uri'] = $app['Project']; + + if(array_key_exists('Registry', $app)) + $item['content'] .= '
Docker Hub'; + + if(array_key_exists('Support', $app)) + $item['content'] .= '
Support'; + + $this->items[] = $item; + + if(count($this->items) >= 15) + break; + } + } + } +}