From 6df30b9cc8ae0f1d812cddc741aaf6750865d374 Mon Sep 17 00:00:00 2001 From: Joshua Hesketh Date: Mon, 16 Feb 2015 15:24:34 +1100 Subject: [PATCH] zuul-swift-log index use icons for mimetype Use the apache icons for the mimetime (similar to mod-autoindex) Change-Id: I7f40c7c344801263a87c756697c087569fac4a20 --- jenkins/scripts/zuul_swift_upload.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/jenkins/scripts/zuul_swift_upload.py b/jenkins/scripts/zuul_swift_upload.py index 2f287fb5c2..06e57fb928 100755 --- a/jenkins/scripts/zuul_swift_upload.py +++ b/jenkins/scripts/zuul_swift_upload.py @@ -30,6 +30,14 @@ import time DEBUG = True +# Map mime types to apache icons +APACHE_MIME_ICON_MAP = { + 'application/gzip': '/icons/compressed.png', + 'folder': '/icons/folder.png', + 'text/html': '/icons/text.png', + 'text/plain': '/icons/text.png', + '../': '/icons/back.png', +} # file_detail format: A dictionary containing details of the file such as # full url links or relative path names etc. @@ -52,16 +60,27 @@ DEBUG = True # } +def get_mime_icon(mime, filename=''): + if filename == '../': + return APACHE_MIME_ICON_MAP[filename] + return APACHE_MIME_ICON_MAP[mime] + + def generate_log_index(folder_links, header_message=''): """Create an index of logfiles and links to them""" output = 'Index of results\n' output += '

%s

\n' % header_message - output += '' - output += '\n' + output += '
NameLast ModifiedSizeMime
' + output += '' for file_details in folder_links: output += '' + output += '[ ]' % ({ + 'm': file_details['metadata']['mime'], + 'i': get_mime_icon(file_details['metadata']['mime'], + file_details['filename']), + }) output += '' % (file_details['url'], file_details['filename']) output += '' % time.asctime( @@ -71,7 +90,6 @@ def generate_log_index(folder_links, header_message=''): else: size = sizeof_fmt(file_details['metadata']['size'], suffix='') output += '' % size - output += '' % file_details['metadata']['mime'] output += '\n'
NameLast ModifiedSize
%s%s%s%s