Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahemoff/7c9de64236f84fb0f424 to your computer and use it in GitHub Desktop.
Save mahemoff/7c9de64236f84fb0f424 to your computer and use it in GitHub Desktop.
Touch icons, manifests, etc in Ruby
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
#!/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 ''
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