Last active
August 29, 2015 14:08
-
-
Save mahemoff/7c9de64236f84fb0f424 to your computer and use it in GitHub Desktop.
Touch icons, manifests, etc in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def touch_icons | |
tags = [tag('link', rel: 'apple-touch-icon-precomposed', href: '/apple-touch-icon-precomposed.png')] | |
%w(36 48 57 72 76 114 120 144 152 180 192 512).each { |size| | |
tags += [tag('link', rel: 'apple-touch-icon-precomposed', size:"#{size}x#{size}", href: asset_path("logos/v3/icon#{size}x#{size}.png"))] | |
} | |
tags.join("\n").safe | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate touch icons etc | |
cd `dirname $0`/path/to/icons | |
for width in 36 48 57 72 76 114 120 144 152 180 192 512 ; do | |
printf "$width " | |
convert -geometry ${width}x${width} icon512x512.png icon${width}x${width}.png | |
done | |
echo '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def manifest | |
app = Hashie::Mash.new( | |
name: 'App Name', | |
start_url: '/', | |
display: 'standalone', | |
orientation: 'portrait', | |
icons: [] | |
) | |
%w(0.75 1 1.5 2 3 4).each { |density| | |
width = (density.to_f * 48).to_i | |
app.icons << Hashie::Mash.new( | |
src: "icon#{width}x#{width}.png", | |
type: 'images/png', | |
sizes: "#{width}x#{width}", | |
density: density | |
) | |
} | |
render json: app.to_json | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment