Added resources folder (Code refactoring)

This commit is contained in:
RainLoop Team 2014-08-15 19:18:40 +04:00
parent 25624c280d
commit 79a5c11556
60 changed files with 246 additions and 349 deletions

View file

@ -1186,17 +1186,6 @@ RainLoopApp.prototype.bootstart = function ()
RL.folderInformationMultiply(true);
}, 500);
_.delay(function () {
RL.remote().servicesPics(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
RL.cache().setServicesData(oData.Result);
}
});
}, 2000);
Plugins.runHook('rl-start-user-screens');
RL.pub('rl.bootstart-user-screens');

View file

@ -115,6 +115,16 @@ LinkBuilder.prototype.messageDownloadLink = function (sRequestHash)
return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sRequestHash;
};
/**
* @param {string} sEmail
* @return {string}
*/
LinkBuilder.prototype.avatarLink = function (sEmail)
{
return this.sServer + '/Raw/0/Avatar/' + window.encodeURIComponent(sEmail) + '/';
// return '//secure.gravatar.com/avatar/' + Utils.md5(sEmail.toLowerCase()) + '.jpg?s=80&d=mm';
};
/**
* @return {string}
*/

View file

@ -5,7 +5,6 @@
*/
function AbstractCacheStorage()
{
this.oServices = {};
this.bCapaGravatar = RL.capa(Enums.Capa.Gravatar);
}
@ -21,7 +20,7 @@ AbstractCacheStorage.prototype.bCapaGravatar = false;
AbstractCacheStorage.prototype.clear = function ()
{
this.oServices = {};
this.bCapaGravatar = !!this.bCapaGravatar; // TODO
};
/**
@ -31,30 +30,5 @@ AbstractCacheStorage.prototype.clear = function ()
AbstractCacheStorage.prototype.getUserPic = function (sEmail, fCallback)
{
sEmail = Utils.trim(sEmail);
var
sUrl = '',
sService = '',
sEmailLower = sEmail.toLowerCase()
;
sService = sEmailLower.substr(sEmail.indexOf('@') + 1);
sUrl = '' !== sService && this.oServices[sService] ? this.oServices[sService] : '';
if (this.bCapaGravatar && '' === sUrl && '' !== sEmailLower)
{
fCallback('//secure.gravatar.com/avatar/' + Utils.md5(sEmailLower) + '.jpg?s=80&d=mm', sEmail);
}
else
{
fCallback(sUrl, sEmail);
}
};
/**
* @param {Object} oData
*/
AbstractCacheStorage.prototype.setServicesData = function (oData)
{
this.oServices = oData;
fCallback(this.bCapaGravatar && '' !== sEmail ? RL.link().avatarLink(sEmail) : '', sEmail);
};

View file

@ -733,14 +733,6 @@ WebMailAjaxRemoteStorage.prototype.suggestions = function (fCallback, sQuery, iP
}, null, '', ['Suggestions']);
};
/**
* @param {?Function} fCallback
*/
WebMailAjaxRemoteStorage.prototype.servicesPics = function (fCallback)
{
this.defaultRequest(fCallback, 'ServicesPics');
};
/**
* @param {?Function} fCallback
*/

View file

