Showing posts with label plugins. Show all posts
Showing posts with label plugins. Show all posts

Wednesday, December 24, 2008

A Grails Christmas

As of this post, Grails 1.1 Beta 2 has been released. We probably don't appreciate the effort and dedication that was involved in getting this release accomplished by the end of the year. Much obliged, all those Grails people.

I celebrate Christmas and I'm also learning the Grails Framework, so I would like to pass on a Christmas list (or in this case, a map) to convey my own Grails feature wishes. If they're not implemented in the 1.1 release then I will post it again during the next holiday season.

def christmasMap = [:]
christmasMap['Grails #5'] = 'Coffee Maker Plugin'
christmasMap['Grails #4'] = 'Email Integration'
christmasMap['Grails #3'] = 'Hannah Montana Security'
christmasMap['Grails #2'] = 'Rock Band/ Guitar Hero Plugin'
christmasMap['Grails #1'] = 'Grails and Groovy Gift Cards'
println christmasMap

#5) Coffee Maker Plugin
I would like to have a USB coffee maker and the ability to program it with Grails. The caffeine in the coffee would in turn motivate me to learn more Grails. This is a win for everyone.

#4) Email Integration
I can't do Christmas cards anymore because I just can't focus. I can do email though and it would be convenient to have email integration to send out mass holiday greetings to family and friends. I can then save the email data to send again next year.

#3) Hannah Montana Security
In order for Grails to gain further acceptance in the world we have to prevent Grails from being used for applications that will not further its cause. I'm guessing a Hannah Montana site would be an example of that and there should be built-in security in the framework. No offense, Disney.

#2) Rock Band/ Guitar Hero Plugin
Some days I just want to stop coding and go home and play Rock Band. How about a plugin that lets me program Grails and Groovy with my guitar, drums or even a microphone?

#1) Gift Cards
In the spirit of Christmas, what could spread good cheer better than Grails and Groovy gift cards?

Happy Holidays and have a Groovy New Year!

Tuesday, November 25, 2008

Quote of Tomorrow via RSS

The latest release of Q2OH went live last night and now it truly delivers the Quote of Tomorrow. Each night a quote is chosen at random and added to the new RSS feed. It uses the Feeds plugin and the Quartz plugin to make it happen and both are remarkable. Here is what it took to create and schedule a job as part of a Grails app:

class FeedSeedJob {

def quoteService

def cronExpression = "1 0 0 * * ?"
def group = "QotdGroup"

def execute() {
def qotd = quoteService.getQotdQuote()
println "QOTD is ${qotd.content}"
}
}

I honestly don't know how it could be any easier.

Thursday, November 20, 2008

Today's Timestamp is Tomorrow's Date

I have been working on a RSS feed for Q2OH. The Feeds plugin makes it as easy as I can imagine. I have run into a quirk or two with data formats that have nothing at all to do with the plugin. It seems my Dates are Timestamps. Grails does such a good job of things just working that I never noticed before. Trying to format a Timestamp is not exactly the same as formatting a Date. Also, when an API needs a Date, it may choke on a Timestamp. This makes sense and once understood is not too huge a stumbling block. However I noticed one thing that I found interesting and works in my favor. Incrementing a Timestamp seems to turn it into a Date.

Since Q2OH is the Quote of Tomorrow, in the feed entry I add a day to the field that holds the day the quote was added to the feed. In the Domain Class Quote, qotd is a Date. Here is the entire code necessary to create the feed:

class FeedsController {

def rss = {
render(feedType:"rss", feedVersion:"2.0") {
title = "Q2OH >> Quote of Tomorrow"
link = "http://host:port/app/rss/feed"
description = "The Quote of Tomorrow"

Quote.findAllByQotdIsNotNull().each() { quote ->
entry("Quote for ${quote.qotd + 1}") {
link = "http://host:port/app/quote/display/${quote.id}"
author = quote.author
publishedDate = (java.util.Date) quote.qotd
quote.content // return the content
}
}
}
}
}

This results in an entry title of : Quote for Fri Nov 21 10:22:50 EST 2008

Originally the code was:
    entry("Quote for ${quote.qotd}") {

That had an entry title of: Quote for 2008-11-20 10:22:50.0

So if you ask me, tomorrow looks better than today.

Thursday, October 16, 2008

Grails Searchable Plugin is Awesome

I am working on adding search to the Q2OH web site. Getting it to work took about 20 minutes. Getting it to work just like I wanted it to took a day. All thanks to the Searchable plugin by Maurice Nicholson. It does exactly what it says it does and it does it well. I did run into a slight setback getting the suggested queries to work correctly. It was a syntax issue and once I got the spellCheck option correctly included in the closure it performed as advertised.

static searchable = {
only = ['content', 'author']
content: spellCheck 'include'
}

Now when you search for "sea", if there are no results it will ask if you want to search for "see" instead.