mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 09:37:26 +00:00
hacky app image support
This commit is contained in:
parent
57f16b454c
commit
76bc068b29
6 changed files with 68 additions and 24 deletions
|
@ -12,7 +12,7 @@ class DownloadActions extends Actions
|
|||
|
||||
public static function executeDownloadReleaseAsset(string $repo, string $ext, bool $allowPrerelease = false)
|
||||
{
|
||||
return Controller::redirect(GitHub::getRepoReleaseUrl($repo, OS::getOsForExtension($ext), $allowPrerelease) ?: '/get', 302);
|
||||
return Controller::redirect(GitHub::getRepoReleaseUrl($repo, $ext, $allowPrerelease) ?: '/get', 302);
|
||||
}
|
||||
|
||||
public static function executeDownloadSnapshot(string $type)
|
||||
|
@ -40,6 +40,7 @@ class DownloadActions extends Actions
|
|||
$osChoices = OS::getAll();
|
||||
list($uri, $osTitle, $osIcon) = $osChoices[$os];
|
||||
$params = [
|
||||
'preferredExt' => $os === Os::OS_LINUX ? 'AppImage' : '',
|
||||
'osTitle' => $osTitle,
|
||||
'osIcon' => $osIcon,
|
||||
'osScreenshotSrc' => 'https://spee.ch/b/desktop-035-og.jpeg',
|
||||
|
@ -53,7 +54,7 @@ class DownloadActions extends Actions
|
|||
}
|
||||
else
|
||||
{
|
||||
$asset = Github::getRepoAsset(GitHub::REPO_LBRY_DESKTOP, $os);
|
||||
$asset = Github::getRepoAsset(GitHub::REPO_LBRY_DESKTOP, $os, $params['preferredExt']);
|
||||
$params['downloadUrl'] = $asset ? $asset['browser_download_url'] : null;
|
||||
}
|
||||
|
||||
|
@ -132,21 +133,36 @@ class DownloadActions extends Actions
|
|||
$os = static::guessOS();
|
||||
|
||||
if ($os && isset($osChoices[$os])) {
|
||||
list($uri, $osTitle, $osIcon, $buttonLabel, $analyticsLabel) = $osChoices[$os];
|
||||
list($uri, $osTitle, $osIcon, $oldButtonLabel, $analyticsLabel) = $osChoices[$os];
|
||||
|
||||
if ($os !== OS::OS_ANDROID) {
|
||||
$asset = Github::getRepoAsset(GitHub::REPO_LBRY_DESKTOP, $os);
|
||||
$asset = Github::getRepoAsset(GitHub::REPO_LBRY_DESKTOP, $os, $vars['preferredExt'] ?? '');
|
||||
} else {
|
||||
$asset = ['browser_download_url' => static::ANDROID_STORE_URL];
|
||||
}
|
||||
|
||||
$buttonLabel = __('download.for-os2', ['%os%' => OS::OS_DETAIL($os)[1]]);
|
||||
if (isset($vars['preferredExt']) && $vars['preferredExt']) {
|
||||
$buttonLabel = __('Download .%ext%', ['%ext%' => $vars['preferredExt']]);
|
||||
}
|
||||
|
||||
$vars += [
|
||||
'analyticsLabel' => $analyticsLabel,
|
||||
'buttonLabel' => $buttonLabel,
|
||||
'isDownload' => true,
|
||||
'downloadUrl' => $asset ? $asset['browser_download_url'] : null,
|
||||
'os' => $os,
|
||||
'skipRender' => isset($vars['preferredExt']) && $vars['preferredExt'] &&
|
||||
substr_compare($asset['browser_download_url'], $vars['preferredExt'], -strlen($vars['preferredExt'])) !== 0,
|
||||
'isAuto' => Request::getParam('auto'),
|
||||
];
|
||||
|
||||
|
||||
|
||||
if ($os === OS::OS_LINUX && !isset($vars['preferredExt'])) {
|
||||
$vars['isDownload'] = false;
|
||||
$vars['downloadUrl'] = '/linux';
|
||||
}
|
||||
}
|
||||
|
||||
return $vars;
|
||||
|
|
25
lib/thirdparty/Github.class.php
vendored
25
lib/thirdparty/Github.class.php
vendored
|
@ -10,7 +10,7 @@ class Github
|
|||
switch ($os) {
|
||||
case OS::OS_LINUX:
|
||||
return
|
||||
in_array($ext, ['deb']) ||
|
||||
in_array($ext, ['deb', 'AppImage']) ||
|
||||
in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb']) ||
|
||||
stripos($asset['name'], 'linux') !== false;
|
||||
case OS::OS_OSX:
|
||||
|
@ -30,7 +30,7 @@ class Github
|
|||
}
|
||||
}
|
||||
|
||||
protected static function findReleaseAssetForOs(array $release, string $os)
|
||||
protected static function findReleaseAsset(array $release, string $os, string $preferredExt = '')
|
||||
{
|
||||
if (!in_array($os, array_keys(OS::getAll()))) {
|
||||
throw new DomainException('Unknown OS');
|
||||
|
@ -40,12 +40,22 @@ class Github
|
|||
throw new Exception('Release array missing assets - possible GitHub auth failure, auth limit, and/or inspect releases array');
|
||||
}
|
||||
|
||||
$bestAsset = null;
|
||||
foreach ($release['assets'] as $asset) {
|
||||
if (static::isAssetForOs($asset, $os)) {
|
||||
return $asset;
|
||||
if (!$bestAsset) {
|
||||
$bestAsset = $asset;
|
||||
} else if ($os === Os::OS_LINUX) {
|
||||
$ext = pathinfo($asset['name'], PATHINFO_EXTENSION);
|
||||
if ($ext === $preferredExt || (!$preferredExt && $ext === 'AppImage')) {
|
||||
$bestAsset = $asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $bestAsset;
|
||||
}
|
||||
|
||||
public static function getRepoRelease($repo, $prerelease = false, $cache = true)
|
||||
{
|
||||
|
@ -63,16 +73,17 @@ class Github
|
|||
return null;
|
||||
}
|
||||
|
||||
public static function getRepoAsset($repo, $os, $prerelease = false, $cache = true)
|
||||
public static function getRepoAsset($repo, $os, $preferredExt = '', $prerelease = false, $cache = true)
|
||||
{
|
||||
$release = static::getRepoRelease($repo, $prerelease, $cache);
|
||||
return $release ? static::findReleaseAssetForOs($release, $os) : null;
|
||||
return $release ? static::findReleaseAsset($release, $os, $preferredExt) : null;
|
||||
}
|
||||
|
||||
|
||||
public static function getRepoReleaseUrl($repo, $os, bool $prerelease = false, $cache = true)
|
||||
public static function getRepoReleaseUrl($repo, $ext, bool $prerelease = false, $cache = true)
|
||||
{
|
||||
$asset = static::getRepoAsset($repo, $os, $prerelease, $cache);
|
||||
$os = OS::getOsForExtension($ext);
|
||||
$asset = static::getRepoAsset($repo, $os, $ext, $prerelease, $cache);
|
||||
return $asset ? $asset['browser_download_url'] : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ class OS
|
|||
{
|
||||
switch ($ext) {
|
||||
case 'deb':
|
||||
case 'AppImage':
|
||||
return OS::OS_LINUX;
|
||||
|
||||
case 'dmg':
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php if ($downloadUrl): ?>
|
||||
<?php if ($skipRender): ?>
|
||||
<?php elseif ($downloadUrl): ?>
|
||||
<?php if ($os !== OS::OS_ANDROID): ?>
|
||||
<?php if ($isDownload): ?>
|
||||
<a class="button button--<?php echo $buttonStyle?>"
|
||||
download
|
||||
href="<?php echo $downloadUrl ?>"
|
||||
|
@ -8,8 +10,15 @@
|
|||
data-analytics-category="Sign Up"
|
||||
data-analytics-action="Download"
|
||||
data-analytics-label="<?php echo $analyticsLabel ?>"
|
||||
title="Download our app"
|
||||
><?php echo __('download.for-os2', ['%os%' => OS::OS_DETAIL($os)[1]]) ?></a>
|
||||
title="Download LBRY App"
|
||||
><?php echo $buttonLabel ?></a>
|
||||
<?php else: ?>
|
||||
<a class="button button--<?php echo $buttonStyle?>"
|
||||
href="<?php echo $downloadUrl ?>"
|
||||
id="get-download-btn"
|
||||
title="Download LBRY App"
|
||||
><?php echo $buttonLabel ?></a>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<a
|
||||
class="button button--google-play"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<br/>
|
||||
|
||||
<?php if ($os === OS::OS_LINUX): ?>
|
||||
Works with Ubuntu, Debian, or any distro with <code>apt</code> or <code>dpkg</code>. For other Linux flavors including Arch and Flatpak support or compiling from source, <a href="https://github.com/lbryio/lbry-desktop#install">see our GitHub install page</a>.
|
||||
We provide app builds as AppImage and .deb. For other Linux flavors including Arch and Flatpak support or compiling from source, <a href="https://github.com/lbryio/lbry-desktop#install">see our GitHub install page</a>.
|
||||
<?php elseif ($os === OS::OS_OSX): ?>
|
||||
Works with with macOS version 10.12.4 (Sierra), and higher.
|
||||
<?php elseif ($sourceLink): ?>
|
||||
|
|
|
@ -19,8 +19,15 @@
|
|||
<p>Securely download the LBRY app here, and see what all the fuss is about!</p>
|
||||
<?php $metaHtml = $os !== OS::OS_ANDROID ? View::Render('download/_meta') : false ?>
|
||||
<?php echo View::Render('download/_downloadButton', [
|
||||
'buttonStyle' => 'primary'
|
||||
'buttonStyle' => 'primary',
|
||||
'preferredExt' => $preferredExt
|
||||
])?>
|
||||
<?php if ($os === OS::OS_LINUX && $preferredExt === 'AppImage'): ?>
|
||||
<?php echo View::Render('download/_downloadButton', [
|
||||
'buttonStyle' => 'primary',
|
||||
'preferredExt' => 'deb'
|
||||
])?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($os === OS::OS_ANDROID): ?>
|
||||
<p style="font-size: 0.8rem;">You can also <a href="http://lbry.com/releases/lbry-android.apk" title="Download our Android app directly">download</a> our Android app directly</p>
|
||||
|
|
Loading…
Add table
Reference in a new issue