namespace Cubist\Backpack\app\Http\Controllers;
use Illuminate\Http\Request;
+use PHP_ICO;
class CubistPWAController extends CubistFrontController
{
public static $androidSizes = [36, 48, 72, 96, 144, 192, 256, 512, 1024];
public static $iosSizes = [57, 72, 76, 114, 120, 144, 152, 167, 182];
- public static $faviconSizes = [16, 32,48,96,144, 192,256,384,512];
+ public static $faviconSizes = [16, 32, 48, 96, 144, 192, 256, 384, 512];
public function manifest(Request $request)
{
$icons = [];
+ foreach (self::$androidSizes as $size) {
+ $icons[] = [
+ 'sizes' => $size . 'x' . $size,
+ 'type' => 'image/png',
+ 'src' => $this->data['global']->getImageUrl('favicon_android', 'favicon_android_' . $size),
+ 'density' => round($size / 48, 3),
+ ];
+ }
$res = ['name' => $this->data['global']->pwa_name,
'short_name' => $this->data['global']->pwa_short_name,
'description' => '',
'display' => 'standalone',
'orientation' => 'any',
- 'background-color' => $this->data['global']->pwa_theme_color,
- 'theme-color' => $this->data['global']->pwa_theme_color,
+ 'background_color' => $this->data['global']->pwa_theme_color,
+ 'theme_color' => $this->data['global']->pwa_theme_color,
'start_url' => '/',
'scope' => '/',
'icons' => $icons];
return response(json_encode($res))->header('Content-Type', 'application/manifest+json');
}
+
+ public function favicon()
+ {
+ $source = $this->data['global']->getImageFile('favicon_android', 'favicon_144');
+ $dest = storage_path('favicon.ico');
+ dd($dest);
+ if (!file_exists($dest) || filemtime($source) > filemtime($dest)) {
+ $ico_lib = new PHP_ICO($source, array(array(16, 16), array(32, 32), array(64, 64), array(128, 128)));
+ $ico_lib->save_ico($dest);
+ }
+ return response(file_get_contents($dest))->header('Content-Type','text/html');
+ }
}