<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://raibledesigns.com/roller-ui/styles/rss.xsl" media="screen"?><rss version="2.0" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
  <title>Raible Designs</title>
  <link>https://raibledesigns.com/rd/</link>
      <atom:link rel="self" type="application/rss+xml" href="https://raibledesigns.com/rd/feed/entries/rss?tags=devoxx2011" />
    <description>Raible Designs is an Enterprise Open Source Consulting company. We specialize in UI and Full Stack Architectures using HTML5, CSS, JavaScript and Java. We love HTML5, Angular, Bootstrap, Spring Boot, and especially JHipster.</description>
  <language>en-us</language>
  <copyright>Copyright 2026</copyright>
  <lastBuildDate>Mon, 25 May 2026 13:53:18 -0600</lastBuildDate>
  <generator>Apache Roller (incubating) 5.0.3 (1388864191739:dave)</generator>
        <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/my_html5_with_play_scala</guid>
    <title>My HTML5 with Play Scala, CoffeeScript and Jade Presentation from Devoxx 2011</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/my_html5_with_play_scala</link>
        <pubDate>Fri, 18 Nov 2011 11:18:38 -0700</pubDate>
    <category>Java</category>
    <category>scala</category>
    <category>play-more</category>
    <category>devoxx2011</category>
    <category>devoxx</category>
    <category>html5</category>
    <category>playframework</category>
    <category>video</category>
    <category>coffeescript</category>
    <category>presentation</category>
    <category>jade</category>
            <description>This week, I had the pleasure of traveling to one of my favorite places in the world: Antwerp, Belgium. Like &lt;a href=&quot;http://raibledesigns.com/rd/entry/an_awesome_trip_to_amsterdam&quot;&gt;last year&lt;/a&gt;, I traveled with the lovely &lt;a href=&quot;http://mcginityphoto.com&quot;&gt;Trish McGinity&lt;/a&gt; and spoke at &lt;a href=&quot;http://www.devoxx.com/display/DV11/Home&quot;&gt;Devoxx 2011&lt;/a&gt;. This year, my talk was on developing a web/mobile app with HTML5, Play, Scala, CoffeeScript and Jade. I was inspired to learn Scala at the beginning of this year and added CoffeeScript and Jade to my learning list after talking to James Strachan at TSSJS 2011. You can read more about how my journey began in my &lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with&quot;&gt;first post about learning these technologies&lt;/a&gt;.
&lt;/p&gt;&lt;p&gt;I started developing with these technologies in August and wrote about my learnings throughout the process. Last week, while writing my presentation, I decided it&apos;d be fun to make my presentation into more of a story-telling-session than a learn-about-new-technologies session. To do this, I focused on talking a bit about the technologies, but more about my experience learning them. I also came up with a challenging idea: create a video that showed the development process, how hard it was to test the app and (hopefully) my success in getting it to work.&lt;/p&gt;
&lt;p&gt;It was all a very close call, but I&apos;m happy to say I pulled it off! I got the app to work on an iPhone (&lt;a href=&quot;http://raibledesigns.com/rd/entry/phonegap_to_the_rescue&quot;&gt;thanks to PhoneGap&lt;/a&gt;) last Saturday, finished the first draft of my presentation on Sunday night (after pulling an all-nighter) and finished editing the demo video on Wednesday night. My talk was on Thursday afternoon and I had a blast talking about my experience to such a large, enthusiastic audience. You can see the presentation below, &lt;a href=&quot;http://www.slideshare.net/mraible/html5-with-play-scala-coffeescript-and-jade-devoxx-2011&quot;&gt;on Slideshare&lt;/a&gt; or &lt;a href=&quot;http://static.raibledesigns.com/repository/presentations/HTML5_with_Play_Scala_CoffeeScript_and_Jade_Devoxx2011.pdf&quot;&gt;download the PDF&lt;/a&gt;.&lt;/p&gt;
&lt;p style=&quot;text-align: center&quot;&gt;
&lt;iframe src=&quot;//www.slideshare.net/slideshow/embed_code/10204272?rel=0&quot; width=&quot;510&quot; height=&quot;426&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;
&lt;/p&gt;
&lt;p&gt;You can find the &quot;demo&quot; for this talk &lt;a href=&quot;http://www.youtube.com/watch?v=bBqtPPfM2xQ&quot;&gt;on YouTube&lt;/a&gt; or watch it below.
&lt;/p&gt;
&lt;p style=&quot;text-align: center&quot;&gt;
&lt;iframe width=&quot;510&quot; height=&quot;289&quot; src=&quot;//www.youtube.com/embed/bBqtPPfM2xQ?rel=0&amp;amp;hd=1&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;/p&gt;
&lt;p&gt;One of the reasons I really enjoyed this talk is it only represents one milestone in my learning process. I plan on continuing to develop this application and learning more about HTML5, Scala, Play and CoffeeScript and Scalate/Jade. Now that &lt;a href=&quot;http://raibledesigns.com/rd/entry/play_2_0_a_web&quot;&gt;Play 2.0 Beta has been released&lt;/a&gt;, I plan on upgrading to it and leveraging its native CoffeeScript and LESS support. I hope to continue using &lt;a href=&quot;http://scalate.fusesource.org/&quot;&gt;Scalate&lt;/a&gt; and its &lt;a href=&quot;http://scalate.fusesource.org/documentation/jade.html&quot;&gt;Jade&lt;/a&gt; format. And it&apos;s very likely &lt;a href=&quot;http://phonegap.com/&quot;&gt;PhoneGap&lt;/a&gt; will continue to be &lt;em&gt;the bridge&lt;/em&gt; that allows everything to run in the background.&lt;/p&gt;
&lt;p&gt;I&apos;ve been talking with the &lt;a href=&quot;www.jfokus.se/&quot;&gt;Jfokus&lt;/a&gt; folks about doing this talk in Sweden in Feburary and &lt;a href=&quot;http://devoxx.fr&quot;&gt;Devoxx France&lt;/a&gt; about presenting there in April. 
&lt;/p&gt;
&lt;p&gt;Learning all these technologies has been a challenging, but fun experience so far. As the last slide in my presentation says, I encourage you to do something similar. Pick something new to learn, have fun doing it, but more importantly - get out there and &lt;em&gt;Play!&lt;/em&gt;
&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Update Dec. 20th:&lt;/strong&gt; A video of this presentation is &lt;a href=&quot;http://parleys.com/d/2925&quot;&gt;now available on Parleys.com&lt;/a&gt;.</description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/deploying_java_and_play_framework</guid>
    <title>Deploying Java and Play Framework Apps to the Cloud with James Ward</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/deploying_java_and_play_framework</link>
        <pubDate>Fri, 18 Nov 2011 08:14:45 -0700</pubDate>
    <category>Java</category>
    <category>maven</category>
    <category>playframework</category>
    <category>sbt</category>
    <category>java</category>
    <category>springroo</category>
    <category>scala</category>
    <category>heroku</category>
    <category>devoxx2011</category>
    <category>jamesward</category>
    <category>devoxx</category>
            <description>Yesterday, I attended &lt;a href=&quot;http://www.jamesward.com/&quot;&gt;James Ward&lt;/a&gt;&apos;s presentation on &lt;a href=&quot;http://www.devoxx.com/pages/viewpage.action?pageId=5015973&quot;&gt;Deploying Java &amp;amp; Play Framework Apps to the Cloud&lt;/a&gt; at Devoxx. I arrived a bit late, but still managed to get there in time to see a lot of demos and learn more about &lt;a href=&quot;http://heroku.com&quot;&gt;Heroku&lt;/a&gt;. Below are my notes from James&apos;s talk.
&lt;/p&gt;
&lt;p&gt;When I arrived, James was doing a demo using &lt;a href=&quot;http://www.springsource.org/spring-roo&quot;&gt;Spring Roo&lt;/a&gt;. He was using Roo&apos;s Petclinic sample app and showed us how you could use Git to create a local repository of the new project and install Heroku&apos;s command line tool. From there, he ran the following command to create a new application on Heroku.
&lt;/p&gt;
&lt;pre&gt;heroku create -s cedar&lt;/pre&gt;
&lt;p&gt;The &lt;a href=&quot;http://devcenter.heroku.com/articles/cedar&quot;&gt;Cedar Stack&lt;/a&gt; is what supports Java, Scala and Play Framework. It&apos;s the 3rd generation stack for Heroku. The command above created two endpoints, one for HTTP and one for Git. It picks from a list of randomly generated names, which all seem to have some humor in them. James ended up with &quot;electric-sword-8877&quot; for this demo.&lt;/p&gt;
&lt;p&gt;From there, he ran &lt;code&gt;git push heroku master&lt;/code&gt; to deploy the project to Heroku. Unfortunately, this resulted in a login error and there was an akward moment where we all thought the Demo Gods were angry. However, James was able to resolve this by using Heroku&apos;s sharing feature with the following command.
&lt;/p&gt;
&lt;pre&gt;
heroku sharing:add jw@heroku.com
&lt;/pre&gt;
&lt;p&gt;For Java projects, Heroku looks for a pom.xml file in the root directory and runs a Maven build on project. All the dependencies get downloaded on the cloud rather than put them into a WAR and requiring you to upload a large WAR file. You don&apos;t have to upload your source code to Heroku; James did it for the sake of the demo because it was faster.
&lt;/p&gt;
&lt;p&gt;After the build finishes, it creates a &lt;em&gt;slug&lt;/em&gt; file. This file contains everything Heroku needs to run your application. 
&lt;p&gt;Next, James showed a demo of the running application and added a new Pet through its UI. Then he scaled it to two servers using the following command:
&lt;/p&gt;
&lt;pre&gt;
heroku scale web=2
&lt;/pre&gt;
&lt;p&gt;
He proved this was working by running &lt;code&gt;heroku ps&lt;/code&gt;, which showed there were two running processes. He showed the app again, but noted that the record he added was missing. This is because when it started up a new dyno, Hibernate created the schema again and deleted all records. To fix, James changed Hibernate to only update the schema instead of create a new one. If you&apos;re a Hibernate user, you know this is as simple as changing:
&lt;/p&gt;
&lt;pre&gt;
hibernate.hbm2ddl.auto=create
&lt;/pre&gt;
&lt;p&gt;to:
&lt;pre&gt;
hibernate.hbm2ddl.auto=update
&lt;/pre&gt;
&lt;p&gt;After committing this change, James redeployed using Git.
&lt;/p&gt;
&lt;pre&gt;
git push heroku master
&lt;/pre&gt;
&lt;p&gt;The slug file got built again and Heroku deployed the new slug onto both dynos, automatically load balancing the app across two servers. James then ran &lt;code&gt;heroku logs&lt;/code&gt; to see the logs of his dynos and prove that a request to his app&apos;s HTTP endpoint made requests to both dynos. The logging is powered by &lt;a href=&quot;https://github.com/heroku/logplex&quot;&gt;Logplex&lt;/a&gt; and you can read about how it works in the article &lt;a href=&quot;http://blog.heroku.com/archives/2010/12/13/logging/&quot;&gt;Heroku Gets Sweet Logging&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;James mentioned that Roo has a Heroku plugin, but after watching his talk and searching a bit on the internet, it seems it&apos;s just the jetty-runner setup as described in &lt;a href=&quot;http://devcenter.heroku.com/articles/spring-mvc-hibernate&quot;&gt;Getting Started with Spring MVC Hibernate on Heroku/Cedar&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
What about autoscaling? There are some 3rd party tools that do this. Heroku&apos;s Management infrastructure has APIs that these tools talk too. Heroku hasn&apos;t built autoscaling into the platform because they don&apos;t know where the bottlenecks are in your application.
&lt;/p&gt;
&lt;p&gt;
Heroku = Polyglot + PaaS + Cloud Components. It supports Ruby, node.js, Java, Clojure, Play and Scala and they&apos;re working on native Grails and Gradle support. There&apos;s currently 534,374 apps running on Heroku.
&lt;/p&gt;
&lt;p&gt;
Heroku is a cloud application platform and there&apos;s 5 different components. 
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Instant deployment&lt;/li&gt;
&lt;li&gt;HTTP Routing / Load Balancing&lt;/li&gt;
&lt;li&gt;Elastic Polyglot Runtime&lt;/li&gt;
&lt;li&gt;Management &amp;amp; Logging&lt;/li&gt;
&lt;li&gt;Component as a Service Ecosystem&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
For instant deployment, it&apos;s a pretty simple process:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;You add files to a git repo&lt;/li&gt;
&lt;li&gt;You provision the app on Heroku (heroku create)&lt;/li&gt;
&lt;li&gt;You upload the files to Heroku (git push heroku master)&lt;/li&gt;
&lt;li&gt;Heroku runs the build and assembles a &quot;slug&quot; file&lt;/li&gt;
&lt;li&gt;Heroku starts a &quot;dyno&quot;&lt;/li&gt;
&lt;li&gt;Heroku copies the &quot;slug&quot; to the &quot;dyno&quot;&lt;/li&gt;
&lt;li&gt;Heroku starts the web application&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Most apps will contain a &lt;em&gt;Procfile&lt;/em&gt; that contains information about how to run the web process. For Spring Roo, it has:
&lt;/p&gt;
&lt;pre&gt;
web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war
&lt;/pre&gt;
&lt;p&gt;So how does Heroku decide what application server to use? It doesn&apos;t, you do. You need to get your application server into the slug file. 
The easiest way to do this is to specify your application server as a dependency in your pom.xml. In the Roo example, James uses the maven-dependency-plugin to get the jetty-runner dependency and copy it to the target directory. On Heroku, you bring your application server with you.
&lt;/p&gt;
&lt;p&gt;Heroku gives you 750 free dyno hours per app, per month. For developers, it&apos;s very easy to get started and use. Once you extend past one dyno, it&apos;s
  $.05 per dyno hour, which works out to around $30/month.

It&apos;s only when you want to scale beyond one dyno where you get charged by Heroku, no matter how much data you transfer.

&lt;a href=&quot;http://www.scalatest.org/&quot;&gt;Scalatest&lt;/a&gt; is running on Heroku. It has one dyno and is doing fine with that. Bill Venners doesn&apos;t have to pay anything for it.
&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://java.herokuapp.com&quot;&gt;java.herokuapp.com&lt;/a&gt; is a site James created that allows you to clone example apps and get started quickly with Heroku&apos;s Cedar Stack.&lt;/p&gt;
&lt;p&gt;
For 
HTTP Routing, 
Heroku uses an Erlang-based routing system to route all the HTTP requests across your dynos. Heroku doesn&apos;t support sticky sessions. Distributed session management does not work well, because it does not scale well. Heroku recommends you use a stateless web architecture or move your state into something like &lt;a href=&quot;http://memcached.org/&quot;&gt;memcached&lt;/a&gt;. Jetty has (in the latest version) the ability to automatically serialize your session into a Mongo system. This works fine on Heroku. The problem with this is if you have 2 dynos running, each request can hit a different dyno and get different session state. Hence the recommendation for an external storage mechanism that can synchronize between dynos.
&lt;/p&gt;
You can also run non-web applications on Heroku. You can have one web process, but as many non-web processes as you want.
&lt;/p&gt;
&lt;p&gt;Heroku has native support for the &lt;a href=&quot;http://www.playframework.org/&quot;&gt;Play framework&lt;/a&gt;. To detect Play applications, it look for a &lt;em&gt;conf/application.conf&lt;/em&gt; file. You don&apos;t need to have a Procfile in your root directory because Heroku knows how to start a Play application.
&lt;/p&gt;
&lt;p&gt;At this point, James created a new Play application, created a new Heroku app (he got &quot;young-night-7104&quot; this time) and pushed it to Heroku. He created a simple model object, a controller to allow adding new data and then wrote some jQuery to show new records via Ajax and JSON. He also showed how to configure the application to talk to Heroku&apos;s PostgreSQL database using the DATABASE_URL environment variable. He explained how you can use the &lt;code&gt;heroku config&lt;/code&gt; command to see your environment variables.
&lt;/p&gt;
&lt;p&gt;
The reason they use environment variables is so Heroku can update DATABASE_URL (and other variables) without having to call up all their customers and have them change them in their source code.
&lt;/p&gt;
&lt;p&gt;
Play on Heroku supports Scala if you create your app with Scala. Play 2.0 uses Scala, Akka and SBT. Heroku added support for SBT a couple month ago, so everything will work just fine.
&lt;/p&gt;
&lt;p&gt;Heroku also supports Scala, detecting it by looking for the &lt;code&gt;build.sbt&lt;/code&gt; file in the root directory. Heroku supports SBT 0.11.0 and it builds the &apos;stage&apos; task.
It currently does not support Lift because Lift uses an older version of SBT and because it&apos;s a very stateful framework that would require sticky sessions. Use Play, &lt;a href=&quot;https://github.com/jdegoes/blueeyes&quot;&gt;BlueEyes&lt;/a&gt; or &lt;a href=&quot;http://www.scalatra.org/&quot;&gt;Scalatra&lt;/a&gt; if you want Scala on Heroku.
&lt;/p&gt;
&lt;p&gt;Heroku has &lt;a href=&quot;http://addons.heroku.com&quot;&gt;addons&lt;/a&gt; for adding functionality to your application, including Custom DNS, HTTPS, Amazon RDS, NoSQL and many more. They&apos;re also working on making their add-on and management APIs available via Java, so you&apos;ll (hopefully) be able to use them from your IDE in the future.
&lt;/p&gt;
&lt;p&gt;From there, James showed us how Heroku keeps slug files around so you can do rollbacks with &lt;code&gt;heroku rollback&lt;/code&gt;. He also showed how you can use:
&lt;/p&gt;
&lt;pre&gt;heroku run &quot;your bash command&quot;&lt;/pre&gt;
to run any Bash command on the cloud.
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br&gt;
I attended James&apos;s talk because he&apos;s a good friend, but also because I&apos;ve been using Heroku to host &lt;a href=&quot;http://raibledesigns.com/rd/entry/phonegap_to_the_rescue&quot;&gt;my latest adventures with Play, Scala, CoffeeScript and Jade&lt;/a&gt;. I&apos;m glad I attended because I learned some good tips and tricks and more about how Heroku works. 
&lt;/p&gt;
&lt;p&gt;Heroku seems like a great development tool to me. In my experience, it&apos;s been really nice to have instant deployments using Git. In fact, I&apos;ve created a &apos;push&apos; alias so I can push to my project&apos;s repo and heroku at the same time.
&lt;/p&gt;
&lt;pre&gt;
alias push=&apos;git push origin master &amp;&amp; git push heroku master&apos;
&lt;/pre&gt;
&lt;p&gt;I&apos;d like to see more organizations embrace something like Heroku for developers. It&apos;d be great if everyone had their own sandbox that business owners and product managers could see. I can&apos;t help but think this would be awesome for demos, prototyping, etc.
&lt;/p&gt;
&lt;p&gt;
There were some other talks I wanted to attend at the same time, particularly Martin Odersky&apos;s &lt;a href=&quot;http://www.devoxx.com/pages/viewpage.action?pageId=5015952&quot;&gt;What&apos;s in store for Scala?&lt;/a&gt; and &lt;a href=&quot;http://www.devoxx.com/display/DV11/WWW++World+Wide+Wait++A+Performance+Comparison+of+Java+Web+Frameworks&quot;&gt;WWW: World Wide Wait? A Performance Comparison of Java Web Frameworks&lt;/a&gt;. The WWW talk has &lt;a href=&quot;http://prezi.com/dr3on1qcajzw/www-world-wide-wait-devoxx-edition/&quot;&gt;posted their presentation&lt;/a&gt; but I&apos;m sure it&apos;d be more fun to watch. 
&lt;/p&gt;
&lt;p&gt;
It&apos;s pretty awesome that all the talks from Devoxx 2011 will be up on &lt;a href=&quot;http://www.parleys.com/&quot;&gt;Parleys.com&lt;/a&gt; soon.
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; James has &lt;a href=&quot;http://www.jamesward.com/2011/11/29/heroku-preso-from-devoxx-2011&quot;&gt;posted his slides&lt;/a&gt; from this talk.</description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/phonegap_for_hybrid_app_development</guid>
    <title>PhoneGap for Hybrid App Development</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/phonegap_for_hybrid_app_development</link>
        <pubDate>Wed, 16 Nov 2011 10:22:16 -0700</pubDate>
    <category>The Web</category>
    <category>devoxx</category>
    <category>ios</category>
    <category>javascript</category>
    <category>phonegap</category>
    <category>android</category>
    <category>adobe</category>
    <category>devoxx2011</category>
            <description>This afternoon, I attended &lt;a href=&quot;http://brian.io&quot; title=&quot;Brian LeRoux&quot;&gt;Brian LeRoux&lt;/a&gt;&apos;s talk on &lt;a href=&quot;http://www.devoxx.com/display/DV11/PhoneGap+for+Hybrid+App+Development&quot;&gt;PhoneGap for Hybrid App Development&lt;/a&gt; at Devoxx. You might remember that I &lt;a href=&quot;http://raibledesigns.com/rd/entry/phonegap_to_the_rescue&quot;&gt;tried PhoneGap last week&lt;/a&gt; and really enjoyed my experience. Below are my notes from Brian&apos;s talk.
&lt;/p&gt;
&lt;p&gt;
PhoneGap is a project for creating native applications using HTML, CSS and JavaScript. PhoneGap started out as a hack. In 2007, Apple shipped the iPhone and Steve Jobs told everyone they should develop webapps. PhoneGap started in 2008 as a lofty summertime hack and gained traction as a concept at Nitobi with Android and Blackberry implementations in the fall. In 2009, people started to pay attention when PhoneGap got rejected by Apple. They added Symbian and webOS support and Sony Ericsson started contributing to the project. They got rejected because all PhoneGap-developed apps were named &quot;PhoneGap&quot;. This turned out to be good press for the project and Apple let them in shortly after.
&lt;/p&gt;
&lt;p&gt;
In 2010, IBM began tag-teaming with Nitobi and added 5 developers to the project after meeting them at OSCON. In 2011, RIM started contributing as well as Microsoft. Then Adobe bought the company, so they&apos;re obviously contributing.
&lt;/p&gt;
&lt;p&gt;PhoneGaps Goals: the web is a first class platform, so let people create installable web apps. Their second goal is to cease to exist and get browsers to adopt their model.
&lt;/p&gt;
&lt;p&gt;
PhoneGap is NOT a runtime or a compiler/transpiler. It&apos;s not an IDE or predefined framework or proprietary lockin. It&apos;s Apache, MIT and BSD licensed to guarantee it&apos;s as free as free software gets. You can do whatever you want to do with it. PhoneGap has &lt;a href=&quot;http://arstechnica.com/open-source/news/2011/10/phonegap-to-become-an-apache-project-as-adobe-acquires-nitobi.ars&quot;&gt;recently been contributed to the Apache Software Foundation&lt;/a&gt;.
&lt;/p&gt;
As far as Adobe vs. PhoneGap is concerned, the Nitobi team remains contributors to PhoneGap. Adobe is a software tools company and has Apache and WebKit contributors. PhoneGap/Build integration will be added to &lt;a href=&quot;http://www.adobe.com/products/creativecloud.html&quot;&gt;Creative Cloud&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
The biggest issues with contributing PhoneGap to Apache is renaming the project and source control. I&apos;m not sure why it needs to be renamed, but it&apos;s likely that &lt;em&gt;Apache Callback&lt;/em&gt; is out. There seems to be some consensus on Apache Cordova. Apache likes SVN and the PhoneGap community currently uses Git. They&apos;re trying to find a medium road there, but would prefer to stay on Git.
&lt;/p&gt;
&lt;p&gt;
The PhoneGap technique is colloquially called &quot;the bridge&quot;. It&apos;s a 3 step process: they instantiate a WebView, then they call JavaScript from native code, then they call native code from JavaScript. Apparently, all device APIs are available via JavaScript in a WebView.
&lt;/p&gt;
&lt;p&gt;The primary platforms supported are iOS &gt;= 3, Android &gt;= 1.5 and BlackBerry &gt;= 5.x. They also support webOS, Symbian, Samsung Bada and Windows Phone. No mobile dev platform supports as many deploy targets as PhoneGap. Primary contributors are Adobe, IBM, RIM and Microsoft. 
&lt;/p&gt;
&lt;p&gt;Documentation for PhoneGap is available at &lt;a href=&quot;http://docs.phonegap.com&quot;&gt;http://docs.phonegap.com&lt;/a&gt;. Device APIs for PhoneGap 1.0 included sensors, data and outputs, which all devices have. Examples of sensors are geolocation and camera. Data examples are the filesystem, contacts and media. Outputs are screens, speakers and the speaker jack. All PhoneGap APIs are plugins, but any native API is permitted. 
&lt;/p&gt;
&lt;p&gt;
What about security? Brian recommends looking at the &lt;a href=&quot;http://html5sec.org&quot;&gt;HTML5 Security Cheatsheet&lt;/a&gt;. PhoneGap has added a lot of security measures since they&apos;ve found the native API pretty much opens up everything. 
&lt;/p&gt;
&lt;p&gt;
PhoneGap doesn&apos;t bundle a UI framework, but they support any JavaScript framework that works in the browser. PhoneGap is just a fancy browser, so your code run in less fancy web browsers too. This means you can develop and test your app in your desktop browser and only use PhoneGap to package and distribute your app.
&lt;/p&gt;
&lt;p&gt;Competition? PhoneGap has no competition. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href=&quot;https://build.phonegap.com/&quot;&gt;PhoneGap/Build&lt;/a&gt; is for compiling your apps in the cloud and free for open source projects. The biggest reason they did this is because they couldn&apos;t redistribute all the SDKs and it was a pain for developers to download and install SDKs in training classes.
&lt;/p&gt;
&lt;p&gt;
For mobile app development, you should have a singular goal. Do one thing really well if you want to be successful. Great UX happens iteratively. You know that the web works and has been widely successfully cross-platform. It&apos;s likely you&apos;ve already invested in the web. Start by building a mobile web client and use PhoneGap as a progressive enhancement technique. 
&lt;/p&gt;
&lt;p&gt;
Shipping and unit testing should be a daily activity. Automate everything so you can have one-click builds (test/dev/release). For web client design, constraints are your ally in the battle against complexity and &quot;clients who are not &lt;em&gt;chill&lt;/em&gt;&quot;. Phones suck and consume a lot: cpu, ram, bandwidth, battery, network... everything! Start with a benchmark of app performance and monitor that benchmark. If you have tons and tons of features, consider splitting into multiple apps.
&lt;/p&gt;
The mobile web is not WebKit! Opera is huge, Firefox is making strides and IE still happens. For layouts: use flex-box rules (anyone got a link to these?), css media queries and meta tags for viewport. You should try to develop your app without frameworks because they come with a ton of code and can effect the size of your app.
&lt;/p&gt;
&lt;p&gt;
Looks can kill: aesthetics that can hurt performance: border-radius, box-shadow and gradients can slow down your apps. Chances are, you really don&apos;t need these features. Design your app for your brand, not for the device manufacturer. An app that looks like an iPhone app on Android doesn&apos;t give a positive impression.&lt;/p&gt;
&lt;p&gt;
For JavaScript libraries, start with your problem, not a generic solution like Sencha or jQuery Mobile. &lt;a href=&quot;http://zeptojs.com/&quot;&gt;Zepto&lt;/a&gt; and its older brother &lt;a href=&quot;http://xuijs.com/&quot;&gt;XUI&lt;/a&gt; are all you need to start. &lt;a href=&quot;http://joapp.com/&quot;&gt;Jo&lt;/a&gt; is a fantastic option. &lt;a href=&quot;http://backbonejs.org/&quot;&gt;Backbone&lt;/a&gt; and &lt;a href=&quot;http://spine.github.io/&quot;&gt;Spine&lt;/a&gt; are worth watching.
&lt;/p&gt;
&lt;p&gt;
For testing, &lt;a href=&quot;http://docs.jquery.com/QUnit&quot;&gt;QUnit&lt;/a&gt; and &lt;a href=&quot;http://pivotal.github.com/jasmine/&quot;&gt;Jasmine&lt;/a&gt; are pretty popular. For deployment, concat, minify and obfuscate your JavaScript and CSS. Or you can inline everything into the markup to minimize HTTP chatter. Gmail inlines and comments all their JavaScript and then evals it.
&lt;/p&gt;
&lt;p&gt;From there, Brian recommended leveraging HTML5&apos;s &lt;a href=&quot;http://www.html5rocks.com/en/tutorials/appcache/beginner/&quot;&gt;AppCache&lt;/a&gt; and and using RESTful JSON endpoints for legacy systems. Next, he tried to show us a demo of a photo sharing application. Unfortunately, the Demo Gods were grumpy and Brian couldn&apos;t get his computer to recognize his Android phone. He did show us the &lt;a href=&quot;http://gist.github.com/1219277&quot;&gt;client code&lt;/a&gt; and it&apos;s pretty impressive you can use 1 line of code to take a picture on a phone.
&lt;/p&gt;
&lt;p&gt;The last thing we looked at was &lt;a href=&quot;http://debug.phonegap.com&quot;&gt;debug.phonegap.com&lt;/a&gt;. This is an app that&apos;s powered by &lt;a href=&quot;http://phonegap.github.com/weinre/&quot;&gt;weinre&lt;/a&gt;. It lets you enter a line of JavaScript in your client and then remotely debug it in a tool that looks like Chrome&apos;s Web Inspector. Very cool stuff if you ask me.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br/&gt;
I really enjoyed learning more about PhoneGap, particularly because Brain emphasized all my web development skills can be used. I don&apos;t have to learn Objective-C or Android to develop native apps and I don&apos;t even have to install an SDK if I use PhoneGap/Build. Of course, my mobile developer friends might disagree with this approach. In the meantime, I look forward to using PhoneGap to turn my mobile web clients into native apps and finding out if it&apos;s really as good as they say it is.
</description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/play_2_0_a_web</guid>
    <title>Play 2.0, A web framework for a new era</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/play_2_0_a_web</link>
        <pubDate>Wed, 16 Nov 2011 05:58:09 -0700</pubDate>
    <category>Java</category>
    <category>devoxx2011</category>
    <category>devoxx</category>
    <category>scala</category>
    <category>playframework</category>
    <category>akka</category>
            <description>This week, I&apos;m in Antwerp, Belgium for the annual &lt;a href=&quot;http://devoxx.com&quot;&gt;Devoxx&lt;/a&gt; conference. After traveling 21 hours door-to-door yesterday, I woke up and came to the conference to attend some talks on Play and PhoneGap. I just got out of the &lt;a href=&quot;http://devoxx.com/display/DV11/Play+2.0%2C+a+Web+framework+for+a+new+era&quot;&gt;session on Play 2.0&lt;/a&gt;, which was presented by &lt;a href=&quot;http://devoxx.com/display/DV11/Sadek+Drobi&quot;&gt;Sadek Drobi&lt;/a&gt; and &lt;a href=&quot;http://devoxx.com/display/DV11/Guillaume+Bort&quot;&gt;Guillaume Bort&lt;/a&gt;. Below are my notes from this presentation.&lt;/p&gt;
&lt;p&gt;The Play 2.0 beta is out! You can read more about this release &lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/6d5783e28efb6931&quot;&gt;on the mailing list&lt;/a&gt;. This beta includes native support for both Scala and Java, meaning you can use both in the same project. The release also bundles &lt;a href=&quot;http://akka.io/&quot;&gt;Akka&lt;/a&gt; and &lt;a href=&quot;https://github.com/harrah/xsbt/wiki&quot;&gt;SBT&lt;/a&gt; by default.
&lt;/p&gt;
&lt;p&gt;In other news, &lt;a href=&quot;http://blog.typesafe.com/typesafe-stack-adds-play-framework&quot;&gt;Play 2.0 is now part of the Typesafe Stack&lt;/a&gt;. Typesafe is the Scala company, started by the founder of Scala (&lt;a href=&quot;http://ch.linkedin.com/in/odersky&quot;&gt;Martin Odersky&lt;/a&gt;) and the founder of Akka (&lt;a href=&quot;http://se.linkedin.com/in/jonasboner&quot;&gt;Jonas Bon&#233;r&lt;/a&gt;). Guillaume is also joining the Typesafe Advisory Board.
&lt;/p&gt;
&lt;p&gt;Sadek and Guillaume both work at &lt;a href=&quot;http://www.zenexity.com/&quot;&gt;zenexity&lt;/a&gt;, where Play is the secret weapon for the web applications they&apos;ve built for the last decade. Play was born in the real world. They kept listening to the market to see what they should add to the project. At some point, they realized they couldn&apos;t keep adding to the old model and they needed to create something new.&lt;/p&gt;
&lt;p&gt;
The web has evolved from static pages to dynamic pages (ASP, PHP). From there, we moved to structured web applications with frameworks and MVC. Then the web moved to Ajax and long-polling to more real-time, live features.  And this changes everything.
&lt;/p&gt;
&lt;p&gt;
Now we need to adapt our tools. We need to handle tremendous flows of data. Need to improve expressiveness for concurrent code. We need to pick the appropriate datastore for the problem (not only SQL). We need to integrate with rapidly-evolving client side technologies like JavaScript, CoffeeScript, and Dart. We need to use elastic deployment that allows scaling up and scaling down.&lt;/p&gt;
&lt;p&gt;zenexity wanted to integrated all of these modern web needs into Play 2.0. But they also wanted to keep Play approachable. They wanted to maintain fast turnaround so you can change your code and hit reload to see the changes. They wanted to keep it as a full stack framework with support for JSON, XML, Web Services, Jobs, etc. And they wanted to continue to use and conventions over configuration.
&lt;/p&gt;
&lt;p&gt;At this point, Guillaume did a Play 2.0 Beta demo, show us how it uses SBT and has a console so everything so it runs really fast. You can have both Scala and Java files in the same project. Play 2.0 templates are based on Scala, but you don&apos;t need to know Scala to use them. You might have to learn how to write a for loop in Scala, but it&apos;s just a subset of Scala for templates and views. SBT is used for the build system, but you don&apos;t have to learn or know SBT. All the old &lt;code&gt;play&lt;/code&gt; commands still work, they&apos;re just powered by a different system.
&lt;/p&gt;
&lt;p&gt;After the demo, Sadek took over and started discussing the key features of Play 2.0.
&lt;/p&gt;
&lt;p&gt;
To handle tremendous amounts of data, you need to do chunking of data and be able to process a stream of data, not just wait until it&apos;s finished. Java&apos;s InputStream is outdated and too low level. Its &lt;em&gt;read()&lt;/em&gt; method reads the next byte of data from the input and this method can block until input data is available.&lt;/p&gt;
&lt;p&gt;
To solve this, Play includes a reactive programming feature, which they borrowed from Haskell. It uses Iteratee/Enumerator IO and leverages inversion of control (not like dependency injection, but more like not micro-managing). The feature allows you to have control when you need it so you don&apos;t have to wait for the input stream to complete. The Enumerator is the component that sends data and the Iteratee is the component that receives data. The Iteratee does incremental processing and can tell the Enumerator when it&apos;s done. The Iteratee can also send back a continuation, where it tells the Enumerator it wants more data and how to give it. With this paradigm, you can do a lot of cool stuff without consuming resources and blocking data flow.
&lt;/p&gt;
&lt;p&gt;
Akka is an actor system that is a great model for doing concurrent code. An Actor could be both an Enumerator and an Iteratee. This vastly improves the expressiveness for concurrent code. For example, here&apos;s how you&apos;d use Akka in Play:
&lt;pre class=&quot;brush: scala&quot;&gt;
def search(keyword: String) = Action {
  AsyncResult {
    // do something with result
  }
}
&lt;/pre&gt;
&lt;p&gt;
Play does not try to abstract data access because datastores are different now. You don&apos;t want to think of everything as objects if you&apos;re using something like MongoDB or navigating a Social Graph. Play 2.0 will provide some default modules for the different datastores, but they also expect a lot of contributed modules. Anorm will be the default SQL implementation for Play Scala and &lt;a href=&quot;https://github.com/playframework/Play20/wiki/JavaEbean&quot;&gt;Ebean&lt;/a&gt; will be the default ORM implementation for Play Java. The reason they&apos;ve moved away from Hibernate is because they needed something that was more stateless.
&lt;/p&gt;
&lt;p&gt;
On the client side, there&apos;s so many technologies (LESS, CoffeeScript, DART, Backbone.js, jQuery, SASS), they didn&apos;t want to bundle any because they move too fast. Instead, there&apos;s plugins you can add that help you leverage these technologies. There&apos;s a lot of richness you can take advantage of on the client side and you need to have the tools for that.&lt;/p&gt;
&lt;p&gt;Lastly, there&apos;s a new type of deployment: container-less deployment to the cloud. Akka allows you to distribute your jobs across many servers and &lt;a href=&quot;http://heroku.com&quot;&gt;Heroku&lt;/a&gt; is an implementation of elastic deployment that has built-in support for Play.
&lt;/p&gt;
&lt;p&gt;
They&apos;ve explained what they tried to design and the results of this new, clean architecture have been suprising. Side effects include: type-safety everywhere for rock-solid applications. There&apos;s an awesome performance boost from Scala. There&apos;s easier integration with existing projects via SBT. And it only takes 10 lines of code to develop an HTTP Server that responds to web requests.
&lt;p&gt;The memory consumption is amazing: only 2MB of heap is used when a Play 2.0 app is started. Tests on Guillaume&apos;s laptop have shown that it can handle up to 40,000 requests per second, without any optimization of the JVM. Not only that, but after the requests subside, garbage collection cleans up everything and reduces the memory consumption back to 2MB.
&lt;/p&gt;
&lt;p&gt;At this point, Guillaume did another demo, showing how everything is type-safe in 2.0, including the routes file. If you mistype (or comment one out) any routes, the compiler will find it and notify you. Play 2.0 also contains a &lt;em&gt;compiled assets&lt;/em&gt; feature. This allows you to &lt;a href=&quot;https://github.com/playframework/Play20/wiki/AssetsGoogleClosureCompiler&quot;&gt;use Google&apos;s Closure Compiler&lt;/a&gt;, &lt;a href=&quot;https://github.com/playframework/Play20/wiki/AssetsCoffeeScript&quot;&gt;CoffeeScript&lt;/a&gt; and &lt;a href=&quot;https://github.com/playframework/Play20/wiki/AssetsLess&quot;&gt;LESS&lt;/a&gt;. If you put your LESS files in &lt;em&gt;app/assets/stylesheets&lt;/em&gt;, compilation errors will show up in your browser. If you put JavaScript files in &lt;em&gt;app/assets/javascripts&lt;/em&gt;, the Closure compiler will be used and compilation errors will show up in your browser.
&lt;/p&gt;
&lt;p&gt;
Play 2.0 ships with 3 different sample applications, all implemented in both Java and Scala. HelloWorld is more than just text in a browser, it includes a form that shows how validation works. Another app is computer-database. When Guillaume started it, we saw how evolutions were used to create the database schema from the browser. The Play Team has done their best to make the development process a browser-based experience rather than having to look in your console. The computer-database is a nice example of how to do CRUD and leverages Twitter&apos;s Bootstrap for its look and feel.
&lt;/p&gt;
The last sample application is zentasks. It uses Ajax and implements security so you can see how to create a login form. It uses LESS for CSS and CoffeeScript and contains features like in-place editing. If you&apos;d like to see any of these applications in action, you can stop by the Typesafe booth this week at Devoxx.
&lt;/p&gt;
&lt;p&gt;Unfortunately, there will be no migrating path for Play 1.x applications. The API seems very similar, but there are subtle changes that make this difficult. The biggest thing is how templating has changed from Groovy to Scala. To migrate from 1.2.x would be mostly a copy/paste, modify process. There are folks working on getting Groovy templates working in 2.0. The good news is zenexity has hundreds of 1.x applications in production, so 1.x will likely be maintained for many years.
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br/&gt;
This was a great talk on what&apos;s new in Play 2.0. I especially like the native support for LESS and CoffeeScript and the emphasis on trying to keep developers using two tools: their editor and the browser. The sample apps look great, but the documentation look sparse. I doubt I&apos;ll get a chance to migrate my Play 1.2.3 app to 2.0 this month, but I hope to try migrating sometime before the end of the year.</description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/phonegap_to_the_rescue</guid>
    <title>PhoneGap to the Rescue!</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/phonegap_to_the_rescue</link>
        <pubDate>Mon, 14 Nov 2011 16:32:19 -0700</pubDate>
    <category>Java</category>
    <category>ios</category>
    <category>html5</category>
    <category>devoxx2011</category>
    <category>play-more</category>
    <category>phonegap</category>
    <category>apple</category>
            <description>This is the 7th article in a series about my adventures developing a web application with HTML5, Play Scala, CoffeeScript and Jade. Previous articles can be found at:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with&quot;&gt;Integrating Scalate and Jade with Play 1.2.3&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/trying_to_make_coffeescript_work&quot;&gt;Trying to make CoffeeScript work with Scalate and Play&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_html5_boilerplate_with_scalate&quot;&gt;Integrating HTML5 Boilerplate with Scalate and Play&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/developing_with_html5_coffeescript_and&quot;&gt;Developing with HTML5, CoffeeScript and Twitter&apos;s Bootstrap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/play_scala_s_anorm_heroku&quot;&gt;Play Scala&apos;s Anorm, Heroku and PostgreSQL Issues&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/more_scalate_goodness_for_play&quot;&gt;More Scalate Goodness for Play&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

A few weeks ago, I wrote about &lt;a href=&quot;http://raibledesigns.com/rd/entry/developing_with_html5_coffeescript_and&quot;&gt;Developing a Stopwatch and Trip Meter with HTML5&lt;/a&gt;. I mentioned I&apos;d run into a major issue when I discovered HTML5 Geo&apos;s &lt;span style=&quot;font-family: monaco; courier&quot;&gt;watchPosition()&lt;/span&gt; feature didn&apos;t run in the background. From that article:
&lt;/p&gt;
&lt;p class=&quot;quote&quot;&gt;
  I tried out the trip meter that evening
    on a bike ride and noticed it said I&apos;d traveled 3 miles when I&apos;d really gone 6. I quickly figured out it was only calculating
    start point to end point and not taking into account all the turns in between. To view what was happening, I integrated my
    odometer.coffee with my map using &lt;a href=&quot;http://code.google.com/apis/maps/documentation/javascript/overlays.html#Polylines&quot; style=&quot;color: #666&quot;&gt;
    Google Maps Polylines&lt;/a&gt;. Upon finishing the integration, I discovered two things, 1) HTML5 geolocation was highly inaccurate and
    2) &lt;a href=&quot;http://stackoverflow.com/questions/7676423/is-it-possible-to-make-an-html5-trip-meter-that-tracks-distance-traveled/7681295&quot; style=&quot;color: #666&quot;&gt;geolocation doesn&apos;t run in the background&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