@ -528,6 +528,11 @@ class Http
public function SaveUrlToFile($sUrl, $rFile, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0,
$oLogger = null, $iTimeout = 10, $sProxy = '', $sProxyAuth = '', $aHttpHeaders = array())
{
if (null === $sCustomUserAgent)
{
$sCustomUserAgent = 'MailSo Http User Agent (v1)';
}
if (!is_resource($rFile))
{
if ($oLogger)

View file

@ -5478,22 +5478,6 @@ class Actions
return $this->DefaultResponse(__FUNCTION__, $aResult);
}
/**
* @return array
*/
public function DoServicesPics()
{
$aData = \RainLoop\Utils::ServicesPics();
$aResult = array();
foreach ($aData as $sDomain => $sPic)
{
$aResult[$sDomain] = APP_WEB_STATIC_PATH.'services/'.$sPic;
}
return $this->DefaultResponse(__FUNCTION__, $aResult);
}
/**
* @return array
*/
@ -6493,6 +6477,60 @@ class Actions
return $this->rawSmart(false);
}
/**
* @return bool
*/
public function RawAvatar()
{
$sData = '';
$sRawKey = (string) $this->GetActionParam('RawKey', '');
$sRawKey = \urldecode($sRawKey);
$this->verifyCacheByKey($sRawKey);
if (0 < \strlen($sRawKey) && \preg_match('/^[^@]+@([^@]+)$/', $sRawKey))
{
$sEmail = \MailSo\Base\Utils::IdnToAscii($sRawKey, true);
$iCode = 0;
$sContentType = '';
$sData = $this->Http()->GetUrlAsString('http://gravatar.com/avatar/'.\md5($sEmail).'.jpg?s=80&d=404',
null, $sContentType, $iCode, $this->Logger(), 5,
$this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''));
$sContentType = \strtolower(\trim($sContentType));
if (200 !== $iCode || empty($sData) ||
!\in_array($sContentType, array('image/jpeg', 'image/jpg', 'image/png')))
{
$sData = '';
$aMatch = array();
if (\preg_match('/^[^@]+@([a-z0-9\-\.]+)$/', $sEmail, $aMatch) && !empty($aMatch[1]))
{
$sDomain = $aMatch[1];
if (\file_exists(APP_VERSION_ROOT_PATH.'app/resources/images/services/'.$sDomain.'.png'))
{
$sContentType = 'image/png';
$sData = \file_get_contents(APP_VERSION_ROOT_PATH.'app/resources/images/services/'.$sDomain.'.png');
}
}
}
}
if (empty($sData) || empty($sContentType))
{
$sContentType = 'image/png';
$sData = \file_get_contents(APP_VERSION_ROOT_PATH.'app/resources/images/empty-contact.png');
}
$this->cacheByKey($sRawKey);
\header('Content-Type: '.$sContentType);
echo $sData;
return true;
}
/**
* @return bool
*/

View file

@ -305,66 +305,6 @@ class Utils
@\setcookie($sName, '', \time() - 3600 * 24 * 30, '/');
}
/**
* @return array
*/
public static function ServicesPics()
{
return array(
'ebay.com' => 'ebay.jpg',
'reply.ebay.com' => 'ebay.jpg',
'reply1.ebay.com' => 'ebay.jpg',
'reply2.ebay.com' => 'ebay.jpg',
'reply3.ebay.com' => 'ebay.jpg',
'facebook.com' => 'facebook.png',
'facebookmail.com' => 'facebook.png',
'cnet.online.com' => 'cnet.jpg',
'github.com' => 'github.png',
'steampowered.com' => 'steam.png',
'myspace.com' => 'myspace.png',
'new.myspace.com' => 'myspace.png',
'youtube.com' => 'youtube.gif',
'amazon.com' => 'amazon.png',
'ted.com' => 'ted.png',
'google.com' => 'google.png',
'plus.google.com' => 'google-plus.png',
'email.microsoft.com' => 'microsoft.jpg',
'microsoftonline.com' => 'microsoft.jpg',
'microsoft.com' => 'microsoft.jpg',
'paypal.com' => 'paypal.jpg',
'intl.paypal.com' => 'paypal.jpg',
'e.paypal.com' => 'paypal.jpg',
'ea.com' => 'ea.png',
'em.ea.com' => 'ea.png',
'battlefieldheroes.com' => 'ea.png',
'battle.net' => 'battle.net.png',
'blizzard.com' => 'battle.net.png',
'email.blizzard.com' => 'battle.net.png',
'battlefieldheroes.com' => 'battle.net.png',
'twitter.com' => 'twitter.jpg',
'postmaster.twitter.com' => 'twitter.jpg',
'skype.com' => 'skype.png',
'email.skype.com' => 'skype.png',
'apple.com' => 'apple.jpg',
'id.apple.com' => 'apple.jpg',
'onlive.com' => 'onlive.png',
'news.onlive.com' => 'onlive.png',
'asana.com' => 'asana.png',
'connect.asana.com' => 'asana.png',
);
}
public static function CustomBaseConvert($sNumberInput, $sFromBaseInput = '0123456789', $sToBaseInput = '0123456789')
{
if ($sFromBaseInput === $sToBaseInput)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

Before

Width:  |  Height:  |  Size: 995 B

After

Width:  |  Height:  |  Size: 995 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 6 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View file

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View file

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View file

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -4007,6 +4007,16 @@ LinkBuilder.prototype.messageDownloadLink = function (sRequestHash)
return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sRequestHash;
};
/**
* @param {string} sEmail
* @return {string}
*/
LinkBuilder.prototype.avatarLink = function (sEmail)
{
return this.sServer + '/Raw/0/Avatar/' + window.encodeURIComponent(sEmail) + '/';
// return '//secure.gravatar.com/avatar/' + Utils.md5(sEmail.toLowerCase()) + '.jpg?s=80&d=mm';
};
/**
* @return {string}
*/
@ -8282,7 +8292,6 @@ AdminAjaxRemoteStorage.prototype.adminPing = function (fCallback)
*/
function AbstractCacheStorage()
{
this.oServices = {};
this.bCapaGravatar = RL.capa(Enums.Capa.Gravatar);
}
@ -8298,7 +8307,7 @@ AbstractCacheStorage.prototype.bCapaGravatar = false;
AbstractCacheStorage.prototype.clear = function ()
{
this.oServices = {};
this.bCapaGravatar = !!this.bCapaGravatar; // TODO
};
/**
@ -8308,32 +8317,7 @@ AbstractCacheStorage.prototype.clear = function ()
AbstractCacheStorage.prototype.getUserPic = function (sEmail, fCallback)
{
sEmail = Utils.trim(sEmail);
var
sUrl = '',
sService = '',
sEmailLower = sEmail.toLowerCase()
;
sService = sEmailLower.substr(sEmail.indexOf('@') + 1);
sUrl = '' !== sService && this.oServices[sService] ? this.oServices[sService] : '';
if (this.bCapaGravatar && '' === sUrl && '' !== sEmailLower)
{
fCallback('//secure.gravatar.com/avatar/' + Utils.md5(sEmailLower) + '.jpg?s=80&d=mm', sEmail);
}
else
{
fCallback(sUrl, sEmail);
}
};
/**
* @param {Object} oData
*/
AbstractCacheStorage.prototype.setServicesData = function (oData)
{
this.oServices = oData;
fCallback(this.bCapaGravatar && '' !== sEmail ? RL.link().avatarLink(sEmail) : '', sEmail);
};
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */

