mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-09-04 04:45:10 +00:00
move github api call out of routing, into action
This commit is contained in:
parent
66c6573db6
commit
0c70d3b9e7
4 changed files with 29 additions and 7 deletions
|
@ -121,11 +121,9 @@ class Controller
|
||||||
'/deck.pdf' => 'https://www.dropbox.com/s/0xj4vgucsbi8rtv/lbry-deck.pdf?dl=1',
|
'/deck.pdf' => 'https://www.dropbox.com/s/0xj4vgucsbi8rtv/lbry-deck.pdf?dl=1',
|
||||||
'/pln.pdf' => 'https://www.dropbox.com/s/uevjrwnyr672clj/lbry-pln.pdf?dl=1',
|
'/pln.pdf' => 'https://www.dropbox.com/s/uevjrwnyr672clj/lbry-pln.pdf?dl=1',
|
||||||
'/plan.pdf' => 'https://www.dropbox.com/s/uevjrwnyr672clj/lbry-pln.pdf?dl=1',
|
'/plan.pdf' => 'https://www.dropbox.com/s/uevjrwnyr672clj/lbry-pln.pdf?dl=1',
|
||||||
'/get/lbry.dmg' => GitHub::getDownloadUrl(OS::OS_OSX) ?: '/get',
|
|
||||||
'/get/lbry.deb' => GitHub::getDownloadUrl(OS::OS_LINUX) ?: '/get',
|
|
||||||
'/get/lbry.msi' => GitHub::getDownloadUrl(OS::OS_WINDOWS) ?: '/get',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
foreach ([302 => $tempRedirects, 301 => $permanentRedirects] as $code => $redirects)
|
foreach ([302 => $tempRedirects, 301 => $permanentRedirects] as $code => $redirects)
|
||||||
{
|
{
|
||||||
foreach ($redirects as $src => $target)
|
foreach ($redirects as $src => $target)
|
||||||
|
@ -134,6 +132,8 @@ class Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$router->any('/get/lbry.{ext:c}', 'DownloadActions::executeGetRedirect');
|
||||||
|
|
||||||
$router->get([ContentActions::URL_NEWS . '/{slug:c}?', 'news'], 'ContentActions::executeNews');
|
$router->get([ContentActions::URL_NEWS . '/{slug:c}?', 'news'], 'ContentActions::executeNews');
|
||||||
$router->get([ContentActions::URL_FAQ . '/{slug:c}?', 'faq'], 'ContentActions::executeFaq');
|
$router->get([ContentActions::URL_FAQ . '/{slug:c}?', 'faq'], 'ContentActions::executeFaq');
|
||||||
$router->get([ContentActions::URL_BOUNTY . '/{slug:c}?', 'bounty'], 'ContentActions::executeBounty');
|
$router->get([ContentActions::URL_BOUNTY . '/{slug:c}?', 'bounty'], 'ContentActions::executeBounty');
|
||||||
|
|
|
@ -76,7 +76,7 @@ class Request
|
||||||
|
|
||||||
public static function getRoutingUri()
|
public static function getRoutingUri()
|
||||||
{
|
{
|
||||||
$host = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
|
$host = preg_replace('/^www\./', '', static::getHost());
|
||||||
switch($host)
|
switch($host)
|
||||||
{
|
{
|
||||||
case 'betteryoutube.com':
|
case 'betteryoutube.com':
|
||||||
|
|
|
@ -2,6 +2,27 @@
|
||||||
|
|
||||||
class DownloadActions extends Actions
|
class DownloadActions extends Actions
|
||||||
{
|
{
|
||||||
|
public static function executeGetRedirect(string $ext)
|
||||||
|
{
|
||||||
|
$uri = null;
|
||||||
|
switch ($ext)
|
||||||
|
{
|
||||||
|
case 'deb':
|
||||||
|
$uri = GitHub::getDownloadUrl(OS::OS_LINUX);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'dmg':
|
||||||
|
$uri = GitHub::getDownloadUrl(OS::OS_OSX);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'msi':
|
||||||
|
$uri = GitHub::getDownloadUrl(OS::OS_WINDOWS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Controller::redirect($target ?: '/get', 302);
|
||||||
|
}
|
||||||
|
|
||||||
public static function executeGet()
|
public static function executeGet()
|
||||||
{
|
{
|
||||||
$email = Request::getParam('e');
|
$email = Request::getParam('e');
|
||||||
|
|
7
lib/thirdparty/Github.class.php
vendored
7
lib/thirdparty/Github.class.php
vendored
|
@ -14,10 +14,11 @@ class Github
|
||||||
$releaseData = static::get('/repos/lbryio/lbry/releases/latest', $cache);
|
$releaseData = static::get('/repos/lbryio/lbry/releases/latest', $cache);
|
||||||
foreach ($releaseData['assets'] as $asset)
|
foreach ($releaseData['assets'] as $asset)
|
||||||
{
|
{
|
||||||
|
$ext = substr($asset['name'], -4);
|
||||||
if (
|
if (
|
||||||
($os == OS::OS_LINUX && in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb'])) ||
|
($os == OS::OS_LINUX && ($ext == '.deb' || in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb']))) ||
|
||||||
($os == OS::OS_OSX && in_array($asset['content_type'], ['application/x-diskcopy', 'application/x-apple-diskimage'])) ||
|
($os == OS::OS_OSX && ($ext == '.dmg' || in_array($asset['content_type'], ['application/x-diskcopy', 'application/x-apple-diskimage']))) ||
|
||||||
($os == OS::OS_WINDOWS && substr($asset['name'], -4) == '.msi')
|
($os == OS::OS_WINDOWS && $ext == '.msi')
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return $asset['browser_download_url'];
|
return $asset['browser_download_url'];
|
||||||
|
|
Loading…
Add table
Reference in a new issue