At the time, I opted to ignore this issue and use my app by setting Auto-Lock to Never. This worked, but if I happened to bump my phone while exercising, the app would get closed. Not to mention it really drained the battery and seemed to crash every-so-often.
&lt;/p&gt;
&lt;p&gt;Last week, I realized things were getting down to the wire and I was running out of time to finish my app&apos;s functionality for my &lt;a href=&quot;http://www.devoxx.com/display/DV11/HTML5+with+Play+Scala%2C+CoffeeScript+and+Jade&quot;&gt;Devoxx Talk&lt;/a&gt;. On Wednesday afternoon, I asked my office-mates (2 iOS developers) about developing a native app and installing it on my phone. They told me I had to be a iOS Certified Developer ($99/year) or jailbreak my iPhone to get an app on it. On Thursday, I downloaded &lt;a href=&quot;http://phonegap.com&quot;&gt;PhoneGap&lt;/a&gt; and installed &lt;a href=&quot;http://developer.apple.com/xcode/&quot;&gt;Xcode 4&lt;/a&gt;. As you can tell from the following image, PhoneGap seemed to be exactly what I was looking for. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href=&quot;http://phonegap.com&quot; title=&quot;PhoneGap&quot;&gt;&lt;img src=&quot;//farm7.static.flickr.com/6055/6345056529_d814790e75.jpg&quot; width=&quot;500&quot; height=&quot;232&quot; alt=&quot;PhoneGap&quot;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;I spent some time going through PhoneGap&apos;s &lt;a href=&quot;http://phonegap.com/start&quot;&gt;Getting Started Guide&lt;/a&gt; and was able to get my app rendering in a short amount of time. I was able to copy the webapp&apos;s generated HTML into my PhoneGap project&apos;s &lt;em&gt;www&lt;/em&gt; directory and launch the app in the iOS Simulator. The only change I had to make was to convert my inline CoffeeScript (that used coffee-script.js for in-browser compilation) to JavaScript. It&apos;s possible the in-browser compiler works, but when things didn&apos;t work and I didn&apos;t see any error messages, it was the first thing I changed.
&lt;/p&gt;
&lt;p&gt;  
For getting the app onto a phone for testing, I opted for the easiest route and applied for an iOS Developer Account on Thursday afternoon. While waiting for approval on Friday, I briefly tried to jailbreak my phone, but encountered all kinds of version issues and gave up after 30 minutes. 24 hours after I applied for my account, Apple emailed asking for a business document to prove I was legit. I was unable to download any from the &lt;a href=&quot;http://www.sos.state.co.us/&quot;&gt;Colorado Secretary of State&lt;/a&gt; that were &lt;em&gt;e-certified&lt;/em&gt;, so expeditiously switched my application from a business account to an individual one. Apple was great in helping me out before the weekend started and I had everything I needed as we drove to our &lt;a href=&quot;http://raibledesigns.com/rd/entry/another_dream_realized_mountain_views&quot;&gt;Ski Shack&lt;/a&gt; on Friday evening. 
&lt;/p&gt;
&lt;p&gt;On Friday night, I upgraded Trish&apos;s iPhone 4 to iOS 5 to make sure I had the latest and greatest platform for my app. Saturday morning, I woke up around 8 and started trying to figure out how to get my app on her phone. It took about an hour of fumbling, grumbling and searching to figure out how to do this. All the while, the troops were getting restless, noting that they were hungry for breakfast and groaning about Daddy taking so long. At 9:30, I finally got my PhoneGap app installed on Trish&apos;s phone and we drove to breakfast at &lt;a href=&quot;http://www.tripadvisor.com/Restaurant_Review-g33431-d382122-Reviews-Sharky_s-Fraser_Colorado.html&quot;&gt;Sharkey&apos;s&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;  
I started the app when we left and checked it 5 minutes later when we arrived for breakfast. The blood drained from my face when I saw the app had drawn a straight line from our condo to the breakfast joint. We had taken several turns along the way and my new native app ignored them all. I assumed I had failed and my talk&apos;s conclusion at Devoxx would be &quot;You can&apos;t develop a reliable Fitness Tracker app with HTML5&quot;. However, after a delicious Eggs Benedict, I became determined to succeed and returned home for some more hacking.
&lt;/p&gt;
&lt;p&gt;This is when I discovered Joel Dare&apos;s &lt;a href=&quot;http://www.joeldare.com/wiki/play_an_mp3_audio_stream_in_phonegap&quot;&gt;Play an MP3 Audio Stream in PhoneGap&lt;/a&gt; tutorial and the &quot;Required background modes&quot; key. This was the knowledge that saved the day and I anxiously added the key and the values to get location updates and allow audio to run in the background. 
&lt;/p&gt;
&lt;p style=&quot;text-align: center&quot;&gt;
&lt;a href=&quot;http://farm7.static.flickr.com/6040/6345880496_62808c5075_b.jpg&quot; title=&quot;Required Background Modes&quot; rel=&quot;lightbox[phonegap]&quot;&gt;&lt;img src=&quot;//farm7.static.flickr.com/6040/6345880496_62808c5075.jpg&quot; width=&quot;500&quot; height=&quot;258&quot; alt=&quot;Required Background Modes&quot; style=&quot;border: 1px solid black&quot;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;Saturday afternoon, I strapped on my recently purchased &lt;a href=&quot;http://gopro.com/&quot;&gt;GoPro Camera&lt;/a&gt;, shot some video for my demo at Devoxx and had a blast skiing with Abbie, Jack and Trish. I celebrated that evening with an executive workout (15 minutes each in hot tub, sauna and steam room) at the &lt;a href=&quot;http://www.fraservalleyrec.org/&quot;&gt;Fraser Rec Center&lt;/a&gt; and again on Sunday when the Broncos whooped the Kansas City Chiefs &lt;a href=&quot;http://raibledesigns.com/rd/entry/an_awesome_trip_to_amsterdam&quot;&gt;just like last year&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;Last night, I stayed up late to put the finishing touches on my Devoxx presentation. Now I&apos;m sitting at the Red Carpet Club in Chicago&apos;s O&apos;Hare getting ready to depart for Belgium. It&apos;s been a fun journey learning about HTML5, Scala, Play, CoffeeScript and Jade. If you&apos;re at Devoxx this week, I think I&apos;ve got a presentation you&apos;re really going to like. &lt;img src=&quot;https://raibledesigns.com/images/smileys/wink.gif&quot; class=&quot;smiley&quot; alt=&quot;;-)&quot; title=&quot;;-)&quot; /&gt;
  </description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/more_scalate_goodness_for_play</guid>
    <title>More Scalate Goodness for Play</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/more_scalate_goodness_for_play</link>
        <pubDate>Mon, 7 Nov 2011 14:07:40 -0700</pubDate>
    <category>Java</category>
    <category>playframework</category>
    <category>scala</category>
    <category>play-more</category>
    <category>devoxx2011</category>
    <category>jade</category>
    <category>scalate</category>
            <description>&lt;a href=&quot;http://scalate.fusesource.org&quot;&gt;&lt;img src=&quot;//scalate.fusesource.org/images/project-icon-160x160.png&quot; width=&quot;80&quot; height=&quot;80&quot; alt=&quot;Scalate&quot; class=&quot;picture&quot; style=&quot;border: 0&quot;/&gt;&lt;/a&gt;
This article is the 6th in a series on about my adventures developing a web application with HTML5, Play Scala, CoffeeScript and Jade. Previous articles can be found at:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with&quot;&gt;Integrating Scalate and Jade with Play 1.2.3&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/trying_to_make_coffeescript_work&quot;&gt;Trying to make CoffeeScript work with Scalate and Play&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_html5_boilerplate_with_scalate&quot;&gt;Integrating HTML5 Boilerplate with Scalate and Play&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/developing_with_html5_coffeescript_and&quot;&gt;Developing with HTML5, CoffeeScript and Twitter&apos;s Bootstrap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/play_scala_s_anorm_heroku&quot;&gt;Play Scala&apos;s Anorm, Heroku and PostgreSQL Issues&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Last week, I wrote about my adventures with &lt;a href=&quot;http://scala.playframework.org/documentation/scala-0.9.1/anorm&quot;&gt;Anorm&lt;/a&gt; and mentioned I&apos;d made some improvements to Scalate Play interoperability. First of all, I&apos;ve been using a Scalate trait and ScalateTemplate class to render Jade templates in my application. I described this setup in my &lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with&quot;&gt;first article on Scalate and Play&lt;/a&gt;. 
&lt;/p&gt;
&lt;p id=&quot;default-variables&quot;&gt;&lt;strong&gt;Adding SiteMesh Features and Default Variables&lt;/strong&gt;&lt;br/&gt;  
When I started making my app look good with CSS, I started longing for a feature I&apos;ve used in SiteMesh. That is, to have a body id or class that can identify the page and allow per-page CSS rules. To do this with SiteMesh, you&apos;d have something like the following in your page:
&lt;/p&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;  
&amp;lt;body id=&quot;signup&quot;/&gt;
&lt;/pre&gt;
&lt;p&gt;  
And then read it in your decorator:
&lt;/p&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;
&amp;lt;body&lt;decorator:getProperty property=&quot;body.id&quot; writeEntireProperty=&quot;true&quot;/&gt;&amp;lt;decorator:getProperty property=&quot;body.class&quot; writeEntireProperty=&quot;true&quot;/&gt;&gt;
&lt;/pre&gt;
&lt;p&gt;As I started looking into how to do this, I came across Play Scala&apos;s &lt;a href=&quot;https://github.com/playframework/play-scala/blob/master/src/play/mvc/ScalaController.scala&quot;&gt;ScalaController&lt;/a&gt; and how it was populating Play&apos;s default variables (request, response, flash, params, etc.). Based on this newfound knowledge, I added a &lt;em&gt;populateRenderArgs()&lt;/em&gt; method to set all the default variables and my desired &lt;em&gt;bodyClass&lt;/em&gt; variable.
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
def populateRenderArgs(args: (Symbol, Any)*): Map[String, Any] = {
  val renderArgs = Scope.RenderArgs.current();

  args.foreach {
    o =&gt;
      renderArgs.put(o._1.name, o._2)
  }

  renderArgs.put(&quot;session&quot;, Scope.Session.current())
  renderArgs.put(&quot;request&quot;, Http.Request.current())
  renderArgs.put(&quot;flash&quot;, Scope.Flash.current())
  renderArgs.put(&quot;params&quot;, Scope.Params.current())
  renderArgs.put(&quot;errors&quot;, validationErrors)
  renderArgs.put(&quot;config&quot;, Play.configuration)

  // CSS class to add to body
  renderArgs.put(&quot;bodyClass&quot;, Http.Request.current().action.replace(&quot;.&quot;, &quot; &quot;).toLowerCase)
  renderArgs.data.toMap
}