File diff suppressed because one or more lines are too long

View file

@ -4010,6 +4010,16 @@ LinkBuilder.prototype.messageDownloadLink = function (sRequestHash)
return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sRequestHash;
};
/**
* @param {string} sEmail
* @return {string}
*/
LinkBuilder.prototype.avatarLink = function (sEmail)
{
return this.sServer + '/Raw/0/Avatar/' + window.encodeURIComponent(sEmail) + '/';
// return '//secure.gravatar.com/avatar/' + Utils.md5(sEmail.toLowerCase()) + '.jpg?s=80&d=mm';
};
/**
* @return {string}
*/
@ -18879,14 +18889,6 @@ WebMailAjaxRemoteStorage.prototype.suggestions = function (fCallback, sQuery, iP
}, null, '', ['Suggestions']);
};
/**
* @param {?Function} fCallback
*/
WebMailAjaxRemoteStorage.prototype.servicesPics = function (fCallback)
{
this.defaultRequest(fCallback, 'ServicesPics');
};
/**
* @param {?Function} fCallback
*/
@ -18951,7 +18953,6 @@ WebMailAjaxRemoteStorage.prototype.socialUsers = function (fCallback)
*/
function AbstractCacheStorage()
{
this.oServices = {};
this.bCapaGravatar = RL.capa(Enums.Capa.Gravatar);
}
@ -18967,7 +18968,7 @@ AbstractCacheStorage.prototype.bCapaGravatar = false;
AbstractCacheStorage.prototype.clear = function ()
{
this.oServices = {};
this.bCapaGravatar = !!this.bCapaGravatar; // TODO
};
/**
@ -18977,32 +18978,7 @@ AbstractCacheStorage.prototype.clear = function ()
AbstractCacheStorage.prototype.getUserPic = function (sEmail, fCallback)
{
sEmail = Utils.trim(sEmail);
var
sUrl = '',
sService = '',
sEmailLower = sEmail.toLowerCase()
;
sService = sEmailLower.substr(sEmail.indexOf('@') + 1);
sUrl = '' !== sService && this.oServices[sService] ? this.oServices[sService] : '';
if (this.bCapaGravatar && '' === sUrl && '' !== sEmailLower)
{
fCallback('//secure.gravatar.com/avatar/' + Utils.md5(sEmailLower) + '.jpg?s=80&d=mm', sEmail);
}
else
{
fCallback(sUrl, sEmail);
}
};
/**
* @param {Object} oData
*/
AbstractCacheStorage.prototype.setServicesData = function (oData)
{
this.oServices = oData;
fCallback(this.bCapaGravatar && '' !== sEmail ? RL.link().avatarLink(sEmail) : '', sEmail);
};
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
@ -21273,17 +21249,6 @@ RainLoopApp.prototype.bootstart = function ()
RL.folderInformationMultiply(true);
}, 500);
_.delay(function () {
RL.remote().servicesPics(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
RL.cache().setServicesData(oData.Result);
}
});
}, 2000);
Plugins.runHook('rl-start-user-screens');
RL.pub('rl.bootstart-user-screens');

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB