Add extendable file types mappings for icons [PIP-46]

This commit is contained in:
Oleksii Kriuchykhin 2018-02-26 14:23:02 +01:00
parent e7f7fe9ff7
commit aa933ad1f4
5 changed files with 24 additions and 6 deletions

View file

@ -15,6 +15,11 @@ module FileIconsHelper
image_link = 'office/PowerPoint-pptx_20x20x32.png'
end
# Now check for custom mappings or possible overrides
if Extends::FILE_ICON_MAPPINGS[file_ext]
image_link = Extends::FILE_ICON_MAPPINGS[file_ext]
end
if image_link
image_tag image_link
else

View file

@ -20,8 +20,11 @@
<% if wopi_file?(result.asset) %>
<%= wopi_asset_file_name(result.asset) %>
<% else %>
<p><%= truncate(result.asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
<p>
<%= file_extension_icon(result.asset) %>
<%= truncate(result.asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %>
</p>
<% end %>
<% end %>
<%= wopi_result_view_file_button(result) %>

View file

@ -123,8 +123,11 @@
<% else %>
<%= image_tag asset.url(:medium) if asset.is_image? %>
<% end %>
<p><%= truncate(asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
<p>
<%= file_extension_icon(asset) %>
<%= truncate(asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %>
</p>
<% end %>
</li>
<% end %>

View file

@ -7,8 +7,11 @@
<% if wopi_file?(asset) %>
<%= wopi_asset_file_name(asset) %>
<% else %>
<p><%= truncate(asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></p>
<p>
<%= file_extension_icon(asset) %>
<%= truncate(asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %>
</p>
<% end %>
<% end %>
<%= wopi_asset_view_button(asset) %>

View file

@ -50,4 +50,8 @@ class Extends
API_PLUGABLE_AUTH_METHODS = []
OMNIAUTH_PROVIDERS = []
# Hash used for mapping file extensions to custom icons,
# 'extension' => 'path_to_the_icon'
FILE_ICON_MAPPINGS = {}
end