implicit def validationErrors:Map[String,play.data.validation.Error] = {
  import scala.collection.JavaConverters._
  Map.empty[String,play.data.validation.Error] ++ 
    Validation.errors.asScala.map( e =&gt; (e.getKey, e) )
}
&lt;/pre&gt;&lt;p&gt;After adding this method, I was able to access these values in my templates by defining them at the top:
&lt;/pre&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
-@ val bodyClass: String 
-@ val params: play.mvc.Scope.Params
-@ val flash: play.mvc.Scope.Flash
&lt;/pre&gt;
&lt;p&gt;And then reading their values in my template:
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
body(class=bodyClass)
...
- if (flash.get(&quot;success&quot;) != null) {
  div(class=&quot;alert-message success&quot; data-alert=&quot;alert&quot;)
    a(class=&quot;close&quot; href=&quot;#&quot;) &amp;&amp;times;
    | #{flash.get(&quot;success&quot;)}
- }
...
  fieldset
    legend Leave a comment &amp;rarr;
    div.clearfix
      label(for=&quot;author&quot;) Your name:
      input(type=&quot;text&quot; name=&quot;author&quot; class=&quot;xlarge&quot; value={params.get(&quot;author&quot;)})
    div.clearfix
      label(for=&quot;content&quot;) Your message:
      textarea(name=&quot;content&quot; class=&quot;xlarge&quot;) #{params.get(&quot;content&quot;)}
    div.actions
      button(type=&quot;submit&quot; class=&quot;btn primary&quot;) Submit your comment
      button(type=&quot;reset&quot; class=&quot;btn&quot;) Cancel
&lt;/pre&gt;  
&lt;p&gt;For a request like Home/index, the body tag is now rendered as:
&lt;pre class=&quot;brush: xml; toolbar: false&quot;&gt;
&amp;lt;body class=&quot;home index&quot;&gt;
&lt;/pre&gt;
This allows you to group CSS styles by Controller names as well as by method names.
&lt;/p&gt;
&lt;p&gt;
Next, I started developing forms and validation logic. I quickly discovered I needed an &lt;em&gt;action()&lt;/em&gt; method like the one defined in &lt;a href=&quot;https://github.com/playframework/play-scala/blob/master/src/play/templates/ScalaTemplate.scala&quot;&gt;ScalaTemplate&apos;s&lt;/a&gt; TemplateMagic class. 
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
def action(action: =&gt; Any) = {
  new play.mvc.results.ScalaAction(action).actionDefinition.url
}
&lt;/pre&gt;
&lt;p&gt;
Since TemplateMagic is an inner class, I determined that copying the method into my ScalateTemplate class was the easiest workaround. After doing this, I was able to import the method and use it in my templates.
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
-import controllers.ScalateTemplate._
...
form(method=&quot;post&quot; class=&quot;form-stacked&quot; id=&quot;commentForm&quot;
     action={action(controllers.Profile.postComment(workout._1.id()))})
&lt;/pre&gt;
&lt;p&gt;After getting the proper URL written into my form&apos;s action attribute, I encountered a new problem. The &lt;a href=&quot;http://scala.playframework.org/documentation/scala-0.9.1/guide4#aAddingvalidationa&quot;&gt;Play Scala Tutorial explains validation flow&lt;/a&gt; as follows:
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
if (Validation.hasErrors) {
  show(postId)
} else {
  Comment.create(Comment(postId, author, content))
  Action(show(postId))
}
&lt;/pre&gt;
&lt;p&gt;However, when I had validation errors, I end up with the following error:
&lt;/p&gt;
&lt;pre&gt;
Could not load resource: [Timeline/postComment.jade]
&lt;/pre&gt;&lt;p&gt;To fix this, I added logic to my Scalate trait that looks for a &quot;template&quot; variable before using &lt;em&gt;Http.Request.current().action.replace(&quot;.&quot;, &quot;/&quot;)&lt;/em&gt; for the name. After making this change, I was able to use the following code to display validation errors.&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
if (Validation.hasErrors) {
  renderArgs.put(&quot;template&quot;, &quot;Timeline/show&quot;)
  show(postId)
} else {
  Comment.create(Comment(postId, author, content))
  Action(show(postId))
}
&lt;/pre&gt;
&lt;p&gt;Next, I wanted to give child pages the ability to set content in parent pages. With SiteMesh, I could use the &amp;lt;content&amp;gt; tag as follows:
&lt;/p&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;
&amp;lt;content tag=&quot;underground&quot;&gt;
  HTML goes here
&amp;lt;/content&gt;
&lt;/pre&gt;
&lt;p&gt;This HTML could then be retrieved in the decorator using the &amp;lt;decorator:getProperty&amp;gt; tag:
&lt;/p&gt;
&lt;pre class=&quot;brush: xml; toolbar: false&quot;&gt;
&amp;lt;decorator:getProperty property=&quot;page.underground&quot;/&gt;
&lt;/pre&gt;
&lt;p&gt;With Scalate, I found it equally easy using the &lt;em&gt;captureAttribute()&lt;/em&gt; method. For example, here&apos;s how I captured a list of an athlete&apos;s workouts for display in a sidebar.
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
- captureAttribute(&quot;sidebar&quot;)
  - Option(older).filterNot(_.isEmpty).map { workouts =&gt;
    .older-workouts
      h3
        | Older workouts
        span.from from this app
      - workouts.map { workout =&gt;
        - render(&quot;workout.jade&quot;, Map(&apos;workout -&gt; workout, &apos;mode -&gt; &quot;teaser&quot;))
      - }
  - }
- }
&lt;/pre&gt;
&lt;p&gt;Then in my layout, I was able to retrieve this and display it. Below is a snippet from the layout I&apos;m using (copied from &lt;a href=&quot;http://twitter.github.com/bootstrap/examples/container-app.html&quot;&gt;Twitter&apos;s Bootstrap example&lt;/a&gt;). You can see how the sidebar is included in the .span4 at the end.
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
-@ val sidebar: String = &quot;&quot;
...
.container
  .content
    .page-header
      h1
        = pageHeader
        small
          = pageTagline
    .row
      .span10
        !~~ body
      .span4
        = unescape(sidebar)
  footer
&lt;/pre&gt;
&lt;p id=&quot;view-vs-render&quot;&gt;&lt;strong&gt;View vs. Render in Scalate&lt;/strong&gt;&lt;br/&gt;
In the sidebar code above, you might notice the &lt;em&gt;render()&lt;/em&gt; call. This is the &lt;a href=&quot;http://scalate.fusesource.org/documentation/user-guide.html#Render_templates&quot;&gt;Scalate version of server-side includes&lt;/a&gt;. It works well, but there&apos;s also a &lt;a href=&quot;http://scalate.fusesource.org/documentation/user-guide.html#Views&quot;&gt;&lt;em&gt;view()&lt;/em&gt; shortcut&lt;/a&gt; you can use if you want to have templates for rendering your model objects. I quickly discovered it might be difficult to use this feature in my app because my object was &lt;em&gt;Option[(models.Workout, models.Athlete, Seq[models.Comment])]&lt;/em&gt; instead of a simple object. You can read the &lt;a href=&quot;http://groups.google.com/group/scalate/browse_thread/thread/bcc6059fc08d4da0&quot;&gt;view vs. render thread&lt;/a&gt; on the Scalate Google Group if you&apos;re interested in learning more.
&lt;/p&gt;
&lt;p id=&quot;scalate-plugin&quot;&gt;&lt;strong&gt;Scalate as a Module&lt;/strong&gt;&lt;br/&gt;
The last enhancement I attempted to make was to put Scalate support into a &lt;a href=&quot;http://www.playframework.org/documentation/1.2.3/modules&quot;&gt;Play module&lt;/a&gt;. At first, I tried overriding Play&apos;s &lt;em&gt;Template&lt;/em&gt; class but &lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/8d1b00ec4304f4ea&quot;&gt;ran into compilation issues&lt;/a&gt;. Then Guillaume Bort (Play&apos;s lead developer) recommended I stick with the trait approach and I was able to get everything working. I looked at the &lt;a href=&quot;https://github.com/pk11/play-scalate&quot;&gt;outdated play-scalate module&lt;/a&gt; to figure out how to add Scala support to build.xml and copied its &lt;a href=&quot;https://github.com/pk11/play-scalate/blob/master/resources/500.scaml&quot;&gt;500.scaml&lt;/a&gt; page for error reporting.&lt;/p&gt;
&lt;p&gt;In order to get line-precise error reporting working, I had to wrap a try/catch around calling Scalate&apos;s &lt;em&gt;TemplateEngine.layout()&lt;/em&gt; method. Again, most of this code was copied from the outdated play-scalate module.
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
case class Template(name: String) {
  
  def render(args: (Symbol, Any)*) = {
    val argsMap = populateRenderArgs(args: _*)
    
    val buffer = new StringWriter()
    var context = new DefaultRenderContext(name, scalateEngine, new PrintWriter(buffer))
    
    try {
      val templatePath = new File(Play.applicationPath+&quot;/app/views&quot;,&quot;/&quot;+name).toString
        .replace(new File(Play.applicationPath+&quot;/app/views&quot;).toString,&quot;&quot;)
      scalateEngine.layout(templatePath + scalateType, argsMap)
    } catch {
      case ex:TemplateNotFoundException =&gt; {
        if(ex.isSourceAvailable) {
          throw ex
        }
        val element = PlayException.getInterestingStrackTraceElement(ex)
        if (element != null) {
           throw new TemplateNotFoundException(name, 
             Play.classes.getApplicationClass(element.getClassName()), element.getLineNumber());
        } else {
           throw ex
        }
      }  
      case ex:InvalidSyntaxException =&gt; handleSpecialError(context,ex)
      case ex:CompilerException =&gt; handleSpecialError(context,ex)
      case ex:Exception =&gt; handleSpecialError(context,ex)
    } finally {
      if (buffer.toString.length &gt; 0)
        throw new ScalateResult(buffer.toString,name)
    }
  }
}
...
private def handleSpecialError(context:DefaultRenderContext,ex:Exception) {
  context.attributes(&quot;javax.servlet.error.exception&quot;) = ex
  context.attributes(&quot;javax.servlet.error.message&quot;) = ex.getMessage
  try {
    scalateEngine.layout(scalateEngine.load(errorTemplate), context)
  } catch {
    case ex:Exception =&gt;
      // TODO use logging API from Play here...
      println(&quot;Caught: &quot; + ex)
      ex.printStackTrace
  }
}

private def errorTemplate:String = {
  val fullPath = new File(Play.applicationPath,&quot;/app/views/errors/500.scaml&quot;).toString 
  fullPath.replace(new File(Play.applicationPath+&quot;/app/views&quot;).toString,&quot;&quot;)
}
&lt;/pre&gt;
&lt;p&gt;Once I had this in place, error messages from Scalate are much better. Not only do I see the error in my browser, but I can click on the offending line to open it directly in TextMate.
&lt;/p&gt;
&lt;p style=&quot;text-align: center&quot;&gt;
&lt;a href=&quot;http://farm7.static.flickr.com/6054/6323523392_91888694bc_o.png&quot; title=&quot;Play Scalate Error Reporting&quot; rel=&quot;lightbox[scalate-goodness]&quot;&gt;&lt;img src=&quot;//farm7.static.flickr.com/6054/6323523392_affe4cf053.jpg&quot; width=&quot;500&quot; height=&quot;290&quot; alt=&quot;Play Scalate Error Reporting&quot;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;I&apos;ve published my &lt;a href=&quot;https://github.com/mraible/play-scalate&quot;&gt;play-scalate module on GitHub&lt;/a&gt; so others can try it out. To give it a whirl, add the following to your dependencies.yml:
&lt;/p&gt;
&lt;pre&gt;
    - upgrades -&gt; play-scalate 0.1

repositories:
    - upgrades:
        type: http
        artifact: &quot;http://static.raibledesigns.com/[module]-[revision].zip&quot;
        contains:
            - upgrades -&gt; *
&lt;/pre&gt;&lt;p&gt;Then add &lt;em&gt;with play.modules.scalate.Scalate&lt;/em&gt; to your controllers and call the &lt;em&gt;render()&lt;/em&gt; method.
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br/&gt;
After using Scalate and Play for almost 3 months, I&apos;m really enjoying the combination. When I first integrated Scalate with a simple trait, the error messages were always in the console. Now that I&apos;ve borrowed some smarts from Play&apos;s ScalaController and play-scalate&apos;s error reporting, I feel like it&apos;s practically a built-in solution. I was easily able to integrate my desired SiteMesh features and it even allows &lt;a href=&quot;http://groups.google.com/group/scalate/browse_thread/thread/f6df5b165024407e&quot;&gt;reusable template blocks&lt;/a&gt;. In the end, it&apos;s just Scala and Scalate does a good job of allowing you to leverage that.&lt;/p&gt;
&lt;p&gt;Other thoughts:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you&apos;re writing a lot of Jade and familiar with HTML, Don Park&apos;s &lt;a href=&quot;https://github.com/donpark/html2jade&quot;&gt;html2jade&lt;/a&gt; is a great tool that comes with Scalate support.&lt;/li&gt;
&lt;li&gt;I&apos;m really enjoying writing CSS with &lt;a href=&quot;http://lesscss.org/&quot;&gt;LESS&lt;/a&gt;, particularly the ability to nest rules and have programming features. The only issue I&apos;ve seen is IntelliJ&apos;s LESS plugin only does code-completion for variables rather than CSS values.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;http://www.packtpub.com/play-framework-cookbook/book&quot;&gt;Play Framework Cookbook&lt;/a&gt; is a great reference for learning how to write modules. Not only does it explain how to create modules, it has some great real-world examples for doing bytecode enhancement, implementing message queues, using Solr and how to do production monitoring.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If this series of articles has intrigued you and you&apos;ll be at &lt;a href=&quot;http://www.devoxx.com/display/DV11/Home&quot;&gt;Devoxx&lt;/a&gt; next week, you should stop by &lt;a href=&quot;http://www.devoxx.com/display/DV11/HTML5+with+Play+Scala%2C+CoffeeScript+and+Jade&quot;&gt;my talk on Thursday afternoon&lt;/a&gt;. In addition, there&apos;s several other Play talks at Devoxx and a possible meetup on Wednesday. Check out the &lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/eaef08eb36f9eb0a&quot;&gt;Devoxx, anyone?&lt;/a&gt; thread for more information.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: There&apos;s one thing I forgot to mention about the Play Scalate Module. When I had Scalate integrated in my app with a trait, I only included the scalate-core and scalate-util JARs in dependencies.yml:&lt;/p&gt;
&lt;pre&gt;
- org.fusesource.scalate -&gt; scalate-core 1.5.2-scala_2.8.1:
    transitive: false
- org.fusesource.scalate -&gt; scalate-util 1.5.2-scala_2.8.1:
    transitive: false
&lt;/pre&gt;&lt;p&gt;However, when I created the play-scalate module, I allowed more dependencies.&lt;/p&gt;
&lt;pre&gt;
- org.fusesource.scalate -&gt; scalate-core 1.5.2-scala_2.8.1:
    exclude:
        - javax.servlet -&gt; *
        - com.sun.jersey -&gt; *
        - org.osgi -&gt; *
- org.fusesource.scalate -&gt; scalate-util 1.5.2-scala_2.8.1
&lt;/pre&gt;Because Scalate depends on &lt;a href=&quot;http://logback.qos.ch/&quot;&gt;Logback&lt;/a&gt;, debug messages started showing up in my console. To fix this, I created &lt;em&gt;conf/logback.xml&lt;/em&gt; in my project and filled it with the following XML.
&lt;/p&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;appender name=&quot;STDOUT&quot; class=&quot;ch.qos.logback.core.ConsoleAppender&quot;&amp;gt;
      &amp;lt;encoder&amp;gt;
          &amp;lt;pattern&amp;gt;%msg%n&amp;lt;/pattern&amp;gt;
      &amp;lt;/encoder&amp;gt;
  &amp;lt;/appender&amp;gt;

  &amp;lt;root level=&quot;info&quot;&amp;gt;
    &amp;lt;appender-ref ref=&quot;STDOUT&quot; /&amp;gt;
  &amp;lt;/root&amp;gt;
&amp;lt;/configuration&amp;gt;
&lt;/pre&gt;
&lt;p&gt;This reduces the logging and allows me to increase Scalate&apos;s logging if I ever have the need.</description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/play_scala_s_anorm_heroku</guid>
    <title>Play Scala&apos;s Anorm, Heroku and PostgreSQL Issues</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/play_scala_s_anorm_heroku</link>
        <pubDate>Wed, 2 Nov 2011 11:54:25 -0600</pubDate>
    <category>Java</category>
    <category>scala</category>
    <category>play-more</category>
    <category>anorm</category>
    <category>heroku</category>
    <category>playframework</category>
    <category>postgresql</category>
    <category>devoxx2011</category>
            <description>This article is the 5th in a series on about my adventures developing a Fitness Tracking application for &lt;a href=&quot;http://www.devoxx.com/display/DV11/HTML5+with+Play+Scala%2C+CoffeeScript+and+Jade&quot;&gt;my talk at Devoxx&lt;/a&gt; in two weeks. Previous articles can be found at:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with&quot;&gt;Integrating Scalate and Jade with Play 1.2.3&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/trying_to_make_coffeescript_work&quot;&gt;Trying to make CoffeeScript work with Scalate and Play&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_html5_boilerplate_with_scalate&quot;&gt;Integrating HTML5 Boilerplate with Scalate and Play&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/developing_with_html5_coffeescript_and&quot;&gt;Developing with HTML5, CoffeeScript and Twitter&apos;s Bootstrap&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p id=&quot;anorm&quot;&gt;&lt;strong&gt;Anorm&lt;/strong&gt;&lt;br/&gt;In my &lt;a href=&quot;http://raibledesigns.com/rd/entry/developing_with_html5_coffeescript_and&quot;&gt;previous article&lt;/a&gt;, I described how I created my application&apos;s features using CoffeeScript and make it look good using Twitter&apos;s Bootstrap. Next, I turned to persisting this data with &lt;a href=&quot;http://scala.playframework.org/documentation/scala-0.9.1/anorm&quot;&gt;Anorm&lt;/a&gt;.&lt;/p&gt;
&lt;p class=&quot;quote&quot;&gt;
The Scala module includes a brand new data access layer called Anorm that uses plain SQL to make your database request and provides several API to parse and transform the resulting dataset.
&lt;/p&gt;
&lt;p&gt;I&apos;m a big fan of ORMs like Hibernate and JPA, so having to learn a new JDBC abstraction wasn&apos;t exactly appealing at first. However, since &lt;a href=&quot;http://groups.google.com/group/play-framework/msg/b4b92f8b085c1bbf&quot;&gt;Anorm is the default for Play Scala&lt;/a&gt;, I decided to try it. The easiest way for me to learn Anorm was to start coding with it. I used &lt;a href=&quot;http://scala.playframework.org/documentation/scala-0.9.1/guide2&quot;&gt;A first iteration for the data model&lt;/a&gt; as my guide and created model objects, companion objects that extended Magic (appropriately named) and wrote some tests using &lt;a href=&quot;http://www.scalatest.org/&quot;&gt;scalatest&lt;/a&gt;. I started with an &quot;Athlete&quot; model since I knew &quot;User&quot; was a keyword in PostgreSQL and &lt;a href=&quot;http://devcenter.heroku.com/articles/database&quot;&gt;that&apos;s what Heroku uses for its database&lt;/a&gt;.
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
package models

import play.db.anorm._
import play.db.anorm.defaults._

case class Athlete(
  id: Pk[Long],
  email: String, password: String, firstName: String, lastName: String
  ) {
}

object Athlete extends Magic[Athlete] {
  def connect(email: String, password: String) = {
    Athlete.find(&quot;email = {email} and password = {password}&quot;)
      .on(&quot;email&quot; -&gt; email, &quot;password&quot; -&gt; password)
      .first()
  }

  def apply(firstName: String) = new Athlete(NotAssigned, null, null, firstName, null)
}
&lt;/pre&gt;
&lt;p&gt;Then I wrote a couple tests for it in test/Tests.scala. &lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
import play._
import play.test._

import org.scalatest._
import org.scalatest.junit._
import org.scalatest.matchers._

class BasicTests extends UnitFlatSpec with ShouldMatchers with BeforeAndAfterEach {

  import models._
  import play.db.anorm._

  override def beforeEach() {
      Fixtures.deleteDatabase()
  }

  it should &quot;create and retrieve a Athlete&quot; in {

      var athlete = Athlete(NotAssigned, &quot;jim@gmail.com&quot;, &quot;secret&quot;, &quot;Jim&quot;, &quot;Smith&quot;)
      Athlete.create(athlete)

      val jim = Athlete.find(
          &quot;email={email}&quot;).on(&quot;email&quot; -&gt; &quot;jim@gmail.com&quot;
      ).first()

      jim should not be (None)
      jim.get.firstName should be(&quot;Jim&quot;)

  }

  it should &quot;connect a Athlete&quot; in {

      Athlete.create(Athlete(NotAssigned, &quot;bob@gmail.com&quot;, &quot;secret&quot;, &quot;Bob&quot;, &quot;Johnson&quot;))

      Athlete.connect(&quot;bob@gmail.com&quot;, &quot;secret&quot;) should not be (None)
      Athlete.connect(&quot;bob@gmail.com&quot;, &quot;badpassword&quot;) should be(None)
      Athlete.connect(&quot;tom@gmail.com&quot;, &quot;secret&quot;) should be(None)
  }
&lt;/pre&gt;
&lt;p&gt;At this point, everything was fine and dandy. I could run &quot;play test&quot;, open http://localhost/@tests in my browser and run the tests to see a beautiful shade of green on my screen. I continued following the tutorial, substituting &quot;Post&quot; with &quot;Workout&quot; and added Comments too. The Workout object shows some of the crazy-ass syntax that is Anorm getting fancy with Scala. 
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
object Workout extends Magic&amp;#91;Workout&amp;#93; {

  def allWithAthlete: List&amp;#91;(Workout, Athlete)&amp;#93; =
    SQL(
      &quot;&quot;&quot;
          select * from Workout w
          join Athlete a on w.athlete_id = a.id
          order by w.postedAt desc
      &quot;&quot;&quot;
    ).as(Workout ~&amp;lt; Athlete ^^ flatten *)

  def allWithAthleteAndComments: List&amp;#91;(Workout, Athlete, List&amp;#91;Comment&amp;#93;)&amp;#93; =
    SQL(
      &quot;&quot;&quot;
          select * from Workout w
          join Athlete a on w.athlete_id = a.id
          left join Comment c on c.workout_id = w.id
          order by w.postedAt desc
      &quot;&quot;&quot;
    ).as(Workout ~&amp;lt; Athlete ~&amp;lt; Workout.spanM(Comment) ^^ flatten *)

  def byIdWithAthleteAndComments(id: Long): Option&amp;#91;(Workout, Athlete, List&amp;#91;Comment&amp;#93;)&amp;#93; =
    SQL(
      &quot;&quot;&quot;
          select * from Workout w
          join Athlete a on w.athlete_id = a.id
          left join Comment c on c.workout_id = w.id
          where w.id = {id}
      &quot;&quot;&quot;
    ).on(&quot;id&quot; -&amp;gt; id).as(Workout ~&amp;lt; Athlete ~&amp;lt; Workout.spanM(Comment) ^^ flatten ?)
}
&lt;/pre&gt;
&lt;p&gt;All of these methods return &lt;a href=&quot;http://codemonkeyism.com/tuples-scala-goodness/&quot;&gt;Tuples&lt;/a&gt;, which is quite different from an ORM that returns an object that you call methods on to get its related items. Below is an example of how this is referenced in a Scalate template:
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
-@ val workout:(models.Workout,models.Athlete,Seq[models.Comment])
-
  var commentsTitle = &quot;No Comments&quot;
  if (workout._3.size &gt; 0)
    commentsTitle = workout._3.size + &quot; comments, lastest by &quot; + workout._3(workout._3.size - 1).author
  
div(class=&quot;workout&quot;)
  h2.title
    a(href={action(controllers.Profile.show(workout._1.id()))}) #{workout._1.title}
  .metadata
    span.user Posted by #{workout._2.firstName} on
    span.date #{workout._1.postedAt}
    .description
      = workout._1.description
&lt;/pre&gt;
&lt;p id=&quot;heroku&quot;&gt;&lt;strong&gt;Evolutions on Heroku&lt;/strong&gt;&lt;br/&gt;
I was happy with my progress until I tried to deploy my app to Heroku. I added &lt;code&gt;db=${DATABASE_URL}&lt;/code&gt; to my application.conf as recommended by &lt;a href=&quot;http://devcenter.heroku.com/articles/database-driven-play-apps&quot;&gt;Database-driven web apps with Play! on Heroku/Cedar&lt;/a&gt;. However, when I deployed, it failed because my database tables weren&apos;t created.
&lt;/p&gt; 
&lt;pre&gt;
2011-10-05T04:08:52+00:00 app[web.1]: 04:08:52,712 WARN  ~ Your database is not up to date.
2011-10-05T04:08:52+00:00 app[web.1]: 04:08:52,712 WARN  ~ Use `play evolutions` command to manage database evolutions.
2011-10-05T04:08:52+00:00 app[web.1]: 04:08:52,713 ERROR ~
2011-10-05T04:08:52+00:00 app[web.1]:
2011-10-05T04:08:52+00:00 app[web.1]: @681m15j3l
2011-10-05T04:08:52+00:00 app[web.1]: Can&apos;t start in PROD mode with errors
2011-10-05T04:08:52+00:00 app[web.1]:
2011-10-05T04:08:52+00:00 app[web.1]: Your database needs evolution!
2011-10-05T04:08:52+00:00 app[web.1]: An SQL script will be run on your database.
2011-10-05T04:08:52+00:00 app[web.1]:
2011-10-05T04:08:52+00:00 app[web.1]: play.db.Evolutions$InvalidDatabaseRevision
&lt;/pre&gt;
&lt;p&gt;With &lt;a href=&quot;http://www.jamesward.com/&quot;&gt;James Ward&lt;/a&gt;&apos;s help, I learned I needed to use &quot;heroku run&quot; to apply &lt;a href=&quot;http://www.playframework.org/documentation/1.2.3/evolutions&quot;&gt;evolutions&lt;/a&gt;. So I ran the following command:
&lt;/p&gt;
&lt;pre&gt;
heroku run &quot;play evolutions:apply --%prod&quot; 
&lt;/pre&gt;
&lt;p&gt;Unfortunately, this failed:
&lt;/p&gt;
&lt;pre&gt;
Running play evolutions:apply --%prod attached to terminal... up, run. 
5 
~        _            _ 
~  _ __ | | __ _ _  _| | 
~ | &apos;_ \| |/ _&apos; | || |_| 
~ |  __/|_|\____|\__ (_) 
~ |_|            |__/ 
~ 
~ play! 1.2.3, http://www.playframework.org 
~ framework ID is prod 
~ 
Oct 17, 2011 7:05:46 PM play.Logger warn 
WARNING: Cannot replace DATABASE_URL in configuration (db=$ 
{DATABASE_URL}) 
Exception in thread &quot;main&quot; java.lang.NullPointerException 
        at play.db.Evolutions.main(Evolutions.java:54)
&lt;/pre&gt;
&lt;p&gt;After opening a ticket with Heroku support, I learned this was because DATABASE_URL was not set (&quot;heroku config&quot; shows your variables). Apparently, this should be set when you create your app, but somehow wasn&apos;t for mine. To fix, I had to run the following command:
&lt;/p&gt;
&lt;pre&gt;
$ heroku pg:promote SHARED_DATABASE 
-----&gt; Promoting SHARED_DATABASE to DATABASE_URL... done
&lt;/pre&gt;
&lt;p id=&quot;postgres&quot;&gt;&lt;strong&gt;PostgreSQL and Dates&lt;/strong&gt;&lt;br/&gt;
The next issue I ran into was with loading default data. I have the following BootStrap.scala class in my project to load default data:
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
class BootStrap extends Job { 
  override def doJob() { 
    import models._ 
    import play.test._ 
    // Import initial data if the database is empty 
    if (Athlete.count().single() == 0) { 
      Yaml[List[Any]](&quot;initial-data.yml&quot;).foreach { 
        _ match { 
          case a: Athlete =&gt; Athlete.create(a) 
          case w: Workout =&gt; Workout.create(w) 
          case c: Comment =&gt; Comment.create(c) 
        } 
      } 
    } 
  } 
} 
&lt;/pre&gt;
&lt;p&gt;For some reason, only my &quot;athlete&quot; table was getting populated and the others weren&apos;t. I tried turning on debugging and trace, but nothing showed up in the logs. This appears to be a &lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/bfa206000cb468e9&quot;&gt;frequent issue&lt;/a&gt; with Play. When data fails to load, there&apos;s no logging indicating what went wrong. To make matters worse with Anorm, there&apos;s no way to log the SQL that it&apos;s attempting to run. My BootStrap job was working fine when connecting to &quot;db=mem&quot;, but stopped after switching to PostgreSQL. The support I got for this issue was disappointing, since it caused &lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/94bd99b1cd486415&quot;&gt;crickets on Play&apos;s Google Group&lt;/a&gt;. I finally figured out &quot;support of Date for insertion&quot; was &lt;a href=&quot;https://github.com/playframework/play-scala/commit/cbe162a0ecbf7996eba2ab028264a9cc332cb915&quot;&gt;added to Anorm a couple months ago&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;To get the latest play-scala code into my project, I cloned &lt;a href=&quot;https://github.com/playframework/play-scala&quot;&gt;play-scala&lt;/a&gt;, built it locally and uploaded it to my server. Then I added the following to dependencies.yml and ran &quot;play deps --sync&quot;.
&lt;/p&gt;
&lt;pre&gt;
require:
    ...
    - upgrades -&gt; scala 0.9.1-20111025
    ...

repositories:
    - upgrades:
        type: http
        artifact: &quot;http://static.raibledesigns.com/[module]-[revision].zip&quot;
        contains:
            - upgrades -&gt; *
&lt;/pre&gt;
&lt;p id=&quot;summary&quot;&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br/&gt;
When I started writing this article, I was going to talk about some improvements I made to &lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with&quot;&gt;Scalate Play interoperability&lt;/a&gt;. However, I think I&apos;ll save that for next time and possibly turn it into a plugin using &lt;a href=&quot;https://github.com/greenlaw110/play-excel/blob/1.2/src/play/modules/excel/Plugin.java&quot;&gt;play-excel&lt;/a&gt; as an example. 
&lt;/p&gt;
&lt;p&gt;
As you can tell from this article, my experience with Anorm was frustrating - particularly due to the lack of error messages when operations failed. The lack of support was expected, as this usually happens when you&apos;re living on the bleeding edge. However, based on this experience, I can&apos;t help but think that it might be a while before &lt;a href=&quot;http://scala.playframework.org/2.0&quot;&gt;Play 2.0&lt;/a&gt; is ready for production use.&lt;/p&gt;
&lt;p&gt;The good news is &lt;a href=&quot;http://www.jamesward.com/2011/10/24/setting-up-play-framework-apps-in-intellij-idea&quot;&gt;IntelliJ is adding support for Play&lt;/a&gt;. Maybe this will help increase adoption and inspire the framework&apos;s developers to stabilize and improve Play Scala before moving the entire framework to Scala. After all, it seems they&apos;ve encountered &lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/e2331dc5097f9919/441849bae162a561&quot;&gt;some issues making Scala as fast as Java&lt;/a&gt;.
</description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/developing_with_html5_coffeescript_and</guid>
    <title>Developing with HTML5, CoffeeScript and Twitter&apos;s Bootstrap </title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/developing_with_html5_coffeescript_and</link>
        <pubDate>Thu, 20 Oct 2011 14:47:36 -0600</pubDate>
    <category>Java</category>
    <category>less</category>
    <category>play-more</category>
    <category>html5</category>
    <category>bootstrap</category>
    <category>coffeescript</category>
    <category>devoxx2011</category>
    <category>html5boilerplate</category>
    <category>geolocation</category>
            <description>&lt;a href=&quot;http://www.w3.org/html/logo/&quot;&gt;&lt;img src=&quot;//www.w3.org/html/logo/downloads/HTML5_Logo_128.png&quot; width=&quot;128&quot; height=&quot;128&quot; alt=&quot;HTML5 Logo&quot; class=&quot;picture&quot; style=&quot;border: 0&quot;&gt;&lt;/a&gt;
This article is the fourth in a series about my adventures developing a Fitness Tracking application with HTML5, Play Scala, CoffeeScript and Jade. Previous articles can be found at:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with&quot;&gt;Integrating Scalate and Jade with Play 1.2.3&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/trying_to_make_coffeescript_work&quot;&gt;Trying to make CoffeeScript work with Scalate and Play&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_html5_boilerplate_with_scalate&quot;&gt;Integrating HTML5 Boilerplate with Scalate and Play&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p id=&quot;features&quot;&gt;&lt;strong&gt;Developing Features&lt;/strong&gt;&lt;br/&gt;After getting my desired infrastructure setup, I started coding like a madman. The first feature I needed was a stopwatch to track the duration of a workout, so I started writing one with CoffeeScript. After spending 20 minutes playing with dates and setTimeout, I searched and found a &lt;a href=&quot;http://www.kellishaver.com/projects/stopwatch/&quot;&gt;stopwatch jQuery plug-in&lt;/a&gt;. I added this to my app, deployed it to &lt;a href=&quot;http://www.heroku.com/&quot;&gt;Heroku&lt;/a&gt;, brought up the app on my iPhone 3G, clicked &lt;em&gt;Start&lt;/em&gt; and started riding my bike to work. 
&lt;/p&gt;
&lt;p&gt;
When I arrived, I unlocked my phone and discovered that the time had stopped. At first, I thought this was a major setback. My disappointed disappeared when I found a &lt;a href=&quot;http://proft.50megs.com/stopwatch.html&quot;&gt;Super Neat JavaScript Stopwatch&lt;/a&gt; and &lt;a href=&quot;http://www.timpelen.com/extra/sidebars/stopwatch/stopwatch.htm&quot;&gt;K&#229;re Byberg&apos;s version&lt;/a&gt; that worked just fine. This stopwatch used setTimeout, so by keeping the start time, the app on the phone would &lt;em&gt;catch up&lt;/em&gt; as soon as you unlocked it. I ported K&#229;re&apos;s script to CoffeeScript and rejoiced in my working stopwatch. 
&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
# Created by K&#229;re Byberg &#169; 21.01.2005. Please acknowledge if used 
# on other domains than http://www.timpelen.com.
# Ported to CoffeeScript by Matt Raible. Also added hours support.
flagClock = 0
flagStop = 0
stopTime = 0
refresh = null
clock = null

start = (button, display) -&gt;
  clock = display
  startDate = new Date()
  startTime = startDate.getTime()
  if flagClock == 0
    $(button).html(&quot;Stop&quot;)
    flagClock = 1
    counter startTime, display
  else
    $(button).html(&quot;Start&quot;)
    flagClock = 0
    flagStop = 1

counter = (startTime) -&gt;
  currentTime = new Date()
  timeDiff = currentTime.getTime() - startTime
  timeDiff = timeDiff + stopTime  if flagStop == 1
  if flagClock == 1
    $(clock).val formatTime timeDiff, &quot;&quot;
    callback = -&gt; counter startTime
    refresh = setTimeout callback, 10
  else
    window.clearTimeout refresh
    stopTime = timeDiff

formatTime = (rawTime, roundType) -&gt;
  if roundType == &quot;round&quot;
    ds = Math.round(rawTime / 100) + &quot;&quot;
  else
    ds = Math.floor(rawTime / 100) + &quot;&quot;
  sec = Math.floor(rawTime / 1000)
  min = Math.floor(rawTime / 60000)
  hour = Math.floor(rawTime / 3600000)
  ds = ds.charAt(ds.length - 1)
  start() if hour &gt;= 24
  sec = sec - 60 * min + &quot;&quot;
  sec = prependZeroCheck sec
  min = min - 60 * hour + &quot;&quot;
  min = prependZeroCheck min
  hour = prependZeroCheck hour
  hour + &quot;:&quot; + min + &quot;:&quot; + sec + &quot;.&quot; + ds

prependZeroCheck = (time) -&gt;
  time = time + &quot;&quot; # convert from int to string
  unless time.charAt(time.length - 2) == &quot;&quot;
    time = time.charAt(time.length - 2) + time.charAt(time.length - 1)
  else
    time = 0 + time.charAt(time.length - 1)

reset = -&gt;
  flagStop = 0
  stopTime = 0
  window.clearTimeout refresh
  if flagClock == 1
    resetDate = new Date()
    resetTime = resetDate.getTime()
    counter resetTime
  else
    $(clock).val &quot;00:00:00.0&quot;

@StopWatch = {
  start: start
  reset: reset
}
&lt;/pre&gt;
&lt;p&gt;The Scalate/Jade template to render this stopwatch looks as follows:
&lt;/p&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;
script(type=&quot;text/javascript&quot; src={uri(&quot;/public/javascripts/stopwatch.coffee&quot;)})

#display
  input(id=&quot;clock&quot; class=&quot;xlarge&quot; type=&quot;text&quot; value=&quot;00:00:00.0&quot; readonly=&quot;readonly&quot;)
#controls
  button(id=&quot;start&quot; type=&quot;button&quot; class=&quot;btn primary&quot;) Start
  button(id=&quot;reset&quot; type=&quot;button&quot; class=&quot;btn :disabled&quot;) Reset

:plain
  &amp;lt;script type=&quot;text/coffeescript&quot;&gt;
    $(document).ready -&gt;
      $(&apos;#start&apos;).click -&gt;
        StopWatch.start this, $(&apos;#clock&apos;)

      $(&apos;#reset&apos;).click -&gt;
        StopWatch.reset()
  &amp;lt;/script&gt;
&lt;/pre&gt;
&lt;p&gt;Next, I wanted to create a map that would show your location. For this, I used &lt;a href=&quot;http://merged.ca/iphone/html5-geolocation&quot;&gt;
  Merge Design&apos;s HTML 5 Geolocation Demo&lt;/a&gt; as a guide. The &lt;a href=&quot;http://dev.w3.org/geo/api/spec-source.html&quot;&gt;HTML5 Geo API&lt;/a&gt; is pretty 
  simple, containing only three methods:
&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
// Gets the users current position
navigator.geolocation.getCurrentPosition(successCallback,
                                         errorCallback,
                                         options);
// Request repeated updates of position
watchId = navigator.geolocation.watchPosition(successCallback, errorCallback);

// Cancel the updates
navigator.geolocation.clearWatch(watchId);
&lt;/pre&gt;
&lt;p&gt;After rewriting the geolocation example in CoffeeScript, I ended up with the following code in my map.coffee script. You&apos;ll notice it uses 
  &lt;a href=&quot;http://code.google.com/apis/maps/documentation/javascript/&quot;&gt;Google Maps JavaScript API&lt;/a&gt; to show an actual map
  with a marker.
&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
# Geolocation with HTML 5 and Google Maps API based on example from maxheapsize: 
# http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/
# This script is by Merge Database and Design, http://merged.ca/ -- if you use some, 
# all, or any of this code, please offer a return link.

map = null
mapCenter = null
geocoder = null
latlng = null
timeoutId = null

initialize = -&gt;
  if Modernizr.geolocation
    navigator.geolocation.getCurrentPosition showMap

showMap = (position) -&gt;
  latitude = position.coords.latitude
  longitude = position.coords.longitude
  mapOptions = {
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  map = new google.maps.Map(document.getElementById(&quot;map&quot;), mapOptions)
  latlng = new google.maps.LatLng(latitude, longitude)
  map.setCenter(latlng)

  geocoder = new google.maps.Geocoder()
  geocoder.geocode({&apos;latLng&apos;: latlng}, addAddressToMap)

addAddressToMap = (results, status) -&gt;
  if (status == google.maps.GeocoderStatus.OK) 
    if (results[1]) 
      marker = new google.maps.Marker({
          position: latlng,
          map: map
      })
      $(&apos;#location&apos;).html(&apos;Your location: &apos; + results[0].formatted_address)
  else 
    alert &quot;Sorry, we were unable to geocode that address.&quot;

start = -&gt;
  timeoutId = setTimeout initialize, 500

reset = -&gt;
  if (timeoutId)
    clearTimeout timeoutId

@Map = {
  start: start
  reset: reset
}
&lt;/pre&gt;
&lt;p&gt;The template to show the map is a mere 20 lines of Jade:
&lt;/p&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;
script(type=&quot;text/javascript&quot; src=&quot;//www.google.com/jsapi&quot;)
script(type=&quot;text/javascript&quot; src=&quot;//maps.googleapis.com/maps/api/js?sensor=false&quot;)

:css
  .demo-map {
    border: 1px solid silver;
    height: 200px;
    margin: 10px auto;
    width: 280px;
  }

#map(class=&quot;demo-map&quot;)

p(id=&quot;location&quot;)
  span(class=&quot;label success&quot;) New
  | Fetching your location with HTML 5 geolocation...

script(type=&quot;text/javascript&quot; src={uri(&quot;/public/javascripts/map.coffee&quot;)})
:javascript
    Map.start();
&lt;/pre&gt;
&lt;p&gt;The last two features I wanted were 1) distance traveled and 2) drawing the route taken on the map. For this I learned from 
  &lt;a href=&quot;http://www.html5rocks.com/en/tutorials/geolocation/trip_meter/&quot;&gt;A Simple Trip Meter using the Geolocation API&lt;/a&gt;.
  As I was beginning to port the JS to CoffeeScript, I thought, &quot;there&apos;s got to be a better way.&quot;  I searched and found &lt;a href=&quot;http://js2coffee.org/&quot;&gt;Js2coffee&lt;/a&gt; to do most of the conversion for me. If you know JavaScript and you&apos;re learning CoffeeScript, this is an invaluable tool. 
&lt;/p&gt;
&lt;p&gt;
I tried out the trip meter that evening
  on a bike ride and noticed it said I&apos;d traveled 3 miles when I&apos;d really gone 6. I quickly figured out it was only calculating
  start point to end point and not taking into account all the turns in between. To view what was happening, I integrated my
  odometer.coffee with my map using &lt;a href=&quot;http://code.google.com/apis/maps/documentation/javascript/overlays.html#Polylines&quot;&gt;
  Google Maps Polylines&lt;/a&gt;. Upon finishing the integration, I discovered two things, 1) HTML5 geolocation was highly inaccurate and
  2) &lt;a href=&quot;http://stackoverflow.com/questions/7676423/is-it-possible-to-make-an-html5-trip-meter-that-tracks-distance-traveled/7681295&quot;&gt;geolocation doesn&apos;t run in the background&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
I was able to solve the first problem by passing in {enableHighAccuracy: true} to navigator.geolocation.watchPosition(). Below are two screenshots showing before high accuracy and after. Both screenshots are from the same two-block walk.&lt;/p&gt;
&lt;p style=&quot;text-align: center&quot;&gt;
  &lt;a href=&quot;http://farm7.static.flickr.com/6101/6264033565_0353120a06.jpg&quot; rel=&quot;lightbox[html5geo]&quot; title=&quot;Without {enableHighAccuracy: true} by mraible, on Flickr&quot;&gt;&lt;img src=&quot;//farm7.static.flickr.com/6101/6264033565_0353120a06_m.jpg&quot; width=&quot;160&quot; height=&quot;240&quot; alt=&quot;Without {enableHighAccuracy: true}&quot; style=&quot;border: 1px solid silver&quot;&gt;&lt;/a&gt;
  
  &lt;a href=&quot;http://farm7.static.flickr.com/6032/6264033561_cf9a8cb311.jpg&quot; rel=&quot;lightbox[html5geo]&quot; title=&quot;With {enableHighAccuracy: true} by mraible, on Flickr&quot;&gt;&lt;img src=&quot;//farm7.static.flickr.com/6032/6264033561_cf9a8cb311_m.jpg&quot; width=&quot;160&quot; height=&quot;240&quot; alt=&quot;With {enableHighAccuracy: true}&quot; style=&quot;margin-left: 30px; border: 1px solid silver&quot;&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The second
issue is a slight show-stopper. &lt;a href=&quot;http://www.phonegap.com/&quot;&gt;PhoneGap&lt;/a&gt; might be able to solve the problem, but I&apos;m currently using a
workaround &amp;rarr; turning off auto-lock and keeping Safari in the foreground. 
&lt;/p&gt;
&lt;p id=&quot;style&quot;&gt;&lt;strong&gt;Making it look good&lt;/strong&gt;&lt;br/&gt;After I got all my desired features developed, I moved onto making the app look good. I started by using &lt;a href=&quot;http://sass-lang.com/&quot;&gt;SASS&lt;/a&gt; for my CSS and installed &lt;a href=&quot;http://www.playframework.org/modules/sass&quot;&gt;Play&apos;s SASS module&lt;/a&gt;. I then switched to &lt;a href=&quot;http://lesscss.org/&quot;&gt;LESS&lt;/a&gt; when I discovered and added &lt;a href=&quot;http://twitter.github.com/bootstrap/&quot;&gt;Twitter&apos;s Bootstrap&lt;/a&gt; to my project. At first I used &lt;a href=&quot;http://www.playframework.org/modules/less-0.3/home&quot;&gt;Play&apos;s LESS module&lt;/a&gt; (version 0.3), but ran into &lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/4d76688608105dd/f886dc32c724b7cd&quot;&gt;compilation issues&lt;/a&gt;. I then tried &lt;a href=&quot;https://github.com/greenlaw110/play-greenscript&quot;&gt;Play&apos;s GreenScript module&lt;/a&gt;, but gave up on it when I found it was incompatible with the &lt;a href=&quot;http://www.playframework.org/modules/coffee&quot;&gt;CoffeeScript module&lt;/a&gt;. Switching back to the LESS module and using the &quot;0.3.compatibility&quot; version solved all remaining issues.
&lt;/p&gt;
&lt;p&gt;You might remember that &lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_html5_boilerplate_with_scalate&quot;&gt;I integrated HTML5 Boilerplate&lt;/a&gt; and wondering why I have both Bootstrap and Boilerplate in my project. At this point, I don&apos;t think Boilerplate is needed, but I&apos;ve kept it just in case it&apos;s doing something for HTML5 cross-browser compatibility. I&apos;ve renamed its style.css to style.less and added the following so it has access to Bootstrap&apos;s variables.
&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
/* Variables from Bootstrap */
@import &quot;libs/variables.less&quot;;
&lt;/pre&gt;
&lt;p&gt;Then I made my app look a lot better with &lt;a href=&quot;http://twitter.github.com/bootstrap/examples/container-app.html&quot;&gt;layouts&lt;/em&gt;, &lt;a href=&quot;http://twitter.github.com/bootstrap/#forms&quot;&gt;stylish forms&lt;/a&gt;, a &lt;a href=&quot;http://twitter.github.com/bootstrap/#navigation&quot;&gt;fixed topbar&lt;/a&gt; and &lt;a href=&quot;http://twitter.github.com/bootstrap/#alerts&quot;&gt;alerts&lt;/a&gt;. For example, here&apos;s the CoffeeScript I wrote to display geolocation errors:
&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
geolocationError = (error) -&gt;
  msg = &apos;Unable to locate position. &apos;
  switch error.code
    when error.TIMEOUT then msg += &apos;Timeout.&apos;
    when error.POSITION_UNAVAILABLE then msg += &apos;Position unavailable.&apos;
    when error.PERMISSION_DENIED then msg += &apos;Please turn on location services.&apos;
    when error.UNKNOWN_ERROR then msg += error.code
  $(&apos;.alert-message&apos;).remove()
  alert = $(&apos;&amp;lt;div class=&quot;alert-message error fade in&quot; data-alert=&quot;alert&quot;&amp;gt;&apos;)
  alert.html(&apos;&amp;lt;a class=&quot;close&quot; href=&quot;#&quot;&amp;gt;&amp;times;&amp;lt;/a&amp;gt;&apos; + msg);
  alert.insertBefore($(&apos;.span10&apos;))
&lt;/pre&gt;
&lt;p&gt;Then I set about styling up the app so it looked good on a smartphone with &lt;a href=&quot;http://thinkvitamin.com/design/getting-started-and-gotchas-of-css-media-queries/&quot;&gt;CSS3 Media Queries&lt;/a&gt;. Below is the LESS code I used to hide elements and squish the widths for smaller devices.
&lt;/p&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
@media all and (max-device-width: 480px) {
  /* hide scrollbar on mobile */
  html { overflow-y:hidden }
  /* hide sidebar on mobile */
  .home .span4, .home .page-header, .topbar form {
    display: none
  }
  .home .container {
    width: 320px;
  } 
  .about {
    .container, .span10 {
      width: 280px;
    }
    .span10 {
      padding-top: 0px;
    }
  }
&lt;/pre&gt;
&lt;p id=&quot;tools&quot;&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;br/&gt;
In the process of developing a stopwatch, odometer, displaying routes and making everything look good, I used a number of tools. I started out primarily with &lt;a href=&quot;http://macromates.com/&quot;&gt;TextMate&lt;/a&gt; and its bundles for &lt;a href=&quot;https://github.com/appden/less.tmbundle&quot;&gt;LESS&lt;/a&gt;, &lt;a href=&quot;https://github.com/jashkenas/coffee-script-tmbundle&quot;&gt;CoffeeScript&lt;/a&gt; and &lt;a href=&quot;https://github.com/miksago/jade-tmbundle&quot;&gt;Jade&lt;/a&gt;. When I started writing more Scala, I installed the &lt;a href=&quot;https://github.com/mads379/scala.tmbundle&quot;&gt;Scala TextMate Bundle&lt;/a&gt;. When I needed some debugging, I switched to &lt;a href=&quot;http://www.jetbrains.com/idea/&quot;&gt;IntelliJ&lt;/a&gt; and installed its Scala plugin. CoffeeScript, LESS and HAML plugins (for Jade) were already installed by default. I also used James Ward&apos;s &lt;a href=&quot;http://www.jamesward.com/2011/07/28/setup-play-framework-with-scala-in-intellij&quot;&gt;Setup Play Framework with Scala in IntelliJ&lt;/a&gt;.
&lt;/p&gt;
&lt;p id=&quot;issues&quot;&gt;
  &lt;strong&gt;Issues&lt;/strong&gt;&lt;br/&gt;
  I think it&apos;s obvious that my biggest issue so far is the fact that a webapp can&apos;t multitask in the background like a native app can. Beyond that, there&apos;s accuracy issues with HTML5&apos;s geolocation that I haven&apos;t seen in native apps. 
&lt;/p&gt;
&lt;p&gt;
I also ran into a caching issue when calling getCurrentPosition(). It only worked the first time and I had to refresh my browser to get it to work again. Strangely enough, this only happened on my desktop (in Safari and Firefox) and worked fine on my iPhone. Unfortunately, it looks like &lt;a href=&quot;https://github.com/phonegap/phonegap-iphone/issues/197&quot;&gt;PhoneGap has issues&lt;/a&gt; similar to this.
&lt;/p&gt;
&lt;p&gt;My workaround for no webapp multitasking is turning off auto-lock and leaving the browser in the foreground while I exercise. The downside to this is it &lt;em&gt;really&lt;/em&gt; drains the battery quickly (~ 3 hours). I constantly have to charge my phone if I&apos;m testing it throughout the day. The testing is a real pain too. I have to deploy to Heroku (which is easy enough), then go on a walk or bike ride. If something&apos;s broke, I have to return home, tweak some things, redeploy and go again. Also, there&apos;s been a few times where Safari crashes halfway through and I lose all the tracking data. This happens with native apps too, but seemingly not as often.  
&lt;/p&gt;
&lt;p&gt;
  If you&apos;d like to try the app on your mobile phone and see if you experience these issues, checkout &lt;a href=&quot;http://play-more.com&quot;&gt;play-more.com&lt;/a&gt;.
&lt;/p&gt;
&lt;p id=&quot;summary&quot;&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br/&gt;Going forward, there&apos;s still more HTML5 features I&apos;d like to use. In particular, I&apos;d like to play music while the fitness tracker is running. I&apos;d love it if cloud music services (e.g. Pandora or Spotify) had an API I could use to play music in a webapp. &lt;a href=&quot;http://soundcloud.com/&quot;&gt;Soundcloud&lt;/a&gt; might be an option, but I&apos;ve also thought of just uploading some MP3s and playing them with the &amp;lt;audio&amp;gt; tag. 
&lt;/p&gt;
&lt;p&gt;I&apos;ve really enjoyed developing with all these technologies and haven&apos;t experienced much frustration so far. The majority has come from integrating Scalate into Play, but I&apos;ve resolved most problems. Next, I&apos;ll talk about how I&apos;ve improved Play&apos;s Scalate support and my experience working with &lt;a href=&quot;http://scala.playframework.org/documentation/scala-0.9.1/anorm&quot;&gt;Anorm&lt;/a&gt;. 
</description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/integrating_html5_boilerplate_with_scalate</guid>
    <title>Integrating HTML5 Boilerplate with Scalate and Play</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/integrating_html5_boilerplate_with_scalate</link>
        <pubDate>Wed, 28 Sep 2011 08:49:35 -0600</pubDate>
    <category>Java</category>
    <category>scalate</category>
    <category>devoxx2011</category>
    <category>html5boilerplate</category>
    <category>coffeescript</category>
    <category>play-more</category>
    <category>playframework</category>
            <description>HTML5 Boilerplate is a project that provides a number of basic files to help you build an HTML5 application. At its core, it&apos;s an HTML template that puts CSS at the top, JavaScript at the bottom, installs Chrome Frame for IE6 users and leverages Modernizr for legacy browser support. It also includes jQuery with the download. One of the major benefits of HTML5 Boilerplate is it ships with a build system (powered by Ant) that concatenates and minimizes CSS and JS for maximum performance. From &lt;a href=&quot;http://html5boilerplate.com/&quot;&gt;html5boilerplate.com&lt;/a&gt;:
&lt;/p&gt;
&lt;p class=&quot;smokey&quot;&gt;
Boilerplate is not a framework, nor does it prescribe any philosophy of development, it&apos;s just got some tricks to get your project off the ground quickly and right-footed.
&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;
I like the idea of its build system to minify and gzip, but I&apos;d probably only use it if I was working on a project that uses Ant. Since I&apos;m using it in a Play project, the whole Ant build system doesn&apos;t help me. Besides, I prefer something like &lt;a href=&quot;http://code.google.com/p/wro4j/&quot;&gt;wro4j&lt;/a&gt;. Wro4j allows you to specify a group of files and then it compiles, minimizes and gzips them all on-the-fly. As far as I know, Play doesn&apos;t have any support for Servlet Filters, so using wro4j in Play is not trivial.
&lt;/p&gt;
&lt;p&gt;
The good news is Play has a &lt;a href=&quot;http://www.playframework.org/modules/greenscript&quot;&gt;GreenScript module&lt;/a&gt; that contains much of the wro4j functionality. However, since I&apos;m using &lt;a href=&quot;http://scalate.fusesource.org/presentations/scalate#(1)&quot;&gt;Scalate&lt;/a&gt; in my project, this goodness is unavailable to me. In the future, the Scalate Team is considering adding &lt;a href=&quot;http://groups.google.com/group/scalate/browse_thread/thread/2904bbdc8ca9dd46&quot;&gt;better wro4j, JavaScript and CSS integration&lt;/a&gt;. In the meantime, I&apos;m going to pretend I don&apos;t care about concatenation and minimization and trundle along without this feature.
&lt;/p&gt;
&lt;p&gt;To add HTML5 Boilerplate to my Play project, I performed the following steps:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Downloaded the &lt;a href=&quot;http://github.com/paulirish/html5-boilerplate/zipball/v2.0&quot;&gt;2.0 Zipball&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Copied all the static files to my project. Below are the commands I used (where &lt;em&gt;$boilerplate-download&lt;/em&gt; is the expanded download directory and &lt;em&gt;~/dev/play-more&lt;/em&gt; is my project):
&lt;pre style=&quot;margin-top: 5px&quot;&gt;
cd $boilerplate-download
cp 404.html ~/dev/play-more/app/views/errors/404.html
cp *.png ~/dev/play-more/public/.
cp crossdomain.xml ~/dev/play-more/public/.
cp -r css ~/dev/play-more/public/stylesheets/.
cp favicon.ico ~/dev/play-more/public/.
cp humans.txt ~/dev/play-more/public/.
cp -r js/libs ~/dev/play-more/public/javascripts/.
cp robots.txt ~/dev/play-more/public/.
&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;Copied the index.html to &lt;em&gt;~/dev/play-more/app/templates/layouts/default.jade&lt;/em&gt; and modified it to use &lt;a href=&quot;http://scalate.fusesource.org/documentation/jade.html&quot;&gt;Jade syntax&lt;/a&gt;. Since I downloaded the comments-heavy version, I modified many of them to be hidden in the final output.
&lt;pre class=&quot;brush: xml&quot;&gt;
-@ val body: String 
-@ var title: String = &quot;Play More&quot;
-@ var header: String = &quot;&quot;
-@ var footer: String = &quot;&quot;
!!! 5
/ paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ 
&amp;lt;!--&amp;#91;if lt IE 7&amp;#93;&amp;gt; &amp;lt;html class=&quot;no-js ie6 oldie&quot; lang=&quot;en&quot;&amp;gt; &amp;lt;!&amp;#91;endif&amp;#93;--&amp;gt;
&amp;lt;!--&amp;#91;if IE 7&amp;#93;&amp;gt;    &amp;lt;html class=&quot;no-js ie7 oldie&quot; lang=&quot;en&quot;&amp;gt; &amp;lt;!&amp;#91;endif&amp;#93;--&amp;gt;
&amp;lt;!--&amp;#91;if IE 8&amp;#93;&amp;gt;    &amp;lt;html class=&quot;no-js ie8 oldie&quot; lang=&quot;en&quot;&amp;gt; &amp;lt;!&amp;#91;endif&amp;#93;--&amp;gt;
-# Consider adding an manifest.appcache: h5bp.com/d/Offline 
&amp;lt;!--&amp;#91;if gt IE 8&amp;#93;&amp;gt;&amp;lt;!--&amp;gt; &amp;lt;html class=&quot;no-js&quot; lang=&quot;en&quot;&amp;gt; &amp;lt;!--&amp;lt;!&amp;#91;endif&amp;#93;--&amp;gt;
head
  meta(charset=&quot;utf-8&quot;)

  -# Use the .htaccess and remove these lines to avoid edge case issues. More info: h5bp.com/b/378 
  meta(http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge,chrome=1&quot;)

  title=title
  meta(name=&quot;description&quot; content=&quot;&quot;)
  meta(name=&quot;author&quot; content=&quot;Matt Raible ~ matt@raibledesigns.com&quot;)

  -# Mobile viewport optimized: j.mp/bplateviewport 
  meta(name=&quot;viewport&quot; content=&quot;width=device-width,initial-scale=1&quot;)

  -# Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons

  -# CSS: implied media=all
  link(rel=&quot;stylesheet&quot; href={uri(&quot;/public/stylesheets/style.css&quot;)})
  -# end CSS

  -# More ideas for your &amp;lt;head&amp;gt; here: h5bp.com/d/head-Tips 
  -#
    All JavaScript at the bottom, except for Modernizr / Respond.
    Modernizr enables HTML5 elements &amp;amp; feature detects; Respond is a polyfill for min/max-width CSS3 Media Queries
    For optimal performance, use a custom Modernizr build: www.modernizr.com/download/ 

  script(type=&quot;text/javascript&quot; src={uri(&quot;/public/javascripts/libs/modernizr-2.0.6.min.js&quot;)})
body
  #container
    header = header
    #main(role=&quot;main&quot;)
      != body
    footer = footer

  -# JavaScript at the bottom for fast page loading 
  
  / Grab Google CDN&apos;s jQuery, with a protocol relative URL; fall back to local if offline 
  script(type=&quot;text/javascript&quot; src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&quot;)
  :javascript
    window.jQuery || document.write(&apos;&amp;lt;script src={uri(&quot;/public/javascripts/libs/jquery-1.6.2.min.js&quot;)}&amp;gt;&amp;lt;\/script&amp;gt;&apos;)

  -# Change UA-XXXXX-X to be your site&apos;s ID 
  :javascript
    window._gaq = &amp;#91;&amp;#91;&apos;_setAccount&apos;,&apos;UA-25859875-1&apos;&amp;#93;,&amp;#91;&apos;_trackPageview&apos;&amp;#93;,&amp;#91;&apos;_trackPageLoadTime&apos;&amp;#93;&amp;#93;;
    Modernizr.load({
      load: (&apos;https:&apos; == location.protocol ? &apos;//ssl&apos; : &apos;//www&apos;) + &apos;.google-analytics.com/ga.js&apos;
    });

  -# Prompt IE 6 users to install Chrome Frame. Remove this if you want to support IE 6. 
  -# http://chromium.org/developers/how-tos/chrome-frame-getting-started 
  /&amp;#91;if lt IE 7&amp;#93;
    script(src=&quot;//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js&quot;)
    :javascript
      window.attachEvent(&apos;onload&apos;,function(){CFInstall.check({mode:&apos;overlay&apos;})})
        
!= &quot;&amp;lt;/html&amp;gt;&quot;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Next, I had to add support for layouts to my &lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with&quot;&gt;homegrown Scalate support&lt;/a&gt;. I did this by specifying a &lt;code&gt;layoutStrategy&lt;/code&gt; when initializing the TemplateEngine. From &lt;em&gt;play-more/app/controllers/ScalateTemplate.scala&lt;/em&gt;:
&lt;pre class=&quot;brush: scala&quot;&gt;
engine.classLoader = Play.classloader
engine.layoutStrategy = new DefaultLayoutStrategy(engine, 
  Play.getFile(&quot;/app/templates/layouts/default&quot; + scalateType).getAbsolutePath)
engine
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&apos;s it! Now I have HTML5 Boilerplate integrated into my Play/Scalate/Jade application. To set the title and header in my &lt;em&gt;index.jade&lt;/em&gt;, I simply added the following lines at the top:&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
- attributes(&quot;title&quot;) = &quot;Counting&quot;
- attributes(&quot;header&quot;) = &quot;HTML5 Rocks!&quot;
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;CoffeeScript Tip&lt;/strong&gt;&lt;br/&gt;
Yesterday, I mentioned that I was &lt;a href=&quot;http://raibledesigns.com/rd/entry/trying_to_make_coffeescript_work&quot;&gt;having issues getting CoffeeScript to work with Scalate&lt;/a&gt; and that I was going to try and get the in-browser compiler working. First of all, reverting to Scalate 1.4.1 didn&apos;t work because there is no CoffeeScript support in 1.4.1. So I stayed with 1.5.2 and used PandaWood&apos;s &lt;a href=&quot;http://forgivingworm.wordpress.com/2010/09/27/running-coffeescript-in-browser/&quot;&gt;Running CoffeeScript In-Browser Tutorial&lt;/a&gt;. I copied &lt;a href=&quot;http://github.com/jashkenas/coffee-script/raw/master/extras/coffee-script.js&quot;&gt;coffee-script.js&lt;/a&gt; to &lt;em&gt;~/dev/play-more/public/javascripts/libs&lt;/em&gt; and added a reference to it in my default.jade layout:
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
-# JavaScript at the bottom for fast page loading 
script(type=&quot;text/javascript&quot; src={uri(&quot;/public/javascripts/libs/coffee-script.js&quot;)})
&lt;/pre&gt;
&lt;p&gt;Then I was able to write CoffeeScript in a .jade template using the following syntax:&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
:plain
  &amp;lt;script type=&quot;text/coffeescript&quot;&amp;gt;
    alert &quot;hello world&quot;
  &amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br/&gt;
If you&apos;ve integrated HTML5 Boilerplate into your Play application, I&apos;d love to hear about it. Now that I have all the infrastructure in place (Jade, CoffeeScript, HTML5 Boilerplate), I&apos;m looking forward to getting some development done. Who knows, maybe I&apos;ll even come up with my own &lt;a href=&quot;http://www.zeroturnaround.com/blog/play-framework-unfeatures-that-irk-my-inner-geek/&quot;&gt;Play Un-Features That Really Irk My Inner Geek&lt;/a&gt;.</description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/trying_to_make_coffeescript_work</guid>
    <title>Trying to make CoffeeScript work with Scalate and Play</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/trying_to_make_coffeescript_work</link>
        <pubDate>Tue, 27 Sep 2011 13:59:18 -0600</pubDate>
    <category>Java</category>
    <category>coffeescript</category>
    <category>play-more</category>
    <category>playframework</category>
    <category>scalate</category>
    <category>devoxx2011</category>
            <description>A few weeks ago, I wrote about &lt;a href=&quot;http://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with&quot;&gt;integrating Scalate with Play&lt;/a&gt;. 
&lt;/p&gt;
&lt;p class=&quot;quote&quot;&gt;The next steps in my Play Scala adventure will be trying to get the &lt;a href=&quot;http://www.playframework.org/modules/coffee&quot; style=&quot;color: #666&quot;&gt;CoffeeScript module&lt;/a&gt; to work. I also hope to integrate &lt;a href=&quot;http://html5boilerplate.com/&quot; style=&quot;color: #666&quot;&gt;HTML5 Boilerplate&lt;/a&gt; with Jade and &lt;a href=&quot;http://scalate.fusesource.org/documentation/user-guide.html#layouts&quot; style=&quot;color: #666&quot;&gt;Scalate Layouts&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Since my last writing, the Scalate Team has created a new branch for Scala 2.8.x (that&apos;s compatible with Play) and &lt;a href=&quot;http://scalate.fusesource.org/blog/releases/release-1.5.2.html&quot;&gt;released 1.5.2&lt;/a&gt;. To upgrade my Play application to use this version, I changed my dependencies.yml to have the following:
&lt;/p&gt;
&lt;pre&gt;
  - org.fusesource.scalate -&gt; scalate-core 1.5.2-scala_2.8.1:
      transitive: false
  - org.fusesource.scalate -&gt; scalate-util 1.5.2-scala_2.8.1:
      transitive: false
&lt;/pre&gt;
&lt;p&gt;Unfortunately, this release breaks Scalate&apos;s CoffeeScript support because it &lt;a href=&quot;http://groups.google.com/group/scalate/msg/519b8ce04336b57e&quot;&gt;wraps the code with illegal comments&lt;/a&gt;. This has been fixed in the latest snapshot, but no new release has been cut. However, even if it did work, it&apos;s not quite what I&apos;m looking for. The 1.5.2 release allows for compiling inline CoffeeScript on-the-fly, but I&apos;d rather store my .coffee files external to the page.
&lt;/p&gt;
&lt;p&gt;To try and figure out how to do this, I sent a message to the Scalate Google Group asking &lt;a href=&quot;http://groups.google.com/group/scalate/browse_thread/thread/868e5c1afb6d38ac&quot;&gt;Does Scalate allow for referencing (and compiling) CoffeeScript files like the plugin for Play?&lt;/a&gt; My email prompted the Scalate Team to do some modifications that seemed to do exactly what I was looking for.
  &lt;/p&gt;
&lt;div class=&quot;quote&quot; style=&quot;margin-left: 0; margin-bottom: 10px&quot;&gt;
FWIW I&apos;ve just checked in a couple of coffeescript examples. To run it, grab the code &amp;amp; do a local build... 
&lt;br/&gt;&lt;br/&gt;
&lt;a href=&quot;http://scalate.fusesource.org/source.html&quot;&gt;http://scalate.fusesource.org/source.html&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://scalate.fusesource.org/building.html&quot;&gt;http://scalate.fusesource.org/building.html&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;
then run this...
&lt;br/&gt;
&lt;pre style=&quot;margin-top: 10px&quot;&gt;
cd samples/scalate-example 
mvn jetty:run
&lt;/pre&gt;
then open &lt;a href=&quot;http://localhost:8080/coffee/index&quot;&gt;http://localhost:8080/coffee/index&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;
there are 2 sample jade files which use embedded coffee or a separate  coffee file (using the .js extension in the &amp;lt;script src attribute&amp;gt; 
&lt;br/&gt;&lt;br/&gt;
&lt;a href=&quot;https://github.com/scalate/scalate/tree/master/samples/scalate-example/src/main/webapp/coffee&quot;&gt;https://github.com/scalate/scalate/tree/master/samples/scalate-exampl...&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;
e.g. here&apos;s a jade file references a separate .js file for a coffee script which gets converted to .js on the server... 
&lt;br/&gt;&lt;br/&gt;
&lt;a href=&quot;https://github.com/scalate/scalate/blob/master/samples/scalate-example/src/main/webapp/coffee/external.jade&quot;&gt;https://github.com/scalate/scalate/blob/master/samples/scalate-exampl...&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;To try out the improved CoffeeScript support, I checked out the source and fumbled with Git branches for a bit before I got latest version of Scalate to build. Unfortunately, it didn&apos;t work because Play doesn&apos;t know how to process the .js and .css files.&lt;/p&gt;
&lt;pre&gt;
@67o8fflce 
Application.foo.js action not found 
Action not found 
Action Application.foo.js could not be found. Error raised is 
Controller controllers.Application.foo not found 
play.exceptions.ActionNotFoundException: Action Application.foo.js not 
found 
        at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java: 
588) 
        at play.mvc.ActionInvoker.resolve(ActionInvoker.java:85) 
        at Invocation.HTTP Request(Play!) 
Caused by: java.lang.Exception: Controller controllers.Application.foo 
not found 
        ... 3 more 
08:20:21,133 ERROR ~
&lt;/pre&gt;
&lt;p&gt;Based on this error, I assumed I needed a Controller to do receive the .js and .css requests and compile them accordingly with Scalate. I changed my Jade template to have the following:
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
script(src=&quot;/assets/foo.js&quot; type=&quot;text/javascript&quot;) 
&lt;/pre&gt;
&lt;p&gt;
Then I added a new route to my Play application: 
&lt;/p&gt;
&lt;pre&gt;
  GET     /                           Application.index
  GET     /assets/{template}          ScalateResource.process
&lt;/pre&gt;
&lt;p&gt;
My ScalateResource.scala class is as follows: 
&lt;/p&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
package controllers 

import play.mvc._ 

object ScalateResource extends Controller { 

  def process(args: (Symbol, Any)*) = { 
    var template = params.get(&quot;template&quot;) 
    // replace .js with .coffee 
    template = template.replace(&quot;.js&quot;, &quot;.coffee&quot;) 
    // replace .css with .scss 
    template = template.replace(&quot;.css&quot;, &quot;.scss&quot;) 
    ScalateTemplate(template).render(); 
  } 
} 
&lt;/pre&gt;
&lt;p&gt;
Unfortunately, when I tried to access http://localhost:9000/assets/foo.js, I received the following error: 
&lt;/p&gt;
&lt;p class=&quot;smokey&quot; style=&quot;background: #ffd; border: 1px solid silver&quot;&gt;
TemplateException occured : Not a template file extension (md | markdown | ssp | scaml | mustache | jade), you requested: coffee 
&lt;/p&gt;
&lt;p&gt;At this point, I still haven&apos;t &lt;a href=&quot;http://groups.google.com/group/scalate/browse_thread/thread/868e5c1afb6d38ac&quot;&gt;figured out how to solve this&lt;/a&gt;. I can only assume that the reason this works in the example application is because it uses a TemplateEngineFilter that&apos;s mapped to /*.
&lt;/p&gt;
&lt;p&gt;As I see it, I have a few choices if I want to continue using CoffeeScript and Scalate in my application:
&lt;ol&gt;
  &lt;li&gt;Revert to an older build of Scalate that uses the in-browser CoffeeScript compiler.&lt;/li&gt;
  &lt;li&gt;Try to get a new version released that fixes the comment bug and use inline CoffeeScript.&lt;/li&gt;
  &lt;li&gt;Keep trying to figure out how to get external files compiled by Scalate.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Obviously, I&apos;d like to do #3 the most, but with the lack of responses from the Scalate group, this seems like the most challenging. Since #1 is the easiest (and I can complete without anyone&apos;s help), I&apos;ll be going that route for now. With any luck, the 2nd and third solutions will surface as options before my talk in November.&lt;/p&gt;
&lt;p id=&quot;update&quot;&gt;&lt;strong&gt;Update Oct 4, 2011:&lt;/strong&gt; I was able to get external CoffeeScript files working! It was rather simple actually. I just tried the &lt;a href=&quot;https://github.com/robfig/play-coffee&quot;&gt;Play CoffeeScript module&lt;/a&gt; again, using Scalate&apos;s &lt;code&gt;{uri(&quot;/path&quot;)}&lt;/code&gt; helper. For example, in a Jade template:
&lt;/p&gt;
&lt;pre class=&quot;brush: scala; toolbar: false&quot;&gt;
script(type=&quot;text/javascript&quot; src={uri(&quot;/public/javascripts/script.coffee&quot;)})
&lt;/pre&gt;
&lt;p&gt;This compiles the CoffeeScript file on the server and returns JavaScript. &lt;em&gt;Sweet!&lt;/em&gt;</description>          </item>
    <item>
    <guid isPermaLink="true">https://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with</guid>
    <title>Integrating Scalate and Jade with Play 1.2.3</title>
    <dc:creator>Matt Raible</dc:creator>
    <link>https://raibledesigns.com/rd/entry/integrating_scalate_and_jade_with</link>
        <pubDate>Wed, 7 Sep 2011 13:21:41 -0600</pubDate>
    <category>Java</category>
    <category>devoxx2011</category>
    <category>jade</category>
    <category>play</category>
    <category>lift</category>
    <category>play-more</category>
    <category>scala</category>
    <category>scalate</category>
            <description>At the beginning of this year, I decided I wanted to learn &lt;a href=&quot;http://www.scala-lang.org/&quot;&gt;Scala&lt;/a&gt;. Since I&apos;m a Web Frameworks Aficionado, I figured the best way to do that would be to learn &lt;a href=&quot;http://liftweb.net/&quot;&gt;Lift&lt;/a&gt;. I entered these two items on my todo list and let them lie for a couple months. After attending &lt;a href=&quot;http://raibledesigns.com/rd/entry/livin_it_up_in_vegas&quot;&gt;TSSJS 2011&lt;/a&gt; and having a conversation with &lt;a href=&quot;http://macstrac.blogspot.com/&quot;&gt;James Strachan&lt;/a&gt;, I added a couple more technologies to my learning list. James had great things to say about both &lt;a href=&quot;http://jashkenas.github.com/coffee-script/&quot;&gt;CoffeeScript&lt;/a&gt; and &lt;a href=&quot;http://jade-lang.com/&quot;&gt;Jade&lt;/a&gt; and I decided to learn those as well.&lt;/p&gt;
&lt;p&gt;In May, &lt;a href=&quot;http://devoxx.com&quot;&gt;Devoxx&lt;/a&gt; announced their Call For Papers and I started reminiscing about how awesome &lt;a href=&quot;http://raibledesigns.com/rd/entry/an_awesome_trip_to_amsterdam&quot;&gt;last year&apos;s trip&lt;/a&gt; was. I decided I&apos;d try to get accepted again and started brainstorming about talks I&apos;d like to give. I came up with &quot;Comparing Scala Web Frameworks&quot; and &quot;HTML5 with Play Scala, CoffeeScript and Jade&quot;. The reason I chose Play over Lift for the latter talk is because I think it fits a lot more with the MVC mindset I have and the easy-to-learn nature of web frameworks I enjoy using. 
Both topics sounded very interesting to me, and I figured they&apos;d also inspire me to learn the technologies in a brute-force fashion; where I was under a time constraint and would be embarrassed in front of a large audience if I didn&apos;t succeed.&lt;/p&gt;
&lt;p&gt;In mid-July, I got an email from &lt;a href=&quot;https://twitter.com/Stephan007&quot;&gt;Stephan&lt;/a&gt; inviting me to speak again at the 10th edition of Devoxx. I smile splashed across my face and I quickly realized I had a lot to learn. Since I was still in vacation mode after &lt;a href=&quot;http://raibledesigns.com/rd/entry/4th_of_july_adventures_in&quot;&gt;summer vacation in Montana&lt;/a&gt;, I decided to wait until I returned from &lt;a href=&quot;http://raibledesigns.com/rd/entry/oregon_cape_cod_and_fun&quot;&gt;Cape Cod&lt;/a&gt; to start studying. While on my 2nd summer vacation, I received an email from Devoxx stating that they&apos;d like me present &quot;HTML5 with Play/Scala, CoffeeScript and Jade&quot;. 
&lt;/p&gt;
&lt;p&gt;To learn all these technologies, I decided on an &lt;em&gt;In Anger&lt;/em&gt; approach - where I would study minimally and learn mostly by doing. I ordered &lt;a href=&quot;http://pragprog.com/book/tbcoffee/coffeescript&quot;&gt;CoffeeScript&lt;/a&gt; on August 8th and &lt;a href=&quot;http://www.artima.com/shop/programming_in_scala_2ed&quot;&gt;Programming in Scala, 2nd Edition&lt;/a&gt; the following week (August 17th). I started reading both books while traveling the following week (I found CoffeeScript and Scala to be very similar, so I don&apos;t know if I&apos;d recommend learning them at the same time). That same week, I started integrating &lt;a href=&quot;http://scalate.fusesource.org/&quot;&gt;Scalate&lt;/a&gt; (Jade) into a new &lt;a href=&quot;http://scala.playframework.org/&quot;&gt;Play Scala&lt;/a&gt; application.&lt;/p&gt;
&lt;p&gt;Scalate advertises on their homepage that it works with Play via the &lt;a href=&quot;https://github.com/pk11/play-scalate&quot;&gt;play-scalate&lt;/a&gt; module. They neglect to mention that this module hasn&apos;t been updated in over a year or what version of Play it works with. I tried to use the &lt;a href=&quot;http://www.playframework.org/modules/scalate-0.7.2/home&quot;&gt;scalate-0.7.2&lt;/a&gt; version and quickly ran into issues. I posted &lt;a href=&quot;http://groups.google.com/group/scalate/browse_thread/thread/398cee0190a47a39&quot;&gt;a message to the Scalate Google Group&lt;/a&gt; explaining my compilation issues and stacktraces. The response? Crickets.&lt;/p&gt;
&lt;p&gt;Next, I tried &lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/f225b1d228b3169&quot;&gt;posting to the Play Google Group&lt;/a&gt; and got a much better response. Here&apos;s what they said:
  &lt;/p&gt;
&lt;p class=&quot;quote&quot;&gt;
  Looking at the Scalate module code, I don&apos;t think it can work as is 
  with Play Scala 0.9.1. The latest version is more than 1 year old, and 
  we have made a lot of changes in the API.
  &lt;br/&gt;...&lt;br/&gt;
  The integration of 
  Scalate is pretty difficult if you plan to get the same kind of 
  experience than the native Play scala template regarding auto-reload 
  and error reports.&lt;br/&gt;&lt;br/&gt;
  You can try to port the module to 0.9.1, basically all it has to do is 
  to provide a plugin that detect changes to scaml file, and recompile 
  them. No special integration with the Play API is needed.
&lt;/p&gt;
&lt;p&gt;After learning that play-scalate was out-of-date, I contacted the project owner via GitHub and tried to get everything working with Play 1.2.3 and Scalate 1.5.1. I updated the dependencies in the project, fixed compilation issues and tried to build. No dice:
&lt;/p&gt;
&lt;pre&gt;
build: 
    [mkdir] Created dir: /Users/mraible/dev/play-scalate/tmp/classes 
   [scalac] Compiling 7 source files to /Users/mraible/dev/play-scalate/tmp/classes 
   [scalac] error: class file needed by Binding is missing. 
   [scalac] reference type Serializable of package scala refers to nonexisting symbol. 
   [scalac] one error found
&lt;/pre&gt;
&lt;p&gt;I &lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/759e29173b3db99d&quot;&gt;posted this error to the Play Group&lt;/a&gt;, discovered it was caused by Scalate 1.5.1 requiring Scala 2.9. I downgraded to Scalate 2.4.1 and got another nice cryptic error:&lt;/p&gt;
&lt;pre&gt;
build: 
    [mkdir] Created dir: /Users/mraible/dev/play-scalate/tmp/classes 
   [scalac] Compiling 7 source files to /Users/mraible/dev/play-scalate/tmp/classes 
   [scalac] error: class file needed by ScalaController is missing. 
   [scalac] reference value dispatch of package &amp;lt;root&gt; refers to nonexisting symbol. 
   [scalac] one error found
&lt;/pre&gt;
&lt;p&gt;Apparently, this was caused by another &lt;em&gt;Scala versioning issue&lt;/em&gt; and I was offered a &lt;a href=&quot;https://gist.github.com/1184490&quot;&gt;much simpler solution&lt;/a&gt; for integrating Scalate. Below are the steps I performed to integrate Scalate 1.4.1 with Play 1.2.3.&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Updated dependencies.yml to references Scala and Scalate dependencies.
&lt;pre style=&quot;margin-top: 5px&quot;&gt;
require:
    - play
    - play -&gt; scala 0.9.1
    - org.fusesource.scalate -&gt; scalate-core 1.4.1:
        transitive: false
    - org.fusesource.scalate -&gt; scalate-util 1.4.1:
        transitive: false
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Added Scalate configuration elements to application.conf.
&lt;pre style=&quot;margin-top: 5px&quot;&gt;
scalate=jade
jvm.memory=-Xmx256M
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Created a ScalateTemplate class to contain the Scalate Engine and render the template.
&lt;pre class=&quot;brush: scala&quot;&gt;
package controllers

import play.Play

object ScalateTemplate {

  import org.fusesource.scalate._
  import org.fusesource.scalate.util._

  lazy val scalateEngine = {
    val engine = new TemplateEngine
    engine.resourceLoader = new FileResourceLoader(Some(Play.getFile(&quot;/app/views&quot;)))
    engine.classpath = Play.getFile(&quot;/tmp/classes&quot;).getAbsolutePath
    engine.workingDirectory = Play.getFile(&quot;tmp&quot;)
    engine.combinedClassPath = true
    engine.classLoader = Play.classloader
    engine
  }

  case class Template(name: String) {
    val scalateType = &quot;.&quot; + Play.configuration.get(&quot;scalate&quot;);

    def render(args: (Symbol, Any)*) = {
      scalateEngine.layout(name + scalateType, args.map {
        case (k, v) =&gt; k.name -&gt; v
      } toMap)
    }
  }

  def apply(template: String) = Template(template)
}
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Created a Scalate trait to override the render() method in Play&apos;s Controller class.
&lt;pre class=&quot;brush: scala&quot;&gt;
package controllers

import play.mvc.Http

trait Scalate {

  def render(args: (Symbol, Any)*) = {
    def defaultTemplate = Http.Request.current().action.replace(&quot;.&quot;, &quot;/&quot;)
    ScalateTemplate(defaultTemplate).render(args: _*);
  }
}
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Created an Application.scala controller with a default &lt;em&gt;index&lt;/em&gt; method.
&lt;pre class=&quot;brush: scala&quot;&gt;
package controllers

import play.mvc._
import models._

object Application extends Controller with Scalate {

  def index = {
    render(&apos;user -&gt; User(&quot;Raible&quot;))
  }
}
&lt;/pre&gt;The models/User.scala class is very simple:
&lt;pre class=&quot;brush: scala&quot;&gt;
package models

case class User(name:String)
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Lastly, I created an index.jade file in views/Application.
&lt;pre class=&quot;brush: scala&quot;&gt;
-@ var user: models.User
p Hi #{user.name},
- for(i &amp;lt;- 1 to 3)
  p= i
p See, I can count!
&lt;/pre&gt;
&lt;/ol&gt;
&lt;p&gt;After getting all this working, I decided it was time to get it into production. As luck would have it, &lt;a href=&quot;http://blog.heroku.com/archives/2011/8/29/play/&quot;&gt;Heroku had just announced Play support&lt;/a&gt; a few days earlier. I heard through the grapevine that Play Scala would work, so I gave it a try. It was amazingly easy. All I had to do was create an account, create a &quot;Procfile&quot; in my application&apos;s root directory and run a &lt;code&gt;heroku&lt;/code&gt; command followed by a &lt;code&gt;git push&lt;/code&gt;. It all looked great until Play tried to compile my Jade templates as Groovy templates:
&lt;/p&gt;
&lt;pre&gt;
Cannot start in PROD mode with errors 
Template compilation error (In /app/views/Application/index.jade around line 2) 
The template /app/views/Application/index.jade does not compile : #{user.name} is not closed. 
play.exceptions.TemplateCompilationException: #{user.name} is not closed. 
       at play.templates.TemplateCompiler.generate(TemplateCompiler.java:102) 
       at play.templates.TemplateCompiler.compile(TemplateCompiler.java:15) 
       at play.templates.GroovyTemplateCompiler.compile(GroovyTemplateCompiler.java:4 1)
&lt;/pre&gt;
&lt;p&gt;The &lt;a href=&quot;http://groups.google.com/group/play-framework/msg/75344463d19e0e36&quot;&gt;solution from Guillaume&lt;/a&gt; was simple enough and I renamed my &quot;views&quot; directory to &quot;templates&quot; and updated ScalateTemplate.scala accordingly. You can see the deployed application at &lt;a href=&quot;http://play-more.herokuapp.com&quot;&gt;http://play-more.herokuapp.com&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;The next steps in my Play Scala adventure will be trying to get the &lt;a href=&quot;http://www.playframework.org/modules/coffee&quot;&gt;CoffeeScript module&lt;/a&gt; to work. I also hope to integrate &lt;a href=&quot;http://html5boilerplate.com/&quot;&gt;HTML5 Boilerplate&lt;/a&gt; with Jade and &lt;a href=&quot;http://scalate.fusesource.org/documentation/user-guide.html#layouts&quot;&gt;Scalate Layouts&lt;/a&gt;. I&apos;ll be doing this with the mindset that HTML and JavaScript aren&apos;t &lt;em&gt;that&lt;/em&gt; bad. I expect a lot from CoffeeScript and Jade and hope I enjoy them as much as Strachan. &lt;img src=&quot;https://raibledesigns.com/images/smileys/wink.gif&quot; class=&quot;smiley&quot; alt=&quot;;-)&quot; title=&quot;;-)&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In the meantime, here&apos;s some interesting links I&apos;ve seen recently encountered that discuss Scala and/or Play. I dig the passion and activity that exists in these communities.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://goodstuff.im/yes-virginia-scala-is-hard&quot;&gt;Yes, Virginia, Scala is hard&lt;/a&gt; and &lt;a href=&quot;http://goodstuff.im/scala-use-is-less-good-than-java-use-for-at-l&quot;&gt;the followup&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://groups.google.com/group/scala-user/browse_thread/thread/55b529c0c81335bc&quot;&gt;Scalatra vs Unfiltered vs Lift vs Play&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://groups.google.com/group/play-framework/browse_thread/thread/8cdca8216bffc464&quot;&gt;Introducing Play 2.0&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;</description>          </item>
  </channel>
</rss>