mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
User background image optimization
This commit is contained in:
parent
98e110fcc7
commit
47cc73c992
8 changed files with 114 additions and 106 deletions
|
|
@ -126,10 +126,10 @@
|
||||||
{
|
{
|
||||||
_.delay(function () {
|
_.delay(function () {
|
||||||
$('#rl-bg').attr('style', 'background-image: none !important;')
|
$('#rl-bg').attr('style', 'background-image: none !important;')
|
||||||
.backstretch(Links.publicLink(Settings.settingsGet('UserBackgroundHash')), {
|
.backstretch(Links.userBackground(Settings.settingsGet('UserBackgroundHash')), {
|
||||||
'fade': Globals.bAnimationSupported ? 1000 : 0
|
'fade': Globals.bAnimationSupported ? 1000 : 0, 'centeredX': true, 'centeredY': true
|
||||||
}).removeAttr('style');
|
}).removeAttr('style');
|
||||||
}, 2000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socialUsers = _.bind(this.socialUsers, this);
|
this.socialUsers = _.bind(this.socialUsers, this);
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,16 @@
|
||||||
return this.sServer + '/Raw/0/Public/' + sHash + '/';
|
return this.sServer + '/Raw/0/Public/' + sHash + '/';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sHash
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
Links.prototype.userBackground = function (sHash)
|
||||||
|
{
|
||||||
|
return this.sServer + '/Raw/' + this.sSubQuery + this.sSpecSuffix + '/UserBackground/' +
|
||||||
|
this.sSubSubQuery + sHash;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sInboxFolderName = 'INBOX'
|
* @param {string} sInboxFolderName = 'INBOX'
|
||||||
* @return {string}
|
* @return {string}
|
||||||
|
|
|
||||||
|
|
@ -1614,7 +1614,7 @@
|
||||||
Utils.__themeTimer = 0;
|
Utils.__themeTimer = 0;
|
||||||
Utils.__themeAjax = null;
|
Utils.__themeAjax = null;
|
||||||
|
|
||||||
Utils.changeTheme = function (sValue, sHash, themeTrigger, Links)
|
Utils.changeTheme = function (sValue, themeTrigger)
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
oThemeLink = $('#rlThemeLink'),
|
oThemeLink = $('#rlThemeLink'),
|
||||||
|
|
@ -1673,26 +1673,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Links)
|
|
||||||
{
|
|
||||||
var $oBg = $('#rl-bg');
|
|
||||||
if (!sHash)
|
|
||||||
{
|
|
||||||
if ($oBg.data('backstretch'))
|
|
||||||
{
|
|
||||||
$oBg.backstretch('destroy').attr('style', '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$oBg.backstretch(Links.publicLink(sHash), {
|
|
||||||
'fade': Globals.bAnimationSupported ? 1000 : 0,
|
|
||||||
'centeredX': true,
|
|
||||||
'centeredY': true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
themeTrigger(Enums.SaveSettingsStep.TrueResult);
|
themeTrigger(Enums.SaveSettingsStep.TrueResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@
|
||||||
|
|
||||||
self.theme.subscribe(function (sValue) {
|
self.theme.subscribe(function (sValue) {
|
||||||
|
|
||||||
Utils.changeTheme(sValue, '', self.themeTrigger);
|
Utils.changeTheme(sValue, self.themeTrigger);
|
||||||
|
|
||||||
Remote.saveAdminConfig(f3, {
|
Remote.saveAdminConfig(f3, {
|
||||||
'Theme': Utils.trim(sValue)
|
'Theme': Utils.trim(sValue)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
var
|
var
|
||||||
_ = require('_'),
|
_ = require('_'),
|
||||||
|
$ = require('$'),
|
||||||
ko = require('ko'),
|
ko = require('ko'),
|
||||||
|
|
||||||
Jua = require('Jua'),
|
Jua = require('Jua'),
|
||||||
|
|
@ -49,7 +50,7 @@
|
||||||
oTheme.selected(sValue === oTheme.name);
|
oTheme.selected(sValue === oTheme.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
Utils.changeTheme(sValue, this.background.hash(), this.themeTrigger, Links);
|
Utils.changeTheme(sValue, this.themeTrigger);
|
||||||
|
|
||||||
Remote.saveSettings(null, {
|
Remote.saveSettings(null, {
|
||||||
'Theme': sValue
|
'Theme': sValue
|
||||||
|
|
@ -58,7 +59,23 @@
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this.background.hash.subscribe(function (sValue) {
|
this.background.hash.subscribe(function (sValue) {
|
||||||
Utils.changeTheme(this.theme(), sValue, this.themeTrigger, Links);
|
|
||||||
|
var $oBg = $('#rl-bg');
|
||||||
|
if (!sValue)
|
||||||
|
{
|
||||||
|
if ($oBg.data('backstretch'))
|
||||||
|
{
|
||||||
|
$oBg.backstretch('destroy').attr('style', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#rl-bg').attr('style', 'background-image: none !important;').backstretch(
|
||||||
|
Links.userBackground(sValue), {
|
||||||
|
'fade': 1000, 'centeredX': true, 'centeredY': true
|
||||||
|
}).removeAttr('style');
|
||||||
|
}
|
||||||
|
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ html.rl-started-trigger.no-mobile .b-login-content .loginFormWrapper {
|
||||||
&.csstransitions .modal.fade {
|
&.csstransitions .modal.fade {
|
||||||
|
|
||||||
.transition(all 200ms ease-out);
|
.transition(all 200ms ease-out);
|
||||||
transform: scale(.9);
|
transform: scale(1.1);
|
||||||
|
|
||||||
&.in {
|
&.in {
|
||||||
transform: none;
|
transform: none;
|
||||||
|
|
|
||||||
|
|
@ -1567,11 +1567,11 @@ class Actions
|
||||||
{
|
{
|
||||||
$aResult['UserBackgroundName'] = (string) $oSettings->GetConf('UserBackgroundName', $aResult['UserBackgroundName']);
|
$aResult['UserBackgroundName'] = (string) $oSettings->GetConf('UserBackgroundName', $aResult['UserBackgroundName']);
|
||||||
$aResult['UserBackgroundHash'] = (string) $oSettings->GetConf('UserBackgroundHash', $aResult['UserBackgroundHash']);
|
$aResult['UserBackgroundHash'] = (string) $oSettings->GetConf('UserBackgroundHash', $aResult['UserBackgroundHash']);
|
||||||
|
// if (!empty($aResult['UserBackgroundName']) && !empty($aResult['UserBackgroundHash']))
|
||||||
if (!empty($aResult['UserBackgroundHash'])) // TODO
|
// {
|
||||||
{
|
// $aResult['IncludeBackground'] = './?/Raw/&s=/{{USER}}/UserBackground/&ss=/'.
|
||||||
$aResult['IncludeBackground'] = './?/Raw/0/Public/'.$aResult['UserBackgroundHash'].'/';
|
// $aResult['UserBackgroundHash'].'/';
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
$aResult['DefaultIdentityID'] = $oSettingsLocal->GetConf('DefaultIdentityID', $oAccount ? $oAccount->Email() : $aResult['DefaultIdentityID']);
|
$aResult['DefaultIdentityID'] = $oSettingsLocal->GetConf('DefaultIdentityID', $oAccount ? $oAccount->Email() : $aResult['DefaultIdentityID']);
|
||||||
|
|
@ -1593,10 +1593,10 @@ class Actions
|
||||||
$aResult['AllowTwitterSocial'] = false;
|
$aResult['AllowTwitterSocial'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sStaticCache = \md5(APP_VERSION.$this->Plugins()->Hash().$aResult['UserBackgroundHash']);
|
$sStaticCache = \md5(APP_VERSION.$this->Plugins()->Hash());
|
||||||
|
|
||||||
$sTheme = $this->ValidateTheme($sTheme);
|
$sTheme = $this->ValidateTheme($sTheme);
|
||||||
$sNewThemeLink = './?/Css/0/'.($bAdmin ? 'Admin' : 'User').'/-/'.$sTheme.'/-/'.$sStaticCache.'/Hash/';
|
$sNewThemeLink = './?/Css/0/'.($bAdmin ? 'Admin' : 'User').'/-/'.$sTheme.'/-/'.$sStaticCache.'/Hash/-/';
|
||||||
|
|
||||||
$bUserLanguage = false;
|
$bUserLanguage = false;
|
||||||
if (!$bAdmin && !$aResult['Auth'] && !empty($_COOKIE['rllang']) &&
|
if (!$bAdmin && !$aResult['Auth'] && !empty($_COOKIE['rllang']) &&
|
||||||
|
|
@ -5703,35 +5703,16 @@ class Actions
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!$oMessage->GetBcc())
|
if (\is_resource($rMessageStream))
|
||||||
{
|
{
|
||||||
if (\is_resource($rMessageStream))
|
\rewind($rMessageStream);
|
||||||
{
|
|
||||||
\rewind($rMessageStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->MailClient()->MessageAppendStream(
|
|
||||||
$rMessageStream, $iMessageStreamSize, $sSentFolder, array(
|
|
||||||
\MailSo\Imap\Enumerations\MessageFlag::SEEN
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$rAppendMessageStream = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
|
|
||||||
|
|
||||||
$iAppendMessageStreamSize = \MailSo\Base\Utils::MultipleStreamWriter(
|
$this->MailClient()->MessageAppendStream(
|
||||||
$oMessage->ToStream(false), array($rAppendMessageStream), 8192, true, true, true);
|
$rMessageStream, $iMessageStreamSize, $sSentFolder, array(
|
||||||
|
\MailSo\Imap\Enumerations\MessageFlag::SEEN
|
||||||
$this->MailClient()->MessageAppendStream(
|
)
|
||||||
$rAppendMessageStream, $iAppendMessageStreamSize, $sSentFolder, array(
|
);
|
||||||
\MailSo\Imap\Enumerations\MessageFlag::SEEN
|
|
||||||
));
|
|
||||||
|
|
||||||
if (\is_resource($rAppendMessageStream))
|
|
||||||
{
|
|
||||||
@fclose($rAppendMessageStream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (\Exception $oException)
|
catch (\Exception $oException)
|
||||||
{
|
{
|
||||||
|
|
@ -5900,8 +5881,7 @@ class Actions
|
||||||
{
|
{
|
||||||
$mResult = null;
|
$mResult = null;
|
||||||
|
|
||||||
$sData = $this->StorageProvider()->Get(
|
$sData = $this->StorageProvider()->Get($oAccount,
|
||||||
$oAccount,
|
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||||
'contacts_sync'
|
'contacts_sync'
|
||||||
);
|
);
|
||||||
|
|
@ -5943,8 +5923,7 @@ class Actions
|
||||||
|
|
||||||
$mData = $this->getContactsSyncData($oAccount);
|
$mData = $this->getContactsSyncData($oAccount);
|
||||||
|
|
||||||
$bResult = $this->StorageProvider()->Put(
|
$bResult = $this->StorageProvider()->Put($oAccount,
|
||||||
$oAccount,
|
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||||
'contacts_sync',
|
'contacts_sync',
|
||||||
\RainLoop\Utils::EncodeKeyValues(array(
|
\RainLoop\Utils::EncodeKeyValues(array(
|
||||||
|
|
@ -6988,14 +6967,10 @@ class Actions
|
||||||
$oSettings = $this->SettingsProvider()->Load($oAccount);
|
$oSettings = $this->SettingsProvider()->Load($oAccount);
|
||||||
if ($oAccount && $oSettings)
|
if ($oAccount && $oSettings)
|
||||||
{
|
{
|
||||||
$sHash = $oSettings->GetConf('UserBackgroundHash', '');
|
$this->StorageProvider()->Clear($oAccount,
|
||||||
if (!empty($sHash))
|
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||||
{
|
'background'
|
||||||
$this->StorageProvider()->Clear(null,
|
);
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
|
||||||
\RainLoop\KeyPathHelper::PublicFile($sHash)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$oSettings->SetConf('UserBackgroundName', '');
|
$oSettings->SetConf('UserBackgroundName', '');
|
||||||
$oSettings->SetConf('UserBackgroundHash', '');
|
$oSettings->SetConf('UserBackgroundHash', '');
|
||||||
|
|
@ -7041,43 +7016,30 @@ class Actions
|
||||||
$sData = @\stream_get_contents($rData);
|
$sData = @\stream_get_contents($rData);
|
||||||
if (!empty($sData) && 0 < \strlen($sData))
|
if (!empty($sData) && 0 < \strlen($sData))
|
||||||
{
|
{
|
||||||
$iLimit = 3;
|
$sName = $aFile['name'];
|
||||||
while (true)
|
if (empty($sName))
|
||||||
{
|
{
|
||||||
$iLimit--;
|
$sName = '_';
|
||||||
if (0 > $iLimit)
|
|
||||||
{
|
|
||||||
$sHash = '';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sHash = \sha1($sSavedName.\microtime(true).\rand(10000, 99999));
|
|
||||||
if (!$this->StorageProvider()->Get(null,
|
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
|
||||||
\RainLoop\KeyPathHelper::PublicFile($sHash), null))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sHash))
|
if ($this->StorageProvider()->Put($oAccount,
|
||||||
{
|
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||||
if ($this->StorageProvider()->Put(null,
|
'background',
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
\json_encode(array(
|
||||||
\RainLoop\KeyPathHelper::PublicFile($sHash),
|
'Name' => $aFile['name'],
|
||||||
'data:'.$sMimeType.':'.$sData
|
'ContentType' => $sMimeType,
|
||||||
|
'Raw' => \base64_encode($sData)
|
||||||
))
|
))
|
||||||
|
))
|
||||||
|
{
|
||||||
|
$oSettings = $this->SettingsProvider()->Load($oAccount);
|
||||||
|
if ($oSettings)
|
||||||
{
|
{
|
||||||
$sName = $aFile['name'];
|
$sHash = \md5($sName.APP_VERSION.APP_SALT.\rand(1000, 9999).\microtime(true));
|
||||||
|
|
||||||
$oSettings = $this->SettingsProvider()->Load($oAccount);
|
$oSettings->SetConf('UserBackgroundName', $sName);
|
||||||
if ($oSettings)
|
$oSettings->SetConf('UserBackgroundHash', $sHash);
|
||||||
{
|
$this->SettingsProvider()->Save($oAccount, $oSettings);
|
||||||
$oSettings->SetConf('UserBackgroundName', $sName);
|
|
||||||
$oSettings->SetConf('UserBackgroundHash', $sHash);
|
|
||||||
|
|
||||||
$this->SettingsProvider()->Save($oAccount, $oSettings);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7622,6 +7584,42 @@ class Actions
|
||||||
return $this->rawSmart(false, true);
|
return $this->rawSmart(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function RawUserBackground()
|
||||||
|
{
|
||||||
|
$sRawKey = (string) $this->GetActionParam('RawKey', '');
|
||||||
|
$this->verifyCacheByKey($sRawKey);
|
||||||
|
|
||||||
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
|
||||||
|
$sData = $this->StorageProvider()->Get($oAccount,
|
||||||
|
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||||
|
'background'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!empty($sData))
|
||||||
|
{
|
||||||
|
$aData = \json_decode($sData, true);
|
||||||
|
unset($sData);
|
||||||
|
|
||||||
|
if (!empty($aData['ContentType']) && !empty($aData['Raw']) &&
|
||||||
|
\in_array($aData['ContentType'], array('image/png', 'image/jpg', 'image/jpeg')))
|
||||||
|
{
|
||||||
|
$this->cacheByKey($sRawKey);
|
||||||
|
|
||||||
|
@\header('Content-Type: '.$aData['ContentType']);
|
||||||
|
echo \base64_decode($aData['Raw']);
|
||||||
|
unset($aData);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
<meta http-equiv="refresh" content="0; URL=./?/BadBrowser" />
|
<meta http-equiv="refresh" content="0; URL=./?/BadBrowser" />
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<script data-cfasync="false">
|
<script data-cfasync="false">
|
||||||
|
window.__rlt__ = (new Date).getTime();
|
||||||
if (!window.navigator || !window.navigator.cookieEnabled) {
|
if (!window.navigator || !window.navigator.cookieEnabled) {
|
||||||
window.document.location.replace('./?/NoCookie');
|
window.document.location.replace('./?/NoCookie');
|
||||||
}
|
}
|
||||||
|
|
@ -100,8 +101,10 @@
|
||||||
.wait(function () {
|
.wait(function () {
|
||||||
__simplePace(20);
|
__simplePace(20);
|
||||||
if (window.rainloopAppData['IncludeBackground']) {
|
if (window.rainloopAppData['IncludeBackground']) {
|
||||||
$('#rl-bg').attr('style', 'background-image: none !important;').backstretch(window.rainloopAppData['IncludeBackground'], {
|
$('#rl-bg').attr('style', 'background-image: none !important;').backstretch(
|
||||||
'fade': 1000
|
window.rainloopAppData['IncludeBackground'].replace('{{USER}}',
|
||||||
|
(window.__rlah ? window.__rlah() || '0' : '0')), {
|
||||||
|
'fade': 100, 'centeredX': true, 'centeredY': true
|
||||||
}).removeAttr('style');
|
}).removeAttr('style');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue