From 4c8d84d07bf604c4714a025f7e9ac932421413ff Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Mon, 30 Jan 2023 09:10:49 +0100 Subject: [PATCH] Merge NoScript, NoCookie and BadBrowser pages in Index.html --- dev/Styles/@Boot.css | 2 +- dev/boot.js | 16 ++++--- .../0.0.0/app/libraries/RainLoop/Service.php | 10 ++++- .../app/libraries/RainLoop/ServiceActions.php | 23 ---------- .../v/0.0.0/app/localization/en/static.json | 6 +-- .../0.0.0/app/localization/nl-NL/static.json | 10 ++--- .../v/0.0.0/app/templates/BadBrowser.html | 43 ------------------- snappymail/v/0.0.0/app/templates/Index.html | 17 +++++--- 8 files changed, 38 insertions(+), 89 deletions(-) delete mode 100644 snappymail/v/0.0.0/app/templates/BadBrowser.html diff --git a/dev/Styles/@Boot.css b/dev/Styles/@Boot.css index 059c251fe..d5a58b9a2 100644 --- a/dev/Styles/@Boot.css +++ b/dev/Styles/@Boot.css @@ -60,7 +60,7 @@ body#rl-app { width: 100vw; } -#rl-loading, #rl-loading-error { +#rl-loading, #rl-loading-error, #rl-BadBrowser, #rl-NoCookie { color: var(--loading-color, #000); text-shadow: var(--loading-text-shadow); font-size: 30px; diff --git a/dev/boot.js b/dev/boot.js index 308af2848..da2bb20b4 100644 --- a/dev/boot.js +++ b/dev/boot.js @@ -6,11 +6,10 @@ const app = eId('app'), admin = app && '1' == app.dataset.admin, layout = doc.cookie.match(/(^|;) ?rllayout=([^;]+)/) || '', - redirect = path => doc.location.replace(qUri(path)), showError = msg => { let div = eId('loading-error'); - div.append(' ' + msg); + div.append(msg); eId('loading').hidden = true; div.hidden = false; }, @@ -29,9 +28,6 @@ const }); }; -navigator.cookieEnabled || redirect('NoCookie'); -[].flat || redirect('BadBrowser'); - try { let smctoken = doc.cookie.match(/(^|;) ?smctoken=([^;]+)/); smctoken = smctoken ? smctoken[2] : localStorage.getItem('smctoken'); @@ -87,7 +83,15 @@ window.rl = { loadScript: loadScript }; -loadScript(qUri(`${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`)) +if (!navigator.cookieEnabled) { + eId('loading').hidden = true; + eId('NoCookie').hidden = false; +} else if (![].flat) { + eId('loading').hidden = true; + eId('BadBrowser').hidden = false; +} else { + loadScript(qUri(`${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`)) .catch(e => showError(e)); +} })(document); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php index 62490e8e6..fcf426208 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php @@ -148,6 +148,8 @@ abstract class Service $sFaviconPngLink = $sFaviconUrl ?: Utils::WebStaticPath('apple-touch-icon.png'); $sAppleTouchLink = $sFaviconUrl ? '' : Utils::WebStaticPath('apple-touch-icon.png'); + $oActions = Api::Actions(); + $aTemplateParameters = array( '{{BaseAppFaviconPngLinkTag}}' => $sFaviconPngLink ? '' : '', '{{BaseAppFaviconTouchLinkTag}}' => $sAppleTouchLink ? '' : '', @@ -155,7 +157,13 @@ abstract class Service '{{BaseAppManifestLink}}' => Utils::WebStaticPath('manifest.json'), '{{BaseFavIconSvg}}' => $sFaviconUrl ? '' : Utils::WebStaticPath('favicon.svg'), '{{LoadingDescriptionEsc}}' => \htmlspecialchars($oConfig->Get('webmail', 'loading_description', 'SnappyMail'), ENT_QUOTES|ENT_IGNORE, 'UTF-8'), - '{{BaseAppAdmin}}' => $bAdmin ? 1 : 0 + '{{BaseAppAdmin}}' => $bAdmin ? 1 : 0, + + '{{NO_SCRIPT_DESC}}' => \nl2br($oActions->StaticI18N('NO_SCRIPT_TITLE') . "\n" . $oActions->StaticI18N('NO_SCRIPT_DESC')), + '{{NO_COOKIE_TITLE}}' => $oActions->StaticI18N('NO_COOKIE_TITLE'), + '{{NO_COOKIE_DESC}}' => $oActions->StaticI18N('NO_COOKIE_DESC'), + '{{BAD_BROWSER_TITLE}}' => $oActions->StaticI18N('BAD_BROWSER_TITLE'), + '{{BAD_BROWSER_DESC}}' => \nl2br($oActions->StaticI18N('BAD_BROWSER_DESC')) ); $sCacheFileName = ''; diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php index 1927a8ce3..7efe3db55 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php @@ -540,29 +540,6 @@ class ServiceActions return $this->localAppData(true); } - public function ServiceNoScript() : string - { - return $this->localError($this->oActions->StaticI18N('NO_SCRIPT_TITLE'), $this->oActions->StaticI18N('NO_SCRIPT_DESC')); - } - - public function ServiceNoCookie() : string - { - return $this->localError($this->oActions->StaticI18N('NO_COOKIE_TITLE'), $this->oActions->StaticI18N('NO_COOKIE_DESC')); - } - - public function ServiceBadBrowser() : string - { - $sTitle = $this->oActions->StaticI18N('BAD_BROWSER_TITLE'); - $sDesc = \nl2br($this->oActions->StaticI18N('BAD_BROWSER_DESC')); - - \header('Content-Type: text/html; charset=utf-8'); - return \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/BadBrowser.html'), array( - '{{ErrorTitle}}' => $sTitle, - '{{ErrorHeader}}' => $sTitle, - '{{ErrorDesc}}' => $sDesc - )); - } - public function ServiceMailto() : string { $this->oHttp->ServerNoCache(); diff --git a/snappymail/v/0.0.0/app/localization/en/static.json b/snappymail/v/0.0.0/app/localization/en/static.json index c1f10c9bd..e6216a2b0 100644 --- a/snappymail/v/0.0.0/app/localization/en/static.json +++ b/snappymail/v/0.0.0/app/localization/en/static.json @@ -1,9 +1,9 @@ { "BACK_LINK": "Reload", "NO_SCRIPT_TITLE": "JavaScript is required for this application.", - "NO_SCRIPT_DESC": "JavaScript support is not available in your browser.\nPlease enable JavaScript support in your browser settings and retry.\n", + "NO_SCRIPT_DESC": "JavaScript support is not available in your browser.\nPlease enable JavaScript support in your browser settings and retry.", "NO_COOKIE_TITLE": "Cookies support is required for this application.", - "NO_COOKIE_DESC": "Cookies support is not available in your browser.\nPlease enable Cookie support in your browser settings and retry.\n", + "NO_COOKIE_DESC": "Cookies support is not available in your browser.\nPlease enable Cookie support in your browser settings and retry.", "BAD_BROWSER_TITLE": "Your browser is outdated.", - "BAD_BROWSER_DESC": "To use all the features of the application,\ndownload and install one of these browsers:\n" + "BAD_BROWSER_DESC": "To use all the features of the application,\ndownload and install one of the latest browsers." } diff --git a/snappymail/v/0.0.0/app/localization/nl-NL/static.json b/snappymail/v/0.0.0/app/localization/nl-NL/static.json index 9c6623a89..d77c47368 100644 --- a/snappymail/v/0.0.0/app/localization/nl-NL/static.json +++ b/snappymail/v/0.0.0/app/localization/nl-NL/static.json @@ -1,9 +1,9 @@ { "BACK_LINK": "Reload", "NO_SCRIPT_TITLE": "JavaScript is required for this application.", - "NO_SCRIPT_DESC": "JavaScript support is not available in your browser.\nPlease enable JavaScript support in your browser settings and retry.\n", - "NO_COOKIE_TITLE": "Cookies support is required for this application.", - "NO_COOKIE_DESC": "Cookies support is not available in your browser.\nPlease enable Cookie support in your browser settings and retry.\n", - "BAD_BROWSER_TITLE": "Your browser is outdated.", - "BAD_BROWSER_DESC": "Om alle functies van deze applicatie te gebruiken,\ndownload en installeer een van de volgende browsers:\n" + "NO_SCRIPT_DESC": "JavaScript support is not available in your browser.\nPlease enable JavaScript support in your browser settings and retry.", + "NO_COOKIE_TITLE": "Cookie-ondersteuning is vereist voor deze applicatie.", + "NO_COOKIE_DESC": "Cookie-ondersteuning is niet beschikbaar in uw browser.\nSchakel Cookie-ondersteuning in uw browserinstellingen in en probeer het opnieuw.", + "BAD_BROWSER_TITLE": "Uw browser is te oud.", + "BAD_BROWSER_DESC": "Om alle functies van deze applicatie te gebruiken,\ndownload en installeer een van de nieuwste browsers." } diff --git a/snappymail/v/0.0.0/app/templates/BadBrowser.html b/snappymail/v/0.0.0/app/templates/BadBrowser.html deleted file mode 100644 index 50dce0464..000000000 --- a/snappymail/v/0.0.0/app/templates/BadBrowser.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - {{ErrorTitle}} - - - -

{{ErrorHeader}}

-
-
-

{{ErrorDesc}}

- Google Chrome - Microsoft Edge - Mozilla Firefox -
- - diff --git a/snappymail/v/0.0.0/app/templates/Index.html b/snappymail/v/0.0.0/app/templates/Index.html index f77faccc2..73e787573 100644 --- a/snappymail/v/0.0.0/app/templates/Index.html +++ b/snappymail/v/0.0.0/app/templates/Index.html @@ -1,10 +1,6 @@ - - @@ -20,13 +16,21 @@ {{BaseAppFaviconPngLinkTag}} {{BaseAppFaviconTouchLinkTag}} -
{{LoadingDescriptionEsc}}
+ +
+ + + -