Today we're going to pick on a good idea gone bad. The good idea being the ability to kickstart a Grails application with Bootstrap from Twitter. What's gone wrong is the actual implementation. But let's start from the beginning.
Create a new application
grails create-app example
You've seen this over and over again, right? Nothing new here. Let's install the
kickstart-with-bootstrap plugin. For that in Grails 2 we'll modify the
grails-app/conf/BuildConfig.groovy
's
plugins
file like this:
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.1"
runtime ":resources:1.1.5"
build ":tomcat:$grailsVersion"
compile ":kickstart-with-bootstrap:0.5"
}
Easy enough. Let's compile the application first (
grails compile
) for the build system to fetch all the plugins and do its other bits. After that we'll execute
grails kickstart-with-bootstrap
(the one that just came about with the
kickstart-with-bootstrap plugin), answer all questions positive and we're done. At this point you can create a domain class and a controller but that's not really the point of this blog. The point here is to pick on the way the master kickstart layout looks like.
The good part
Well... the appearance is really great! But let's face it: it's so because
Bootstrap looks great. It has all the usual stuff, the top bar, nicely looking fonts, the layout is floating. That's all nice and dandy...
The ughly
Let's open the newly created
grails-app/views/layouts/kickstart.gsp
. Here are a few points I'd like to make:
<%-- <div class="container">--%>
What for the love of god was going through the author's mind to leave commented out code in official release? And believe me this is not a single place. There are actually 21 of those!
But that's as long as purity goes - let's try to find something scarier:
<g:if test="${ params.controller != null
&& params.controller != ''
&& params.controller != 'home'
&& params.controller != 'login'
}">
I mean what the heck is this?! We're in a reusable layout! Ok, you might think I'm bitching about one place in the layout... Well actually no. There is more:
class="${ params.action == "list" ? 'active' : '' }"
class="${ params.action == "create" ? 'active' : '' }"
So a list should be shown, right? Or maybe we're actually creating an entity... Hm,... What was going through the author's mind at this point???
Does it by any chance belong in a reusable layout?!
Summary
I personally think that such a plugin is a blessing for someone that starts a new project now and then. The original Bootstrap plugin just doesn't cut it. But for the love of God do it right! By providing such a half-done tool to others you're actually doing more harm than good.
I'd love to get in touch with the original author to straighten things out. I love the idea of having a plugin that supplies a set of scaffolding templates and a layout to get me started with a nice look and feel quickly. Never mind the fact that it doesn't use the resources plugin. I actually like it. But it needs to be done the proper way, the way it is reusable!