diff --git a/composer.phar b/composer.phar new file mode 100755 index 00000000..508f9cf2 Binary files /dev/null and b/composer.phar differ diff --git a/controller/action/DownloadActions.class.php b/controller/action/DownloadActions.class.php index e97f7389..9c91d7e5 100644 --- a/controller/action/DownloadActions.class.php +++ b/controller/action/DownloadActions.class.php @@ -33,14 +33,19 @@ class DownloadActions extends Actions if ($os && isset($osChoices[$os])) { - list($uri, $osTitle, $osIcon, $partial) = $osChoices[$os]; + list($uri, $osTitle, $osIcon, $buttonLabel, $analyticsLabel) = $osChoices[$os]; + $release = GitHub::getAppRelease(); + $asset = GitHub::getAppAsset($os); return ['download/get', [ - 'os' => $os, - 'osTitle' => $osTitle, - 'osIcon' => $osIcon, - 'downloadHtml' => View::exists('download/' . $partial) ? - View::render('download/' . $partial, ['downloadUrl' => Github::getAppDownloadUrl($os)]) : - false + 'analyticsLabel' => $analyticsLabel, + 'buttonLabel' => $buttonLabel, + 'downloadUrl' => $asset ? $asset['browser_download_url'] : null, + 'os' => $os, + 'osTitle' => $osTitle, + 'osIcon' => $osIcon, + 'releaseTimestamp' => $release ? strtotime($release['created_at']) : null, + 'size' => $asset ? $asset['size'] / ( 1024 * 1024 ) : 0, //bytes -> MB + 'version' => $release ? $release['name'] : null, ]]; } diff --git a/data/i18n/en.yaml b/data/i18n/en.yaml index 8f5dbda5..3be4e3cc 100644 --- a/data/i18n/en.yaml +++ b/data/i18n/en.yaml @@ -32,7 +32,6 @@ download: creator: Creator? Skip the Line credits: Claim Credits curse: It may crash, work unreliably, or inadvertently put a curse on your family for generations (a common programming error). - deb: Download .deb earn1: Earn # this many credits earn2: for completing the survey below after install. diff --git a/lib/thirdparty/Github.class.php b/lib/thirdparty/Github.class.php index 61cc9dfa..f4895ba0 100644 --- a/lib/thirdparty/Github.class.php +++ b/lib/thirdparty/Github.class.php @@ -2,7 +2,7 @@ class Github { - protected static function findReleaseDownloadUrl(array $release, string $os) + protected static function findReleaseAssetForOs(array $release, string $os) { if (!in_array($os, array_keys(OS::getAll()))) { @@ -14,26 +14,22 @@ class Github $ext = substr($asset['name'], -4); if ( ($os == OS::OS_LINUX && - ($ext == '.deb' || in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb']))) || + ($ext == '.deb' || in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb']))) || ($os == OS::OS_OSX && - ($ext == '.dmg' || in_array($asset['content_type'], ['application/x-diskcopy', 'application/x-apple-diskimage']))) || + ($ext == '.dmg' || in_array($asset['content_type'], ['application/x-diskcopy', 'application/x-apple-diskimage']))) || ($os == OS::OS_WINDOWS && $ext == '.exe') ) { - return $asset['browser_download_url']; + return $asset; } } } - public static function getAppDownloadUrl($os, $cache = true) + public static function getAppRelease($cache = true) { try { - $release = static::get('/repos/lbryio/lbry-app/releases/latest', $cache); - if ($release) - { - return static::findReleaseDownloadUrl($release, $os); - } + return static::get('/repos/lbryio/lbry-app/releases/latest', $cache); } catch (Exception $e) { @@ -42,6 +38,19 @@ class Github return null; } + public static function getAppAsset($os, $cache = true) + { + $release = static::getAppRelease($cache); + return $release ? static::findReleaseAssetForOs($release, $os) : null; + } + + + public static function getAppDownloadUrl($os, $cache = true) + { + $asset = static::getAppAsset($os, $cache); + return $asset ? $asset['browser_download_url'] : null; + } + public static function getAppPrereleaseDownloadUrl($os, $cache = true) { try @@ -49,7 +58,8 @@ class Github $releases = static::get('/repos/lbryio/lbry-app/releases', $cache); if (count($releases)) { - return static::findReleaseDownloadUrl($releases[0], $os); + $asset = static::findReleaseAssetForOs($releases[0], $os); + return $asset ? $asset['browser_download_url'] : null; } } catch (Exception $e) diff --git a/lib/tools/OS.class.php b/lib/tools/OS.class.php index ff88e877..0939c68b 100644 --- a/lib/tools/OS.class.php +++ b/lib/tools/OS.class.php @@ -13,11 +13,11 @@ class OS //url, English name, icon class, partial name //yes, this is probably a bad pattern return [ - OS::OS_WINDOWS => ['/windows', 'Windows', 'icon-windows', '_windows'], - OS::OS_OSX => ['/osx', 'macOS', 'icon-apple', '_osx'], - OS::OS_LINUX => ['/linux', 'Linux', 'icon-linux', '_linux'], - OS::OS_ANDROID => ['/android', 'Android', 'icon-android', '_android'], - OS::OS_IOS => ['/ios', 'iOS', 'icon-mobile', '_ios'] + OS::OS_WINDOWS => ['/windows', 'Windows', 'icon-windows', __("Download for Windows"), "Windows"], + OS::OS_OSX => ['/osx', 'macOS', 'icon-apple', __("Download for macOS"), "OSX"], + OS::OS_LINUX => ['/linux', 'Linux', 'icon-linux', __("Download .deb"), "Linux"], + OS::OS_ANDROID => ['/android', 'Android', 'icon-android', false, false], + OS::OS_IOS => ['/ios', 'iOS', 'icon-mobile', false, false] ]; } diff --git a/view/template/download/_linux.php b/view/template/download/_linux.php deleted file mode 100644 index eaed891d..00000000 --- a/view/template/download/_linux.php +++ /dev/null @@ -1,17 +0,0 @@ -
- diff --git a/view/template/download/_osx.php b/view/template/download/_osx.php deleted file mode 100644 index c53a599f..00000000 --- a/view/template/download/_osx.php +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/view/template/download/_windows.php b/view/template/download/_windows.php deleted file mode 100644 index b1964281..00000000 --- a/view/template/download/_windows.php +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/view/template/download/get.php b/view/template/download/get.php index c1843d96..641b934f 100644 --- a/view/template/download/get.php +++ b/view/template/download/get.php @@ -7,16 +7,40 @@- This is the latest version of the LBRY App. + This is the latest version of the LBRY App. What is LBRY?
{{download.beta}} {{download.curse}}
- +{{download.unavailable}}
@@ -25,7 +49,7 @@