February 2007

Using Textile with Grails

During the process of writing my first Grails application, Groovyquiz.com (coming soon), I needed a clean way to write the quiz text, and was generally not interested in writing everything as HTML.

I have always liked Textile, and quickly found a couple of options for using that format via two Java libraries: JTextile and textile4j. Now, I don’t know about you, but when I need a Java library of any nature, I tend to go with one that has most and preferably all of the following:

  • Jar file
  • JavaDocs
  • Example code
  • README file
  • Tests

When I don’t see those, I generally disregard the project and try to find something else. That was the case with JTextile… the download included 3 files: one java source file (JTextile.java), one text file for testing, and another java source file for running the test (Test.java). Where as textile4j had all of the features I listed above.

So, after deciding that I would use textile4j to Textilize my app, I followed these steps to get everything set up.

1. Copy textile4j jar to my

<grails-root>/lib

folder.

2. Created a

TextileCodec.groovy

file in

<grails-root>/grails-app/utils

folder with the following contents:

  1. import net.sf.textile4j.Textile
  2. class TextileCodec {
  3.   static encode = { str ->
  4.         return new Textile().process(str)
  5.   }
  6. }

3. Used it in my code! I needed it for a view:

  1. ${quiz.problem.encodeAsTextile()}

Simple as that!

General
Grails
Groovy
Software Development

Comments (3)

Permalink

Upcoming talks

I’ve got a few talks coming up in the next couple months:

March:

Domain Specific Languages - I’ll be talking to the Omaha Dynamic Language Users Group on March 6th.    I will be focusing on the Groovy language, but may slip in some Ruby and Lisp.

Basic Spring -  This talk will be part of the Omaha Java Users Group March 20th meeting.  It will be a “nothing but Spring” meeting.   Nick Larson will be talking about Spring MVC, whil I will focus on the fundamentals.

April:

This year I will be presenting at Infotec, the local Omaha conference for Information Technologies, put together by the local AITP association.  I have one session and one tutorial:

Agile Java Web Frameworks - sort of an omnibus of the latest frameworks, and of course what a “agile web framework” is.

Introduction to Ruby on Rails - this will be a four, yes FOUR, hour tutorial  using Ruby on Rails.  I am so excited to be doing this!  We will be building an application from scratch, covering most of the features in Rails.
Should be a fun couple of months!

AJAX/Web 2.0
Agile
Java
OJUG
Rails
Ruby
Self
Software Development
Speaking
Thought

Comments (0)

Permalink

Groovy Quiz coming to a website near you!

I’ve been working on my first Grails app off and on since I posted my Groovy peg game code last month.   It is a site dedicated to learning Groovy, using the quiz format in the spirit of Ruby Quiz.

The premise is pretty simple:  every week a new quiz  will  be posted on the website (groovyquiz.com), and interested developers will be able to discuss the quiz (without giving solutions ;)) for 48 hours, and then they can post their solutions on the website.

Personally, I find the quiz format to be a wonderful way to learn a new language.  It gives me focus on a specific task, and how to solve it, versus meandering through the language’s documentation.  I still do a little bit of the latter, as it has always been a good way of learning things about the language that I may not have know before.  Once I figured out a way to make dynamic calls in COBOL using that learning technique, but thats a story for another time.

You can help!

I can use your help coming up with Quizzes, and if someone wants to help moderate the site, I would really appreciate it.

I am thinking that groovyquiz.com should be operational in the next week or two… at which point I will be posting again here and in the Groovy User/Dev mailing lists.

General
Groovy
Java
Software Development

Comments (0)

Permalink