1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00
This commit is contained in:
max 2012-05-01 20:20:10 +07:00
parent 36216fe118
commit c770457883
5 changed files with 22 additions and 16 deletions

View File

@ -29,4 +29,4 @@ 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
MAX_SIZE = 1024 * 50

View File

@ -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

View File

@ -54,11 +54,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."}

View File

@ -259,6 +259,10 @@ button.btn, input[type="submit"].btn {
top:-4px;
}
#alert-template {
display: none;
}
/** Progress bar */
.progress {

View File

@ -74,4 +74,4 @@
</span>
%rebase base
%rebase base