rstacruz / sinatra-assetpack

Package your assets transparently in Sinatra.
http://ricostacruz.com/sinatra-assetpack/
MIT License
541 stars 97 forks source link

How to add a Favicon and Apple Touch Icons? #83

Closed danielbayerlein closed 11 years ago

danielbayerlein commented 11 years ago

Hi guys, how to add a Favicon and Apple Touch Icons with Sinatra AssetPack?

assets {
  serve '/assets/images', from: 'app/assets/images'
}
%link{rel: 'icon', type: 'image/ico', href: '/assets/images/favicon.ico'}
%link{rel: 'apple-touch-icon', href: '/assets/images/touch-icon-iphone.png'}
%link{rel: 'apple-touch-icon', size: '72x72',
      href: '/assets/images/touch-icon-ipad.png'}
%link{rel: 'apple-touch-icon', size: '114x114',
      href: '/assets/images/touch-icon-iphone-retina.png'}
%link{rel: 'apple-touch-icon', size: '144x144',
      href: '/assets/images/touch-icon-ipad-retina.png'}
j15e commented 11 years ago

That's something we must improve, there is only an helper for image tag and we should provide a simple asset_path helper to get any asset versioned path.

But this code and url without version numbers should work too, are you getting 404s?

danielbayerlein commented 11 years ago

@j15e Thanks for your feedback. .png images works fine, but the favicon (.ico) is broken.

$ rake assetpack:build

+ /public/assets/images/favicon.ico
+ /public/assets/images/favicon.110302.ico
+ /public/assets/images/touch-icon-ipad-retina.png
+ /public/assets/images/touch-icon-ipad-retina.854426.png
+ /public/assets/images/touch-icon-ipad.png
+ /public/assets/images/touch-icon-ipad.476348.png
+ /public/assets/images/touch-icon-iphone-retina.png
+ /public/assets/images/touch-icon-iphone-retina.660437.png
+ /public/assets/images/touch-icon-iphone.png
+ /public/assets/images/touch-icon-iphone.583499.png

Use Sinatra AssetPack a image compressor? app/assets/images/favicon.ico = 100 KB /public/assets/images/favicon.ico = 458 Byte

j15e commented 11 years ago

There is no image compressor, but the is a defined list of supported file extensions and that is why ico are rejected (you could extend it, not real reason behind this) :

https://github.com/rstacruz/sinatra-assetpack/blob/master/lib/sinatra/assetpack.rb#L13

danielbayerlein commented 11 years ago

I will use a .png favicon. That's ok for me. :wink:

j15e commented 11 years ago

Thanks for raising the issue, I'll add improving the supported extension list to the improvements list.