Get the icons

This commit is contained in:
Charles Haley 2010-10-16 15:28:25 +01:00
parent 9706f72041
commit 8a6e6c07e7

View File

@ -18,6 +18,7 @@ from calibre.utils.filenames import ascii_filename
from calibre.utils.config import prefs from calibre.utils.config import prefs
from calibre.library.comments import comments_to_html from calibre.library.comments import comments_to_html
from calibre.library.server import custom_fields_to_display from calibre.library.server import custom_fields_to_display
from calibre.library.field_metadata import category_icon_map
def render_book_list(ids, suffix=''): # {{{ def render_book_list(ids, suffix=''): # {{{
pages = [] pages = []
@ -279,6 +280,16 @@ class BrowseServer(object):
continue continue
if meta['is_custom'] and category not in displayed_custom_fields: if meta['is_custom'] and category not in displayed_custom_fields:
continue continue
# get the icon files
if category in category_icon_map:
icon = I(category_icon_map[category])
elif meta['is_custom']:
icon = I(category_icon_map[':custom'])
elif meta['kind'] == 'user':
icon = I(category_icon_map[':user'])
else:
icon = None # shouldn't get here
cats.append((meta['name'], category)) cats.append((meta['name'], category))
cats = ['<li title="{2} {0}">{0}<span>/browse/category/{1}</span></li>'\ cats = ['<li title="{2} {0}">{0}<span>/browse/category/{1}</span></li>'\
.format(xml(x, True), xml(quote(y)), xml(_('Browse books by'))) .format(xml(x, True), xml(quote(y)), xml(_('Browse books by')))