mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-15 16:19:28 +01:00
Better thumbs loading, now with browser caching
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
"aTargets": [ 0 ],
|
||||
"mData":"ArtistID",
|
||||
"mRender": function ( data, type, full ) {
|
||||
return '<div id="artistImg"><img class="albumArt" alt="" id="'+ data + '"/></div>';
|
||||
return '<div id="artistImg"><img class="albumArt" alt="" id="'+ data + '" src="/thumbs/artist/' + data + '"/></div>';
|
||||
}
|
||||
},
|
||||
{"aTargets":[1],"mDataProp":"ArtistSortName"},
|
||||
@@ -73,7 +73,6 @@
|
||||
},
|
||||
"fnInitComplete": function(oSettings, json)
|
||||
{
|
||||
getArtistArt();
|
||||
}});
|
||||
|
||||
|
||||
|
||||
@@ -872,3 +872,37 @@ class WebInterface(object):
|
||||
return simplejson.dumps(image_dict)
|
||||
|
||||
getImageLinks.exposed = True
|
||||
|
||||
class Thumbs(object):
|
||||
def index(self):
|
||||
return "Here be thumbs"
|
||||
index.exposed = True
|
||||
def default(self,ArtistOrAlbum="",ID=None):
|
||||
from headphones import cache
|
||||
ArtistID = None
|
||||
AlbumID = None
|
||||
if ArtistOrAlbum == "artist":
|
||||
ArtistID = ID
|
||||
elif ArtistOrAlbum == "album":
|
||||
AlbumID = None
|
||||
|
||||
relpath = cache.getThumb(ArtistID,AlbumID)
|
||||
|
||||
if not relpath:
|
||||
if ArtistOrAlbum == "artist":
|
||||
relpath = "data/interfaces/default/images/no-cover-artist.png"
|
||||
elif ArtistOrAlbum == "album":
|
||||
relpath = "data/interfaces/default/images/no-cover-art.png"
|
||||
cherrypy.response.headers['Content-type'] = 'image/png'
|
||||
cherrypy.response.headers['Cache-Control'] = 'no-cache'
|
||||
else:
|
||||
fileext = os.path.splitext(relpath)[1][1::]
|
||||
cherrypy.response.headers['Content-type'] = 'image/' + fileext
|
||||
cherrypy.response.headers['Cache-Control'] = 'max-age=31556926'
|
||||
|
||||
path = os.path.abspath(relpath)
|
||||
f = open(path,'rb')
|
||||
return f.read()
|
||||
default.exposed = True
|
||||
|
||||
WebInterface.thumbs = Thumbs()
|
||||
|
||||
Reference in New Issue
Block a user