1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00

Added email obfuscation and dynamic menu entry

This commit is contained in:
sam 2012-05-08 17:52:17 +07:00
parent 5240bf5614
commit 230b762bf4
4 changed files with 65 additions and 13 deletions

View File

@ -31,8 +31,13 @@ GROUP = None
MAX_SIZE = 1024 * 500 MAX_SIZE = 1024 * 500
MAX_SIZE_KB = int(math.ceil(MAX_SIZE / 1024.0)) MAX_SIZE_KB = int(math.ceil(MAX_SIZE / 1024.0))
# Email for contact # Names/links to insert in the menu bar.
EMAIL = "your@email.com" # Any link with "mailto:" will be escaped to prevent spam
MENU = (
('Home', '/'), # internal link
('Download 0bin', 'https://github.com/sametmax/0bin'), # external link
('Contact', 'mailto:your@email.com') # email
)
# this import a file named settings_local.py if it exists # this import a file named settings_local.py if it exists
# you may want to create such a file to have different settings # you may want to create such a file to have different settings

View File

@ -28,6 +28,14 @@ PORT= "8000"
USER = None USER = None
GROUP = None GROUP = None
# Names/links to insert in the menu bar.
# Any link with "mailto:" will be escaped to prevent spam
MENU = (
('Home', '/'), # internal link. First link will be highlited
('Download 0bin', 'https://github.com/sametmax/0bin'), # external link
('Contact', 'mailto:your@email.com') # email
)
# limit size of pasted text in bytes. Be carefull allowing too much size can slow down user's # limit size of pasted text in bytes. Be carefull allowing too much size can slow down user's
# browser # browser
MAX_SIZE = 1024 * 500 MAX_SIZE = 1024 * 500

View File

@ -234,12 +234,23 @@ zerobin = {
}, },
/** Return an link object with the URL as href so you can extract host, /** Return an link object with the URL as href so you can extract host,
protocol, hash, etc*/ protocol, hash, etc.
parseUrl: function(url){
var a = document.createElement('a'); This function use a closure to store a <div> parent for the <a>
a.href = url because IE requires the link be processed by it's HTML parser
return a for the URL to be parsed. */
}, parseUrl: (function(){
var div = document.createElement('div');
div.innerHTML = "<a></a>";
return function(url){
div.firstChild.href = url;
div.innerHTML = div.innerHTML;
return div.firstChild;
};
})(),
getPasteId: function(url){ getPasteId: function(url){
loc = url ? zerobin.parseUrl(url) : window.location loc = url ? zerobin.parseUrl(url) : window.location
@ -631,5 +642,17 @@ $(".close").on('click', function(e){
}); });
/* Parse obfuscaded emails and make them usable */
$('.email-link').each(function(i, elem){
var $obfuscatedEmail = $(this);
var address = $obfuscatedEmail.attr('title').replace('__AT__', '@');
var text = $obfuscatedEmail.text().replace('__AT__', '@');
var $plainTextEmail = $('<a href="mailto:' + address + '">'+ text +'</a>');
$obfuscatedEmail.replaceWith($plainTextEmail);
});
}); /* End of "document ready" jquery callback */ }); /* End of "document ready" jquery callback */

View File

@ -43,10 +43,25 @@
<a class="brand" href="/"><span>ø</span>bin<em>.net</em></a> <a class="brand" href="/"><span>ø</span>bin<em>.net</em></a>
<div class="nav-collapse"> <div class="nav-collapse">
<ul class="nav"> <ul class="nav">
<li class="active"><a href="/">Home</a></li>
<li><a href="https://github.com/sametmax/0bin">Download 0bin</a></li> %for i, entry in enumerate(settings.MENU):
<li><a href="mailto:{{ settings.EMAIL }}">Contact us</a></li> <li
<!-- <li><a href="#faq">Faq</a></li> --> %if not i:
class="active"
%end
>
%if "mailto:" in entry[1]:
<span title="{{ entry[1].replace('mailto:', '').replace('@', '__AT__') }}"
class="email-link" >
{{ entry[0] }}
</span>
%else:
<a href="{{ entry[1] }}">{{ entry[0] }}</a>
%end
</li>
%end
</ul> </ul>
<p class="navbar-text pull-right"><i>"A client side encrypted PasteBin..."</i></p> <p class="navbar-text pull-right"><i>"A client side encrypted PasteBin..."</i></p>
</div><!--/.nav-collapse --> </div><!--/.nav-collapse -->
@ -104,7 +119,8 @@
<p class="greetings span12"> <p class="greetings span12">
Based on an original idea from Based on an original idea from
<a href="http://sebsauvage.net/paste/">sebsauvage.net</a><br> <a href="http://sebsauvage.net/paste/">sebsauvage.net</a><br>
<a href="http://sametmax.com">Sam &amp; Max</a> | <a href="mailto:{{ settings.EMAIL }}"> Contact us</a> <a href="http://sametmax.com">Sam &amp; Max</a> |
<span title="lesametlemax__AT__gmail.com" class="email-link">Contact us</span>
</p> </p>
</footer> </footer>