Better cache. Better gc.
This commit is contained in:
parent
319ac51d60
commit
9220ea44b5
@ -146,6 +146,7 @@ class Photo(object):
|
|||||||
right = image.size[0]
|
right = image.size[0]
|
||||||
bottom = image.size[1] - ((image.size[1] - image.size[0]) / 2)
|
bottom = image.size[1] - ((image.size[1] - image.size[0]) / 2)
|
||||||
image = image.crop((left, top, right, bottom))
|
image = image.crop((left, top, right, bottom))
|
||||||
|
gc.collect()
|
||||||
image.thumbnail((size, size), Image.ANTIALIAS)
|
image.thumbnail((size, size), Image.ANTIALIAS)
|
||||||
try:
|
try:
|
||||||
image.save(thumb_path, "JPEG")
|
image.save(thumb_path, "JPEG")
|
||||||
|
@ -11,19 +11,25 @@ $(document).ready(function() {
|
|||||||
return "cache/" + cachePath(path + "/" + image + "_" + suffix + ".jpg");
|
return "cache/" + cachePath(path + "/" + image + "_" + suffix + ".jpg");
|
||||||
}
|
}
|
||||||
function loadAlbum(path) {
|
function loadAlbum(path) {
|
||||||
|
if (path in album_cache) {
|
||||||
|
albumLoaded(album_cache[path]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "cache/" + path + ".json",
|
url: "cache/" + path + ".json",
|
||||||
error: function() { $(document.body).html("Couldn't fetch it."); },
|
error: function() { $(document.body).html("Couldn't fetch it."); },
|
||||||
success: function(album) {
|
success: albumLoaded
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function albumLoaded(album) {
|
||||||
|
album_cache[cachePath(album.path)] = album;
|
||||||
current_album = album;
|
current_album = album;
|
||||||
if (current_image_cache != null)
|
if (current_image_cache != null)
|
||||||
showPhoto();
|
showPhoto();
|
||||||
else
|
else if (cachePath(album.path) == current_album_cache)
|
||||||
showAlbum();
|
showAlbum();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
function showAlbum() {
|
function showAlbum() {
|
||||||
$("html, body").animate({ scrollTop: 0 }, "slow");
|
$("html, body").animate({ scrollTop: 0 }, "slow");
|
||||||
var title = "";
|
var title = "";
|
||||||
@ -73,6 +79,7 @@ $(document).ready(function() {
|
|||||||
var current_album_cache = "";
|
var current_album_cache = "";
|
||||||
var current_image_cache = "";
|
var current_image_cache = "";
|
||||||
var current_album = null;
|
var current_album = null;
|
||||||
|
var album_cache = new Array();
|
||||||
$(window).hashchange(function() {
|
$(window).hashchange(function() {
|
||||||
var new_album_cache = location.hash.substring(1);
|
var new_album_cache = location.hash.substring(1);
|
||||||
var index = new_album_cache.lastIndexOf("/");
|
var index = new_album_cache.lastIndexOf("/");
|
||||||
|
Loading…
Reference in New Issue
Block a user