mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Expired pastes are removed from localStorage
This commit is contained in:
parent
470194806e
commit
a824bc2a21
|
@ -158,7 +158,7 @@ class Paste(object):
|
||||||
|
|
||||||
#remove lock file
|
#remove lock file
|
||||||
os.remove(lock_file)
|
os.remove(lock_file)
|
||||||
except (IOError, OSError):
|
finally:
|
||||||
if os.path.isfile(lock_file):
|
if os.path.isfile(lock_file):
|
||||||
#remove lock file
|
#remove lock file
|
||||||
os.remove(lock_file)
|
os.remove(lock_file)
|
||||||
|
|
|
@ -117,7 +117,6 @@ def display_paste(paste_id):
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
|
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
#abort(404, u"This paste doesn't exist or has expired")
|
|
||||||
return error404(ValueError)
|
return error404(ValueError)
|
||||||
|
|
||||||
context = {'paste': paste, 'keep_alive': keep_alive}
|
context = {'paste': paste, 'keep_alive': keep_alive}
|
||||||
|
@ -137,7 +136,7 @@ def server_static(filename):
|
||||||
|
|
||||||
def get_app(debug=None, settings_file='', compressed_static=None):
|
def get_app(debug=None, settings_file='', compressed_static=None):
|
||||||
"""
|
"""
|
||||||
Return a tuple (settings, app) configured using passed options and
|
Return a tuple (settings, app) configured using passed parameters and/or
|
||||||
a setting file.
|
a setting file.
|
||||||
"""
|
"""
|
||||||
if settings_file:
|
if settings_file:
|
||||||
|
|
|
@ -163,7 +163,7 @@ window.zerobin = {
|
||||||
are prefixed with with the passed version (default being this lib
|
are prefixed with with the passed version (default being this lib
|
||||||
version) */
|
version) */
|
||||||
getLocalStorageKeys: function(){
|
getLocalStorageKeys: function(){
|
||||||
version = 'zerobinV0.1';
|
var version = 'zerobinV0.1';
|
||||||
var keys = [];
|
var keys = [];
|
||||||
for (var key in localStorage){
|
for (var key in localStorage){
|
||||||
if (key.indexOf(version) !== -1){
|
if (key.indexOf(version) !== -1){
|
||||||
|
@ -674,10 +674,24 @@ $('.email-link').each(function(i, elem){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Show the page using javascript. Non js enabled browser will see an
|
||||||
|
error message */
|
||||||
$('#wrap-content').each(function(i, elem){
|
$('#wrap-content').each(function(i, elem){
|
||||||
$(elem).show();
|
$(elem).show();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Remove expired pasted from history */
|
||||||
|
if (zerobin.support.history && zerobin.paste_not_found){
|
||||||
|
var paste_id = zerobin.getPasteId();
|
||||||
|
var keys = zerobin.getLocalStorageKeys();
|
||||||
|
$.each(keys, function(i, key){
|
||||||
|
if (localStorage[key].indexOf(paste_id) !== -1){
|
||||||
|
localStorage.removeItem(key);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}); /* End of "document ready" jquery callback */
|
}); /* End of "document ready" jquery callback */
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
<script type="text/javascript">
|
||||||
|
zerobin.paste_not_found = true;
|
||||||
|
</script>
|
||||||
|
|
||||||
<p class="alert alert-error">
|
<p class="alert alert-error">
|
||||||
<a class="close" data-dismiss="alert" href="#">×</a>
|
<a class="close" data-dismiss="alert" href="#">×</a>
|
||||||
<strong class="title">404 Error!</strong>
|
<strong class="title">404 Error!</strong>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user