mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47: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)
|
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)
|
public static function executeDownloadSnapshot(string $type)
|
||||||
|
@ -40,6 +40,7 @@ class DownloadActions extends Actions
|
||||||
$osChoices = OS::getAll();
|
$osChoices = OS::getAll();
|
||||||
list($uri, $osTitle, $osIcon) = $osChoices[$os];
|
list($uri, $osTitle, $osIcon) = $osChoices[$os];
|
||||||
$params = [
|
$params = [
|
||||||
|
'preferredExt' => $os === Os::OS_LINUX ? 'AppImage' : '',
|
||||||
'osTitle' => $osTitle,
|
'osTitle' => $osTitle,
|
||||||
'osIcon' => $osIcon,
|
'osIcon' => $osIcon,
|
||||||
'osScreenshotSrc' => 'https://spee.ch/b/desktop-035-og.jpeg',
|
'osScreenshotSrc' => 'https://spee.ch/b/desktop-035-og.jpeg',
|
||||||
|
@ -53,7 +54,7 @@ class DownloadActions extends Actions
|
||||||
}
|
}
|
||||||
else
|
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;
|
$params['downloadUrl'] = $asset ? $asset['browser_download_url'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,21 +133,36 @@ class DownloadActions extends Actions
|
||||||
$os = static::guessOS();
|
$os = static::guessOS();
|
||||||
|
|
||||||
if ($os && isset($osChoices[$os])) {
|
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) {
|
if ($os !== OS::OS_ANDROID) {
|
||||||
$asset = Github::getRepoAsset(GitHub::REPO_LBRY_DESKTOP, $os);
|
$asset = Github::getRepoAsset(GitHub::REPO_LBRY_DESKTOP, $os, $vars['preferredExt'] ?? '');
|
||||||
} else {
|
} else {
|
||||||
$asset = ['browser_download_url' => static::ANDROID_STORE_URL];
|
$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 += [
|
$vars += [
|
||||||
'analyticsLabel' => $analyticsLabel,
|
'analyticsLabel' => $analyticsLabel,
|
||||||
'buttonLabel' => $buttonLabel,
|
'buttonLabel' => $buttonLabel,
|
||||||
|
'isDownload' => true,
|
||||||
'downloadUrl' => $asset ? $asset['browser_download_url'] : null,
|
'downloadUrl' => $asset ? $asset['browser_download_url'] : null,
|
||||||
'os' => $os,
|
'os' => $os,
|
||||||
|
'skipRender' => isset($vars['preferredExt']) && $vars['preferredExt'] &&
|
||||||
|
substr_compare($asset['browser_download_url'], $vars['preferredExt'], -strlen($vars['preferredExt'])) !== 0,
|
||||||
'isAuto' => Request::getParam('auto'),
|
'isAuto' => Request::getParam('auto'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($os === OS::OS_LINUX && !isset($vars['preferredExt'])) {
|
||||||
|
$vars['isDownload'] = false;
|
||||||
|
$vars['downloadUrl'] = '/linux';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $vars;
|
return $vars;
|
||||||
|
|
25
lib/thirdparty/Github.class.php
vendored
25
lib/thirdparty/Github.class.php
vendored
|
@ -10,7 +10,7 @@ class Github
|
||||||
switch ($os) {
|
switch ($os) {
|
||||||
case OS::OS_LINUX:
|
case OS::OS_LINUX:
|
||||||
return
|
return
|
||||||
in_array($ext, ['deb']) ||
|
in_array($ext, ['deb', 'AppImage']) ||
|
||||||
in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb']) ||
|
in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb']) ||
|
||||||
stripos($asset['name'], 'linux') !== false;
|
stripos($asset['name'], 'linux') !== false;
|
||||||
case OS::OS_OSX:
|
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()))) {
|
if (!in_array($os, array_keys(OS::getAll()))) {
|
||||||
throw new DomainException('Unknown OS');
|
throw new DomainException('Unknown OS');
|
||||||
|
@ -40,11 +40,21 @@ class Github
|
||||||
throw new Exception('Release array missing assets - possible GitHub auth failure, auth limit, and/or inspect releases array');
|
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) {
|
foreach ($release['assets'] as $asset) {
|
||||||
if (static::isAssetForOs($asset, $os)) {
|
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)
|
public static function getRepoRelease($repo, $prerelease = false, $cache = true)
|
||||||
|
@ -63,16 +73,17 @@ class Github
|
||||||
return null;
|
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);
|
$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;
|
return $asset ? $asset['browser_download_url'] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ class OS
|
||||||
{
|
{
|
||||||
switch ($ext) {
|
switch ($ext) {
|
||||||
case 'deb':
|
case 'deb':
|
||||||
|
case 'AppImage':
|
||||||
return OS::OS_LINUX;
|
return OS::OS_LINUX;
|
||||||
|
|
||||||
case 'dmg':
|
case 'dmg':
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
<?php if ($downloadUrl): ?>
|
<?php if ($skipRender): ?>
|
||||||
|
<?php elseif ($downloadUrl): ?>
|
||||||
<?php if ($os !== OS::OS_ANDROID): ?>
|
<?php if ($os !== OS::OS_ANDROID): ?>
|
||||||
<a class="button button--<?php echo $buttonStyle?>"
|
<?php if ($isDownload): ?>
|
||||||
download
|
<a class="button button--<?php echo $buttonStyle?>"
|
||||||
href="<?php echo $downloadUrl ?>"
|
download
|
||||||
id="get-download-btn"
|
href="<?php echo $downloadUrl ?>"
|
||||||
data-facebook-track="1"
|
id="get-download-btn"
|
||||||
data-analytics-category="Sign Up"
|
data-facebook-track="1"
|
||||||
data-analytics-action="Download"
|
data-analytics-category="Sign Up"
|
||||||
data-analytics-label="<?php echo $analyticsLabel ?>"
|
data-analytics-action="Download"
|
||||||
title="Download our app"
|
data-analytics-label="<?php echo $analyticsLabel ?>"
|
||||||
><?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: ?>
|
<?php else: ?>
|
||||||
<a
|
<a
|
||||||
class="button button--google-play"
|
class="button button--google-play"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php if ($os === OS::OS_LINUX): ?>
|
<?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): ?>
|
<?php elseif ($os === OS::OS_OSX): ?>
|
||||||
Works with with macOS version 10.12.4 (Sierra), and higher.
|
Works with with macOS version 10.12.4 (Sierra), and higher.
|
||||||
<?php elseif ($sourceLink): ?>
|
<?php elseif ($sourceLink): ?>
|
||||||
|
|
|
@ -19,8 +19,15 @@
|
||||||
<p>Securely download the LBRY app here, and see what all the fuss is about!</p>
|
<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 $metaHtml = $os !== OS::OS_ANDROID ? View::Render('download/_meta') : false ?>
|
||||||
<?php echo View::Render('download/_downloadButton', [
|
<?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): ?>
|
<?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>
|
<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