diff --git a/settings.py b/settings.py index 00e1963..245e34e 100644 --- a/settings.py +++ b/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') \ No newline at end of file +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 \ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css index c4e2686..fc551ba 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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 { diff --git a/static/js/ZeroClipboard.js b/static/js/ZeroClipboard.js index 5adde95..c4b548b 100755 --- a/static/js/ZeroClipboard.js +++ b/static/js/ZeroClipboard.js @@ -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 } - + }; diff --git a/static/js/behavior.js b/static/js/behavior.js index efd40e4..d587d8d 100644 --- a/static/js/behavior.js +++ b/static/js/behavior.js @@ -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); diff --git a/static/js/swfobject.js b/static/js/swfobject.js deleted file mode 100644 index 8eafe9d..0000000 --- a/static/js/swfobject.js +++ /dev/null @@ -1,4 +0,0 @@ -/* SWFObject v2.2 - is released under the MIT License -*/ -var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y0){for(var af=0;af0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad'}}aa.outerHTML='"+af+"";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab

- - Copy To Clipboard - | + Copy To Clipboard + | Get short url