mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Added upload file button (HTML5)
This commit is contained in:
parent
e34e740808
commit
658149240e
@ -16,11 +16,7 @@ def setup_path():
|
|||||||
Add the project dir in the python path to the site to run with the
|
Add the project dir in the python path to the site to run with the
|
||||||
source code beeing just copied/pasted and not installed.
|
source code beeing just copied/pasted and not installed.
|
||||||
|
|
||||||
Also try to import dependancies. If it fails, fallback on embeded libs.
|
Add fallback on embeded libs to path.
|
||||||
"""
|
"""
|
||||||
sys.path.insert(0, os.path.dirname(settings.ROOT_DIR))
|
sys.path.insert(0, os.path.dirname(settings.ROOT_DIR))
|
||||||
|
sys.path.append(os.path.join(settings.ROOT_DIR, 'libs'))
|
||||||
try:
|
|
||||||
import bottle
|
|
||||||
except ImportError:
|
|
||||||
sys.path.append(os.path.join(settings.ROOT_DIR, 'libs'))
|
|
14
src/paste.py
14
src/paste.py
@ -154,12 +154,14 @@ class Paste(object):
|
|||||||
self.expiration = self.expiration + '#%s' % datetime.now()
|
self.expiration = self.expiration + '#%s' % datetime.now()
|
||||||
|
|
||||||
# write the paste
|
# write the paste
|
||||||
with open(self.path, 'w') as f:
|
try:
|
||||||
f.write(unicode(self.expiration) + '\n')
|
with open(self.path, 'w') as f:
|
||||||
f.write(self.content + '\n')
|
f.write(unicode(self.expiration) + '\n')
|
||||||
if self.comments:
|
f.write(self.content + '\n')
|
||||||
f.write(comments)
|
if self.comments:
|
||||||
|
f.write(comments)
|
||||||
|
except Exception as e:
|
||||||
|
import ipdb; ipdb.set_trace()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,14 +2,13 @@
|
|||||||
|
|
||||||
|
|
||||||
.brand {
|
.brand {
|
||||||
font-size: 38px !important;
|
font-size: 38px !important;
|
||||||
padding: 0px 55px 3px !important;
|
padding: 0px 55px 3px !important;
|
||||||
|
|
||||||
text-shadow: 0 1px 0 rgba(255, 255, 255, .1), 0 0 30px rgba(255, 255, 255, .125);
|
|
||||||
-webkit-transition: all .2s linear;
|
|
||||||
-moz-transition: all .2s linear;
|
|
||||||
transition: all .2s linear;
|
|
||||||
|
|
||||||
|
text-shadow: 0 1px 0 rgba(255, 255, 255, .1), 0 0 30px rgba(255, 255, 255, .125);
|
||||||
|
-webkit-transition: all .2s linear;
|
||||||
|
-moz-transition: all .2s linear;
|
||||||
|
transition: all .2s linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
.brand span {
|
.brand span {
|
||||||
@ -34,15 +33,6 @@ body {
|
|||||||
padding: 9px 0;
|
padding: 9px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-group {
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.paste-option {
|
|
||||||
float:right;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
width: 135px;
|
width: 135px;
|
||||||
}
|
}
|
||||||
@ -61,7 +51,7 @@ ul, ol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
margin-left: -4px;
|
margin-left: -9px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -73,24 +63,169 @@ p {
|
|||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.items {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-list {
|
.nav-list {
|
||||||
padding-right: 0px !important;
|
padding-right: 0px !important;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-options li{
|
blockquote {
|
||||||
|
width: 630px;
|
||||||
float: left;
|
float: left;
|
||||||
list-style-type: none;
|
}
|
||||||
|
|
||||||
|
h4 p {
|
||||||
|
float: left;
|
||||||
|
font-size: 80px;
|
||||||
|
text-shadow: 1px 3px 1px #DDD, 0 0 4px #333;
|
||||||
|
-webkit-transition: all 0.2s linear;
|
||||||
|
-moz-transition: all .2s linear;
|
||||||
|
transition: all .2s linear;
|
||||||
|
margin-right: 7px;
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4#pixels-total {
|
||||||
|
position: relative;
|
||||||
|
width: 166px;
|
||||||
|
float: right;
|
||||||
|
margin: 8px 0 0 0;
|
||||||
|
padding: 0 0 0 54px;
|
||||||
|
font-size: 1.1em;
|
||||||
|
line-height: 1.4;
|
||||||
|
font-weight: normal;
|
||||||
|
color: #777;
|
||||||
|
-webkit-border-top-right-radius: 6px;
|
||||||
|
-webkit-border-top-left-radius: 20px;
|
||||||
|
-moz-border-top-right-radius: 6px;
|
||||||
|
-moz-border-top-left-radius: 20px;
|
||||||
|
border-top-right-radius: 6px;
|
||||||
|
border-top-left-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.greetings {
|
||||||
|
clear: both;
|
||||||
|
margin: 0 auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Home */
|
||||||
|
|
||||||
|
.btn-group {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-upload {
|
||||||
|
float: left;
|
||||||
|
margin: 22px 0px 0px 21px;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.btn-upload {
|
||||||
|
position: relative;
|
||||||
|
left: -6px;
|
||||||
|
width: 100px;
|
||||||
|
z-index: 1;
|
||||||
|
margin-top: -13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.hide-upload {
|
||||||
|
position: relative;
|
||||||
|
left: -110px;
|
||||||
|
-moz-opacity: 0;
|
||||||
|
filter: alpha(opacity: 0);
|
||||||
|
opacity: 0 ;
|
||||||
|
z-index: 2;
|
||||||
|
width: 100px;
|
||||||
|
margin-top: -20px;
|
||||||
|
cursor: pointer;
|
||||||
|
cursor: hand;
|
||||||
|
height: 49px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Paste Page */
|
||||||
|
|
||||||
|
.items {
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#paste-content {
|
#paste-content {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#copy-success,
|
||||||
|
#short-url-success,
|
||||||
|
.submit-form {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paste-option {
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
|
|
||||||
|
a#clip-button.hover{
|
||||||
|
cursor:pointer;
|
||||||
|
text-decoration:underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.L0, li.L1, li.L2, li.L3, li.L4,
|
||||||
|
li.L5, li.L6, li.L7, li.L8, li.L9
|
||||||
|
{
|
||||||
|
list-style-type: decimal;
|
||||||
|
background: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums {
|
||||||
|
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
|
||||||
|
-moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
|
||||||
|
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Specify class=linenums on a pre to get line numbering */
|
||||||
|
ol.linenums {
|
||||||
|
margin: 0 0 0 55px; /* IE indents via margin-left */
|
||||||
|
}
|
||||||
|
ol.linenums li {
|
||||||
|
color: #bebec5;
|
||||||
|
line-height: 18px;
|
||||||
|
text-shadow: 0 1px 0 #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint {
|
||||||
|
padding: 8px;
|
||||||
|
background-color: #f7f7f9;
|
||||||
|
border: 1px solid #e1e1e8;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, monospace, serif;
|
||||||
|
line-height: 21px;
|
||||||
|
font-size: 12px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.kwd {
|
||||||
|
color: #66F;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pun, .opn, .clo {
|
||||||
|
color: #0A0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lit {
|
||||||
|
color: #933;
|
||||||
|
}
|
||||||
|
|
||||||
|
.com {
|
||||||
|
color: #C0C;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Common css */
|
||||||
|
|
||||||
|
form {
|
||||||
|
padding-bottom:3em !important;
|
||||||
|
padding-right: 17px;
|
||||||
|
}
|
||||||
|
|
||||||
form textarea {
|
form textarea {
|
||||||
overflow-y:auto;
|
overflow-y:auto;
|
||||||
@ -100,10 +235,6 @@ button.btn, input[type="submit"].btn {
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.submit-form {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.well {
|
.well {
|
||||||
padding-bottom: 40px;
|
padding-bottom: 40px;
|
||||||
padding-right: 17px;
|
padding-right: 17px;
|
||||||
@ -120,48 +251,9 @@ button.btn, input[type="submit"].btn {
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
form {
|
|
||||||
padding-bottom:3em !important;
|
|
||||||
padding-right: 17px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
position:relative;
|
position:relative;
|
||||||
top:-4px;
|
top:-4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pre {
|
|
||||||
padding:1em 20px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.linenums {
|
|
||||||
padding-left: 35px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ol.linenums li {
|
|
||||||
line-height:14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol.linenums span:first-child {
|
|
||||||
border-left: solid 1px #999;
|
|
||||||
padding-left:1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
li.L0, li.L1, li.L2, li.L3, li.L4,
|
|
||||||
li.L5, li.L6, li.L7, li.L8, li.L9
|
|
||||||
{
|
|
||||||
list-style-type: decimal;
|
|
||||||
background: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
a#clip-button.hover{
|
|
||||||
cursor:pointer;
|
|
||||||
text-decoration:underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
#copy-success, #short-url-success {
|
|
||||||
display:none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ sjcl.random.startCollectors();
|
|||||||
$.ajaxSetup({ cache: true });
|
$.ajaxSetup({ cache: true });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
zerobin = {
|
zerobin = {
|
||||||
encrypt: function(key, content) {
|
encrypt: function(key, content) {
|
||||||
content = sjcl.codec.base64.fromBits(sjcl.codec.utf8String.toBits(content));
|
content = sjcl.codec.base64.fromBits(sjcl.codec.utf8String.toBits(content));
|
||||||
@ -234,6 +233,38 @@ $('.btn-clone').click(function(e){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/* Upload file using HTML5 File API */
|
||||||
|
|
||||||
|
if (window.File && window.FileReader && window.FileList && window.Blob) {
|
||||||
|
$('.file-upload').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_upload = function(file) {
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function(event) {
|
||||||
|
var content = event.target.result;
|
||||||
|
$('#content').val(content);
|
||||||
|
$('#content').trigger('change');
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsText(file[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$('#file-upload').change(function() {
|
||||||
|
file_upload(this.files);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
alert(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#file-upload').mouseover(function(){
|
||||||
|
$(this).css( 'cursor', 'pointer' );
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,12 +75,17 @@
|
|||||||
<p>«Few persons can be made to believe that it is not quite an easy thing to invent a method of secret writing which shall baffle investigation. Yet it may be roundly asserted that human ingenuity cannot concoct a cipher which human ingenuity cannot resolve...»</p>
|
<p>«Few persons can be made to believe that it is not quite an easy thing to invent a method of secret writing which shall baffle investigation. Yet it may be roundly asserted that human ingenuity cannot concoct a cipher which human ingenuity cannot resolve...»</p>
|
||||||
<small>Edgar Allan Poe</small>
|
<small>Edgar Allan Poe</small>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
|
<h4 id="pixels-total" >
|
||||||
|
<p>ø</p>
|
||||||
|
<strong>41,017,923,819</strong> pastes øbinned
|
||||||
|
</h4>
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
<p>
|
<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>
|
<a href="http://sebsauvage.net/paste/">sebsauvage.net</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
<p class="file-upload">
|
||||||
|
<input type="button" class="btn btn-upload" value="Upload File">
|
||||||
|
<input type="file" class="hide-upload" id="file-upload" >
|
||||||
|
</p>
|
||||||
|
|
||||||
<form class="well" method="post" action="/paste/create">
|
<form class="well" method="post" action="/paste/create">
|
||||||
<p class="paste-option">
|
<p class="paste-option">
|
||||||
<label for="expiration" >Expiration:</label>
|
<label for="expiration" >Expiration:</label>
|
||||||
|
@ -21,12 +21,11 @@
|
|||||||
|
|
||||||
<div class="well paste-form">
|
<div class="well paste-form">
|
||||||
<form action="/" method="get" accept-charset="utf-8">
|
<form action="/" method="get" accept-charset="utf-8">
|
||||||
<p>
|
<p class="lnk-option">
|
||||||
<a id="clip-button">Copy To Clipboard</a>
|
<a id="clip-button">Copy To Clipboard</a>
|
||||||
|
|
|
|
||||||
<a id="short-url" href=""
|
<a id="short-url" href=""
|
||||||
target="_blank">Get short url</a>
|
target="_blank">Get short url</a>
|
||||||
|
|
||||||
<span class="paste-option btn-group top">
|
<span class="paste-option btn-group top">
|
||||||
<button class="btn btn-clone"><i class="icon-camera"></i> Clone</button>
|
<button class="btn btn-clone"><i class="icon-camera"></i> Clone</button>
|
||||||
<button class="btn">New Paste</button>
|
<button class="btn">New Paste</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user