mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
Improve scripts load system
This commit is contained in:
parent
58b9eed8e8
commit
72bf212f67
39 changed files with 916 additions and 411 deletions
|
|
@ -1905,11 +1905,6 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
|||
}
|
||||
}
|
||||
|
||||
$sStaticCache = \md5(APP_VERSION.$this->Plugins()->Hash());
|
||||
|
||||
$sTheme = $this->ValidateTheme($sTheme, $bMobile);
|
||||
$sNewThemeLink = './?/Css/0/'.($bAdmin ? 'Admin' : 'User').'/-/'.$sTheme.'/-/'.$sStaticCache.'/Hash/-/';
|
||||
|
||||
if (!$aResult['Auth'])
|
||||
{
|
||||
if (!$bAdmin)
|
||||
|
|
@ -1923,14 +1918,11 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
|||
}
|
||||
}
|
||||
|
||||
$sPluginsLink = '';
|
||||
if (0 < $this->Plugins()->Count() && $this->Plugins()->HaveJs($bAdmin))
|
||||
{
|
||||
$sPluginsLink = './?/Plugins/0/'.($bAdmin ? 'Admin' : 'User').'/'.$sStaticCache.'/';
|
||||
}
|
||||
$sTheme = $this->ValidateTheme($sTheme, $bMobile);
|
||||
$sStaticCache = $this->StaticCache();
|
||||
|
||||
$aResult['Theme'] = $sTheme;
|
||||
$aResult['NewThemeLink'] = $sNewThemeLink;
|
||||
$aResult['NewThemeLink'] = $this->ThemeLink($sTheme, $bAdmin);
|
||||
|
||||
$aResult['Language'] = $this->ValidateLanguage($sLanguage, '', false);
|
||||
$aResult['LanguageAdmin'] = $this->ValidateLanguage($sLanguageAdmin, '', true);
|
||||
|
|
@ -1940,11 +1932,23 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
|||
$aResult['UserLanguage'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', false, true);
|
||||
$aResult['UserLanguageAdmin'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', true, true);
|
||||
|
||||
$aResult['PluginsLink'] = '';
|
||||
if (0 < $this->Plugins()->Count() && $this->Plugins()->HaveJs($bAdmin))
|
||||
{
|
||||
$aResult['PluginsLink'] = './?/Plugins/0/'.($bAdmin ? 'Admin' : 'User').'/'.$sStaticCache.'/';
|
||||
}
|
||||
|
||||
$aResult['LangLink'] = './?/Lang/0/'.($bAdmin ? 'Admin' : 'App').'/'.
|
||||
($bAdmin ? $aResult['LanguageAdmin'] : $aResult['Language']).'/'.$sStaticCache.'/';
|
||||
|
||||
$aResult['TemplatesLink'] = './?/Templates/0/'.($bAdmin ? 'Admin' : 'App').'/'.$sStaticCache.'/';
|
||||
$aResult['PluginsLink'] = $sPluginsLink;
|
||||
|
||||
$bAppJsDebug = !!$this->Config()->Get('labs', 'use_app_debug_js', false);
|
||||
|
||||
$aResult['StaticLibJsLink'] = $this->StaticPath('js/min/libs.js');
|
||||
$aResult['StaticAppJsLink'] = $this->StaticPath('js/'.($bAppJsDebug ? '' : 'min/').($bAdmin ? 'admin' : 'app').'.js');
|
||||
$aResult['StaticEditorJsLink'] = $this->StaticPath('ckeditor/ckeditor.js');
|
||||
|
||||
$aResult['EditorDefaultType'] = \in_array($aResult['EditorDefaultType'], array('Plain', 'Html', 'HtmlForced', 'PlainForced')) ?
|
||||
$aResult['EditorDefaultType'] : 'Plain';
|
||||
|
||||
|
|
@ -9057,6 +9061,29 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
|||
return $mResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function StaticCache()
|
||||
{
|
||||
static $sCache = null;
|
||||
if (!$sCache)
|
||||
{
|
||||
$sCache = \md5(APP_VERSION.$this->Plugins()->Hash());
|
||||
}
|
||||
return $sCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sTheme
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ThemeLink($sTheme, $bAdmin)
|
||||
{
|
||||
return './?/Css/0/'.($bAdmin ? 'Admin' : 'User').'/-/'.$sTheme.'/-/'.$this->StaticCache().'/Hash/-/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sTheme
|
||||
*
|
||||
|
|
@ -9694,6 +9721,18 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
|||
return isset($aLang[$sKey]) ? $aLang[$sKey] : $sKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPath
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function StaticPath($sPath)
|
||||
{
|
||||
$sResult = \RainLoop\Utils::WebStaticPath().$sPath;
|
||||
return $sResult.(false === \strpos($sResult, '?') ? '?' : '&').
|
||||
($this->IsOpen() ? 'community' : 'standard');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MailSo\Cache\CacheClient|null
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ class Service
|
|||
}
|
||||
|
||||
$sResult .= '<!--';
|
||||
$sResult .= ' [time:'.\substr(\microtime(true) - APP_START, 0, 6);
|
||||
$sResult .= '[time:'.\substr(\microtime(true) - APP_START, 0, 6);
|
||||
|
||||
// $sResult .= '][version:'.APP_VERSION;
|
||||
if ($this->oActions->IsOpen())
|
||||
|
|
@ -241,7 +241,7 @@ class Service
|
|||
$sResult .= '][owncloud:true';
|
||||
}
|
||||
|
||||
$sResult .= '] //-->';
|
||||
$sResult .= ']-->';
|
||||
}
|
||||
|
||||
// Output result
|
||||
|
|
@ -259,9 +259,7 @@ class Service
|
|||
*/
|
||||
private function staticPath($sPath)
|
||||
{
|
||||
$sResult = \RainLoop\Utils::WebStaticPath().$sPath;
|
||||
return $sResult.(false === \strpos($sResult, '?') ? '?' : '&').
|
||||
($this->oActions->IsOpen() ? 'v=community' : 'v=standard');
|
||||
return $this->oActions->StaticPath($sPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -283,42 +281,27 @@ class Service
|
|||
|
||||
$sFaviconUrl = (string) $this->oActions->Config()->Get('webmail', 'favicon_url', '');
|
||||
|
||||
$aData = array(
|
||||
'Language' => $sLanguage,
|
||||
'Theme' => $sTheme,
|
||||
'FaviconPngLink' => $sFaviconUrl ? $sFaviconUrl : $this->staticPath('apple-touch-icon.png'),
|
||||
'AppleTouchLink' => $sFaviconUrl ? '' : $this->staticPath('apple-touch-icon.png'),
|
||||
'AppCssLink' => $this->staticPath('css/app'.($bAppCssDebug ? '' : '.min').'.css'),
|
||||
'BootJsLink' => $this->staticPath('js/'.($bAppJsDebug ? '' : 'min/').'boot.js'),
|
||||
'LibJsLink' => $this->staticPath('js/min/libs.js'),
|
||||
'EditorJsLink' => $this->staticPath('ckeditor/ckeditor.js'),
|
||||
'OpenPgpJsLink' => $this->staticPath('js/min/openpgp.min.js'),
|
||||
'AppJsCommonLink' => $this->staticPath('js/'.($bAppJsDebug ? '' : 'min/').'common.js'),
|
||||
'AppJsLink' => $this->staticPath('js/'.($bAppJsDebug ? '' : 'min/').($bAdmin ? 'admin' : 'app').'.js')
|
||||
);
|
||||
|
||||
$aAdd = array();
|
||||
$aAdd[] = $bMobile ? 'mobile' : 'no-mobile';
|
||||
$aAdd[] = $bMobileDevice ? '1' : '0';
|
||||
$sFaviconPngLink = $sFaviconUrl ? $sFaviconUrl : $this->staticPath('apple-touch-icon.png');
|
||||
$sAppleTouchLink = $sFaviconUrl ? '' : $this->staticPath('apple-touch-icon.png');
|
||||
|
||||
$aTemplateParameters = array(
|
||||
'{{BaseAppDataScriptLink}}' => ($bAdmin ? './?/AdminAppData' : './?/AppData').(0 < \count($aAdd) ? '@'.\implode('-', $aAdd) : '').'/',
|
||||
'{{BaseAppFaviconPngLinkTag}}' => $aData['FaviconPngLink'] ? '<link rel="shortcut icon" href="'.$aData['FaviconPngLink'].'" type="image/png" />' : '',
|
||||
'{{BaseAppFaviconTouchLinkTag}}' => $aData['AppleTouchLink'] ? '<link rel="apple-touch-icon" href="'.$aData['AppleTouchLink'].'" type="image/png" />' : '',
|
||||
'{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'],
|
||||
'{{BaseAppMainCssLink}}' => $aData['AppCssLink'],
|
||||
'{{BaseAppBootScriptLink}}' => $aData['BootJsLink'],
|
||||
'{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'],
|
||||
'{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'],
|
||||
'{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'],
|
||||
'{{BaseAppMainCommonScriptLink}}' => $aData['AppJsCommonLink'],
|
||||
'{{BaseAppMainScriptLink}}' => $aData['AppJsLink'],
|
||||
'{{BaseVersion}}' => APP_VERSION,
|
||||
'{{BaseAppFaviconPngLinkTag}}' => $sFaviconPngLink ? '<link type="image/png" rel="shortcut icon" href="'.$sFaviconPngLink.'" />' : '',
|
||||
'{{BaseAppFaviconTouchLinkTag}}' => $sAppleTouchLink ? '<link type="image/png" rel="apple-touch-icon" href="'.$sAppleTouchLink.'" />' : '',
|
||||
'{{BaseAppMainCssLink}}' => $this->staticPath('css/app'.($bAppCssDebug ? '' : '.min').'.css'),
|
||||
'{{BaseAppThemeCssLink}}' => $this->oActions->ThemeLink($sTheme, $bAdmin),
|
||||
'{{BaseAppBootScriptLink}}' => $this->staticPath('js/'.($bAppJsDebug ? '' : 'min/').'boot.js'),
|
||||
'{{BaseViewport}}' => $bMobile ? 'width=device-width,initial-scale=1,user-scalable=no' : 'width=950,maximum-scale=2',
|
||||
'{{BaseDir}}' => 'ltr'
|
||||
// '{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr'
|
||||
'{{BaseDir}}' => false && \in_array($sLanguage, array('ar', 'he', 'ur')) ? 'rtl' : 'ltr'
|
||||
);
|
||||
|
||||
$aTemplateParameters['{{RainloopBootData}}'] = \json_encode(array(
|
||||
'admin' => $bAdmin,
|
||||
'language' => $sLanguage,
|
||||
'theme' => $sTheme,
|
||||
'mobile' => $bMobile,
|
||||
'mobileDevice' => $bMobileDevice
|
||||
));
|
||||
|
||||
$aTemplateParameters['{{BaseHash}}'] = \md5(
|
||||
\implode('~', array(
|
||||
$bAdmin ? '1' : '0',
|
||||
|
|
|
|||
|
|
@ -1369,9 +1369,8 @@ class ServiceActions
|
|||
private function compileAppData($aAppData, $bWrapByScriptTag = true)
|
||||
{
|
||||
return
|
||||
($bWrapByScriptTag ? '<script data-cfasync="false">' : '').
|
||||
'window.rainloopAppData='.\json_encode($aAppData).';'.
|
||||
'if(window.__rlah_set){__rlah_set()};'.
|
||||
($bWrapByScriptTag ? '<script type="text/javascript" data-cfasync="false">' : '').
|
||||
'if(window.__initAppData){window.__initAppData('.\json_encode($aAppData).');}'.
|
||||
($bWrapByScriptTag ? '</script>' : '')
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -475,12 +475,13 @@ class Utils
|
|||
public static function ClearHtmlOutput($sHtml)
|
||||
{
|
||||
// return $sHtml;
|
||||
return \str_replace('> <', '><',
|
||||
return \trim(\str_replace('> <', '><',
|
||||
\str_replace('" />', '"/>',
|
||||
\preg_replace('/[\s]+ /i', ' ',
|
||||
\preg_replace('/ [\s]+/i', ' ',
|
||||
\preg_replace('/[\r\n\t]+/', ' ',
|
||||
$sHtml
|
||||
))));
|
||||
))))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,74 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="no-js rl-booted-trigger rl-started-trigger" dir="{{BaseDir}}">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta id="rl-head-viewport" name="viewport" content="{{BaseViewport}}">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<noscript>
|
||||
<meta http-equiv="refresh" content="0; URL=./?/NoScript" />
|
||||
</noscript>
|
||||
<!--[if lte IE 8]>
|
||||
<meta http-equiv="refresh" content="0; URL=./?/BadBrowser" />
|
||||
<![endif]-->
|
||||
<script type="text/javascript" data-cfasync="false">
|
||||
if (!window.navigator || !window.navigator.cookieEnabled) {
|
||||
window.document.location.replace('./?/NoCookie');
|
||||
}
|
||||
</script>
|
||||
<meta name="Author" content="RainLoop Team" />
|
||||
<meta name="robots" content="noindex,nofollow,noodp" />
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="viewport" content="{{BaseViewport}}" id="app-head-viewport">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="google" content="notranslate" />
|
||||
<meta name="robots" content="noindex,nofollow,noodp" />
|
||||
<meta name="AppBootData" content='{{RainloopBootData}}' id="app-boot-data" />
|
||||
<title></title>
|
||||
<style>#rl-content{display:none;}#rl-check{display:none;}</style>
|
||||
{{BaseAppFaviconPngLinkTag}}{{BaseAppFaviconTouchLinkTag}}
|
||||
{{BaseAppFaviconPngLinkTag}}
|
||||
{{BaseAppFaviconTouchLinkTag}}
|
||||
<style>#rl-check{display:none}</style>
|
||||
<link type="text/css" rel="stylesheet" href="{{BaseAppMainCssLink}}" />
|
||||
<link type="text/css" rel="stylesheet" id="rlThemeLink" />
|
||||
<script type="text/javascript" data-cfasync="false" src="{{BaseAppBootScriptLink}}"></script>
|
||||
<script type="text/javascript" data-cfasync="false">
|
||||
window.__includeAppScr('{{BaseAppDataScriptLink}}');
|
||||
</script>
|
||||
<script type="text/javascript" data-cfasync="false">
|
||||
if (window.rainloopAppData && window.rainloopAppData['NewThemeLink']) {
|
||||
window.document.getElementById('rlThemeLink').href = window.rainloopAppData['NewThemeLink'];
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" data-cfasync="false">
|
||||
if (window.rainloopAppData && window.rainloopAppData['IncludeCss']) {
|
||||
window.__includeStyle(window.rainloopAppData['IncludeCss']);
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" data-cfasync="false"></script>
|
||||
<link type="text/css" rel="stylesheet" href="{{BaseAppThemeCssLink}}" id="app-theme-link" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="rl-app"></div>
|
||||
<div id="rl-check"></div>
|
||||
<div id="rl-bg" class="thm-body"></div>
|
||||
<div id="rl-loading" class="thm-loading">
|
||||
<div id="rl-loading-desc">Loading</div>
|
||||
<div class="e-spinner">
|
||||
<div class="e-bounce bounce1"></div>
|
||||
<div class="e-bounce bounce2"></div>
|
||||
<div class="e-bounce bounce3"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="rl-loading-error" class="thm-loading">
|
||||
An Error occurred,
|
||||
<br />
|
||||
please refresh the page and try again.
|
||||
<div id="rl-loading-error-additional"></div>
|
||||
</div>
|
||||
<div id="rl-content">
|
||||
<div id="rl-popups"></div>
|
||||
<div id="rl-center">
|
||||
<div id="rl-top"></div>
|
||||
<div id="rl-left"></div>
|
||||
<div id="rl-right"></div>
|
||||
<div id="rl-bottom"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="rl-templates"></div>
|
||||
<div id="rl-hidden"></div>
|
||||
<script type="text/javascript" data-cfasync="false">__showDescription(window.rainloopAppData ? window.rainloopAppData['LoadingDescriptionEsc'] : '');</script>
|
||||
<script type="text/javascript" data-cfasync="false">__runApp('{{BaseAppLibsScriptLink}}', '{{BaseAppMainScriptLink}}', '{{BaseAppEditorScriptLink}}');</script>
|
||||
<script type="text/javascript" data-cfasync="false" src="{{BaseAppBootScriptLink}}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -187,9 +187,39 @@
|
|||
.thm-rgba-background-color(@message-background-color, @message-rgba-background-color);
|
||||
}
|
||||
|
||||
#rl-app{
|
||||
display: block;
|
||||
}
|
||||
|
||||
html.no-css {
|
||||
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: Arial, Verdana, Geneva, sans-serif;
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#rl-loading, #rl-loading-error {
|
||||
position: absolute;
|
||||
font-size: 30px;
|
||||
line-height: 130%;
|
||||
top: 50%;
|
||||
width: 100%;
|
||||
height: 65px;
|
||||
margin: 0;
|
||||
margin-top: -60px;
|
||||
background-color: transparent;
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.progressjs-container {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.thm-body {
|
||||
color: #333;
|
||||
background-color: #aaa;
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@
|
|||
<div class="btn-toolbar">
|
||||
<div class="btn-group btn-group-last pull-right dropdown colored-toggle" data-bind="registrateBootstrapDropdown: true, openDropdownTrigger: accountMenuDropdownTrigger">
|
||||
<a id="top-system-dropdown-id" href="#" tabindex="-1" class="btn single btn-ellipsis btn-block dropdown-toggle system-dropdown" data-toggle="dropdown">
|
||||
<i data-bind="css: {'icon-user': !accounts.loading(), 'icon-spinner animated': accounts.loading()}"
|
||||
></i>
|
||||
<i data-bind="css: {'icon-user': !accounts.loading(), 'icon-spinner animated': accounts.loading()}"></i>
|
||||
<!--
|
||||
<b data-bind="text: accountsUnreadCount, visible: 100 > accountsUnreadCount() && 0 < accountsUnreadCount()"></b>
|
||||
<b data-bind="visible: 99 < accountsUnreadCount()">99+</b>
|
||||
-->
|
||||
|
||||
-->
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue