Tuesday 23 December 2008

Grails: OpenSearch in Fainit

This week I've been improving Fainit. One of the features that I've added is OpenSearch, it's really easy in Grails.

The result is that you can add a search engine in firefox, and search in the site like in this screenshot:

First you have to create a controller to server XML for OpenSearch:
def site_osd = {
render(template: '/common/site_osd', contentType:"text/xml")
}
To be more user friendly add a mapping in URLMappings.groovy
"/site_osd"(controller:'home', action: 'site_osd')
Next you have to do a template _site_osd.gsp to server XML descriptor
<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>${message(code:'search.opensearch.title')}</ShortName>
<Description>${message(code:'search.opensearch.description')}</Description>
<Url type="text/html" method="get" template="${createLink(controller: 'search', absolute: true)}?q={searchTerms}"/>
</OpenSearchDescription>
And the last step is add Opensearch descriptor to your main layout (main.gsp) in the head section,, like this:
<link rel="search" href="${createLink(controller:'home',action:'site_osd')}" type="application/opensearchdescription+xml" title="${message(code:'search.opensearch.title2')}"/>
And that's it, really easy and good result.

Monday 1 December 2008

Coming Soon Fainit


Have you ever looked for a plumber? Do you know the best restaurant in your city? Do you ask your friends to know the best services and places?

I've been working the whole past month in a collaboratively site to share the best places and services with your friends and with the world. Now I have the first beta, the chosen name is fainit.com, it's a really beta service and for this period I have a limited number of users, try to register and start to share your recommendations.

Behind fainit there is a grails project, and great experience developing my first social network.

Enjoy the site and send me feedback.