diff --git a/.env b/.env deleted file mode 100644 index f179b16..0000000 --- a/.env +++ /dev/null @@ -1,4 +0,0 @@ -COMPOSE_PROJECT_NAME=m2_meanbee_webappmanifest - -PROJECT_HOSTNAME=m2-meanbee-webappmanifest.dev.docker -PROJECT_CERT=dev.docker diff --git a/README.md b/README.md index fb2b8e5..632c1b6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Meanbee_WebAppManifest +# M2Boilerplate WebAppManifest A Magento 2 extension that adds a [Web App Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) to the store. @@ -6,17 +6,9 @@ A Magento 2 extension that adds a [Web App Manifest](https://developer.mozilla.o Install this extension via Composer: - composer require meanbee/magento2-webappmanifest + composer require m2boilerplate/module-web-app-manifest ## Usage Configure the information displayed in the manifest and enable it in * Stores > Configuration > General > Web > Web App Manifest Settings *. -## Development - -### Setting up a development environment - -A Docker development environment is included with the project: - - docker-compose run --rm cli magento-extension-installer Meanbee_WebAppManifest \ - && docker-compose up -d diff --git a/composer.json b/composer.json index ada76bb..8f5d9f8 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,7 @@ { - "name": "meanbee/magento2-webappmanifest", + "name": "m2-boilerplate/module-web-app-manifest", "description": "A Magento 2 extension that adds a Web App Manifest to the store.", "type": "magento2-module", - "version": "1.1.0", "license": [ "MIT" ], @@ -10,6 +9,10 @@ { "name": "Tomas Gerulaitis", "email": "tomas.gerulaitis@meanbee.com" + }, + { + "name": "Thomas Hampe", + "email": "github@hampe.co" } ], "repositories": { @@ -19,17 +22,17 @@ } }, "require": { - "magento/framework": "^101.0.0", - "magento/module-backend": "^100.1.2", - "magento/module-config": "^101.0.0", - "magento/module-store": "^100.1.3" + "magento/framework": ">=101.0.0", + "magento/module-backend": ">=100.1.2", + "magento/module-config": ">=101.0.0", + "magento/module-store": ">=100.1.3" }, "autoload": { "files": [ "src/registration.php" ], "psr-4": { - "Meanbee\\WebAppManifest\\": "src/" + "M2Boilerplate\\WebAppManifest\\": "src/" } } } diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 7e3a16f..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,98 +0,0 @@ -version: "2" -services: - varnish: - image: meanbee/magento2-varnish:latest - hostname: ${PROJECT_HOSTNAME} - ports: - - 80 - environment: - VIRTUAL_HOST: ${PROJECT_HOSTNAME} - VIRTUAL_PORT: 80 - HTTPS_METHOD: noredirect - CERT_NAME: ${PROJECT_CERT} - links: - - web - - web: - image: meanbee/magento2-nginx:1.9 - hostname: web.${PROJECT_HOSTNAME} - ports: - - 80 - volumes_from: - - magento - links: - - fpm - - fpm: - image: meanbee/magento2-php:7.0-fpm - hostname: fpm.${PROJECT_HOSTNAME} - ports: - - 9000 - volumes_from: - - magento - environment: - ENABLE_SENDMAIL: "true" - PHP_ENABLE_XDEBUG: - links: - - db - - cron: - image: meanbee/magento2-php:7.0-cli - hostname: cron.${PROJECT_HOSTNAME} - command: run-cron - volumes_from: - - magento - environment: - ENABLE_SENDMAIL: "true" - links: - - db - - cli: - image: meanbee/magento2-php:7.0-cli - volumes_from: - - magento - environment: - COMPOSER_HOME: /root/.composer - COMPOSER_ALLOW_SUPERUSER: 1 - M2SETUP_INSTALL_DB: "true" - M2SETUP_VERSION: 2.2.* - M2SETUP_USE_SAMPLE_DATA: "true" - M2SETUP_DB_HOST: db - M2SETUP_DB_NAME: magento2 - M2SETUP_DB_USER: magento2 - M2SETUP_DB_PASSWORD: magento2 - M2SETUP_BASE_URL: https://${PROJECT_HOSTNAME}/ - M2SETUP_BACKEND_FRONTNAME: admin - M2SETUP_ADMIN_FIRSTNAME: Admin - M2SETUP_ADMIN_LASTNAME: User - M2SETUP_ADMIN_EMAIL: admin@example.com - M2SETUP_ADMIN_USER: admin - M2SETUP_ADMIN_PASSWORD: password123 - links: - - db - - db: - image: mariadb:10 - ports: - - 3306 - volumes: - - dbdata:/var/lib/mysql - environment: - MYSQL_ROOT_PASSWORD: magento2 - MYSQL_USER: magento2 - MYSQL_PASSWORD: magento2 - MYSQL_DATABASE: magento2 - TERM: dumb - - magento: - image: meanbee/magento2-data:2.2-sample - volumes: - - .:/extensions/Meanbee_WebAppManifest - environment: - SYNC_DESTINATION: /extensions/Meanbee_WebAppManifest/magento - privileged: true - -volumes: - dbdata: - # Database tables - diff --git a/src/Api/Data/ManifestInterface.php b/src/Api/Data/ManifestInterface.php index 8098137..6165605 100644 --- a/src/Api/Data/ManifestInterface.php +++ b/src/Api/Data/ManifestInterface.php @@ -1,6 +1,6 @@ getUrl('m2bp/webAppManifest/cleanResizedImages'); + } +} \ No newline at end of file diff --git a/src/Block/Register.php b/src/Block/Register.php index 289ff81..91d95f5 100644 --- a/src/Block/Register.php +++ b/src/Block/Register.php @@ -1,11 +1,19 @@ config = $config; - $this->template = $template; + $this->pageConfig = $pageConfig; + $this->imageService = $imageService; } - /** - * @inheritdoc - */ - protected function _toHtml() + protected function _prepareLayout() { + // add theme color if ($this->config->isEnabled()) { - return sprintf( - $this->template, - $this->_urlBuilder->getDirectUrl(\Meanbee\WebAppManifest\Controller\Router::MANIFEST_ENDPOINT) - ); - } else { - return ''; + if ($title = $this->config->getShortName()) { + $this->pageConfig->setMetadata('apple-mobile-web-app-title', $title); + } + + $displayType = $this->config->getDisplayType(); + if (in_array($displayType, [Displaytype::FULL_SCREEN, Displaytype::STANDALONE])) { + $this->pageConfig->setMetadata('mobile-web-app-capable', 'yes'); + $this->pageConfig->setMetadata('apple-touch-fullscreen', 'yes'); + $this->pageConfig->setMetadata('apple-mobile-web-app-capable', 'yes'); + $this->pageConfig->setMetadata('apple-mobile-web-app-status-bar-style', 'default'); + $this->generateSplashScreens(); + } + + if ($themeColor = $this->config->getThemeColor()) { + $this->pageConfig->setMetadata('theme-color', $themeColor); + } + if ($icon = $this->config->getIcon()) { + $url = $this->imageService->resize(180, 180); + if ($url) { + $this->pageConfig->addRemotePageAsset($url, '', ['attributes' => ['rel' => 'apple-touch-icon', 'sizes' => '180x180']]); + } + } + $manifestUrl = $this->_urlBuilder->getDirectUrl(Router::MANIFEST_ENDPOINT); + $this->pageConfig->addRemotePageAsset($manifestUrl, '', ['attributes' => ['rel' => 'manifest']]); } + + return parent::_prepareLayout(); + } + + protected function generateSplashScreens() + { + $splashScreen = $this->imageService->resizeSplashScreen(1136, 640); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(2436, 1125); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(1792,828); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(828,1792); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(1334,750); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(1242,2688); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(2208, 1242); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(1125, 2436); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(1242,2208); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(2732,2048); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(2688,1242); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(2224,1668); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(750,1334); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(2048,2732); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(2388,1668); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(1668,2224); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(640,1136); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(1668,2388); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(2048,1536); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)' + ]]); + $splashScreen = $this->imageService->resizeSplashScreen(1536,2048); + $this->pageConfig->addRemotePageAsset($splashScreen, '', ['attributes' => [ + 'rel' => 'apple-touch-startup-image', + 'media' => 'screen and (device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)' + ]]); } } diff --git a/src/Controller/Adminhtml/WebAppManifest/CleanResizedImages.php b/src/Controller/Adminhtml/WebAppManifest/CleanResizedImages.php new file mode 100644 index 0000000..38ab63c --- /dev/null +++ b/src/Controller/Adminhtml/WebAppManifest/CleanResizedImages.php @@ -0,0 +1,68 @@ +filesystem = $filesystem; + } + + /** + * Clean JS/css files cache + * + * @return Redirect + */ + public function execute() + { + try { + $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA)->delete(Image::CACHE_DIRECTORY); + $this->_eventManager->dispatch('m2bp_web_app_manifest_clean_images_cache_after'); + $this->messageManager->addSuccessMessage(__('The resized images cache was cleaned.')); + } catch (LocalizedException $e) { + $this->messageManager->addErrorMessage($e->getMessage()); + } catch (\Exception $e) { + $this->messageManager->addExceptionMessage($e, __('An error occurred while clearing the resized images cache.')); + } + + /** @var Redirect $resultRedirect */ + $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + return $resultRedirect->setPath('adminhtml/cache'); + } +} \ No newline at end of file diff --git a/src/Controller/Index/Json.php b/src/Controller/Index/Json.php index 84da94a..53c6953 100644 --- a/src/Controller/Index/Json.php +++ b/src/Controller/Index/Json.php @@ -1,21 +1,25 @@ actionFactory = $actionFactory; $this->config = $config; diff --git a/src/Helper/Config.php b/src/Helper/Config.php index 28d2b8e..73f5d49 100644 --- a/src/Helper/Config.php +++ b/src/Helper/Config.php @@ -1,6 +1,6 @@ scopeConfig->isSetFlag(static::XML_PATH_ENABLE, ScopeInterface::SCOPE_STORE, $scope); } + + public function getThemeColor($scope = null): ?string + { + return $this->scopeConfig->getValue(static::XML_PATH_THEME_COLOR, ScopeInterface::SCOPE_STORE, $scope); + } + + public function getBackgroundColor($scope = null): ?string + { + return $this->scopeConfig->getValue(static::XML_PATH_BACKGROUND_COLOR, ScopeInterface::SCOPE_STORE, $scope); + } + + public function getIcon($scope = null) + { + return $this->scopeConfig->getValue(static::XML_PATH_ICON, ScopeInterface::SCOPE_STORE, $scope); + } + + public function getShortName($scope = null) + { + return $this->scopeConfig->getValue(static::XML_PATH_SHORT_NAME, ScopeInterface::SCOPE_STORE, $scope); + } + + public function getDisplayType($scope = null) + { + return $this->scopeConfig->getValue(static::XML_PATH_DISPLAY_TYPE, ScopeInterface::SCOPE_STORE, $scope); + } } diff --git a/src/Model/Config/Source/Displaytype.php b/src/Model/Config/Source/Displaytype.php index 65690d4..7f86e0c 100644 --- a/src/Model/Config/Source/Displaytype.php +++ b/src/Model/Config/Source/Displaytype.php @@ -1,9 +1,14 @@ scopeConfig = $scopeConfig; $this->urlBuilder = $urlBuilder; + $this->imageService = $imageService; $this->data = []; $this->populate(); @@ -68,16 +81,16 @@ public function populate() */ protected function populateStoreInformation() { - $this->populateFromConfig("short_name", static::XML_PATH_STORE_INFO_SHORT_NAME); - $this->populateFromConfig("name", static::XML_PATH_STORE_INFO_NAME); - $this->populateFromConfig("description", static::XML_PATH_STORE_INFO_DESCRIPTION, true); + $this->populateFromConfig('short_name', static::XML_PATH_STORE_INFO_SHORT_NAME); + $this->populateFromConfig('name', static::XML_PATH_STORE_INFO_NAME); + $this->populateFromConfig('description', static::XML_PATH_STORE_INFO_DESCRIPTION, true); if ($path = $this->scopeConfig->getValue(static::XML_PATH_STORE_INFO_START_URL, ScopeInterface::SCOPE_STORE)) { $start_url = $this->urlBuilder->getDirectUrl($path); } else { $start_url = $this->urlBuilder->getBaseUrl(); } - $this->data["start_url"] = $start_url; + $this->data['start_url'] = $start_url; return $this; } @@ -89,10 +102,10 @@ protected function populateStoreInformation() */ protected function populateDisplayOptions() { - $this->populateFromConfig("theme_color", static::XML_PATH_DISPLAY_THEME_COLOR, true); - $this->populateFromConfig("background_color", static::XML_PATH_DISPLAY_BACKGROUND_COLOR, true); - $this->populateFromConfig("display", static::XML_PATH_DISPLAY_DISPLAY_TYPE); - $this->populateFromConfig("orientation", static::XML_PATH_DISPLAY_ORIENTATION); + $this->populateFromConfig('theme_color', static::XML_PATH_DISPLAY_THEME_COLOR, true); + $this->populateFromConfig('background_color', static::XML_PATH_DISPLAY_BACKGROUND_COLOR, true); + $this->populateFromConfig('display', static::XML_PATH_DISPLAY_DISPLAY_TYPE); + $this->populateFromConfig('orientation', static::XML_PATH_DISPLAY_ORIENTATION); return $this; } @@ -104,16 +117,27 @@ protected function populateDisplayOptions() */ protected function populateIcons() { - if ($icon = $this->scopeConfig->getValue(static::XML_PATH_ICONS_ICON, ScopeInterface::SCOPE_STORE)) { - $url = implode("", [ - $this->urlBuilder->getBaseUrl(["_type" => UrlInterface::URL_TYPE_MEDIA]), - "webappmanifest/icons/", - $icon, - ]); - - $sizes = $this->scopeConfig->getValue(static::XML_PATH_ICONS_SIZES, ScopeInterface::SCOPE_STORE); + $icon = $this->scopeConfig->getValue(static::XML_PATH_ICONS_ICON, ScopeInterface::SCOPE_STORE); + if (!$icon) { + return $this; + } - $this->data["icons"] = [["src" => $url, "sizes" => $sizes]]; + $this->data['icons'] = []; + $sizes = $this->scopeConfig->getValue(static::XML_PATH_ICONS_SIZES, ScopeInterface::SCOPE_STORE); + $sizes = explode(' ', $sizes); + $sizes = array_map('trim', $sizes); + $sizes = array_filter($sizes); + foreach ($sizes as $size) { + $withAndHeight = explode('x', $size); + if (count($withAndHeight) !== 2) { + continue; + } + list($with, $height) = $withAndHeight; + $url = $this->imageService->resize((int) $with, (int) $height); + if (!$url) { + continue; + } + $this->data['icons'][] = ['src' => $url, 'sizes' => $size, 'purpose' => 'any maskable']; } return $this; diff --git a/src/Service/Image.php b/src/Service/Image.php new file mode 100644 index 0000000..dab3a24 --- /dev/null +++ b/src/Service/Image.php @@ -0,0 +1,140 @@ +filesystem = $filesystem; + $this->imageFactory = $imageFactory; + $this->config = $config; + $this->url = $url; + } + + public function resize(int $width, int $height): ?string + { + $image = $this->config->getIcon(); + if (!$image) { + return null; + } + $directory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); + $path = 'webappmanifest/icons/'.$image; + + if (!$directory->isFile($path)) { + return null; + } + $absolutePath = $directory->getAbsolutePath($path); + + $resizedImage = sprintf('%s/%sx%s/%s', self::CACHE_DIRECTORY, $width, $height, $image); + + if (!$directory->isFile($resizedImage) || !$directory->isReadable($resizedImage)) { + try { + // Only resize image if not already exists. + $imageResize = $this->imageFactory->create(); + $imageResize->open($absolutePath); + $imageResize->constrainOnly(false); + $imageResize->keepTransparency(true); + $imageResize->keepFrame(false); + $imageResize->keepAspectRatio(true); + $imageResize->resize($width, $height); + //destination folder + //save image + $imageResize->save($directory->getAbsolutePath($resizedImage)); + } + catch (\Exception $e) { + return null; + } + } + return $this->url->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]).$resizedImage; + } + + public function resizeSplashScreen(int $width, int $height) + { + $url = $this->resize(round($height*0.2), round($height*0.2)); + if (!$url) { + return null; + } + $baseUrl = $this->url->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]); + $logoPath = str_replace($baseUrl,'', $url); + $image = $this->config->getIcon(); + + $directory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); + $absolutePath = $directory->getAbsolutePath($logoPath); + $resizedImage = sprintf('%s/splash_%sx%s/%s', self::CACHE_DIRECTORY, $width, $height, $image); + if (!$directory->isFile($resizedImage) || !$directory->isReadable($resizedImage)) { + try { + // Only resize image if not already exists. + $imageResize = $this->imageFactory->create(); + $imageResize->open($absolutePath); + $imageResize->constrainOnly(true); + $imageResize->keepTransparency(false); + $imageResize->keepFrame(true); + $imageResize->keepAspectRatio(true); + $backgroundColor = $this->config->getBackgroundColor(); + if ($backgroundColor && strpos($backgroundColor, '#') === 0) { + $backgroundColor = substr($backgroundColor, 1); + $r = null; + $g = null; + $b = null; + if ( strlen( $backgroundColor ) == 6 ) { + list($r, $g, $b ) = [$backgroundColor[0] . $backgroundColor[1], $backgroundColor[2] . $backgroundColor[3], $backgroundColor[4] . $backgroundColor[5]]; + } elseif ( strlen( $backgroundColor ) == 3 ) { + list($r, $g, $b ) = [$backgroundColor[0] . $backgroundColor[0], $backgroundColor[1] . $backgroundColor[1], $backgroundColor[2] . $backgroundColor[2]]; + } + + if ($r && $g && $b) { + $r = hexdec( $r ); + $g = hexdec( $g ); + $b = hexdec( $b ); + $imageResize->backgroundColor([$r, $g, $b]); + } + } + + + $imageResize->resize($width, $height); + //destination folder + //save image + $imageResize->save($directory->getAbsolutePath($resizedImage)); + } + catch (\Exception $e) { + return null; + } + } + return $this->url->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]).$resizedImage; + } +} \ No newline at end of file diff --git a/src/etc/adminhtml/routes.xml b/src/etc/adminhtml/routes.xml new file mode 100644 index 0000000..80214d4 --- /dev/null +++ b/src/etc/adminhtml/routes.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/etc/adminhtml/system.xml b/src/etc/adminhtml/system.xml index 838f472..7063499 100644 --- a/src/etc/adminhtml/system.xml +++ b/src/etc/adminhtml/system.xml @@ -32,12 +32,12 @@ - Meanbee\WebAppManifest\Model\Config\Source\Displaytype + M2Boilerplate\WebAppManifest\Model\Config\Source\Displaytype - Meanbee\WebAppManifest\Model\Config\Source\Orientation + M2Boilerplate\WebAppManifest\Model\Config\Source\Orientation diff --git a/src/etc/config.xml b/src/etc/config.xml index 341b677..54cbc09 100644 --- a/src/etc/config.xml +++ b/src/etc/config.xml @@ -7,7 +7,7 @@ 0 browser any - 48x48 72x72 128x128 256x256 + 48x48 72x72 128x128 192x192 256x256 512x512 diff --git a/src/etc/di.xml b/src/etc/di.xml index befad3b..ff82153 100644 --- a/src/etc/di.xml +++ b/src/etc/di.xml @@ -1,4 +1,4 @@ - + diff --git a/src/etc/frontend/di.xml b/src/etc/frontend/di.xml index 4ce71fd..5119040 100644 --- a/src/etc/frontend/di.xml +++ b/src/etc/frontend/di.xml @@ -4,16 +4,11 @@ - Meanbee\WebAppManifest\Controller\Router + M2Boilerplate\WebAppManifest\Controller\Router false 55 - - - ]]> - - diff --git a/src/etc/frontend/routes.xml b/src/etc/frontend/routes.xml index a20ed17..7cf3f73 100644 --- a/src/etc/frontend/routes.xml +++ b/src/etc/frontend/routes.xml @@ -2,7 +2,7 @@ - + diff --git a/src/etc/module.xml b/src/etc/module.xml index b707d21..b8ee84d 100644 --- a/src/etc/module.xml +++ b/src/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/src/registration.php b/src/registration.php index 975e65f..911cd50 100644 --- a/src/registration.php +++ b/src/registration.php @@ -2,6 +2,6 @@ \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, - "Meanbee_WebAppManifest", + "M2Boilerplate_WebAppManifest", __DIR__ ); diff --git a/src/view/adminhtml/layout/adminhtml_cache_index.xml b/src/view/adminhtml/layout/adminhtml_cache_index.xml new file mode 100644 index 0000000..7050244 --- /dev/null +++ b/src/view/adminhtml/layout/adminhtml_cache_index.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/view/adminhtml/templates/system/cache/additional.phtml b/src/view/adminhtml/templates/system/cache/additional.phtml new file mode 100644 index 0000000..df7120e --- /dev/null +++ b/src/view/adminhtml/templates/system/cache/additional.phtml @@ -0,0 +1,9 @@ + +

+ + +

\ No newline at end of file diff --git a/src/view/frontend/layout/default.xml b/src/view/frontend/layout/default.xml index 7b9df7c..13cab3a 100644 --- a/src/view/frontend/layout/default.xml +++ b/src/view/frontend/layout/default.xml @@ -2,7 +2,7 @@ - +