proxy for external links and preview feature for multiple images

This commit is contained in:
erqan 2014-04-09 15:45:14 +03:00
parent dabff232be
commit 7fdc40fd3c
6 changed files with 38 additions and 22 deletions

View File

@ -956,12 +956,15 @@ button.disabled:hover
max-height: 500px;
max-width: 530px;
width: auto;
display: block;
margin: 0 auto;
}
.preview-container
{
max-height: 500px;
width: 100%;
text-align: center;
overflow-y: auto;
}
.post-stats
{

View File

@ -342,9 +342,20 @@ var postExpandFunction = function( e, postLi )
if ($(previewContainer).children().length == 0) {
var link = originalPost.find("a[rel='nofollow']");
/*is there any link in the post?*/
if (link.siblings().length > 0){
if (/((\.jpe{0,1}g)|(\.gif)|(\.png))$/i.test(link.html())){
$(previewContainer).append($("<img src='" + link.html() + "' class='image-preview' />"));
for (var i=0; i<link.length; i++){
if (/((\.jpe{0,1}g)|(\.gif)|(\.png))$/i.test(link[i].href)){
var url = link[i].href;
if ($.Options.getUseProxyOpt() !== 'disable' && $.Options.getUseProxyForImgOnlyOpt()){
//proxy alternatives may be added to options page...
if ($.Options.getUseProxyOpt() === 'ssl-proxy-my-addr') {
url = 'https://ssl-proxy.my-addr.org/myaddrproxy.php/' +
url.substring(0, url.indexOf(':')) +
url.substr(url.indexOf('/') + 1);
} else if ($.Options.getUseProxyOpt() ==='anonymouse') {
url = 'http://anonymouse.org/cgi-bin/anon-www.cgi/' + url;
}
}
$(previewContainer).append($("<img src='" + url + "' class='image-preview' />"));
}
}
}

View File

@ -204,6 +204,8 @@ if(preferredLanguage == "en"){
"none": "none",
"Custom": "Custom",
"Mentions": "Mentions",
"Use proxy for image preview only": "Use proxy for image preview only",
"Use external links behind a proxy": "Use external links behind a proxy"
};
}
if(preferredLanguage == "es"){
@ -1806,7 +1808,9 @@ if(preferredLanguage == "tr"){
"You are not following anyone because you are not logged in.": "Giriş yapmadığınız için kimseyi takip etmiyorsunuz.",
"You don't have any followers because you are not logged in.": "Giriş yapmadığınız için hiç takipçiniz yok.",
"No one can mention you because you are not logged in.": "Giriş yapmadığınız için kimse adınıza mesaj gönderemiyor.",
"You don't have any profile because you are not logged in.": "Giriş yapmadığınız için profiliniz yok."
"You don't have any profile because you are not logged in.": "Giriş yapmadığınız için profiliniz yok.",
"Use proxy for image preview only": "Vekil sunucuyu sadece resim ön izleme için kullan",
"Use external links behind a proxy": "Harici bağlantılar için vekil sunucu kullan"
};
}

View File

@ -218,7 +218,7 @@ var TwisterOptions = function()
this.setUseProxyOpt = function () {
$('#useProxy')[0].value = this.getUseProxyOpt();
if (this.getProxyOpt() === 'disable')
if (this.getUseProxyOpt() === 'disable')
$('#useProxyForImgOnly').attr('disabled','disabled');
$('#useProxy').on('change', function () {
@ -238,8 +238,8 @@ var TwisterOptions = function()
this.setUseProxyForImgOnlyOpt = function () {
$('#useProxyForImgOnly')[0].checked = this.getUseProxyForImgOnlyOpt();
$('useProxyForImgOnly').on('change', function () {
$.Options.setOption(this.id, this.value);
$('#useProxyForImgOnly').on('change', function () {
$.Options.setOption(this.id, this.checked);
});
}
@ -256,6 +256,8 @@ var TwisterOptions = function()
this.setConvertEmotionsOpt();
this.setConvertSignsOpt();
this.setConvertFractionsOpt();
this.setUseProxyOpt();
this.setUseProxyForImgOnlyOpt();
}
}

View File

@ -195,23 +195,18 @@ function htmlFormatMsg( msg, output, mentions ) {
url = url.replace('&amp;', '&');
var extLinkTemplate = $("#external-page-link-template").clone(true);
extLinkTemplate.removeAttr("id");
var proxy = false;
if ($.Options.getOption('useProxy') === 'disable'){
extLinkTemplate.attr("href",url);
} else if ($.Options.getOption('useProxyForImgOnly')){
if ($.Options.getOption('displayPreview') !== 'disable' && /((\.jpe{0,1}g)|(\.gif)|(\.png))$/i.test(url))
proxy = true;
} else {
proxy = true;
}
if (proxy){
if ($.Options.getUseProxyOpt() !== 'disable' && !$.Options.getUseProxyForImgOnlyOpt()){
//proxy alternatives may be added to options page...
if ($.Options.getOption('useProxy') === 'ssl-proxy-my-addr') {
extLinkTemplate.attr('href', 'https://ssl-proxy.my-addr.com/' +
if ($.Options.getUseProxyOpt() === 'ssl-proxy-my-addr') {
extLinkTemplate.attr('href', 'https://ssl-proxy.my-addr.org/myaddrproxy.php/' +
url.substring(0, url.indexOf(':')) +
url.substr(url.indexOf('/') + 1));
} else if ($.Options.getUseProxyOpt() ==='anonymouse') {
extLinkTemplate.attr('href', 'http://anonymouse.org/cgi-bin/anon-www.cgi/' + url);
}
} else {
extLinkTemplate.attr("href",url);
}
extLinkTemplate.text(url);

View File

@ -160,12 +160,13 @@
<br/>
<div>
<form action="" id="useProxyOpt">
<p class="label">Use links behind a proxy</p>
<p class="label">Use external links behind a proxy</p>
<select name="" id="useProxy">
<option value="disable">none</option>
<option value="ssl-proxy-my-addr">ssl-proxy.my-addr.com</option>
<option value="ssl-proxy-my-addr">ssl-proxy.my-addr.org</option>
<option value="anonymouse">anonymouse.org</option>
</select>
<input name="" id="useProxyForImgOnly" type="checkbox" /> Use proxy for image preview only
<input name="" id="useProxyForImgOnly" type="checkbox" /> <span class="label">Use proxy for image preview only</span>
</form>
</div>
</div>