Display HTML files inline #1191
This commit is contained in:
parent
8513f817bb
commit
99bba3710c
@ -464,8 +464,12 @@ class DmsfFile < ActiveRecord::Base
|
||||
last_revision && Redmine::MimeType.is_type?('video', last_revision.disk_filename)
|
||||
end
|
||||
|
||||
def html?
|
||||
last_revision && (Redmine::MimeType.of(last_revision.disk_filename) == 'text/html')
|
||||
end
|
||||
|
||||
def disposition
|
||||
(image? || pdf? || video?) ? 'inline' : 'attachment'
|
||||
(image? || pdf? || video? || html?) ? 'inline' : 'attachment'
|
||||
end
|
||||
|
||||
def preview(limit)
|
||||
|
||||
@ -195,6 +195,9 @@ class DmsfFileTest < RedmineDmsf::Test::UnitTest
|
||||
# Video
|
||||
@file1.last_revision.disk_filename = 'test.mp4'
|
||||
assert_equal 'inline', @file1.disposition
|
||||
# HTML
|
||||
@file1.last_revision.disk_filename = 'test.html'
|
||||
assert_equal 'inline', @file1.disposition
|
||||
end
|
||||
|
||||
def test_image
|
||||
@ -221,6 +224,12 @@ class DmsfFileTest < RedmineDmsf::Test::UnitTest
|
||||
assert @file1.video?
|
||||
end
|
||||
|
||||
def test_html
|
||||
assert !@file1.html?
|
||||
@file1.last_revision.disk_filename = 'test.html'
|
||||
assert @file1.html?
|
||||
end
|
||||
|
||||
def test_findn_file_by_name
|
||||
assert DmsfFile.find_file_by_name(@project1, nil, 'test.txt')
|
||||
assert_nil DmsfFile.find_file_by_name(@project1, nil, 'test.odt')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user