Make sure there is a default icon for swift index

Check an icon exists for the file mimetype or otherwise use a
default icon on the swift log indexes.

Change-Id: Id8ae918c5888b19c2702a711a292ca8f0176cbdd
This commit is contained in:
Joshua Hesketh 2015-02-25 11:39:59 +11:00
parent 982cea8730
commit 6a95d63dd5

View File

@ -32,6 +32,7 @@ DEBUG = True
# Map mime types to apache icons
APACHE_MIME_ICON_MAP = {
'_default': '/icons/unknown.png',
'application/gzip': '/icons/compressed.png',
'folder': '/icons/folder.png',
'text/html': '/icons/text.png',
@ -61,9 +62,11 @@ APACHE_MIME_ICON_MAP = {
def get_mime_icon(mime, filename=''):
if filename == '../':
if filename == '../' and filename in APACHE_MIME_ICON_MAP:
return APACHE_MIME_ICON_MAP[filename]
return APACHE_MIME_ICON_MAP[mime]
if mime in APACHE_MIME_ICON_MAP:
return APACHE_MIME_ICON_MAP[mime]
return APACHE_MIME_ICON_MAP['_default']
def generate_log_index(folder_links, header_message=''):