May 14 2008

Okay, Grails, That Was Cute: Taglibs

Published by Robert Fischer under To Be Categorized

So, a while back I was impressed by Rails routing. It was a nice little surprise which came out of left field to impress me: I love it when frameworks do that.

Grails just had its time — taglibs. Now, because of the pain of JSP tag libraries, I’ve avoided anything that sounded anything like UI taglibs. But, I was starting to repeat myself in views, and in such a way that partials seemed a bit hokey. This is where custom tags come in.

So, I sucked it up and checked out Grails taglibs. The limited documentation on the page scared the crap out of me, because I assumed I was going to get stuck and there’d be no help.

Turned out I didn’t need any. Nice.

The code that repeated looked like this:


            <g:if test="${data.otherDobs}">
                <g:link action="otherDobs" id="${id}">
                    Other Date(s) of Birth
                </g:link>
            </g:if>
            <g:else>&nbsp;</g:else>

The argument to “test”, the “action”, the “id”, and the text to display all varied.

After the taglib, it looks like this:


            <g:moreData test="${data.otherDobs}"
                    action="otherDobs" id="${id}">
                    Other Date(s) of Birth
            </g:moreData>

The taglib was just:


class MyAppTagLib {
  def moreData = { attr, body ->
    if(attr['test']) {
      out << link([action: attr['action'], id: attr['id']], { body() })
    } else {
      out << ' '
    }
  }
}

Cute. For bonus points, I could have passed all the attrs except for ‘test’ down into link, but I decided against doing that right now. All the magic was freaking me out.

Popularity: 1% [?]

3 responses so far

May 14 2008

My Story on “In the Loop”

Published by Robert Fischer under To Be Categorized

I got up at the last Story Slam that In the Loop did. If you’re interested in hearing it, check out the MP3 here (mirrored here).

I got bounced to the bonus reel, which shows the quality of the people they had show up. If you want to hear more of this stuff, check out the “In the Loop” podcast for the prime cut. You probably also want to check out the “In the Loop” blog (fed to Twitter here).

Popularity: 1% [?]

No responses yet

May 14 2008

Just Confirmed: Presenting Ocaml 101 for Ruby.MN

Published by Robert Fischer under To Be Categorized

I’m going to be doing an Ocaml/Functional Programming 101 at June’s Ruby.MN. I think I’m going to implement a LOLCode runtime.

I’ll try to figure out how to record it like all the cool kids. Any tips on doing that with a Mac would be appreciated.

Popularity: 1% [?]

2 responses so far

May 12 2008

Ruby + XML: A Serious Question That Only Sounds Facetious

Published by Robert Fischer under To Be Categorized

How does anyone actually do XML parsing in Ruby? I’m talking about real XML parsing with namespaces, entities, XML encoded text nodes — the whole 9 yards. I don’t need XPath: I’m willing to walk the tree a la Groovy’s XMLSlurper. But I need something that doesn’t suck.

I’ve been trying to do some simple XML parsing: read in an XML, extract some data elements (including namespaces that are declared), and then take one particular node and store all the child nodes in a CLOB (a.k.a. “text”) database field.

REXML has been a nightmare. It just barely works for parsing. Its XPath, while nominally supported, is getting me all kinds of weird results. It’s never clear if it’s resolving entities or XML encoding or not. The pretty printer will wrap in the middle of an XML encoded entity. The deprecated #write method completely fails. And, best of all, the formatters ship with ruby 1.8.6 patchlevel 111 for darwin, but not ruby 1.8.6 patchlevel 36 for x86_64-linux. And the website is down, so I can’t pull down the code manually.

The alternatives I’ve looked at haven’t been awesome. LibXML-ruby is experimental, requires nonportable library installations, and has the libxml interface that we know and hate. Hpricot half-supports XML, and doesn’t support namespaces.

Quite frankly, XML parsing is one of those things that needs to be a solved problem before any language can be considered ready for the real world. As far as I can tell, Ruby fails at this point.

I know that it’s the open source world, and I should quit my bitchin’ and write up my own XML parser which doesn’t suck. There are two problems with this — 1) I’m not an XML expert, I don’t want to be an XML expert, and so if I were to write something, it’d take me a very long, very unhappy time and probably be wrong in nonobvious ways; 2) in the same amount of time, I could probably rewrite my application in Groovy/Grails, where XML parsing is easy. This amount of time, though, is a lot more than I want to spend. So if I flushed the time I’ve spent building my application down the toilet because something as common as XML parsing is broke in Ruby, I’m going to be really unhappy.

So someone please, please, please correct me by pointing out a great and glorious and easy-to-use XML library in Ruby.

Popularity: 4% [?]

19 responses so far

May 11 2008

Digg Away

Published by Robert Fischer under To Be Categorized

I’ve implemented WP Super Cache, because WP Cache just wasn’t cutting it. It’s actually caching pages, and provides all kinds of other high-traffic support. So hopefully we’ll survive our next Digging/Reditting/Slashdotting/whatever.

Popularity: 1% [?]

No responses yet

Next »

Green Web Hosting! This site hosted by DreamHost.