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')
|
||||||
|
@ -41,7 +41,7 @@ body {
|
|||||||
.paste-option {
|
.paste-option {
|
||||||
float:right;
|
float:right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
width: 135px;
|
width: 135px;
|
||||||
@ -152,8 +152,8 @@ ol.linenums span:first-child {
|
|||||||
li.L0, li.L1, li.L2, li.L3, li.L4,
|
li.L0, li.L1, li.L2, li.L3, li.L4,
|
||||||
li.L5, li.L6, li.L7, li.L8, li.L9
|
li.L5, li.L6, li.L7, li.L8, li.L9
|
||||||
{
|
{
|
||||||
list-style-type: decimal;
|
list-style-type: decimal;
|
||||||
background: inherit;
|
background: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#clip-container div:hover,
|
#clip-container div:hover,
|
||||||
@ -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(){
|
||||||
});
|
});
|
||||||
@ -169,15 +195,15 @@ $('#content').live('keyup change', function(){
|
|||||||
|
|
||||||
/* Display previous pastes */
|
/* Display previous pastes */
|
||||||
$('.previous-pastes .items').html(zerobin.get_pastes());
|
$('.previous-pastes .items').html(zerobin.get_pastes());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* clone a paste */
|
/* clone a paste */
|
||||||
$('.btn-clone').click(function(e){
|
$('.btn-clone').click(function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
content_clone = '' ;
|
content_clone = '' ;
|
||||||
$("#paste-content li").each(function(index) {
|
$("#paste-content li").each(function(index) {
|
||||||
content_clone = content_clone + $(this).text() + '\n';
|
content_clone = content_clone + $(this).text() + '\n';
|
||||||
});
|
});
|
||||||
$('.submit-form').show();
|
$('.submit-form').show();
|
||||||
$('.paste-form').remove();
|
$('.paste-form').remove();
|
||||||
|
@ -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