mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Code refactoring
This commit is contained in:
parent
7c25098c1b
commit
ff7b71fd6c
9 changed files with 203 additions and 211 deletions
|
|
@ -1121,13 +1121,9 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
if (bValue)
|
||||
{
|
||||
if (window.crypto && window.crypto.getRandomValues && RL.capa(Enums.Capa.OpenPGP))
|
||||
if (window.$LAB && window.crypto && window.crypto.getRandomValues && RL.capa(Enums.Capa.OpenPGP))
|
||||
{
|
||||
$.ajax({
|
||||
'url': RL.link().openPgpJs(),
|
||||
'dataType': 'script',
|
||||
'cache': true,
|
||||
'success': function () {
|
||||
window.$LAB.script(window.openpgp ? '' : RL.link().openPgpJs()).wait(function () {
|
||||
if (window.openpgp)
|
||||
{
|
||||
RL.data().openpgpKeyring = new window.openpgp.Keyring();
|
||||
|
|
@ -1137,7 +1133,6 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
RL.reloadOpenPgpKeys();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -137,8 +137,7 @@ class Api
|
|||
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
|
||||
|
||||
$oStorageProvider = \RainLoop\Api::Actions()->StorageProvider();
|
||||
|
||||
if ($oStorageProvider)
|
||||
if ($oStorageProvider && $oStorageProvider->IsActive())
|
||||
{
|
||||
// TwoFactor Auth User Data
|
||||
$oStorageProvider->Clear(null,
|
||||
|
|
@ -157,12 +156,15 @@ class Api
|
|||
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||
'contacts_sync'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
\RainLoop\Api::Actions()->SettingsProvider()->ClearByEmail($sEmail);
|
||||
|
||||
if (\RainLoop\Api::Actions()->AddressBookProvider() &&
|
||||
\RainLoop\Api::Actions()->AddressBookProvider()->IsActive())
|
||||
{
|
||||
\RainLoop\Api::Actions()->AddressBookProvider()->DeleteAllContactsAndTags($sEmail);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,32 +162,18 @@ class Service
|
|||
@header('Content-Type: text/html; charset=utf-8');
|
||||
$this->oHttp->ServerNoCache();
|
||||
|
||||
$aData = $this->startUpData($bAdmin);
|
||||
$aTemplateParameters = $this->indexTemplateParameters($bAdmin);
|
||||
|
||||
$sCacheFileName = '';
|
||||
if ($this->oActions->Config()->Get('labs', 'cache_system_data', true))
|
||||
{
|
||||
$sCacheFileName = 'TMPL:'.$aData['Hash'];
|
||||
$sCacheFileName = 'TMPL:'.$aTemplateParameters['{{BaseHash}}'];
|
||||
$sResult = $this->oActions->Cacher()->Get($sCacheFileName);
|
||||
}
|
||||
|
||||
if (0 === \strlen($sResult))
|
||||
{
|
||||
$sJsBoot = \file_get_contents(APP_VERSION_ROOT_PATH.'static/js/boot.js');
|
||||
$sResult = \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Index.html'), array(
|
||||
'{{BaseRandHash}}' => \md5(\rand(1000, 9000).\microtime(true)),
|
||||
'{{BaseAppDataScriptLink}}' => ($bAdmin ? './?/AdminAppData/' : './?/AppData/'),
|
||||
'{{BaseAppFaviconIcoFile}}' => $aData['FaviconIcoLink'],
|
||||
'{{BaseAppFaviconPngFile}}' => $aData['FaviconPngLink'],
|
||||
'{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'],
|
||||
'{{BaseAppMainCssLink}}' => $aData['AppCssLink'],
|
||||
'{{BaseAppBootScriptSource}}' => $sJsBoot,
|
||||
'{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'],
|
||||
'{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'],
|
||||
'{{BaseAppMainScriptLink}}' => $aData['AppJsLink'],
|
||||
'{{BaseAppLoadingDescription}}' => \htmlspecialchars($aData['LoadingDescription'], ENT_QUOTES|ENT_IGNORE, 'UTF-8'),
|
||||
'{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr'
|
||||
));
|
||||
$sResult = \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Index.html'), $aTemplateParameters);
|
||||
|
||||
$sResult = \RainLoop\Utils::ClearHtmlOutput($sResult);
|
||||
if (0 < \strlen($sCacheFileName))
|
||||
|
|
@ -204,6 +190,7 @@ class Service
|
|||
$sResult .= ' [version:'.APP_VERSION;
|
||||
$sResult .= '][time:'.\substr(\microtime(true) - APP_START, 0, 6);
|
||||
$sResult .= '][cached:'.($bCached ? 'true' : 'false');
|
||||
$sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}'];
|
||||
$sResult .= '][session:'.\md5(\RainLoop\Utils::GetShortToken());
|
||||
$sResult .= '] -->';
|
||||
}
|
||||
|
|
@ -216,27 +203,12 @@ class Service
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bAppJsDebug
|
||||
* @param bool $bAdmin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateIndexCacheHash($bAppJsDebug, $bAdmin)
|
||||
{
|
||||
return \md5(APP_WEB_PATH.
|
||||
$this->oActions->Config()->Get('webmail', 'loading_description', 'RainLoop').
|
||||
\md5($this->oActions->Config()->Get('cache', 'index', '')).
|
||||
$this->oActions->Plugins()->Hash().
|
||||
APP_VERSION.($bAppJsDebug ? 'd' : 'm').($bAdmin ? 'a' : 'w'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bAdmin
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function startUpData($bAdmin)
|
||||
private function indexTemplateParameters($bAdmin)
|
||||
{
|
||||
$sLanguage = 'en';
|
||||
$sTheme = 'Default';
|
||||
|
|
@ -253,18 +225,46 @@ class Service
|
|||
$bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false);
|
||||
|
||||
$sStaticPrefix = APP_WEB_STATIC_PATH;
|
||||
return array(
|
||||
|
||||
$aData = array(
|
||||
'Language' => $sLanguage,
|
||||
'Theme' => $sTheme,
|
||||
'Hash' => $this->generateIndexCacheHash($bAppJsDebug, $bAdmin),
|
||||
'LoadingDescription' => $this->oActions->Config()->Get('webmail', 'loading_description', 'RainLoop'),
|
||||
'FaviconIcoLink' => $sStaticPrefix.'favicon.ico',
|
||||
'FaviconPngLink' => $sStaticPrefix.'favicon.png',
|
||||
'AppleTouchLink' => $sStaticPrefix.'apple-touch-icon.png',
|
||||
'AppCssLink' => $sStaticPrefix.'css/app'.($bAppCssDebug ? '' : '.min').'.css',
|
||||
'BootJsLink' => $sStaticPrefix.'js/boot.js',
|
||||
'LibJsLink' => $sStaticPrefix.'js/libs.js',
|
||||
'EditorJsLink' => $sStaticPrefix.'ckeditor/ckeditor.js',
|
||||
'OpenPgpJsLink' => $sStaticPrefix.'js/openpgp.min.js',
|
||||
'AppJsLink' => $sStaticPrefix.'js/'.($bAdmin ? 'admin' : 'app').($bAppJsDebug ? '' : '.min').'.js'
|
||||
);
|
||||
|
||||
$aTemplateParameters = array(
|
||||
'{{BaseAppDataScriptLink}}' => ($bAdmin ? './?/AdminAppData/' : './?/AppData/'),
|
||||
'{{BaseAppFaviconIcoFile}}' => $aData['FaviconIcoLink'],
|
||||
'{{BaseAppFaviconPngFile}}' => $aData['FaviconPngLink'],
|
||||
'{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'],
|
||||
'{{BaseAppMainCssLink}}' => $aData['AppCssLink'],
|
||||
'{{BaseAppBootScriptLink}}' => $aData['BootJsLink'],
|
||||
'{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'],
|
||||
'{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'],
|
||||
'{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'],
|
||||
'{{BaseAppMainScriptLink}}' => $aData['AppJsLink'],
|
||||
'{{BaseAppLoadingDescription}}' => \htmlspecialchars($aData['LoadingDescription'], ENT_QUOTES|ENT_IGNORE, 'UTF-8'),
|
||||
'{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr'
|
||||
);
|
||||
|
||||
$aTemplateParameters['{{BaseHash}}'] = \md5(
|
||||
\implode('~', array(
|
||||
\md5($this->oActions->Config()->Get('cache', 'index', '')),
|
||||
$this->oActions->Plugins()->Hash(),
|
||||
APP_WEB_PATH, APP_VERSION
|
||||
)).
|
||||
\implode('~', $aTemplateParameters)
|
||||
);
|
||||
|
||||
return $aTemplateParameters;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@
|
|||
<link rel="apple-touch-icon" href="{{BaseAppAppleTouchFile}}" type="image/png" />
|
||||
<link type="text/css" rel="stylesheet" href="{{BaseAppMainCssLink}}" />
|
||||
<link type="text/css" rel="stylesheet" id="rlThemeLink" />
|
||||
<script type="text/javascript" data-cfasync="false">{{BaseAppBootScriptSource}}</script>
|
||||
<script type="text/javascript" data-cfasync="false" src="{{BaseAppBootScriptLink}}"></script>
|
||||
<script type="text/javascript" data-cfasync="false">
|
||||
__includeScr('{{BaseAppDataScriptLink}}' + (window.__rlah ? window.__rlah() || '0' : '0') + '/{{BaseRandHash}}/');
|
||||
__includeScr('{{BaseAppDataScriptLink}}' + (window.__rlah ? window.__rlah() || '0' : '0') + '/' + Math.random().toString().substr(2) + '/');
|
||||
</script>
|
||||
<script type="text/javascript" data-cfasync="false">
|
||||
if (window.rainloopAppData && window.rainloopAppData['NewThemeLink']) {
|
||||
|
|
|
|||
|
|
@ -21203,13 +21203,9 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
if (bValue)
|
||||
{
|
||||
if (window.crypto && window.crypto.getRandomValues && RL.capa(Enums.Capa.OpenPGP))
|
||||
if (window.$LAB && window.crypto && window.crypto.getRandomValues && RL.capa(Enums.Capa.OpenPGP))
|
||||
{
|
||||
$.ajax({
|
||||
'url': RL.link().openPgpJs(),
|
||||
'dataType': 'script',
|
||||
'cache': true,
|
||||
'success': function () {
|
||||
window.$LAB.script(window.openpgp ? '' : RL.link().openPgpJs()).wait(function () {
|
||||
if (window.openpgp)
|
||||
{
|
||||
RL.data().openpgpKeyring = new window.openpgp.Keyring();
|
||||
|
|
@ -21219,7 +21215,6 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
RL.reloadOpenPgpKeys();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
|
|
|
|||
2
rainloop/v/0.0.0/static/js/app.min.js
vendored
2
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue