diff --git a/settings.py b/settings.py index e91491e..c5b0d3c 100644 --- a/settings.py +++ b/settings.py @@ -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 \ No newline at end of file + pass diff --git a/src/__init__.py b/src/__init__.py index fbc1537..faaaf79 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,4 +1,3 @@ # -*- coding: utf-8 -*- - diff --git a/src/utils.py b/src/utils.py index a54bcea..d3a1501 100644 --- a/src/utils.py +++ b/src/utils.py @@ -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." \ No newline at end of file + 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 diff --git a/start.py b/start.py index d1fccab..2569ad0 100755 --- a/start.py +++ b/start.py @@ -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) diff --git a/static/css/style.css b/static/css/style.css index f66e380..d0a7d55 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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; -} \ No newline at end of file +} + diff --git a/static/js/behavior.js b/static/js/behavior.js index 104e597..996d2c5 100644 --- a/static/js/behavior.js +++ b/static/js/behavior.js @@ -633,5 +633,3 @@ $(".close").on('click', function(e){ }); /* End of "document ready" jquery callback */ - - diff --git a/views/404.tpl b/views/404.tpl index c3d5418..4629d6b 100644 --- a/views/404.tpl +++ b/views/404.tpl @@ -33,4 +33,4 @@ -%rebase base max_size=max_size +%rebase base settings=settings diff --git a/views/base.tpl b/views/base.tpl index 30dbf1e..a230e1b 100644 --- a/views/base.tpl +++ b/views/base.tpl @@ -24,7 +24,7 @@ @@ -45,6 +45,7 @@ @@ -103,7 +104,7 @@

Based on an original idea from sebsauvage.net
- Sam & Max + Sam & Max | Contact us

diff --git a/views/home.tpl b/views/home.tpl index bf07c84..863db88 100644 --- a/views/home.tpl +++ b/views/home.tpl @@ -25,4 +25,4 @@ -%rebase base max_size=max_size +%rebase base settings=settings diff --git a/views/paste.tpl b/views/paste.tpl index 1d87c1b..b0073f0 100644 --- a/views/paste.tpl +++ b/views/paste.tpl @@ -37,7 +37,7 @@

-

+  
     
       {{ paste.content }}
     
@@ -77,4 +77,4 @@
 
 
 
-%rebase base max_size=max_size
+%rebase base settings=settings