Add PWA app manifest to public player page.
This commit is contained in:
parent
b8261bbf61
commit
b58004b97a
|
@ -12,6 +12,9 @@ return function (App $app) {
|
|||
$group->get('[/{embed:embed|social}]', Controller\Frontend\PublicPages\PlayerAction::class)
|
||||
->setName('public:index');
|
||||
|
||||
$group->get('/app.webmanifest', Controller\Frontend\PublicPages\AppManifestAction::class)
|
||||
->setName('public:manifest');
|
||||
|
||||
$group->get('/embed-requests', Controller\Frontend\PublicPages\RequestsAction::class)
|
||||
->setName('public:embedrequests');
|
||||
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\Frontend\PublicPages;
|
||||
|
||||
use App\Environment;
|
||||
use App\Exception\StationNotFoundException;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class AppManifestAction
|
||||
{
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
Response $response,
|
||||
Environment $environment
|
||||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
if (!$station->getEnablePublicPage()) {
|
||||
throw new StationNotFoundException();
|
||||
}
|
||||
|
||||
$iconBaseUrl = $environment->getAssetUrl() . '/icons/' . $environment->getAppEnvironment();
|
||||
|
||||
$manifest = [
|
||||
'name' => $station->getName() . ' - AzuraCast',
|
||||
'short_name' => $station->getName(),
|
||||
'description' => $station->getDescription(),
|
||||
'start_url' => '.',
|
||||
'display' => 'minimal-ui',
|
||||
'theme_color' => '#2196F3',
|
||||
'icons' => [
|
||||
[
|
||||
'src' => $iconBaseUrl . '/android-icon-36x36.png',
|
||||
'sizes' => '36x36',
|
||||
'type' => 'image/png',
|
||||
'density' => '0.75',
|
||||
],
|
||||
[
|
||||
'src' => $iconBaseUrl . '/android-icon-48x48.png',
|
||||
'sizes' => '48x48',
|
||||
'type' => 'image/png',
|
||||
'density' => '1.0',
|
||||
],
|
||||
[
|
||||
'src' => $iconBaseUrl . '/android-icon-72x72.png',
|
||||
'sizes' => '72x72',
|
||||
'type' => 'image/png',
|
||||
'density' => '1.5',
|
||||
],
|
||||
[
|
||||
'src' => $iconBaseUrl . '/android-icon-96x96.png',
|
||||
'sizes' => '96x96',
|
||||
'type' => 'image/png',
|
||||
'density' => '2.0',
|
||||
],
|
||||
[
|
||||
'src' => $iconBaseUrl . '/android-icon-144x144.png',
|
||||
'sizes' => '144x144',
|
||||
'type' => 'image/png',
|
||||
'density' => '3.0',
|
||||
],
|
||||
[
|
||||
'src' => $iconBaseUrl . '/android-icon-192x192.png',
|
||||
'sizes' => '192x192',
|
||||
'type' => 'image/png',
|
||||
'density' => '4.0',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$customization = $request->getCustomization();
|
||||
$publicTheme = $customization->getPublicTheme();
|
||||
|
||||
if ($customization::THEME_BROWSER !== $publicTheme) {
|
||||
$manifest['background_color'] = match ($publicTheme) {
|
||||
$customization::THEME_DARK => '#222222',
|
||||
default => '#EEEEEE'
|
||||
};
|
||||
}
|
||||
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/manifest+json')
|
||||
->withJson($manifest);
|
||||
}
|
||||
}
|
|
@ -40,6 +40,7 @@ $assets
|
|||
|
||||
$this->push('head');
|
||||
?>
|
||||
<link rel="manifest" href="<?=(string)$router->fromHere('public:manifest')?>">
|
||||
|
||||
<meta property="og:title" content="<?=$this->e($station->getName())?>">
|
||||
<meta property="og:url" content="<?=$this->e($station->getUrl())?>">
|
||||
|
@ -54,7 +55,6 @@ $this->push('head');
|
|||
)?>">
|
||||
<meta property="twitter:player:width" content="400">
|
||||
<meta property="twitter:player:height" content="125">
|
||||
|
||||
<?php
|
||||
$this->end();
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue