mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Prevent 0bin to crash if the locale formatting is not supported. Moved get_pastes_count into the Paste class. Added 0bin version as query parameter in the scrip and css tags URL
This commit is contained in:
@ -23,16 +23,16 @@ from bottle import (Bottle, run, static_file, view, request)
|
||||
import clize
|
||||
|
||||
from paste import Paste
|
||||
from utils import drop_privileges, dmerge, get_pastes_count
|
||||
from utils import drop_privileges, dmerge
|
||||
|
||||
|
||||
app = Bottle()
|
||||
GLOBAL_CONTEXT = {
|
||||
'settings': settings,
|
||||
'pastes_count': get_pastes_count(),
|
||||
'pastes_count': Paste.get_pastes_count(),
|
||||
'refresh_counter': datetime.now()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@app.route('/')
|
||||
@view('home')
|
||||
@ -66,17 +66,20 @@ def create_paste():
|
||||
expiration = request.forms.get('expiration', u'burn_after_reading')
|
||||
paste = Paste(expiration=expiration, content=content)
|
||||
paste.save()
|
||||
|
||||
|
||||
# display counter
|
||||
if settings.DISPLAY_COUNTER:
|
||||
|
||||
#increment paste counter
|
||||
paste.increment_counter()
|
||||
|
||||
|
||||
# if refresh time elapsed pick up new counter value
|
||||
if GLOBAL_CONTEXT['refresh_counter'] + timedelta(seconds=settings.REFRESH_COUNTER) < datetime.now():
|
||||
GLOBAL_CONTEXT['pastes_count'] = get_pastes_count()
|
||||
GLOBAL_CONTEXT['refresh_counter'] = datetime.now()
|
||||
now = datetime.now()
|
||||
timeout = (GLOBAL_CONTEXT['refresh_counter']
|
||||
+ timedelta(seconds=settings.REFRESH_COUNTER))
|
||||
if timeout < now:
|
||||
GLOBAL_CONTEXT['pastes_count'] = Paste.get_pastes_count()
|
||||
GLOBAL_CONTEXT['refresh_counter'] = now
|
||||
|
||||
|
||||
return {'status': 'ok',
|
||||
|
Reference in New Issue
Block a user