add additional details to downloads page, including version, file size, and build date

This commit is contained in:
Jeremy Kauffman 2017-10-04 18:42:00 -04:00
parent 17372739d6
commit 9321a9c2b8
9 changed files with 66 additions and 69 deletions

BIN
composer.phar Executable file

Binary file not shown.

View file

@ -33,14 +33,19 @@ class DownloadActions extends Actions
if ($os && isset($osChoices[$os])) 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', [ return ['download/get', [
'os' => $os, 'analyticsLabel' => $analyticsLabel,
'osTitle' => $osTitle, 'buttonLabel' => $buttonLabel,
'osIcon' => $osIcon, 'downloadUrl' => $asset ? $asset['browser_download_url'] : null,
'downloadHtml' => View::exists('download/' . $partial) ? 'os' => $os,
View::render('download/' . $partial, ['downloadUrl' => Github::getAppDownloadUrl($os)]) : 'osTitle' => $osTitle,
false 'osIcon' => $osIcon,
'releaseTimestamp' => $release ? strtotime($release['created_at']) : null,
'size' => $asset ? $asset['size'] / ( 1024 * 1024 ) : 0, //bytes -> MB
'version' => $release ? $release['name'] : null,
]]; ]];
} }

View file

@ -32,7 +32,6 @@ download:
creator: Creator? Skip the Line creator: Creator? Skip the Line
credits: Claim Credits credits: Claim Credits
curse: It may crash, work unreliably, or inadvertently put a curse on your family for generations (a common programming error). 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 earn1: Earn
# this many credits # this many credits
earn2: for completing the survey below after install. earn2: for completing the survey below after install.

View file

