File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 53
53
USER = None
54
54
GROUP = None
55
55
56
- # Display a tiny counter for pastes created
56
+ # Display a tiny counter for pastes created.
57
57
# Be carreful if your site have to many pastes this can hurt your hard drive performances.
58
+ # Refresh counter interval. Default to every minute after a paste.
58
59
DISPLAY_COUNTER = True
60
+ REFRESH_COUNTER = 60 * 1
59
61
60
62
# Names/links to insert in the menu bar.
61
63
# Any link with "mailto:" will be escaped to prevent spam
Original file line number Diff line number Diff line change 29
29
app = Bottle ()
30
30
GLOBAL_CONTEXT = {
31
31
'settings' : settings ,
32
- 'pastes_count' : get_pastes_count ()
32
+ 'pastes_count' : get_pastes_count (),
33
+ 'refresh_counter' : datetime .now ()
33
34
}
34
-
35
+
35
36
36
37
@app .route ('/' )
37
38
@view ('home' )
@@ -66,8 +67,17 @@ def create_paste():
66
67
paste = Paste (expiration = expiration , content = content )
67
68
paste .save ()
68
69
70
+ # display counter
69
71
if settings .DISPLAY_COUNTER :
72
+
73
+ #increment paste counter
70
74
paste .increment_counter ()
75
+
76
+ # if refresh time elapsed pick up new counter value
77
+ if GLOBAL_CONTEXT ['refresh_counter' ] + timedelta (seconds = settings .REFRESH_COUNTER ) < datetime .now ():
78
+ GLOBAL_CONTEXT ['pastes_count' ] = get_pastes_count ()
79
+ GLOBAL_CONTEXT ['refresh_counter' ] = datetime .now ()
80
+
71
81
72
82
return {'status' : 'ok' ,
73
83
'paste' : paste .uuid }
You can’t perform that action at this time.
0 commit comments