1
0
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:
sam 2012-05-07 17:44:00 +07:00
commit 407e8a3538
10 changed files with 41 additions and 22 deletions

View File

@ -31,10 +31,13 @@ GROUP = None
MAX_SIZE = 1024 * 500
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
# you may want to create such a file to have different settings
# on each machine
try:
from settings_local import *
except ImportError:
pass
pass

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

View File

@ -35,4 +35,17 @@ def drop_privileges(user=None, group=None, wait=5):
drop_privileges_permanently(user, group, ())
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

View File

@ -27,17 +27,21 @@ from bottle import (Bottle, route, run, abort, error,
import clize
from src.paste import Paste
from src.utils import drop_privileges
from src.utils import drop_privileges, dmerge
app = Bottle()
global_vars = {
'settings' : settings
}
@app.route('/')
@view('home')
def index():
return {'max_size': settings.MAX_SIZE, 'max_size_kb': settings.MAX_SIZE_KB}
def index():
return global_vars
@app.route('/paste/create', method='POST')
@ -71,6 +75,7 @@ def create_paste():
@view('paste')
def display_paste(paste_id):
now = datetime.now()
keep_alive = False
try:
@ -98,16 +103,13 @@ def display_paste(paste_id):
#abort(404, u"This paste doesn't exist or has expired")
return error404(ValueError)
return {'paste': paste, 'keep_alive': keep_alive,
'max_size': settings.MAX_SIZE,
'max_size_kb': settings.MAX_SIZE_KB}
context = {'paste': paste, 'keep_alive': keep_alive}
return dmerge(context, global_vars)
@app.error(404)
@view('404')
def error404(code):
return {'max_size': settings.MAX_SIZE, 'max_size_kb': settings.MAX_SIZE_KB}
return global_vars
@clize.clize
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")
if __name__ == "__main__":
clize.run(runserver)

View File

@ -191,7 +191,7 @@ li.L5, li.L6, li.L7, li.L8, li.L9
background: inherit;
}
.prettyprint.linenums.done {
.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;
@ -320,4 +320,5 @@ html.no-local-storage .local-storage {
canvas {
border: 1px solid white;
}
}

View File

@ -633,5 +633,3 @@ $(".close").on('click', function(e){
}); /* End of "document ready" jquery callback */

View File

@ -33,4 +33,4 @@
</form>
%rebase base max_size=max_size
%rebase base settings=settings

View File

@ -24,7 +24,7 @@
<script src="/static/js/behavior.js"></script>
<script type="text/javascript">
zerobin.max_size = {{ get('max_size', -1)}};
zerobin.max_size = {{ settings.MAX_SIZE }};
</script>
</head>
@ -45,6 +45,7 @@
<ul class="nav">
<li class="active"><a href="/">Home</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> -->
</ul>
<p class="navbar-text pull-right"><i>"A client side encrypted PasteBin..."</i></p>
@ -103,7 +104,7 @@
<p class="greetings span12">
Based on an original idea from
<a href="http://sebsauvage.net/paste/">sebsauvage.net</a><br>
<a href="http://sametmax.com">Sam &amp; Max</a>
<a href="http://sametmax.com">Sam &amp; Max</a> | <a href="mailto:{{ settings.EMAIL }}"> Contact us</a>
</p>
</footer>

View File

@ -25,4 +25,4 @@
</form>
%rebase base max_size=max_size
%rebase base settings=settings

View File

@ -37,7 +37,7 @@
</div>
<p>
<pre id="paste-content" class="prettyprint linenums">
<pre id="paste-content" class="prettyprint linenums">
<code>
{{ paste.content }}
</code>
@ -77,4 +77,4 @@
</div>
%rebase base max_size=max_size
%rebase base settings=settings