@ -2,7 +2,7 @@
class Github 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()))) if (!in_array($os, array_keys(OS::getAll())))
{ {
@ -14,26 +14,22 @@ class Github
$ext = substr($asset['name'], -4); $ext = substr($asset['name'], -4);
if ( if (
($os == OS::OS_LINUX && ($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 && ($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') ($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 try
{ {
$release = static::get('/repos/lbryio/lbry-app/releases/latest', $cache); return static::get('/repos/lbryio/lbry-app/releases/latest', $cache);
if ($release)
{
return static::findReleaseDownloadUrl($release, $os);
}
} }
catch (Exception $e) catch (Exception $e)
{ {
@ -42,6 +38,19 @@ class Github
return null; 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) public static function getAppPrereleaseDownloadUrl($os, $cache = true)
{ {
try try
@ -49,7 +58,8 @@ class Github
$releases = static::get('/repos/lbryio/lbry-app/releases', $cache); $releases = static::get('/repos/lbryio/lbry-app/releases', $cache);
if (count($releases)) 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) catch (Exception $e)

View file

@ -13,11 +13,11 @@ class OS
//url, English name, icon class, partial name //url, English name, icon class, partial name
//yes, this is probably a bad pattern //yes, this is probably a bad pattern
return [ return [
OS::OS_WINDOWS => ['/windows', 'Windows', 'icon-windows', '_windows'], OS::OS_WINDOWS => ['/windows', 'Windows', 'icon-windows', __("Download for Windows"), "Windows"],
OS::OS_OSX => ['/osx', 'macOS', 'icon-apple', '_osx'], OS::OS_OSX => ['/osx', 'macOS', 'icon-apple', __("Download for macOS"), "OSX"],
OS::OS_LINUX => ['/linux', 'Linux', 'icon-linux', '_linux'], OS::OS_LINUX => ['/linux', 'Linux', 'icon-linux', __("Download .deb"), "Linux"],
OS::OS_ANDROID => ['/android', 'Android', 'icon-android', '_android'], OS::OS_ANDROID => ['/android', 'Android', 'icon-android', false, false],
OS::OS_IOS => ['/ios', 'iOS', 'icon-mobile', '_ios'] OS::OS_IOS => ['/ios', 'iOS', 'icon-mobile', false, false]
]; ];
} }

View file

@ -1,17 +0,0 @@
<div class="text-center">
<p>
<a id="linux-download" class="btn-alt btn-large" <?php echo $downloadUrl ? 'download' : '' ?>
href="<?php echo $downloadUrl ?: 'https://github.com/lbryio/lbry-app/releases' ?>"
data-facebook-track="1"
<?php /* data-twitter-track-id="XXXXX" */ ?>
data-analytics-category="Sign Up"
data-analytics-action="Download"
data-analytics-label="Linux"
>{{download.deb}}</a>
</p>
<div class="meta">
{{download.works}}
Prefer to build from source? Go <a href="https://github.com/lbryio/lbry-app" class="link-primary">here</a>.
</div>
</div>

View file

@ -1,12 +0,0 @@
<div class="text-center">
<p>
<a class="btn-alt btn-large" <?php echo $downloadUrl ? 'download' : '' ?>
href="<?php echo $downloadUrl ?: 'https://github.com/lbryio/lbry-app/releases' ?>"
data-facebook-track="1"
<?php /* data-twitter-track-id="XXXXX" */ ?>
data-analytics-category="Sign Up"
data-analytics-action="Download"
data-analytics-label="OSX"
>{{download.osx2}}</a>
</p>
</div>

View file

@ -1,12 +0,0 @@
<div class="text-center">
<p>
<a class="btn-alt btn-large" <?php echo $downloadUrl ? 'download' : '' ?>
href="<?php echo $downloadUrl ?: 'https://github.com/lbryio/lbry-app/releases' ?>"
data-facebook-track="1"
<?php /* data-twitter-track-id="XXXXX" */ ?>
data-analytics-category="Sign Up"
data-analytics-action="Download"
data-analytics-label="Windows"
>{{download.windows}}</a>
</p>
</div>

View file

@ -7,16 +7,40 @@
<div class="span7"> <div class="span7">
<div class="cover cover-dark cover-dark-grad content content-stretch content-dark"> <div class="cover cover-dark cover-dark-grad content content-stretch content-dark">
<h1><?php echo __('download.for-os', ['%os%' => $osTitle]) ?> <span class="<?php echo $osIcon ?>"></span></h1> <h1><?php echo __('download.for-os', ['%os%' => $osTitle]) ?> <span class="<?php echo $osIcon ?>"></span></h1>
<?php if ($downloadHtml): ?> <?php if ($downloadUrl): ?>
<p> <p>
This is the latest version of the LBRY App. This is the latest version of the LBRY App.
<a href="https://lbry.io/faq/what-is-lbry" class="link-primary">What is LBRY?</a> <a href="https://lbry.io/faq/what-is-lbry" class="link-primary">What is LBRY?</a>
</p> </p>
<p> <p>
<strong>{{download.beta}}</strong> <strong>{{download.beta}}</strong>
{{download.curse}} {{download.curse}}
</p> </p>
<?php echo $downloadHtml ?> <div class="text-center">
<p>
<a class="btn-alt btn-large"
download
href="<?php echo $downloadUrl ?>"
data-facebook-track="1"
data-analytics-category="Sign Up"
data-analytics-action="Download"
data-analytics-label="<?php echo $analyticsLabel ?>"
><?php echo $buttonLabel ?></a>
<br/>
<span class="meta">
<?php echo $version ?>,
<?php echo number_format($size, 1) ?>MB,
built on <?php echo date('F d') ?>
at <?php echo date('H:i:s', $releaseTimestamp) ?>
</span>
</p>
<div class="meta">
<?php if ($os === OS::OS_LINUX): ?>
{{download.works}}
<?php endif ?>
Like source code? Go <a href="https://github.com/lbryio/lbry-app" class="link-primary">here</a>.
</div>
</div>
<?php else: ?> <?php else: ?>
<p>{{download.unavailable}}</p> <p>{{download.unavailable}}</p>
<?php echo View::render('download/_signup') ?> <?php echo View::render('download/_signup') ?>
@ -25,7 +49,7 @@
</div> </div>
<div class="span5"> <div class="span5">
<?php echo View::render('download/_list', [ <?php echo View::render('download/_list', [
'excludeOs' => $os 'excludeOs' => $os
]) ?> ]) ?>
<?php echo View::render('download/_social') ?> <?php echo View::render('download/_social') ?>
</div> </div>