mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Added get short url
This commit is contained in:
parent
59f7b9bb56
commit
572a907dc9
@ -153,7 +153,7 @@ class Paste(object):
|
|||||||
if self.expiration == "burn_after_reading":
|
if self.expiration == "burn_after_reading":
|
||||||
self.expiration = self.expiration + '#%s' % datetime.now()
|
self.expiration = self.expiration + '#%s' % datetime.now()
|
||||||
|
|
||||||
# writethe paste
|
# write the paste
|
||||||
with open(self.path, 'w') as f:
|
with open(self.path, 'w') as f:
|
||||||
f.write(unicode(self.expiration) + '\n')
|
f.write(unicode(self.expiration) + '\n')
|
||||||
f.write(self.content + '\n')
|
f.write(self.content + '\n')
|
||||||
|
@ -162,7 +162,7 @@ li.L5, li.L6, li.L7, li.L8, li.L9
|
|||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#copy-success {
|
#copy-success, #short-url-success {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,18 @@ zerobin = {
|
|||||||
if (s<10) {s = "0" + s}
|
if (s<10) {s = "0" + s}
|
||||||
return h+":"+m+":"+s;
|
return h+":"+m+":"+s;
|
||||||
},
|
},
|
||||||
|
/** Get a tinyurl using JSONP */
|
||||||
|
getTinyURL: function(longURL, success) {
|
||||||
|
|
||||||
|
callback = 'zerobin_tiny_url_callback';
|
||||||
|
window[callback] = function(response){
|
||||||
|
success(response.tinyurl);
|
||||||
|
delete window[callback];
|
||||||
|
};
|
||||||
|
|
||||||
|
var api = 'http://json-tinyurl.appspot.com/?url=';
|
||||||
|
$.getJSON(api + encodeURIComponent(longURL) + '&callback=' + callback);
|
||||||
|
},
|
||||||
support_localstorage: function(){
|
support_localstorage: function(){
|
||||||
if (localStorage){
|
if (localStorage){
|
||||||
return true;
|
return true;
|
||||||
@ -123,17 +135,31 @@ if (content && key) {
|
|||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
|
||||||
|
ZeroClipboard.setMoviePath('/static/js/ZeroClipboard.swf' );
|
||||||
|
var clip = new ZeroClipboard.Client();
|
||||||
|
|
||||||
|
$('#short-url').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$('#short-url').text('Loading short url...');
|
||||||
|
zerobin.getTinyURL(window.location.toString(), function(tinyurl){
|
||||||
|
clip.setText(tinyurl);
|
||||||
|
$('#copy-success').hide();
|
||||||
|
$('#short-url-success')
|
||||||
|
.html('Short url: <a href="' + tinyurk + '">' + tinyurk + '</a>')
|
||||||
|
.show('fadeUp');
|
||||||
|
$('#short-url').text('Get short url');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
prettyPrint();
|
prettyPrint();
|
||||||
|
|
||||||
/* Setup flash clipboard button */
|
/* Setup flash clipboard button */
|
||||||
ZeroClipboard.setMoviePath('/static/js/ZeroClipboard.swf' );
|
|
||||||
var clip = new ZeroClipboard.Client();
|
|
||||||
|
|
||||||
clip.addEventListener('onMouseUp', function(){
|
clip.addEventListener('onMouseUp', function(){
|
||||||
clip.setText($('#paste-content').text());
|
clip.setText($('#paste-content').text());
|
||||||
});
|
});
|
||||||
clip.addEventListener('complete', function(){
|
clip.addEventListener('complete', function(){
|
||||||
$('#copy-success').show();
|
$('#copy-success').show('fadeUp');
|
||||||
});
|
});
|
||||||
clip.addEventListener('onLoad', function(){
|
clip.addEventListener('onLoad', function(){
|
||||||
});
|
});
|
||||||
|
@ -17,9 +17,13 @@
|
|||||||
The paste is now in your clipboad
|
The paste is now in your clipboad
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="short-url-success" class="alert alert-success"></div>
|
||||||
|
|
||||||
<div class="well">
|
<div class="well">
|
||||||
<form action="/" method="get" accept-charset="utf-8">
|
<form action="/" method="get" accept-charset="utf-8">
|
||||||
<p>
|
<p>
|
||||||
|
<a id="short-url" href=""
|
||||||
|
target="_blank">Get short url</a> |
|
||||||
<span id="clip-container" style="position:relative">
|
<span id="clip-container" style="position:relative">
|
||||||
<a id="clip-button">Copy To Clipboard</a>
|
<a id="clip-button">Copy To Clipboard</a>
|
||||||
</span>
|
</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user