cache manifest, otf fonts

This commit is contained in:
Kyle Drake 2014-12-30 23:07:22 -06:00
parent 0de126d6b1
commit fe5b47ce53
4 changed files with 22 additions and 8 deletions

View file

@ -17,6 +17,7 @@ class Site < Sequel::Model
image/svg+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/vnd.ms-opentype
application/octet-stream
text/csv
text/tsv
@ -28,10 +29,11 @@ class Site < Sequel::Model
text/xml
application/xml
audio/midi
text/cache-manifest
}
VALID_EXTENSIONS = %w{
html htm txt text css js jpg jpeg png gif svg md markdown eot ttf woff woff2 json
geojson csv tsv mf ico pdf asc key pgp xml mid midi manifest
html htm txt text css js jpg jpeg png gif svg md markdown eot ttf woff woff2 json geojson csv tsv mf ico pdf asc key pgp xml mid midi manifest otf
}
MINIMUM_PASSWORD_LENGTH = 5
@ -464,9 +466,10 @@ class Site < Sequel::Model
mime_type = Magic.guess_file_mime_type uploaded_file[:tempfile].path
extname = File.extname uploaded_file[:filename]
if extname == ''
extname = uploaded_file[:filename]
end
# Possibly needed logic for .dotfiles
#if extname == ''
# extname = uploaded_file[:filename]
#end
unless (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/) &&
Site::VALID_EXTENSIONS.include?(extname.sub(/^./, '').downcase)

View file

@ -0,0 +1,7 @@
CACHE MANIFEST
NETWORK:
/test.html
CACHE:
/test.css
/test.js
/test.png

BIN
tests/files/chunkfive.otf Normal file

Binary file not shown.

View file

@ -40,9 +40,13 @@ describe 'site_files' do
end
it 'works with manifest files' do
$debug = true
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/.manifest', 'text/plain')
File.exists?(@site.files_path('.manifest')).must_equal true
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/cache.manifest', 'text/cache-manifest')
File.exists?(@site.files_path('cache.manifest')).must_equal true
end
it 'works with otf fonts' do
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/chunkfive.otf', 'application/vnd.ms-opentype')
File.exists?(@site.files_path('chunkfive.otf')).must_equal true
end
it 'succeeds with index.html file' do