Website Preview Images
Dependency :
compile ":webthumbs:0.1"
Summary
Installation
grails install-plugin webthumbs
Description
Webthumbs plugin
Take care, it's early days for this plugin. The signed URL that the plugin generates includes a dateString which needs to be in the UTC time zone. If this is not the case, the signed URLs will be invalid. Having a UTC offset configuration property and a little tag library is on my list but I got little time right now.The webthumbs plugin generates signed URLs for the bluga.net webthumbs service. You will first have to sign up to be able to use this plugin. You will get 100 free credits per month which makes it easy to try it out for free.
Installation
To install the webthumbs plug-in just run the following commandgrails install-plugin webthumbs
webthumbs.key = 'key' webthumbs.user = 'user'
Usage
The plugin installs the WebthumbService and a small example controller that uses this service to create a preview URL to http://www.groovytweets.org. You should be able to call this demo controller with a URL like this:http://localhost:8080/<yourapp>/webthumbs/
class WebthumbsController { def webthumbsService def index = { render webthumbsService.getThumbURL('http://www.groovytweets.org') }
}Be warned that it is a bad idea to expose a general purpose action which takes the URL to preview as an input parameter. You would be exposing a free preview service if others find out. This demo controller does not do any harm as it would just create signed preview URLs for a single URL, the groovytweets website.The
webthumbsService.getThumbURL() method can be called with up to three parameters. By default the size will be set to medium2 and cache to 1. Cache specifies the number of days the preview image may be old (this makes sense as each preview request takes a few second to create the preview if the image has not been generated yet). The default size medium2 will return a preview image URL for a 320x240px image. A detailed description can be found at the Easythumbs API documentation.A couple more examples:{script}
//preview URL for grailspodcast.com, 320x240 image size, image may be 1 day old (default)
def url = webthumbService.getThumbURL("http://grailspodcast.com", "medium2")//preview URL for grailspodcast.com, 160x120 image size, image may be 5 days old
url = webthumbService.getThumbURL("http://grailspodcast.com", "medium", 5)
{script}TODO
- support for date offset so servers not in UTC can generate valid preview URLs all the time
- a basic tag library that takes a normal URL and outputs a signed preview URL