mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 15:07:02 +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
|
||||
))));
|
||||
))))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue