mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
spacing and formatting
This commit is contained in:
parent
ff49e3e1fd
commit
f4cb4df64a
6 changed files with 65 additions and 57 deletions
|
@ -115,9 +115,9 @@ class Controller
|
|||
'/deck.pdf' => 'https://www.dropbox.com/s/0xj4vgucsbi8rtv/lbry-deck.pdf?dl=1',
|
||||
'/pln.pdf' => 'https://www.dropbox.com/s/uevjrwnyr672clj/lbry-pln.pdf?dl=1',
|
||||
'/plan.pdf' => 'https://www.dropbox.com/s/uevjrwnyr672clj/lbry-pln.pdf?dl=1',
|
||||
'/get/lbry.dmg' => GitHub::getDownloadUrl(Os::OS_OSX) ?: '/get',
|
||||
'/get/lbry.deb' => GitHub::getDownloadUrl(Os::OS_LINUX) ?: '/get',
|
||||
'/get/lbry.msi' => GitHub::getDownloadUrl(Os::OS_WINDOWS) ?: '/get',
|
||||
'/get/lbry.dmg' => GitHub::getDownloadUrl(OS::OS_OSX) ?: '/get',
|
||||
'/get/lbry.deb' => GitHub::getDownloadUrl(OS::OS_LINUX) ?: '/get',
|
||||
'/get/lbry.msi' => GitHub::getDownloadUrl(OS::OS_WINDOWS) ?: '/get',
|
||||
];
|
||||
|
||||
foreach ([302 => $tempRedirects, 301 => $permanentRedirects] as $code => $redirects)
|
||||
|
|
|
@ -35,7 +35,7 @@ class DownloadActions extends Actions
|
|||
return ['download/get'];
|
||||
}
|
||||
|
||||
$osChoices = Os::getAll();
|
||||
$osChoices = OS::getAll();
|
||||
$os = static::guessOs();
|
||||
|
||||
if ($os && isset($osChoices[$os]))
|
||||
|
@ -105,8 +105,8 @@ class DownloadActions extends Actions
|
|||
public static function prepareListPartial(array $vars)
|
||||
{
|
||||
return $vars + ['osChoices' => isset($vars['excludeOs']) ?
|
||||
array_diff_key(Os::getAll(), [$vars['excludeOs'] => null]) :
|
||||
Os::getAll()
|
||||
array_diff_key(OS::getAll(), [$vars['excludeOs'] => null]) :
|
||||
OS::getAll()
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ class DownloadActions extends Actions
|
|||
{
|
||||
//if exact OS is requested, use that
|
||||
$uri = Request::getRelativeUri();
|
||||
foreach (Os::getAll() as $os => $osChoice)
|
||||
foreach (OS::getAll() as $os => $osChoice)
|
||||
{
|
||||
if ($osChoice[0] == $uri)
|
||||
{
|
||||
|
@ -164,15 +164,15 @@ class DownloadActions extends Actions
|
|||
$ua = Request::getUserAgent();
|
||||
if (stripos($ua, 'OS X') !== false)
|
||||
{
|
||||
return strpos($ua, 'iPhone') !== false || stripos($ua, 'iPad') !== false ? Os::OS_IOS : Os::OS_OSX;
|
||||
return strpos($ua, 'iPhone') !== false || stripos($ua, 'iPad') !== false ? OS::OS_IOS : OS::OS_OSX;
|
||||
}
|
||||
if (stripos($ua, 'Linux') !== false || strpos($ua, 'X11') !== false)
|
||||
{
|
||||
return strpos($ua, 'Android') !== false ? Os::OS_ANDROID : Os::OS_LINUX;
|
||||
return strpos($ua, 'Android') !== false ? OS::OS_ANDROID : OS::OS_LINUX;
|
||||
}
|
||||
if (stripos($ua, 'Windows') !== false)
|
||||
{
|
||||
return Os::OS_WINDOWS;
|
||||
return OS::OS_WINDOWS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
56
lib/thirdparty/Github.class.php
vendored
56
lib/thirdparty/Github.class.php
vendored
|
@ -2,22 +2,22 @@
|
|||
|
||||
class Github
|
||||
{
|
||||
public static function getDownloadUrl($os, $useCache = true)
|
||||
public static function getDownloadUrl($os, $cache = true)
|
||||
{
|
||||
if (!in_array($os, array_keys(Os::getAll())))
|
||||
if (!in_array($os, array_keys(OS::getAll())))
|
||||
{
|
||||
throw new DomainException('Unknown OS');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$releaseData = static::get('/repos/lbryio/lbry/releases/latest');
|
||||
$releaseData = static::get('/repos/lbryio/lbry/releases/latest', $cache);
|
||||
foreach ($releaseData['assets'] as $asset)
|
||||
{
|
||||
if (
|
||||
($os == Os::OS_LINUX && in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb'])) ||
|
||||
($os == Os::OS_OSX && in_array($asset['content_type'], ['application/x-diskcopy', 'application/x-apple-diskimage'])) ||
|
||||
($os == Os::OS_WINDOWS && substr($asset['name'], -4) == '.msi')
|
||||
($os == OS::OS_LINUX && in_array($asset['content_type'], ['application/x-debian-package', 'application/x-deb'])) ||
|
||||
($os == OS::OS_OSX && in_array($asset['content_type'], ['application/x-diskcopy', 'application/x-apple-diskimage'])) ||
|
||||
($os == OS::OS_WINDOWS && substr($asset['name'], -4) == '.msi')
|
||||
)
|
||||
{
|
||||
return $asset['browser_download_url'];
|
||||
|
@ -33,36 +33,40 @@ class Github
|
|||
|
||||
public static function get($endpoint, $cache = true)
|
||||
{
|
||||
return CurlWithCache::get('https://api.github.com' . $endpoint, [], ['user_agent' => 'LBRY', 'json_response' => true, 'cache' => $cache]);
|
||||
return CurlWithCache::get('https://api.github.com' . $endpoint, [],
|
||||
['user_agent' => 'LBRY', 'json_response' => true, 'cache' => $cache]);
|
||||
}
|
||||
|
||||
public static function listRoadmapChangesets($cache = true)
|
||||
{
|
||||
$sets = [];
|
||||
$sets = [];
|
||||
$allReleases = [];
|
||||
|
||||
$projects = [
|
||||
'lbry' => ''
|
||||
];
|
||||
|
||||
foreach($projects as $project => $label)
|
||||
foreach ($projects as $project => $label)
|
||||
{
|
||||
$page = 1;
|
||||
do
|
||||
{
|
||||
$releases = static::get('/repos/lbryio/' . $project . '/releases?page=' . $page, $cache);
|
||||
$page++;
|
||||
$allReleases = array_merge($allReleases, array_map(function($release) use($label, $project) {
|
||||
$allReleases = array_merge($allReleases, array_map(function ($release) use ($label, $project)
|
||||
{
|
||||
return $release + ['project_label' => $label, 'project' => $project];
|
||||
}, array_filter($releases, function ($release) {
|
||||
return isset($release['tag_name']) && isset($release['published_at']) && $release['published_at'] && $release['tag_name'] != 'v0.4.0';
|
||||
}, array_filter($releases, function ($release)
|
||||
{
|
||||
return isset($release['tag_name']) && isset($release['published_at']) && $release['published_at'] &&
|
||||
$release['tag_name'] != 'v0.4.0';
|
||||
})));
|
||||
} while (count($releases) >= 30);
|
||||
}
|
||||
|
||||
foreach($allReleases as $release)
|
||||
foreach ($allReleases as $release)
|
||||
{
|
||||
$group = null;
|
||||
$group = null;
|
||||
$matches = null;
|
||||
if (isset($release['tag_name']) && preg_match('/v(\d+)\.(\d+).?(\d+)?/', $release['tag_name'], $matches))
|
||||
{
|
||||
|
@ -70,20 +74,24 @@ class Github
|
|||
}
|
||||
if ($group)
|
||||
{
|
||||
$sets[$group][] = array_intersect_key($release, ['prerelease' => null, 'tag_name' => null, 'published_at' => null, 'project' => null, 'project_label' => null]) + [
|
||||
'date' => date('Y-m-d', strtotime($release['created_at'])), //I thought published_at, but GitHub displays created_at and published_at is out of sync sometimes (0.3.2, 0.3.3)
|
||||
'name' => $release['name'] ?: $release['tag_name'],
|
||||
'github_url' => $release['url'],
|
||||
$sets[$group][] = array_intersect_key($release, [
|
||||
'prerelease' => null, 'tag_name' => null, 'published_at' => null, 'project' => null, 'project_label' => null
|
||||
]) + [
|
||||
'date' => date('Y-m-d', strtotime($release['created_at'])),
|
||||
//I thought published_at, but GitHub displays created_at and published_at is out of sync sometimes (0.3.2, 0.3.3)
|
||||
'name' => $release['name'] ?: $release['tag_name'],
|
||||
'github_url' => $release['url'],
|
||||
'major_version' => $matches[1],
|
||||
'minor_version' => $matches[2],
|
||||
'patch_version' => isset($matches[3]) ? $matches[3] : null,
|
||||
'version' => $matches[1] . '.' . $matches[2] . '.' . (isset($matches[3]) ? $matches[3] : ''),
|
||||
'body' => ParsedownExtra::instance()->text($release['body'])
|
||||
];
|
||||
'version' => $matches[1] . '.' . $matches[2] . '.' . (isset($matches[3]) ? $matches[3] : ''),
|
||||
'body' => ParsedownExtra::instance()->text($release['body'])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
uasort($sets, function($sA, $sB) {
|
||||
uasort($sets, function ($sA, $sB)
|
||||
{
|
||||
if ($sA[0]['project'] != $sB[0]['project'])
|
||||
{
|
||||
return $sA[0]['project'] < $sB[0]['project'] ? -1 : 1;
|
||||
|
@ -99,9 +107,9 @@ class Github
|
|||
return $sA[0]['patch_version'] < $sB[0]['patch_version'] ? -1 : 1;
|
||||
});
|
||||
|
||||
foreach($sets as $group => &$groupSet)
|
||||
foreach ($sets as $group => &$groupSet)
|
||||
{
|
||||
usort($groupSet, function($rA, $rB) {
|
||||
usort($groupSet, function ($rA, $rB) {
|
||||
if ($rA['major_version'] != $rB['major_version'])
|
||||
{
|
||||
return $rA['major_version'] < $rB['major_version'] ? -1 : 1;
|
||||
|
|
23
lib/tools/OS.class.php
Normal file
23
lib/tools/OS.class.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
class OS
|
||||
{
|
||||
const OS_ANDROID = 'android',
|
||||
OS_IOS = 'ios',
|
||||
OS_LINUX = 'linux',
|
||||
OS_OSX = 'osx',
|
||||
OS_WINDOWS = 'windows';
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
//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', 'OS X', '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']
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Os
|
||||
{
|
||||
const OS_ANDROID = 'android',
|
||||
OS_IOS = 'ios',
|
||||
OS_LINUX = 'linux',
|
||||
OS_OSX = 'osx',
|
||||
OS_WINDOWS = 'windows';
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
//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', 'OS X', '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']
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue