diff options
author | Sullivan SENECHAL <soullivaneuh@gmail.com> | 2014-10-04 12:29:18 +0200 |
---|---|---|
committer | Sullivan SENECHAL <soullivaneuh@gmail.com> | 2015-03-28 16:49:05 +0100 |
commit | 8ef7220c2316810e2a9bd784f22d25b4a073c138 (patch) | |
tree | c4a0398366e34aca7620ff7417fb44564392630d /app/helpers/icons_helper.rb | |
parent | db948ff3d6a72620391c7cb0f169334cef0438c7 (diff) | |
download | gitlab-ce-8ef7220c2316810e2a9bd784f22d25b4a073c138.tar.gz |
Improve file icons rendering on tree
Diffstat (limited to 'app/helpers/icons_helper.rb')
-rw-r--r-- | app/helpers/icons_helper.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 18260f0ed4d..187e21832f0 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -36,4 +36,48 @@ module IconsHelper def private_icon icon('lock') end + + def file_type_icon_class(type, mode, name) + if type == 'folder' + icon_class = 'folder' + elsif mode == 0120000 + icon_class = 'share' + else + # Guess which icon to choose based on file extension. + # If you think a file extension is missing, feel free to add it on PR + + case File.extname(name).downcase + when '.pdf' + icon_class = 'file-pdf-o' + when '.jpg', '.jpeg', '.jif', '.jfif', + '.jp2', '.jpx', '.j2k', '.j2c', + '.png', '.gif', '.tif', '.tiff', + '.svg', '.ico', '.bmp' + icon_class = 'file-image-o' + when '.zip', '.zipx', '.tar', '.gz', '.bz', '.bzip', + '.xz', '.rar', '.7z' + icon_class = 'file-archive-o' + when '.mp3', '.wma', '.ogg', '.oga', '.wav', '.flac', '.aac' + icon_class = 'file-audio-o' + when '.mp4', '.m4p', '.m4v', + '.mpg', '.mp2', '.mpeg', '.mpe', '.mpv', + '.mpg', '.mpeg', '.m2v', + '.avi', '.mkv', '.flv', '.ogv', '.mov', + '.3gp', '.3g2' + icon_class = 'file-video-o' + when '.doc', '.dot', '.docx', '.docm', '.dotx', '.dotm', '.docb' + icon_class = 'file-word-o' + when '.xls', '.xlt', '.xlm', '.xlsx', '.xlsm', '.xltx', '.xltm', + '.xlsb', '.xla', '.xlam', '.xll', '.xlw' + icon_class = 'file-excel-o' + when '.ppt', '.pot', '.pps', '.pptx', '.pptm', '.potx', '.potm', + '.ppam', '.ppsx', '.ppsm', '.sldx', '.sldm' + icon_class = 'file-powerpoint-o' + else + icon_class = 'file-text-o' + end + end + + icon_class + end end |