MetaInspector
MetaInspector is a handy gem which makes it easy to get information about a webpage such as…
- its title
- its description
- metadata like Facebook Open Graph or Twitter Cards
- a list of all images on the page
So let's say that you have a field in your app's user profiles for "personal website". Now you can display a nice preview of the url. Here's a simplistic example in haml:
- data = MetaInspector.new(@user.personal_website)
%a{href: data.url, target: "_blank"}
%img{src: data.image, size: 50}
%strong= data.title
%br
%blockquote= data.description
Recently I've had a fun time contributing some improvements, the maintainer Jaime Iniesta is great to work with! I made cookies persist across redirects (some websites require that before allowing you to land on the final page), and made it so if accessing a URL tries out, it will be tried 2 more times (both the timeout time and the retry count can be specified).
You can try out MetaInspector at the demo app.