Skip to content
Snippets Groups Projects
Commit 03c36eb1 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

add link to installation documentation and increase filesize speed, fixes #45

parent 27b9ff56
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ final class ReleasesController extends \TracToGitlab\Controller
const CACHE_KEY = 'studip-releases';
private static $curl_handle = null;
private $filesize_cache;
public function before_filter(&$action, &$args)
{
......@@ -26,7 +27,18 @@ final class ReleasesController extends \TracToGitlab\Controller
Icon::create('link2'),
['target' => '_blank']
);
$widget->addLink(
_('Installationsanleitung'),
'https://hilfe.studip.de/admin/Admins/Installationsanleitung',
Icon::create('rescue'),
['target' => '_blank']
);
Sidebar::get()->addWidget($widget);
$this->filesize_cache = new StudipCachedArray(
self::CACHE_KEY . '/filesizes',
strtotime('+10 years')
);
}
public function after_filter($action, $args)
......@@ -40,7 +52,7 @@ final class ReleasesController extends \TracToGitlab\Controller
public function index_action()
{
$version = Request::get('version');
$version = Request::get('version', Request::get('v'));
$this->releases = $this->getReleases();
......@@ -58,6 +70,7 @@ final class ReleasesController extends \TracToGitlab\Controller
{
if ($this->isAdmin()) {
StudipCacheFactory::getCache()->expire(self::CACHE_KEY);
$this->filesize_cache->expire();
}
$this->relocate($this->indexURL());
......@@ -159,6 +172,7 @@ final class ReleasesController extends \TracToGitlab\Controller
return $hardcoded_size;
}
if (!isset($this->filesize_cache[$url])) {
// Init curl if necessary
if (self::$curl_handle === null) {
self::$curl_handle = curl_init(null);
......@@ -189,7 +203,10 @@ final class ReleasesController extends \TracToGitlab\Controller
// TODO: Check status
// Get filesize by Content-Length header
return (int) ($headers['Content-Length'] ?? -1);
$this->filesize_cache[$url] = (int) ($headers['Content-Length'] ?? -1);
}
return $this->filesize_cache[$url];
}
private function addVersionFilter(array $releases, ?string $version): void
......
......@@ -2,5 +2,5 @@ pluginname=Trac to gitlab converter
pluginclassname=TracToGitlabPlugin
pluginclassname=StudipReleasesPlugin
origin=UOL
version=1.4.2
version=1.4.3
studipMinVersion=5.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment