This commit is contained in:
the-djmaze 2023-01-19 16:46:39 +01:00
parent dba125ad59
commit 79510eb79c
10 changed files with 24 additions and 26 deletions

View file

@ -1,13 +1,13 @@
import { pInt } from 'Common/Utils'; import { pInt } from 'Common/Utils';
import { Settings } from 'Common/Globals'; import { doc, Settings } from 'Common/Globals';
const const
BASE = doc.location.pathname.replace(/\/+$/,'') + '/',
HASH_PREFIX = '#/', HASH_PREFIX = '#/',
SERVER_PREFIX = './?',
adminPath = () => rl.adminArea() && !Settings.app('adminHostUse'), adminPath = () => rl.adminArea() && !Settings.app('adminHostUse'),
prefix = () => SERVER_PREFIX + (adminPath() ? Settings.app('adminPath') : ''); prefix = () => BASE + '?' + (adminPath() ? Settings.app('adminPath') : '');
export const export const
SUB_QUERY_PREFIX = '&q[]=', SUB_QUERY_PREFIX = '&q[]=',
@ -21,7 +21,7 @@ export const
/** /**
* @returns {string} * @returns {string}
*/ */
logoutLink = () => adminPath() ? prefix() : './', logoutLink = () => adminPath() ? prefix() : BASE,
/** /**
* @param {string} type * @param {string} type
@ -30,7 +30,7 @@ export const
* @returns {string} * @returns {string}
*/ */
serverRequestRaw = (type, hash) => serverRequestRaw = (type, hash) =>
SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' BASE + '?/Raw/' + SUB_QUERY_PREFIX + '/'
+ '0/' // Settings.get('AccountHash') ? + '0/' // Settings.get('AccountHash') ?
+ (type + (type
? type + '/' + (hash ? SUB_QUERY_PREFIX + '/' + hash : '') ? type + '/' + (hash ? SUB_QUERY_PREFIX + '/' + hash : '')
@ -45,7 +45,7 @@ export const
serverRequestRaw('Download', download, customSpecSuffix), serverRequestRaw('Download', download, customSpecSuffix),
proxy = url => proxy = url =>
SERVER_PREFIX + '/ProxyExternal/' BASE + '?/ProxyExternal/'
+ btoa(url.replace(/ /g, '%20')).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''), + btoa(url.replace(/ /g, '%20')).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''),
// + b64EncodeJSONSafe(url.replace(/ /g, '%20')), // + b64EncodeJSONSafe(url.replace(/ /g, '%20')),
@ -55,13 +55,16 @@ export const
*/ */
serverRequest = type => prefix() + '/' + type + '/' + SUB_QUERY_PREFIX + '/0/', serverRequest = type => prefix() + '/' + type + '/' + SUB_QUERY_PREFIX + '/0/',
// Is '?/Css/0/Admin' needed?
cssLink = theme => BASE + '?/Css/0/User/-/' + encodeURI(theme) + '/-/' + Date.now() + '/Hash/-/Json/',
/** /**
* @param {string} lang * @param {string} lang
* @param {boolean} isAdmin * @param {boolean} isAdmin
* @returns {string} * @returns {string}
*/ */
langLink = (lang, isAdmin) => langLink = (lang, isAdmin) =>
SERVER_PREFIX + '/Lang/0/' + (isAdmin ? 'Admin' : 'App') BASE + '?/Lang/0/' + (isAdmin ? 'Admin' : 'App')
+ '/' + encodeURI(lang) + '/' + encodeURI(lang)
+ '/' + Settings.app('version') + '/', + '/' + Settings.app('version') + '/',

View file

@ -1,7 +1,7 @@
import ko from 'ko'; import ko from 'ko';
import { $htmlCL, elementById, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals'; import { $htmlCL, elementById, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals';
import { isArray, arrayLength } from 'Common/Utils'; import { isArray, arrayLength } from 'Common/Utils';
import { serverRequestRaw } from 'Common/Links'; import { cssLink, serverRequestRaw } from 'Common/Links';
import { SaveSettingStatus } from 'Common/Enums'; import { SaveSettingStatus } from 'Common/Enums';
let __themeTimer = 0; let __themeTimer = 0;
@ -41,7 +41,7 @@ export const
clearTimer = () => { clearTimer = () => {
__themeTimer = setTimeout(() => themeTrigger(SaveSettingStatus.Idle), 1000); __themeTimer = setTimeout(() => themeTrigger(SaveSettingStatus.Idle), 1000);
}, },
url = themeStyle.dataset.href.replace(/(Admin|User)\/-\/[^/]+\//, '$1/-/' + value + '/') + 'Json/'; url = cssLink(value);
clearTimeout(__themeTimer); clearTimeout(__themeTimer);

View file

@ -1,12 +1,12 @@
(doc => { (doc => {
const const
query = path => doc.location.pathname.replace(/\/+$/,'') + '/?/' + path, qUri = path => doc.location.pathname.replace(/\/+$/,'') + '/?/' + path,
eId = id => doc.getElementById('rl-'+id), eId = id => doc.getElementById('rl-'+id),
app = eId('app'), app = eId('app'),
admin = app && '1' == app.dataset.admin, admin = app && '1' == app.dataset.admin,
layout = doc.cookie.match(/(^|;) ?rllayout=([^;]+)/) || '', layout = doc.cookie.match(/(^|;) ?rllayout=([^;]+)/) || '',
redirect = path => doc.location.replace(query(path)), redirect = path => doc.location.replace(qUri(path)),
showError = msg => { showError = msg => {
let div = eId('loading-error'); let div = eId('loading-error');
@ -68,7 +68,7 @@ window.rl = {
cb = () => rl.app.bootstart(); cb = () => rl.app.bootstart();
loadScript(url) loadScript(url)
.then(() => loadScript(url.replace('/libs.', `/${admin?'admin':'app'}.`))) .then(() => loadScript(url.replace('/libs.', `/${admin?'admin':'app'}.`)))
.then(() => appData.PluginsLink ? loadScript(appData.PluginsLink) : Promise.resolve()) .then(() => appData.PluginsLink ? loadScript(qUri(appData.PluginsLink)) : Promise.resolve())
.then(() => rl.app .then(() => rl.app
? cb() ? cb()
: doc.addEventListener('readystatechange', () => 'complete' == doc.readyState && cb()) : doc.addEventListener('readystatechange', () => 'complete' == doc.readyState && cb())
@ -87,7 +87,7 @@ window.rl = {
loadScript: loadScript loadScript: loadScript
}; };
loadScript(query(`${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`)) loadScript(qUri(`${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`))
.catch(e => showError(e)); .catch(e => showError(e));
})(document); })(document);

View file

@ -9,6 +9,10 @@ This stylesheet is used when SnappyMail runs in embed mode.
min-height: 100%; min-height: 100%;
} }
#content #rl-app #rl-left, #content #rl-app #rl-right {
position: absolute;
}
.squire-wysiwyg { .squire-wysiwyg {
min-width: 100%; min-width: 100%;
min-height: 100%; min-height: 100%;

View file

@ -66,7 +66,6 @@ class PageController extends Controller
'BaseAppBootScriptNonce' => $sNonce, 'BaseAppBootScriptNonce' => $sNonce,
'BaseLanguage' => $oActions->compileLanguage($sLanguage, $bAdmin), 'BaseLanguage' => $oActions->compileLanguage($sLanguage, $bAdmin),
'BaseAppBootCss' => \file_get_contents(APP_VERSION_ROOT_PATH.'static/css/boot'.$sAppCssMin.'.css'), 'BaseAppBootCss' => \file_get_contents(APP_VERSION_ROOT_PATH.'static/css/boot'.$sAppCssMin.'.css'),
'BaseAppThemeCssLink' => $oActions->ThemeLink($bAdmin),
'BaseAppThemeCss' => \preg_replace( 'BaseAppThemeCss' => \preg_replace(
'/\\s*([:;{},]+)\\s*/s', '/\\s*([:;{},]+)\\s*/s',
'$1', '$1',

View file

@ -1,5 +1,5 @@
<style id="app-boot-css"><?php echo $_['BaseAppBootCss']; ?></style> <style id="app-boot-css"><?php echo $_['BaseAppBootCss']; ?></style>
<style id="app-theme-style" data-href="<?php echo $_['BaseAppThemeCssLink']; ?>"><?php echo $_['BaseAppThemeCss']; ?></style> <style id="app-theme-style"><?php echo $_['BaseAppThemeCss']; ?></style>
<div id="rl-app" data-admin="<?php echo $_['Admin']; ?>" spellcheck="false"> <div id="rl-app" data-admin="<?php echo $_['Admin']; ?>" spellcheck="false">
<div id="rl-loading"> <div id="rl-loading">
<div id="rl-loading-desc"><?php echo $_['LoadingDescriptionEsc']; ?></div> <div id="rl-loading-desc"><?php echo $_['LoadingDescriptionEsc']; ?></div>

View file

@ -869,15 +869,13 @@ class Actions
$aResult['System']['themes'] = $this->GetThemes(); $aResult['System']['themes'] = $this->GetThemes();
} }
$sStaticCache = $this->StaticCache();
$aResult['Theme'] = $this->GetTheme($bAdmin); $aResult['Theme'] = $this->GetTheme($bAdmin);
$aResult['Language'] = $this->ValidateLanguage($sLanguage, '', false); $aResult['Language'] = $this->ValidateLanguage($sLanguage, '', false);
$aResult['UserLanguage'] = $this->ValidateLanguage($UserLanguageRaw, '', false, true); $aResult['UserLanguage'] = $this->ValidateLanguage($UserLanguageRaw, '', false, true);
$aResult['PluginsLink'] = $this->oPlugins->HaveJs($bAdmin) $aResult['PluginsLink'] = $this->oPlugins->HaveJs($bAdmin)
? './?/Plugins/0/' . ($bAdmin ? 'Admin' : 'User') . '/' . $sStaticCache . '/' ? 'Plugins/0/' . ($bAdmin ? 'Admin' : 'User') . '/' . $this->StaticCache() . '/'
: ''; : '';
$bAppJsDebug = $this->oConfig->Get('debug', 'javascript', false) $bAppJsDebug = $this->oConfig->Get('debug', 'javascript', false)

View file

@ -82,11 +82,6 @@ trait Themes
return $aCache; return $aCache;
} }
public function ThemeLink(bool $bAdmin): string
{
return './?/Css/0/' . ($bAdmin ? 'Admin' : 'User') . '/-/' . $this->GetTheme($bAdmin) . '/-/' . $this->StaticCache() . '/Hash/-/';
}
public function ValidateTheme(string $sTheme): string public function ValidateTheme(string $sTheme): string
{ {
return \in_array($sTheme, $this->GetThemes()) ? $sTheme : $this->Config()->Get('themes', 'default', 'Default'); return \in_array($sTheme, $this->GetThemes()) ? $sTheme : $this->Config()->Get('themes', 'default', 'Default');

View file

@ -152,7 +152,6 @@ abstract class Service
'{{BaseAppFaviconPngLinkTag}}' => $sFaviconPngLink ? '<link type="image/png" rel="shortcut icon" href="'.$sFaviconPngLink.'">' : '', '{{BaseAppFaviconPngLinkTag}}' => $sFaviconPngLink ? '<link type="image/png" rel="shortcut icon" href="'.$sFaviconPngLink.'">' : '',
'{{BaseAppFaviconTouchLinkTag}}' => $sAppleTouchLink ? '<link type="image/png" rel="apple-touch-icon" href="'.$sAppleTouchLink.'">' : '', '{{BaseAppFaviconTouchLinkTag}}' => $sAppleTouchLink ? '<link type="image/png" rel="apple-touch-icon" href="'.$sAppleTouchLink.'">' : '',
'{{BaseAppMainCssLink}}' => Utils::WebStaticPath('css/'.($bAdmin ? 'admin' : 'app').$sAppCssMin.'.css'), '{{BaseAppMainCssLink}}' => Utils::WebStaticPath('css/'.($bAdmin ? 'admin' : 'app').$sAppCssMin.'.css'),
'{{BaseAppThemeCssLink}}' => $oActions->ThemeLink($bAdmin),
'{{BaseAppManifestLink}}' => Utils::WebStaticPath('manifest.json'), '{{BaseAppManifestLink}}' => Utils::WebStaticPath('manifest.json'),
'{{BaseFavIconSvg}}' => $sFaviconUrl ? '' : Utils::WebStaticPath('favicon.svg'), '{{BaseFavIconSvg}}' => $sFaviconUrl ? '' : Utils::WebStaticPath('favicon.svg'),
'{{LoadingDescriptionEsc}}' => \htmlspecialchars($oConfig->Get('webmail', 'loading_description', 'SnappyMail'), ENT_QUOTES|ENT_IGNORE, 'UTF-8'), '{{LoadingDescriptionEsc}}' => \htmlspecialchars($oConfig->Get('webmail', 'loading_description', 'SnappyMail'), ENT_QUOTES|ENT_IGNORE, 'UTF-8'),

View file

@ -3,7 +3,7 @@
<head> <head>
<noscript> <noscript>
<meta http-equiv="refresh" content="0; URL=./?/NoScript"> <meta http-equiv="refresh" content="0; URL=?/NoScript">
</noscript> </noscript>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
@ -16,7 +16,7 @@
<link type="text/css" rel="stylesheet" href="{{BaseAppMainCssLink}}"> <link type="text/css" rel="stylesheet" href="{{BaseAppMainCssLink}}">
<link rel="manifest" href="{{BaseAppManifestLink}}"> <link rel="manifest" href="{{BaseAppManifestLink}}">
<link rel="icon" href="{{BaseFavIconSvg}}" type="image/svg+xml"> <link rel="icon" href="{{BaseFavIconSvg}}" type="image/svg+xml">
<style id="app-theme-style" data-href="{{BaseAppThemeCssLink}}">{{BaseAppThemeCss}}</style> <style id="app-theme-style">{{BaseAppThemeCss}}</style>
{{BaseAppFaviconPngLinkTag}} {{BaseAppFaviconPngLinkTag}}
{{BaseAppFaviconTouchLinkTag}} {{BaseAppFaviconTouchLinkTag}}
</head> </head>