mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Drop privilege
This commit is contained in:
parent
ea93fcf35e
commit
1a4c5d399b
13
settings.py
13
settings.py
@ -15,4 +15,15 @@ DEBUG = True
|
||||
# absolute path where the paste files should be store
|
||||
# default in projectdirectory/static/content/
|
||||
# use "/" even under Windows
|
||||
PASTE_FILES_ROOT = os.path.join(STATIC_FILES_ROOT, 'content')
|
||||
PASTE_FILES_ROOT = os.path.join(STATIC_FILES_ROOT, 'content')
|
||||
|
||||
# Port and host the embeded python server should be using in prod and in dev
|
||||
PROD_HOST = "0.0.0.0"
|
||||
PROD_PORT= "80"
|
||||
DEV_HOST = "127.0.0.1"
|
||||
DEV_PORT= "8000"
|
||||
|
||||
# User and group the server should run as. Set to None if it should be the
|
||||
# current user
|
||||
USER = None
|
||||
GROUP = None
|
@ -156,10 +156,9 @@ li.L5, li.L6, li.L7, li.L8, li.L9
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
#clip-container div:hover,
|
||||
#clip-button:hover,
|
||||
#clip-button a:hover{
|
||||
a#clip-button.hover{
|
||||
cursor:pointer;
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
#copy-success, #short-url-success {
|
||||
|
@ -2,12 +2,12 @@
|
||||
// Author: Joseph Huckaby
|
||||
|
||||
var ZeroClipboard = {
|
||||
|
||||
|
||||
version: "1.0.7",
|
||||
clients: {}, // registered upload clients on page, indexed by id
|
||||
moviePath: 'ZeroClipboard.swf', // URL to movie
|
||||
nextId: 1, // ID of next movie
|
||||
|
||||
|
||||
$: function(thingy) {
|
||||
// simple DOM lookup utility function
|
||||
if (typeof(thingy) == 'string') thingy = document.getElementById(thingy);
|
||||
@ -34,31 +34,31 @@ var ZeroClipboard = {
|
||||
}
|
||||
return thingy;
|
||||
},
|
||||
|
||||
|
||||
setMoviePath: function(path) {
|
||||
// set path to ZeroClipboard.swf
|
||||
this.moviePath = path;
|
||||
},
|
||||
|
||||
|
||||
dispatch: function(id, eventName, args) {
|
||||
// receive event from flash movie, send to client
|
||||
// receive event from flash movie, send to client
|
||||
var client = this.clients[id];
|
||||
if (client) {
|
||||
client.receiveEvent(eventName, args);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
register: function(id, client) {
|
||||
// register new client to receive events
|
||||
this.clients[id] = client;
|
||||
},
|
||||
|
||||
|
||||
getDOMObjectPosition: function(obj, stopObj) {
|
||||
// get absolute coordinates for dom element
|
||||
var info = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: obj.width ? obj.width : obj.offsetWidth,
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: obj.width ? obj.width : obj.offsetWidth,
|
||||
height: obj.height ? obj.height : obj.offsetHeight
|
||||
};
|
||||
|
||||
@ -70,25 +70,25 @@ var ZeroClipboard = {
|
||||
|
||||
return info;
|
||||
},
|
||||
|
||||
|
||||
Client: function(elem) {
|
||||
// constructor for new simple upload client
|
||||
this.handlers = {};
|
||||
|
||||
|
||||
// unique ID
|
||||
this.id = ZeroClipboard.nextId++;
|
||||
this.movieId = 'ZeroClipboardMovie_' + this.id;
|
||||
|
||||
|
||||
// register client with singleton to receive flash events
|
||||
ZeroClipboard.register(this.id, this);
|
||||
|
||||
|
||||
// create movie
|
||||
if (elem) this.glue(elem);
|
||||
}
|
||||
};
|
||||
|
||||
ZeroClipboard.Client.prototype = {
|
||||
|
||||
|
||||
id: 0, // unique ID for us
|
||||
ready: false, // whether movie is ready to receive events or not
|
||||
movie: null, // reference to movie object
|
||||
@ -96,28 +96,28 @@ ZeroClipboard.Client.prototype = {
|
||||
handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor
|
||||
cssEffects: true, // enable CSS mouse effects on dom container
|
||||
handlers: null, // user event handlers
|
||||
|
||||
|
||||
glue: function(elem, appendElem, stylesToAdd) {
|
||||
// glue to DOM element
|
||||
// elem can be ID or actual DOM element object
|
||||
this.domElement = ZeroClipboard.$(elem);
|
||||
|
||||
|
||||
// float just above object, or zIndex 99 if dom element isn't set
|
||||
var zIndex = 99;
|
||||
if (this.domElement.style.zIndex) {
|
||||
zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
|
||||
}
|
||||
|
||||
|
||||
if (typeof(appendElem) == 'string') {
|
||||
appendElem = ZeroClipboard.$(appendElem);
|
||||
}
|
||||
else if (typeof(appendElem) == 'undefined') {
|
||||
appendElem = document.getElementsByTagName('body')[0];
|
||||
}
|
||||
|
||||
|
||||
// find X/Y position of domElement
|
||||
var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem);
|
||||
|
||||
|
||||
// create floating DIV above element
|
||||
this.div = document.createElement('div');
|
||||
var style = this.div.style;
|
||||
@ -127,27 +127,27 @@ ZeroClipboard.Client.prototype = {
|
||||
style.width = '' + box.width + 'px';
|
||||
style.height = '' + box.height + 'px';
|
||||
style.zIndex = zIndex;
|
||||
|
||||
|
||||
if (typeof(stylesToAdd) == 'object') {
|
||||
for (addedStyle in stylesToAdd) {
|
||||
style[addedStyle] = stylesToAdd[addedStyle];
|
||||
}
|
||||
}
|
||||
|
||||
// style.backgroundColor = '#f00'; // debug
|
||||
|
||||
|
||||
//style.backgroundColor = '#f00'; // debug
|
||||
|
||||
appendElem.appendChild(this.div);
|
||||
|
||||
|
||||
this.div.innerHTML = this.getHTML( box.width, box.height );
|
||||
},
|
||||
|
||||
|
||||
getHTML: function(width, height) {
|
||||
// return HTML for movie
|
||||
var html = '';
|
||||
var flashvars = 'id=' + this.id +
|
||||
'&width=' + width +
|
||||
var flashvars = 'id=' + this.id +
|
||||
'&width=' + width +
|
||||
'&height=' + height;
|
||||
|
||||
|
||||
if (navigator.userAgent.match(/MSIE/)) {
|
||||
// IE gets an OBJECT tag
|
||||
var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
|
||||
@ -159,33 +159,33 @@ ZeroClipboard.Client.prototype = {
|
||||
}
|
||||
return html;
|
||||
},
|
||||
|
||||
|
||||
hide: function() {
|
||||
// temporarily hide floater offscreen
|
||||
if (this.div) {
|
||||
this.div.style.left = '-2000px';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
show: function() {
|
||||
// show ourselves after a call to hide()
|
||||
this.reposition();
|
||||
},
|
||||
|
||||
|
||||
destroy: function() {
|
||||
// destroy control and floater
|
||||
if (this.domElement && this.div) {
|
||||
this.hide();
|
||||
this.div.innerHTML = '';
|
||||
|
||||
|
||||
var body = document.getElementsByTagName('body')[0];
|
||||
try { body.removeChild( this.div ); } catch(e) {;}
|
||||
|
||||
|
||||
this.domElement = null;
|
||||
this.div = null;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
reposition: function(elem) {
|
||||
// reposition our floating div, optionally to new container
|
||||
// warning: container CANNOT change size, only position
|
||||
@ -193,7 +193,7 @@ ZeroClipboard.Client.prototype = {
|
||||
this.domElement = ZeroClipboard.$(elem);
|
||||
if (!this.domElement) this.hide();
|
||||
}
|
||||
|
||||
|
||||
if (this.domElement && this.div) {
|
||||
var box = ZeroClipboard.getDOMObjectPosition(this.domElement);
|
||||
var style = this.div.style;
|
||||
@ -201,13 +201,13 @@ ZeroClipboard.Client.prototype = {
|
||||
style.top = '' + box.top + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
setText: function(newText) {
|
||||
// set text to be copied to clipboard
|
||||
this.clipText = newText;
|
||||
if (this.ready) this.movie.setText(newText);
|
||||
},
|
||||
|
||||
|
||||
addEventListener: function(eventName, func) {
|
||||
// add user event listener for event
|
||||
// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
|
||||
@ -215,22 +215,22 @@ ZeroClipboard.Client.prototype = {
|
||||
if (!this.handlers[eventName]) this.handlers[eventName] = [];
|
||||
this.handlers[eventName].push(func);
|
||||
},
|
||||
|
||||
|
||||
setHandCursor: function(enabled) {
|
||||
// enable hand cursor (true), or default arrow cursor (false)
|
||||
this.handCursorEnabled = enabled;
|
||||
if (this.ready) this.movie.setHandCursor(enabled);
|
||||
},
|
||||
|
||||
|
||||
setCSSEffects: function(enabled) {
|
||||
// enable or disable CSS effects on DOM container
|
||||
this.cssEffects = !!enabled;
|
||||
},
|
||||
|
||||
|
||||
receiveEvent: function(eventName, args) {
|
||||
// receive event from flash
|
||||
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
|
||||
|
||||
|
||||
// special behavior for certain events
|
||||
switch (eventName) {
|
||||
case 'load':
|
||||
@ -242,7 +242,7 @@ ZeroClipboard.Client.prototype = {
|
||||
setTimeout( function() { self.receiveEvent('load', null); }, 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// firefox on pc needs a "kick" in order to set these in certain cases
|
||||
if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
|
||||
var self = this;
|
||||
@ -250,19 +250,19 @@ ZeroClipboard.Client.prototype = {
|
||||
this.ready = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.ready = true;
|
||||
this.movie.setText( this.clipText );
|
||||
this.movie.setHandCursor( this.handCursorEnabled );
|
||||
break;
|
||||
|
||||
|
||||
case 'mouseover':
|
||||
if (this.domElement && this.cssEffects) {
|
||||
this.domElement.addClass('hover');
|
||||
if (this.recoverActive) this.domElement.addClass('active');
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'mouseout':
|
||||
if (this.domElement && this.cssEffects) {
|
||||
this.recoverActive = false;
|
||||
@ -273,13 +273,13 @@ ZeroClipboard.Client.prototype = {
|
||||
this.domElement.removeClass('hover');
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'mousedown':
|
||||
if (this.domElement && this.cssEffects) {
|
||||
this.domElement.addClass('active');
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'mouseup':
|
||||
if (this.domElement && this.cssEffects) {
|
||||
this.domElement.removeClass('active');
|
||||
@ -287,11 +287,11 @@ ZeroClipboard.Client.prototype = {
|
||||
}
|
||||
break;
|
||||
} // switch eventName
|
||||
|
||||
|
||||
if (this.handlers[eventName]) {
|
||||
for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
|
||||
var func = this.handlers[eventName][idx];
|
||||
|
||||
|
||||
if (typeof(func) == 'function') {
|
||||
// actual function reference
|
||||
func(this, args);
|
||||
@ -307,5 +307,5 @@ ZeroClipboard.Client.prototype = {
|
||||
} // foreach event handler defined
|
||||
} // user defined handler for event
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
@ -81,6 +81,13 @@ zerobin = {
|
||||
}else{
|
||||
return 'Sorry your browser does not support LocalStorage, We cannot display your previous pastes.';
|
||||
}
|
||||
},
|
||||
get_paste_content: function(){
|
||||
var content_clone = '' ;
|
||||
$("#paste-content li").each(function(index) {
|
||||
content_clone = content_clone + $(this).text() + '\n';
|
||||
});
|
||||
return content_clone;
|
||||
}
|
||||
};
|
||||
|
||||
@ -152,17 +159,15 @@ if (content && key) {
|
||||
|
||||
/* Setup flash clipboard button */
|
||||
ZeroClipboard.setMoviePath('/static/js/ZeroClipboard.swf' );
|
||||
var clip = new ZeroClipboard.Client();
|
||||
|
||||
clip.addEventListener('onMouseUp', function(){
|
||||
clip.setText($('#paste-content').text());
|
||||
var clip = new ZeroClipboard.Client();
|
||||
clip.addEventListener('mouseup', function(){
|
||||
clip.setText(zerobin.get_paste_content());
|
||||
});
|
||||
clip.addEventListener('complete', function(){
|
||||
$('#copy-success').show('fadeUp');
|
||||
$('#copy-success').show('fadeUp', function(){clip.reposition()});
|
||||
});
|
||||
clip.addEventListener('onLoad', function(){
|
||||
});
|
||||
clip.glue('clip-button', 'clip-container' );
|
||||
clip.glue('clip-button');
|
||||
|
||||
window.onresize = clip.reposition;
|
||||
}
|
||||
@ -200,10 +205,7 @@ $('.previous-pastes .items').html(zerobin.get_pastes());
|
||||
/* clone a paste */
|
||||
$('.btn-clone').click(function(e){
|
||||
e.preventDefault();
|
||||
var content_clone = '' ;
|
||||
$("#paste-content li").each(function(index) {
|
||||
content_clone = content_clone + $(this).text() + '\n';
|
||||
});
|
||||
var content_clone = zerobin.get_paste_content();
|
||||
$('.submit-form').show();
|
||||
$('.paste-form').remove();
|
||||
$('#content').val(content_clone);
|
||||
|
File diff suppressed because one or more lines are too long
@ -22,9 +22,8 @@
|
||||
<div class="well paste-form">
|
||||
<form action="/" method="get" accept-charset="utf-8">
|
||||
<p>
|
||||
<span id="clip-container" style="position:relative">
|
||||
<a id="clip-button">Copy To Clipboard</a>
|
||||
</span> |
|
||||
<a id="clip-button">Copy To Clipboard</a>
|
||||
|
|
||||
<a id="short-url" href=""
|
||||
target="_blank">Get short url</a>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user