Browse Source

proxy for external links and preview feature for multiple images

master
erqan 11 years ago
parent
commit
7fdc40fd3c
  1. 3
      css/style.css
  2. 17
      js/interface_common.js
  3. 6
      js/interface_localization.js
  4. 8
      js/options.js
  5. 19
      js/twister_formatpost.js
  6. 7
      options.html

3
css/style.css

@ -956,12 +956,15 @@ button.disabled:hover @@ -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
{

17
js/interface_common.js

@ -342,9 +342,20 @@ var postExpandFunction = function( e, postLi ) @@ -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' />"));
}
}
}

6
js/interface_localization.js

@ -204,6 +204,8 @@ if(preferredLanguage == "en"){ @@ -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"){ @@ -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"
};
}

8
js/options.js

@ -218,7 +218,7 @@ var TwisterOptions = function() @@ -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() @@ -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() @@ -256,6 +256,8 @@ var TwisterOptions = function()
this.setConvertEmotionsOpt();
this.setConvertSignsOpt();
this.setConvertFractionsOpt();
this.setUseProxyOpt();
this.setUseProxyForImgOnlyOpt();
}
}

19
js/twister_formatpost.js

@ -195,23 +195,18 @@ function htmlFormatMsg( msg, output, mentions ) { @@ -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);

7
options.html

@ -160,12 +160,13 @@ @@ -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>

Loading…
Cancel
Save