From 57ff6674384e7d6a18f505fdf51232f42b75cc72 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 13 Jan 2022 10:18:53 +0000 Subject: pwa improvements according to lighthouse --- Zotlabs/Module/Manifest.php | 9 +++++++-- Zotlabs/Render/Theme.php | 4 +++- boot.php | 7 ++++++- include/plugin.php | 4 +++- view/theme/redbasic/php/theme.php | 8 +++++--- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Zotlabs/Module/Manifest.php b/Zotlabs/Module/Manifest.php index 859efe737..4c418a56a 100644 --- a/Zotlabs/Module/Manifest.php +++ b/Zotlabs/Module/Manifest.php @@ -4,11 +4,15 @@ namespace Zotlabs\Module; use App; use Zotlabs\Web\Controller; use Zotlabs\Lib\System; +use Zotlabs\Render\Theme; class Manifest extends Controller { function init() { + // populate App::$theme_info + Theme::current(); + $ret = [ 'name' => ucfirst(System::get_platform_name()), 'short_name' => ucfirst(System::get_platform_name()), @@ -18,12 +22,13 @@ class Manifest extends Controller { [ 'src' => '/images/app/hz-128.png', 'sizes' => '128x128', 'type' => 'image/png' ], [ 'src' => '/images/app/hz-144.png', 'sizes' => '144x144', 'type' => 'image/png' ], [ 'src' => '/images/app/hz-152.png', 'sizes' => '152x152', 'type' => 'image/png' ], - [ 'src' => '/images/app/hz-192.png', 'sizes' => '192x192', 'type' => 'image/png' ], + [ 'src' => '/images/app/hz-192.png', 'sizes' => '192x192', 'type' => 'image/png', 'purpose' => 'any maskable' ], [ 'src' => '/images/app/hz-348.png', 'sizes' => '384x384', 'type' => 'image/png' ], [ 'src' => '/images/app/hz-512.png', 'sizes' => '512x512', 'type' => 'image/png' ], [ 'src' => '/images/app/hz.svg', 'sizes' => '64x64', 'type' => 'image/xml+svg' ] ], - 'theme_color' => '#343a40', + 'theme_color' => App::$theme_info['theme_color'], + 'background_color' => App::$theme_info['background_color'], 'scope' => '/', 'start_url' => z_root(), 'display' => 'standalone', diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 0eebba1ba..2e6ca0c32 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -60,14 +60,16 @@ class Theme { // Allow theme selection of the form 'theme_name:schema_name' $themepair = explode(':', $chosen_theme); - // Check if $chosen_theme is compatible with core. If not fall back to default $info = get_theme_info($themepair[0]); + $compatible = check_plugin_versions($info); if(!$compatible) { $chosen_theme = ''; } + App::$theme_info = $info; + if($chosen_theme && (file_exists('view/theme/' . $themepair[0] . '/css/style.css') || file_exists('view/theme/' . $themepair[0] . '/php/style.php'))) { return($themepair); } diff --git a/boot.php b/boot.php index 8d3953f13..16b81c3d0 100644 --- a/boot.php +++ b/boot.php @@ -1186,6 +1186,8 @@ class App { if($interval < 10000) $interval = 80000; + $theme_color = ((local_channel()) ? get_pconfig(local_channel(), 'redbasic', 'nav_bg') : App::$theme_info['theme_color']); + if(! isset(self::$page['title']) && isset(self::$config['system']['sitename'])) self::$page['title'] = self::$config['system']['sitename']; @@ -1200,13 +1202,17 @@ class App { } } + // webmanifest head_add_link(['rel' => 'manifest', 'href' => '/manifest.json']); self::$meta->set('application-name', Zotlabs\Lib\System::get_platform_name()); self::$meta->set('generator', Zotlabs\Lib\System::get_platform_name()); + self::$meta->set('theme-color', $theme_color); head_add_link(['rel' => 'shortcut icon', 'href' => head_get_icon()]); + head_add_link(['rel' => 'apple-touch-icon', 'href' => '/images/app/hz-192.png']); + $x = [ 'header' => '' ]; /** @@ -2342,7 +2348,6 @@ function construct_page() { $current_theme = Zotlabs\Render\Theme::current(); - // logger('current_theme: ' . print_r($current_theme,true)); // Zotlabs\Render\Theme::debug(); diff --git a/include/plugin.php b/include/plugin.php index 5b041f228..95c9882d0 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -742,7 +742,9 @@ function get_theme_info($theme){ 'credits' => '', 'maintainer' => array(), 'experimental' => false, - 'unsupported' => false + 'unsupported' => false, + 'theme_color' => '', + 'background_color' => '' ); if(file_exists("view/theme/$theme/experimental")) diff --git a/view/theme/redbasic/php/theme.php b/view/theme/redbasic/php/theme.php index 3c07e1582..783bd9d4e 100644 --- a/view/theme/redbasic/php/theme.php +++ b/view/theme/redbasic/php/theme.php @@ -3,12 +3,14 @@ /** * * Name: Redbasic * * Description: Hubzilla standard theme - * * Version: 2.1 - * * MinVersion: 5.9 - * * MaxVersion: 7.0 + * * Version: 2.2 + * * MinVersion: 6.5.13 + * * MaxVersion: 8.0 * * Author: Fabrixxm * * Maintainer: Mike Macgirvin * * Maintainer: Mario Vavti + * * Theme_Color: #343a40 + * * Background_Color: rgb(254,254,254) */ function redbasic_init(&$a) { -- cgit v1.2.3