diff --git a/README.md b/README.md index 65c5169..3c70261 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ 0bin ==== +Have try here: 0bin.net + 0bin is client side encrypted pastebin that can run without a database. It allows anybody to host a pastebin while welcoming any type of content to be pasted in it. The idea is that one can (probably...) not be legally entitled to moderate the pastebin content (http://www.zdnet.com/blog/security/pastebin-to-hunt-for-hacker-pastes-anonymous-cries-censorship/11336) as one has no way to decrypt it. diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..7005cfb Binary files /dev/null and b/screenshot.png differ diff --git a/settings.py b/settings.py index c9771d9..9da618f 100644 --- a/settings.py +++ b/settings.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os +import math ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_FILES_ROOT = os.path.join(ROOT_DIR, 'static') @@ -28,4 +29,5 @@ GROUP = None # limit size of pasted text in bytes. Be carefull allowing too much size can slow down user's # browser -MAX_SIZE = 500 * 1000 \ No newline at end of file +MAX_SIZE = 1024 * 500 +MAX_SIZE_KB = int(math.ceil(MAX_SIZE / 1024.0)) diff --git a/src/paste.py b/src/paste.py index 687d8b4..b2d8f27 100644 --- a/src/paste.py +++ b/src/paste.py @@ -153,15 +153,13 @@ class Paste(object): if self.expiration == "burn_after_reading": self.expiration = self.expiration + '#%s' % datetime.now() - # write the paste - try: - with open(self.path, 'w') as f: - f.write(unicode(self.expiration) + '\n') - f.write(self.content + '\n') - if self.comments: - f.write(comments) - except Exception as e: - import ipdb; ipdb.set_trace() + # write the paste + with open(self.path, 'w') as f: + f.write(unicode(self.expiration) + '\n') + f.write(self.content + '\n') + if self.comments: + f.write(comments) + return self diff --git a/start.py b/start.py index 64052e5..536cbb8 100755 --- a/start.py +++ b/start.py @@ -32,8 +32,7 @@ app = Bottle() @app.route('/') @view('home') def index(): - max_size_kb = int(math.ceil(settings.MAX_SIZE / 1024.0)) - return {'max_size': settings.MAX_SIZE, 'max_size_kb': max_size_kb} + return {'max_size': settings.MAX_SIZE, 'max_size_kb': settings.MAX_SIZE_KB} @app.route('/paste/create', method='POST') @@ -49,11 +48,15 @@ def create_paste(): return '' if content: - expiration = request.forms.get('expiration', u'burn_after_reading') - paste = Paste(expiration=expiration, content=content) - paste.save() - return {'status': 'ok', - 'paste': paste.uuid} + # check size of the paste. if more than settings return error without saving paste. + # prevent from unusual use of the system. + # need to be improved + if len(content) < settings.MAX_SIZE: + expiration = request.forms.get('expiration', u'burn_after_reading') + paste = Paste(expiration=expiration, content=content) + paste.save() + return {'status': 'ok', + 'paste': paste.uuid} return {'status': 'error', 'message': u"Serveur error: the paste couldn't be saved. Please try later."} @@ -89,7 +92,7 @@ def display_paste(paste_id): except (TypeError, ValueError): abort(404, u"This paste doesn't exist or has expired") - return {'paste': paste, 'keep_alive': keep_alive} + return {'paste': paste, 'keep_alive': keep_alive, 'max_size': settings.MAX_SIZE, 'max_size_kb': settings.MAX_SIZE_KB} @clize.clize diff --git a/static/css/style.css b/static/css/style.css index e3addf0..efd437d 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -259,6 +259,10 @@ button.btn, input[type="submit"].btn { top:-4px; } +#alert-template { + display: none; +} + /** Progress bar */ .progress { diff --git a/static/js/behavior.js b/static/js/behavior.js index 02ecfdd..a206844 100644 --- a/static/js/behavior.js +++ b/static/js/behavior.js @@ -221,6 +221,8 @@ zerobin = { }, message: function(type, message, title, flush, callback) { + $(window).scrollTop(0); + if (flush) {$('.alert-'+type).remove()} $message = $('#alert-template').clone().attr('id', null) diff --git a/views/base.tpl b/views/base.tpl index f4583bb..942994f 100644 --- a/views/base.tpl +++ b/views/base.tpl @@ -42,9 +42,9 @@ ΓΈbin.net diff --git a/views/paste.tpl b/views/paste.tpl index dd9739b..a9156e4 100644 --- a/views/paste.tpl +++ b/views/paste.tpl @@ -74,4 +74,4 @@ -%rebase base +%rebase base max_size=max_size