FileTree: Show more distinct icons where possible

This commit is contained in:
Sebastian Serth
2022-10-04 15:08:09 +02:00
committed by Sebastian Serth
parent 1f95324029
commit ad8743a7d0
3 changed files with 20 additions and 4 deletions

View File

@@ -7,8 +7,14 @@ class FileType < ApplicationRecord
include DefaultValues
AUDIO_FILE_EXTENSIONS = %w[.aac .flac .m4a .mp3 .ogg .wav .wma].freeze
COMPRESSED_FILE_EXTENSIONS = %w[.7z .bz2 .gz .rar .tar .zip].freeze
CSV_FILE_EXTENSIONS = %w[.csv].freeze
EXCEL_FILE_EXTENSIONS = %w[.xls .xlsx].freeze
IMAGE_FILE_EXTENSIONS = %w[.bmp .gif .jpeg .jpg .png].freeze
PDF_FILE_EXTENSIONS = %w[.pdf].freeze
POWERPOINT_FILE_EXTENSIONS = %w[.ppt .pptx].freeze
VIDEO_FILE_EXTENSIONS = %w[.avi .flv .mkv .mp4 .m4v .ogv .webm].freeze
WORD_FILE_EXTENSIONS = %w[.doc .docx].freeze
after_initialize :set_default_values
@@ -23,7 +29,7 @@ class FileType < ApplicationRecord
validates :name, presence: true
validates :renderable, boolean_presence: true
%i[audio image video].each do |type|
%i[audio compressed csv excel image pdf powerpoint video word].each do |type|
define_method("#{type}?") do
self.class.const_get("#{type.upcase}_FILE_EXTENSIONS").include?(file_extension)
end