mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
Refactoring the button into a partial
This commit is contained in:
parent
77a8ea52f7
commit
42a59116f6
4 changed files with 74 additions and 49 deletions
|
@ -29,28 +29,18 @@ class DownloadActions extends Actions
|
||||||
public static function executeGet()
|
public static function executeGet()
|
||||||
{
|
{
|
||||||
$osChoices = OS::getAll();
|
$osChoices = OS::getAll();
|
||||||
$os = static::guessOs();
|
|
||||||
|
|
||||||
if ($os && isset($osChoices[$os]))
|
$os = static::guessOS();
|
||||||
{
|
|
||||||
|
if(isset($os) && isset($osChoices[$os])){
|
||||||
list($uri, $osTitle, $osIcon, $buttonLabel, $analyticsLabel) = $osChoices[$os];
|
list($uri, $osTitle, $osIcon, $buttonLabel, $analyticsLabel) = $osChoices[$os];
|
||||||
$release = GitHub::getAppRelease();
|
$asset = Github::getAppAsset($os);
|
||||||
$asset = GitHub::getAppAsset($os);
|
$param = ['osTitle' => $osTitle, 'osIcon' => $osIcon, 'os' => $os, 'downloadUrl' => $asset ? $asset['browser_download_url'] : null];
|
||||||
return ['download/get', [
|
return ['download/get', $param];
|
||||||
'analyticsLabel' => $analyticsLabel,
|
}
|
||||||
'buttonLabel' => $buttonLabel,
|
else{
|
||||||
'downloadUrl' => $asset ? $asset['browser_download_url'] : null,
|
return ['download/get-no-os'];
|
||||||
'isAuto' => Request::getParam('auto'),
|
|
||||||
'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,
|
|
||||||
]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['download/get-no-os'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function prepareListPartial(array $vars)
|
public static function prepareListPartial(array $vars)
|
||||||
|
@ -113,4 +103,32 @@ class DownloadActions extends Actions
|
||||||
|
|
||||||
return $email;
|
return $email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function prepareDownloadButtonPartial(array $vars)
|
||||||
|
{
|
||||||
|
$osChoices = OS::getAll();
|
||||||
|
|
||||||
|
$os = static::guessOS();
|
||||||
|
|
||||||
|
if ($os && isset($osChoices[$os])) {
|
||||||
|
list($uri, $osTitle, $osIcon, $buttonLabel, $analyticsLabel) = $osChoices[$os];
|
||||||
|
$release = Github::getAppRelease();
|
||||||
|
$asset = Github::getAppAsset($os);
|
||||||
|
|
||||||
|
$vars = $vars + [
|
||||||
|
'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,
|
||||||
|
'isAuto' => Request::getParam('auto'),
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
return $vars;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
32
view/template/download/_downloadButton.php
Normal file
32
view/template/download/_downloadButton.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php if ($downloadUrl): ?>
|
||||||
|
<a class="btn-<?php echo $buttonStyle?> btn-large"
|
||||||
|
download
|
||||||
|
href="<?php echo $downloadUrl ?>"
|
||||||
|
id="get-download-btn"
|
||||||
|
data-facebook-track="1"
|
||||||
|
data-analytics-category="Sign Up"
|
||||||
|
data-analytics-action="Download"
|
||||||
|
data-analytics-label="<?php echo $analyticsLabel ?>"
|
||||||
|
><?php echo $buttonLabel ?></a>
|
||||||
|
<?php if ($isAuto): ?>
|
||||||
|
<?php js_start() ?>
|
||||||
|
var anchor = document.getElementById('get-download-btn');
|
||||||
|
ga('send', 'event', anchor.getAttribute('data-analytics-category'), anchor.getAttribute('data-analytics-action'), anchor.getAttribute('data-analytics-label'));
|
||||||
|
setTimeout(function() { window.location = anchor.getAttribute('href'); }, 500);
|
||||||
|
<?php js_end() ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<br/>
|
||||||
|
<span class="meta"> Latest Version :
|
||||||
|
<?php echo $version ?>, Download Size :
|
||||||
|
<?php echo number_format($size, 1) ?> MB,
|
||||||
|
built on <?php echo date('F d', $releaseTimestamp) ?>
|
||||||
|
at <?php echo date('H:i:s', $releaseTimestamp) ?> UTC
|
||||||
|
</span>
|
||||||
|
<div class="meta">
|
||||||
|
<?php if ($os === OS::OS_LINUX): ?>
|
||||||
|
{{download.works}}
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<a href="/get" class="btn-primary btn-large spacer1">Download LBRY</a><BR>
|
||||||
|
<?php endif ?>
|
|
@ -2,7 +2,6 @@
|
||||||
<?php Response::addMetaImage(Request::getHostAndProto() . '/img/lbry-ui.png') ?>
|
<?php Response::addMetaImage(Request::getHostAndProto() . '/img/lbry-ui.png') ?>
|
||||||
<?php NavActions::setNavUri('/get') ?>
|
<?php NavActions::setNavUri('/get') ?>
|
||||||
<?php echo View::render('nav/_header', ['isDark' => false]) ?>
|
<?php echo View::render('nav/_header', ['isDark' => false]) ?>
|
||||||
|
|
||||||
<main class="column-fluid">
|
<main class="column-fluid">
|
||||||
<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">
|
||||||
|
@ -15,35 +14,12 @@
|
||||||
</p>
|
</p>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<p>
|
<p>
|
||||||
<a class="btn-alt btn-large"
|
<?php echo View::Render('download/_downloadButton', ['buttonStyle'=>'alt',])?>
|
||||||
download
|
<div class="meta">
|
||||||
href="<?php echo $downloadUrl ?>"
|
Like source code? Go <a href="https://github.com/lbryio/lbry-app" class="link-primary">here</a>.<P><P>
|
||||||
id="get-download-btn"
|
</div>
|
||||||
data-facebook-track="1"
|
|
||||||
data-analytics-category="Sign Up"
|
|
||||||
data-analytics-action="Download"
|
|
||||||
data-analytics-label="<?php echo $analyticsLabel ?>"
|
|
||||||
><?php echo $buttonLabel ?></a>
|
|
||||||
<?php if ($isAuto): ?>
|
|
||||||
<?php js_start() ?>
|
|
||||||
var anchor = document.getElementById('get-download-btn');
|
|
||||||
ga('send', 'event', anchor.getAttribute('data-analytics-category'), anchor.getAttribute('data-analytics-action'), anchor.getAttribute('data-analytics-label'));
|
|
||||||
setTimeout(function() { window.location = anchor.getAttribute('href'); }, 500);
|
|
||||||
<?php js_end() ?>
|
|
||||||
<?php endif ?>
|
|
||||||
<br/>
|
|
||||||
<span class="meta"> Latest Version :
|
|
||||||
<?php echo $version ?>, Download Size :
|
|
||||||
<?php echo number_format($size, 1) ?> MB,
|
|
||||||
built on <?php echo date('F d', $releaseTimestamp) ?>
|
|
||||||
at <?php echo date('H:i:s', $releaseTimestamp) ?>
|
|
||||||
</span>
|
|
||||||
</p>
|
</p>
|
||||||
<div class="meta">
|
<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>.<P><P>
|
|
||||||
<img src="https://spee.ch/5a3e08d52dd2d7cb1c63a480b45dea8b4679cf01/lbryget-gif-mastertest.gif" />
|
<img src="https://spee.ch/5a3e08d52dd2d7cb1c63a480b45dea8b4679cf01/lbryget-gif-mastertest.gif" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
<h3 class="cover-subtitle cover-title-flat">Hollywood films, college lessons, amazing streamers and more are on the first media network ruled by <em>you</em>.</h3>
|
<h3 class="cover-subtitle cover-title-flat">Hollywood films, college lessons, amazing streamers and more are on the first media network ruled by <em>you</em>.</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="spacer2 text-center">
|
<div class="spacer2 text-center">
|
||||||
<a href="/get" class="btn-primary btn-large spacer1">Download LBRY</a><BR>
|
<?php echo View::render('download/_downloadButton', ['buttonStyle' => 'primary',])?>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
Loading…
Add table
Reference in a new issue