mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Merge branch 'master' of sametmax-github:sametmax/0bin
This commit is contained in:
commit
407e8a3538
@ -31,10 +31,13 @@ GROUP = None
|
|||||||
MAX_SIZE = 1024 * 500
|
MAX_SIZE = 1024 * 500
|
||||||
MAX_SIZE_KB = int(math.ceil(MAX_SIZE / 1024.0))
|
MAX_SIZE_KB = int(math.ceil(MAX_SIZE / 1024.0))
|
||||||
|
|
||||||
|
# Email for contact
|
||||||
|
EMAIL = "your@email.com"
|
||||||
|
|
||||||
# this import a file named settings_local.py if it exists
|
# this import a file named settings_local.py if it exists
|
||||||
# you may want to create such a file to have different settings
|
# you may want to create such a file to have different settings
|
||||||
# on each machine
|
# on each machine
|
||||||
try:
|
try:
|
||||||
from settings_local import *
|
from settings_local import *
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
15
src/utils.py
15
src/utils.py
@ -35,4 +35,17 @@ def drop_privileges(user=None, group=None, wait=5):
|
|||||||
|
|
||||||
drop_privileges_permanently(user, group, ())
|
drop_privileges_permanently(user, group, ())
|
||||||
except Exception:
|
except Exception:
|
||||||
print "Failed to drop privileges. Running with current user."
|
print "Failed to drop privileges. Running with current user."
|
||||||
|
|
||||||
|
|
||||||
|
def dmerge(*args):
|
||||||
|
"""
|
||||||
|
return new directionay being the sum of all merged dictionaries passed as arguments
|
||||||
|
"""
|
||||||
|
|
||||||
|
dictionary = {}
|
||||||
|
|
||||||
|
for arg in args:
|
||||||
|
dictionary.update(arg)
|
||||||
|
|
||||||
|
return dictionary
|
||||||
|
22
start.py
22
start.py
@ -27,17 +27,21 @@ from bottle import (Bottle, route, run, abort, error,
|
|||||||
|
|
||||||
import clize
|
import clize
|
||||||
|
|
||||||
|
|
||||||
from src.paste import Paste
|
from src.paste import Paste
|
||||||
from src.utils import drop_privileges
|
from src.utils import drop_privileges, dmerge
|
||||||
|
|
||||||
|
|
||||||
app = Bottle()
|
app = Bottle()
|
||||||
|
|
||||||
|
global_vars = {
|
||||||
|
'settings' : settings
|
||||||
|
}
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@view('home')
|
@view('home')
|
||||||
def index():
|
def index():
|
||||||
return {'max_size': settings.MAX_SIZE, 'max_size_kb': settings.MAX_SIZE_KB}
|
return global_vars
|
||||||
|
|
||||||
|
|
||||||
@app.route('/paste/create', method='POST')
|
@app.route('/paste/create', method='POST')
|
||||||
@ -71,6 +75,7 @@ def create_paste():
|
|||||||
@view('paste')
|
@view('paste')
|
||||||
def display_paste(paste_id):
|
def display_paste(paste_id):
|
||||||
|
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
keep_alive = False
|
keep_alive = False
|
||||||
try:
|
try:
|
||||||
@ -98,16 +103,13 @@ def display_paste(paste_id):
|
|||||||
#abort(404, u"This paste doesn't exist or has expired")
|
#abort(404, u"This paste doesn't exist or has expired")
|
||||||
return error404(ValueError)
|
return error404(ValueError)
|
||||||
|
|
||||||
return {'paste': paste, 'keep_alive': keep_alive,
|
context = {'paste': paste, 'keep_alive': keep_alive}
|
||||||
'max_size': settings.MAX_SIZE,
|
return dmerge(context, global_vars)
|
||||||
'max_size_kb': settings.MAX_SIZE_KB}
|
|
||||||
|
|
||||||
|
|
||||||
@app.error(404)
|
@app.error(404)
|
||||||
@view('404')
|
@view('404')
|
||||||
def error404(code):
|
def error404(code):
|
||||||
return {'max_size': settings.MAX_SIZE, 'max_size_kb': settings.MAX_SIZE_KB}
|
return global_vars
|
||||||
|
|
||||||
|
|
||||||
@clize.clize
|
@clize.clize
|
||||||
def runserver(host=settings.HOST, port=settings.PORT, debug=settings.DEBUG,
|
def runserver(host=settings.HOST, port=settings.PORT, debug=settings.DEBUG,
|
||||||
@ -128,6 +130,8 @@ def runserver(host=settings.HOST, port=settings.PORT, debug=settings.DEBUG,
|
|||||||
run(app, host=host, port=port, server="cherrypy")
|
run(app, host=host, port=port, server="cherrypy")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
clize.run(runserver)
|
clize.run(runserver)
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ li.L5, li.L6, li.L7, li.L8, li.L9
|
|||||||
background: inherit;
|
background: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prettyprint.linenums.done {
|
.prettyprint.linenums {
|
||||||
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
|
-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;
|
-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;
|
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
|
||||||
@ -320,4 +320,5 @@ html.no-local-storage .local-storage {
|
|||||||
|
|
||||||
canvas {
|
canvas {
|
||||||
border: 1px solid white;
|
border: 1px solid white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,5 +633,3 @@ $(".close").on('click', function(e){
|
|||||||
|
|
||||||
}); /* End of "document ready" jquery callback */
|
}); /* End of "document ready" jquery callback */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,4 +33,4 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
%rebase base max_size=max_size
|
%rebase base settings=settings
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<script src="/static/js/behavior.js"></script>
|
<script src="/static/js/behavior.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
zerobin.max_size = {{ get('max_size', -1)}};
|
zerobin.max_size = {{ settings.MAX_SIZE }};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
@ -45,6 +45,7 @@
|
|||||||
<ul class="nav">
|
<ul class="nav">
|
||||||
<li class="active"><a href="/">Home</a></li>
|
<li class="active"><a href="/">Home</a></li>
|
||||||
<li><a href="https://github.com/sametmax/0bin">Download 0bin</a></li>
|
<li><a href="https://github.com/sametmax/0bin">Download 0bin</a></li>
|
||||||
|
<li><a href="mailto:{{ settings.EMAIL }}">Contact us</a></li>
|
||||||
<!-- <li><a href="#faq">Faq</a></li> -->
|
<!-- <li><a href="#faq">Faq</a></li> -->
|
||||||
</ul>
|
</ul>
|
||||||
<p class="navbar-text pull-right"><i>"A client side encrypted PasteBin..."</i></p>
|
<p class="navbar-text pull-right"><i>"A client side encrypted PasteBin..."</i></p>
|
||||||
@ -103,7 +104,7 @@
|
|||||||
<p class="greetings span12">
|
<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><br>
|
<a href="http://sebsauvage.net/paste/">sebsauvage.net</a><br>
|
||||||
<a href="http://sametmax.com">Sam & Max</a>
|
<a href="http://sametmax.com">Sam & Max</a> | <a href="mailto:{{ settings.EMAIL }}"> Contact us</a>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
@ -25,4 +25,4 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
%rebase base max_size=max_size
|
%rebase base settings=settings
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<pre id="paste-content" class="prettyprint linenums">
|
<pre id="paste-content" class="prettyprint linenums">
|
||||||
<code>
|
<code>
|
||||||
{{ paste.content }}
|
{{ paste.content }}
|
||||||
</code>
|
</code>
|
||||||
@ -77,4 +77,4 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
%rebase base max_size=max_size
|
%rebase base settings=settings
|
||||||
|
Loading…
Reference in New Issue
Block a user