diff --git a/protected/humhub/docs/guide/theme/migrate-1.4.md b/protected/humhub/docs/guide/theme/migrate-1.4.md
index 6932e6c4a5..7226e603ea 100644
--- a/protected/humhub/docs/guide/theme/migrate-1.4.md
+++ b/protected/humhub/docs/guide/theme/migrate-1.4.md
@@ -2,3 +2,27 @@
- Added jquery.atwho.modified.css to `mentioning.less`
- Minor changes in `notification/views/index.php`
+
+
+## PWA
+
+Remove all icon and web app related head tags such as:
+
+-
+-
+-
+
+
+Remove Metatags:
+
+- apple-mobile-web-app-title
+- apple-mobile-web-app-capable
+- apple-mobile-web-app-status-bar-style
+- mobile-web-app-capable
+- msapplication-TileColor
+- msapplication-TileImage
+- msapplication-TileImage
+- theme-color
+- application-name
+
+
diff --git a/protected/humhub/modules/ui/Events.php b/protected/humhub/modules/ui/Events.php
index 935c1ffbf8..119c79bab3 100644
--- a/protected/humhub/modules/ui/Events.php
+++ b/protected/humhub/modules/ui/Events.php
@@ -20,4 +20,5 @@ class Events
$application = $event->sender;
$application->controllerMap['theme'] = commands\ThemeController::class;
}
+
}
diff --git a/protected/humhub/modules/ui/Module.php b/protected/humhub/modules/ui/Module.php
index 18a26b2bce..724986be99 100644
--- a/protected/humhub/modules/ui/Module.php
+++ b/protected/humhub/modules/ui/Module.php
@@ -23,6 +23,10 @@ class Module extends \humhub\components\Module
*/
public $isCoreModule = true;
+
+ public $themeColor = '';
+
+
/**
* @inheritdoc
*/
diff --git a/protected/humhub/modules/ui/controllers/ManifestController.php b/protected/humhub/modules/ui/controllers/ManifestController.php
new file mode 100644
index 0000000000..d773af7c70
--- /dev/null
+++ b/protected/humhub/modules/ui/controllers/ManifestController.php
@@ -0,0 +1,59 @@
+handleIcons();
+ $this->handlePwa();
+
+ return $this->asJson($this->manifest);
+ }
+
+ private function handlePwa()
+ {
+ $this->manifest['display'] = 'standalone';
+ $this->manifest['start_url'] = Url::home();
+ $this->manifest['name'] = Yii::$app->name;
+ $this->manifest['background_color'] = $this->module->themeColor;
+ $this->manifest['theme_color'] = $this->module->themeColor;
+ }
+
+ private function handleIcons()
+ {
+ $this->manifest['icons'] = [];
+
+ foreach ([48, 72, 96, 192, 512] as $size) {
+ $this->manifest['icons'][] = [
+ 'src' => SiteIcon::getUrl($size),
+ 'type' => 'image/png',
+ 'sizes' => $size . 'x' . $size
+ ];
+ }
+ }
+}
diff --git a/protected/humhub/modules/ui/view/components/View.php b/protected/humhub/modules/ui/view/components/View.php
index 8f7462cd44..9890097b66 100644
--- a/protected/humhub/modules/ui/view/components/View.php
+++ b/protected/humhub/modules/ui/view/components/View.php
@@ -9,6 +9,7 @@
namespace humhub\modules\ui\view\components;
use humhub\libs\Html;
+use humhub\modules\ui\widgets\SiteIcon;
use humhub\widgets\CoreJsConfig;
use humhub\widgets\LayoutAddons;
use yii\helpers\ArrayHelper;
@@ -171,7 +172,12 @@ class View extends \yii\web\View
*/
protected function renderHeadHtml()
{
- return (!Yii::$app->request->isAjax) ? parent::registerCsrfMetaTags() . parent::renderHeadHtml() : parent::renderHeadHtml();
+ if (!Yii::$app->request->isAjax) {
+ SiteIcon::registerMetaTags($this);
+ parent::registerCsrfMetaTags();
+ }
+
+ return parent::renderHeadHtml();
}
public function setStatusMessage($type, $message)
@@ -257,8 +263,8 @@ class View extends \yii\web\View
/**
* Writes the currently registered jsConfig entries and flushes the the config array.
*
- * @since v1.2
* @param string $key see View::registerJs
+ * @since v1.2
*/
protected function flushJsConfig($key = null)
{
diff --git a/protected/humhub/modules/ui/widgets/MobileAppHeader.php b/protected/humhub/modules/ui/widgets/MobileAppHeader.php
new file mode 100644
index 0000000000..297825c479
--- /dev/null
+++ b/protected/humhub/modules/ui/widgets/MobileAppHeader.php
@@ -0,0 +1,47 @@
+getModule('ui');;
+
+ $view->registerMetaTag(['name' => 'theme-color', 'content' => $module->themeColor]);
+ $view->registerMetaTag(['name' => 'application-name', 'content' => Yii::$app->name]);
+
+ // Apple/IOS headers
+ // https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
+ $view->registerMetaTag(['name' => 'apple-mobile-web-app-title', 'content' => Yii::$app->name]);
+ $view->registerMetaTag(['name' => 'apple-mobile-web-app-capable', 'content' => 'yes']);
+ $view->registerMetaTag(['name' => 'apple-mobile-web-app-status-bar-style', 'content' => $module->themeColor]);
+
+ $view->registerLinkTag(['rel' => 'manifest', 'href' => Url::to(['/ui/manifest'])]);
+ }
+
+}
diff --git a/protected/humhub/modules/ui/widgets/SiteIcon.php b/protected/humhub/modules/ui/widgets/SiteIcon.php
index 8a5c9764bd..43fc441d70 100644
--- a/protected/humhub/modules/ui/widgets/SiteIcon.php
+++ b/protected/humhub/modules/ui/widgets/SiteIcon.php
@@ -9,6 +9,7 @@
namespace humhub\modules\ui\widgets;
use humhub\modules\file\libs\FileHelper;
+use humhub\modules\ui\view\components\View;
use Imagine\Image\Box;
use Yii;
use humhub\components\Widget;
@@ -101,4 +102,23 @@ class SiteIcon extends Widget
$fileName = ($size === null) ? 'icon.png' : $size . 'x' . $size . '.png';
return $fileName;
}
+
+
+ /**
+ * @param View $view
+ */
+ public static function registerMetaTags(View $view)
+ {
+ // Add Apple touch icons
+ // https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
+ $view->registerLinkTag(['rel' => 'apple-touch-icon', 'href' => static::getUrl()]);
+ $view->registerLinkTag(['rel' => 'apple-touch-icon', 'href' => static::getUrl(152), 'sizes' => '152x152']);
+ $view->registerLinkTag(['rel' => 'apple-touch-icon', 'href' => static::getUrl(180), 'sizes' => '180x180']);
+ $view->registerLinkTag(['rel' => 'apple-touch-icon', 'href' => static::getUrl(167), 'sizes' => '167x167']);
+
+ // Chrome, Firefox & Co.
+ $view->registerLinkTag(['rel' => 'icon', 'href' => static::getUrl(192), 'sizes' => '192x192']);
+ $view->registerLinkTag(['rel' => 'icon', 'href' => static::getUrl(96), 'sizes' => '96x96']);
+ $view->registerLinkTag(['rel' => 'icon', 'href' => static::getUrl(32), 'sizes' => '32x32']);
+ }
}
diff --git a/themes/HumHub/views/layouts/head.php b/themes/HumHub/views/layouts/head.php
index 557b81890b..e69de29bb2 100644
--- a/themes/HumHub/views/layouts/head.php
+++ b/themes/HumHub/views/layouts/head.php
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-