<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>QuirkeyBlog &#187; Software/Scripts</title>
	<atom:link href="http://www.quirkey.com/blog/category/softwarescripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quirkey.com/blog</link>
	<description>A Developer with too little time.</description>
	<lastBuildDate>Mon, 01 Aug 2011 16:07:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Sammy 0.7: Boy Meets Girl</title>
		<link>http://www.quirkey.com/blog/2011/08/01/sammy-0-7-boy-meets-girl/</link>
		<comments>http://www.quirkey.com/blog/2011/08/01/sammy-0-7-boy-meets-girl/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 13:00:07 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Sammy]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=541</guid>
		<description><![CDATA[Another long time in the making, Sammy 0.7 is here and its sexy. Check out the HISTORY and the full Changes to get the full details. The Boy of &#8220;Boy meets Girl&#8221; is Sammy, and the Girl is HTML5. Download it! It&#8217;s probably seemed like Sammy development had stopped a while ago. With all the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.quirkey.com/skitch/boymeetsgirl-20110730-170414.png" alt="" /></p>
<p>Another long time in the making, Sammy 0.7 is here and its sexy. Check out the <a href="https://github.com/quirkey/sammy/blob/master/HISTORY.md"><span class="caps">HISTORY</span></a> and the full <a href="https://github.com/quirkey/sammy/compare/v0.6.3...v0.7.0">Changes</a> to get the full details. The Boy of &#8220;Boy meets Girl&#8221; is Sammy, and the Girl is HTML5.</p>
<p><a href="http://github.com/quirkey/sammy/tarball/v0.7.0">Download it!</a></p>
<span id="more-541"></span>
<p>It&#8217;s probably seemed like Sammy development had stopped a while ago. With all the other similar frameworks bouncing around these days, I&#8217;ll admit there were some dark days of doubt leading up to this release. In fact, most of the code that comprises Sammy 0.7 has been in the master branch for over 4 months. However, development and my belief in this project hasn&#8217;t wained, its more just that I&#8217;ve been completely consumed by my work at <a href="http://www.paperlesspost.com">Paperless Post</a> (and in a very good way). One of the benefits of leading the team there has been the ability to push the boundaries of what we can do with our code and our libraries. We use Sammy extensively at PP and I was super excited to have a use case and a way to develop and test this latest version and all its power. The big addition of HTML5 History support has made the big new app we&#8217;ve been working on for the past 6 months seamlessly deep-link between full urls and hash urls between multiple browsers. We&#8217;re pretty psyched about it.</p>
<h3>History is History</h3>
<p>Despite which side you fell in on in the <a href="http://www.quirkey.com/blog/2011/02/10/ish/">Great hashchange debacle of '11</a> you can&#8217;t argue with the pure fact that regular <span class="caps">URI</span> paths are just better than hash (#) paths. The makers of the great browsers of the world and the HTML5 History spec have a solution that attempts to appeal to everyone. The premise is simple &#8211; create a JS <span class="caps">API</span> for manipulating the full path of the current browsers location without forcing a page reload. Meaning, you can tell the url to change from <code>http://www.example.org/one</code> to <code>http://www.example.org/two</code> without having to reload the window, and allowing you to then manipulate the state of the page. Seems sort of like a dream, doesn&#8217;t it? Not only that but it really is a perfect fit for the way Sammy manages state and how Sammy applications are already built around routes and paths. I knew this was the case the first time I saw it, but I was unsure how to mix it with the existing hash based routing that works (and would have to persist) across every browser, not just the latest and greatest.</p>
<p>I believe Sammy 0.7 presents a pretty solid solution. Now, instead of routing on paths that look like <code>#/mypath</code> you just route on paths that look like a server side path <code>/mypath</code></p>
<div class="highlight"><pre><span class="kd">var</span> <span class="nx">Sammy</span><span class="p">(</span><span class="s1">&#39;#container&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="s1">&#39;Mustache&#39;</span><span class="p">);</span><br />
<br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;templates/index.mustache&#39;</span><span class="p">);</span> <br />
  <span class="p">});</span><br />
<br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/:user&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="s1">&#39;users/&#39;</span> <span class="o"><ins></span> <span class="k">this</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">user</span> <span class="o"></ins></span> <span class="s1">&#39;.json&#39;</span><span class="p">)</span><br />
        <span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;user.mustache&#39;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
<br />
<span class="p">});</span><br />
</pre></div>
<p>The beauty and magic of above is a those routes will match both <code>quirkey.com/#!/aq</code> and <code>quirkey.com/aq</code> and execute the user route as expected. I&#8217;ve created a simple working example for you to play with at <a href="http://pushstate.quirkey.com/">http://pushstate.quirkey.com/</a> (source <a href="https://github.com/quirkey/sammy-pushstate">here</a>). We&#8217;ve been using and testing this for the past months and I can say its pretty solid (and pretty awesome).</p>
<p>There are some known caveats:</p>
<ul>
	<li>History only works in latest and greatest browsers (Chrome, FF5, Safari 4) but support for it is growing. Ben Cherry and the team at twitter also found some issues with certain versions of <a href="https://bugs.webkit.org/show_bug.cgi?id=42940">webkit and URLs getting out of sync (though its been resolved</a></li>
	<li>Your server side needs to be able to handle whatever urls you&#8217;re changing to. This means that if you route/redirect to something like <code>/path/one/two</code> in Sammy, the server better be able to handle that url as well and point you in the right direction. Otherwise, refreshing the browser will lead users to a 404 or worse. The <a href="https://github.com/quirkey/sammy-pushstate">sammy-pushstate</a> example has a pretty clever way of dealing with this in couchapps. It uses CouchDB rewrite rules to route any url request (minus the key files) to the index.html page (and hence allows sammy to handle the routing).</li>
	<li>Currently, mobile webkit (aka Mobile Safari and the Android browser) report support for pushState/History when in fact they don&#8217;t have it. Since I&#8217;ve tried to keep browser sniffing out of the core Sammy repo, it currently doesn&#8217;t detect for this. You can manually disable push state per application, though, and do the browser sniff yourself if you plan to use your app on mobile.</li>
	<li>This causes some possible breaking changes for upgrading Sammy apps. If you previously did any routing (or path checking) the path reported in a route (EventContext.prototype.path) is now the full path starting at <code>/</code> not just the path beyond the hash. Also HashLocationProxy was renamed to DefaultLocationProxy.</li>
</ul>
<p>That being said, its a pretty awesome feature and it makes writing Sammy apps really powerful when exposed to the full path. Theres more information in the <span class="caps">API</span> docs <a href="http://sammyjs.org/docs/api/0.7.0/all#Sammy.DefaultLocationProxy">here</a>.</p>
<h3>Templating engines are so 2010</h3>
<p>One thing thats frustrated a number of Sammy users is that previously all the template plugins (aka Sammy.Mustache, Sammy.Handlebars, etc) included the source for the engine in the plugin. In the beginning, I thought this was a great idea because it reduced the number of potential headaches and complaints of &#8216;Mustache isn&#8217;t working (because I didn&#8217;t include the source)&#8217;. However, what turned out to be a bigger issue was keeping up with all the plugins and their individual rapid development cycles. Because of this, all templating plugins (with the exception of Sammy.Template and Sammy.Meld) are now just simple wrappers and expect you to include the respective templating library in your own source. This also makes the case of using Mustache outside of Sammy in the same source/app as a Sammy.Mustache application a lot easier. For the sake of making the transition easier, the latest version of all of the engines is included in the repo (in <a href="https://github.com/quirkey/sammy/tree/master/vendor/templating">vendor/templating</a>).</p>
<h3>More!</h3>
<p>Those are  certainly the biggest things with this release but its also not the whole deal. There were <a href="https://github.com/quirkey/sammy/blob/master/HISTORY.md">12 other changes, bug fixes, and new plugins written by 10 different contributors!</a> I can&#8217;t thank the people who use and contribute patches and ideas back to Sammy, enough. You guys rock.</p>]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2011/08/01/sammy-0-7-boy-meets-girl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SammyJS.org</title>
		<link>http://www.quirkey.com/blog/2011/01/27/sammyjs-org/</link>
		<comments>http://www.quirkey.com/blog/2011/01/27/sammyjs-org/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 19:50:12 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Sammy]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=486</guid>
		<description><![CDATA[Sammy.js is finally official because now we have a real dedicated website: http://sammyjs.org. It only took two years. Along with the website the logo I designed before JSConf.eu last year now has an official place to proudly be displayed. Since we&#8217;re a REAL project now, we&#8217;re also starting up the SWAG train, so logo stickers [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://sammyjs.org"><img src="http://www.quirkey.com/skitch/Sammy.js___A_Small_Web_Framework_with_Class___RESTFul_Evented_JavaScript-20110127-114132.jpg" alt="sammyjs.org" width="550" height="386" /></a></p>

	<p>Sammy.js is finally official because now we have a real dedicated website: <a href="http://sammyjs.org" title="">http://sammyjs.org</a>. It only took two years.</p>

	<p>Along with the website the logo I designed before JSConf.eu last year now has an official place to proudly be displayed. Since we&#8217;re a <span class="caps">REAL</span> project now, we&#8217;re also starting up the <span class="caps">SWAG</span> train, so logo stickers are on their way.</p>

	<p>The biggest change with the new site is the <span class="caps">API</span> documentation has been <a href="http://sammyjs.org/docs/api/stable" title="">significantly cleaned up</a>. The text is still being generated from the code itself, but now we have easier navigation, the ability to keep multiple versions of the docs (generated per release) and probably the most fun &#8211; method level comments powered by Sammy users and contributors, <a href="http://disqus.com" title=""><span class="caps">DISQUS</span></a>. I&#8217;ve made good use of the method level comments featured in sites like <a href="http://apidock.com" title="">apidock</a> so I&#8217;m very excited to see if the community participates here.</p>

	<p>Sammy.js is growing up and its been so much fun to see how and where people use it. I don&#8217;t see that many big changes in the future for it before we push a real 1.0 (See a <a href="http://groups.google.com/group/sammyjs/browse_frm/thread/cd17332e9e82abc6" title="">brief roadmap on the mailing list</a>) and a big goal is to get push the big one oh before this year&#8217;s <a href="http://2011.jsconf.us" title="">JSConf in Portland.</a></p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2011/01/27/sammyjs-org/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Getting to know Sammy.js: Helpers</title>
		<link>http://www.quirkey.com/blog/2010/11/04/getting-to-know-sammy-js-helpers/</link>
		<comments>http://www.quirkey.com/blog/2010/11/04/getting-to-know-sammy-js-helpers/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 12:07:08 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Sammy]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=475</guid>
		<description><![CDATA[For part of this month&#8217;s writing I&#8217;m going to write focused posts about features of Sammy.js that people may not know about or have used. In the end I hope to compile these into part of the new Sammy.js site. A question came up on the mailing list recently about overriding previously defined routes after [...]]]></description>
			<content:encoded><![CDATA[<p><em>For part of this month&#8217;s writing I&#8217;m going to write focused posts about features of Sammy.js that people may not know about or have used. In the end I hope to compile these into part of the new Sammy.js site.</em></p>
<p>A question came up on the <a href="http://groups.google.com/group/sammyjs/browse_frm/thread/8234ef63d20c99ae/580e66ac59a483cf">mailing list recently about overriding previously defined routes</a> after struggling thinking of how to do this with the current codebase, the answer was simple: Use helpers!</p>
<p>Coming from Sinatra or Rails the idea of <code>helpers</code> might be associated with just &#8220;view helpers&#8221; &#8211; methods added to the controller which are passed down to the view to help refactor/encapsulate common view logic. In Sammy.js helpers are really a way of refactoring common logic out of routes and into a reusable named method.</p>
<span id="more-475"></span>
<h3>Refactorin&#8217;</h3>
<p>In any app you&#8217;ll have startup code or code that needs to be run for every or multiple pages (routes). In Sammy this might looks like:</p>
<div class="highlight"><pre><span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">grid</span><span class="p">)</span> <span class="p">{</span><br />
      <span class="k">this</span><span class="p">.</span><span class="nx">$element</span><span class="p">().</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;grid&#39;</span><span class="p">);</span><br />
    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span><br />
      <span class="k">this</span><span class="p">.</span><span class="nx">$element</span><span class="p">().</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;grid&#39;</span><span class="p">);</span><br />
    <span class="p">}</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;index.html&#39;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/user&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">grid</span><span class="p">)</span> <span class="p">{</span><br />
      <span class="k">this</span><span class="p">.</span><span class="nx">$element</span><span class="p">().</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;grid&#39;</span><span class="p">);</span><br />
    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span><br />
      <span class="k">this</span><span class="p">.</span><span class="nx">$element</span><span class="p">().</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;grid&#39;</span><span class="p">);</span><br />
    <span class="p">}</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;user.html&#39;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
  <br />
<span class="p">})</span><br />
</pre></div>
<p>A contrived example, but you can tell we&#8217;re doing almost the exactly same thing in each of the routes. A common JS convention and something you could do pretty easily here, would just be to extract the functionality out into a closure/function and call it for each route.</p>
<div class="highlight"><pre><span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <br />
  <span class="kd">var</span> <span class="nx">displayGrid</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">$element</span><span class="o">,</span> <span class="nx">display</span><span class="p">)</span> <span class="p">{</span><br />
    <span class="k">if</span> <span class="p">(</span><span class="nx">display</span><span class="p">)</span> <span class="p">{</span><br />
      <span class="nx">$element</span><span class="p">.</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;grid&#39;</span><span class="p">);</span><br />
    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span><br />
      <span class="nx">$element</span><span class="p">.</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;grid&#39;</span><span class="p">);</span><br />
    <span class="p">}</span><br />
  <span class="p">};</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="nx">displayGrid</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">$element</span><span class="p">()</span><span class="o">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">grid</span><span class="p">);</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;index.html&#39;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/user&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="nx">displayGrid</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">$element</span><span class="p">()</span><span class="o">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">grid</span><span class="p">);</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;user.html&#39;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
  <br />
<span class="p">})</span><br />
</pre></div>
<p>This works, it prevents global leakage by declaring it inside the app, and it gets rid of a number of lines of repetitive code. However, we&#8217;re still passing a bunch of route attributes into the closure. This is where helpers can shine.</p>
<div class="highlight"><pre><span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">helpers</span><span class="p">({</span><br />
    <span class="nx">displayGrid</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
      <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">grid</span><span class="p">)</span> <span class="p">{</span><br />
        <span class="k">this</span><span class="p">.</span><span class="nx">$element</span><span class="p">().</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;grid&#39;</span><span class="p">);</span><br />
      <span class="p">}</span> <span class="k">else</span> <span class="p">{</span><br />
        <span class="k">this</span><span class="p">.</span><span class="nx">$element</span><span class="p">().</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;grid&#39;</span><span class="p">);</span><br />
      <span class="p">}</span><br />
  <span class="p">});</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">displayGrid</span><span class="p">();</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;index.html&#39;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/user&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">displayGrid</span><span class="p">();</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;user.html&#39;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
  <br />
<span class="p">});</span><br />
</pre></div>
<p>This looks a lot cleaner to me. You might not love <code>this</code> but it makes some things really magical. By making <code>displayGrid</code> a helper it automagically has access to the context of the current route. That means that just like the route&#8217;s callback, it has access to everything in the <code>EventContext</code> including <code>params</code>, <code>redirect</code>, <code>render</code> and <em>other helpers</em>. This is important, because it basically allows you to extract common code from routes into helpers and then refactor those helpers even further into <em>other</em> helpers.</p>
<h3>stOOPid inheritance and mixins</h3>
<p>Helpers are actually just methods on the app&#8217;s <code>EventContext</code> prototype, and event though there&#8217;s no classical inheritance with <code>super</code>&#8217;s and all that jazz we can do some fun <span class="caps">OOP</span>-like magic.</p>
<p>In the example from the mailing list, we wanted to override an application&#8217;s existing route with a new route. Though the way routes are stored and handled makes it difficult on the app level, doing it on the helper level is EZ:</p>
<div class="highlight"><pre><span class="c">// initializing a new app</span><br />
<span class="kd">var</span> <span class="nx">app</span> <span class="o">=</span> <span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">helpers</span><span class="p">({</span><br />
    <span class="c">// define a helper to load the index as the default behavior</span><br />
    <span class="nx">loadIndex</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
      <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;index.html&#39;</span><span class="p">);</span><br />
    <span class="p">}</span><br />
  <span class="p">});</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">loadIndex</span><span class="p">();</span><br />
  <span class="p">});</span><br />
<span class="p">});</span><br />
<br />
<span class="c">// override the specific helper, and hence the index route</span><br />
<span class="c">// we can also do this by calling `helpers()`</span><br />
<span class="nx">app</span><span class="p">.</span><span class="nx">helper</span><span class="p">(</span><span class="s1">&#39;loadIndex&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;specialindex.html&#39;</span><span class="p">);</span><br />
<span class="p">});</span><br />
</pre></div>
<p><code>use()</code> is how Sammy includes a plugin in an app. A plugin is really just another app function, though, that get&#8217;s evaluated at the time you <code>use()</code> it. In fact, when you call <code>$.sammy()</code> you&#8217;re just creating a new instance of <code>Sammy.Application</code> and then calling <code>use()</code> on it with the app function. This is a simple way of doing &#8220;mixin&#8221; style inheritance. A plugin can do anything an app can, including and <em>especially</em> helpers. So with multiple apps we be all like tag team:  <a href="http://www.youtube.com/watch?v=Z-FPimCmbX8"><span class="caps">OOP</span> there it is</a></p>
<div class="highlight"><pre><span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="s1">&#39;#hiphop&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">helpers</span><span class="p">({</span><br />
    <span class="nx">playCatchPhrase</span><span class="o">:</span> <span class="nx">$</span><span class="p">.</span><span class="nx">noop</span><br />
    <span class="c">// noop there it is </span><br />
    <span class="c">// this is sort of like an abstract method</span><br />
  <span class="p">});</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/catchphrase&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">playCatchPhrase</span><span class="p">();</span><br />
  <span class="p">})</span><br />
<span class="p">});</span><br />
<br />
<span class="kd">var</span> <span class="nx">atlanta</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">helper</span><span class="p">(</span><span class="s1">&#39;playCatchPhrase&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;whoomp there it is!&#39;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
<span class="p">};</span><br />
<br />
<span class="kd">var</span> <span class="nx">la</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">helper</span><span class="p">(</span><span class="s1">&#39;playCatchPhrase&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;do the hump!&#39;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
<span class="p">};</span><br />
<br />
<span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="s1">&#39;#hiphop&#39;</span><span class="p">).</span><span class="nx">use</span><span class="p">(</span><span class="nx">la</span><span class="p">);</span><br />
<span class="c">// get &#39;#/catchphrase&#39; //=&gt; &#39;do the hump!&#39;</span><br />
</pre></div>
<p>Thats still pretty simple, though combining these ideas is actually pretty powerful. Almost all of Sammy&#8217;s existing plugins are based on this simple approach. I&#8217;m hoping soon, it can get even more abstract and complex. Why not a <code>Sammy.Auth</code> that handles displaying/posting/and doing all the basic authentication? You could use helpers for most of the dirty work and then one could just override the defaults in their specific apps. You could even create <em>another</em> set of plugins that were different displays or authentication systems that override the simple base methods. Do it! ( <em>so I dont have to</em> )</p>]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2010/11/04/getting-to-know-sammy-js-helpers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sammy.js Tutorial finally updated for 0.6</title>
		<link>http://www.quirkey.com/blog/2010/11/02/sammy-js-tutorial-finally-updated-for-0-6/</link>
		<comments>http://www.quirkey.com/blog/2010/11/02/sammy-js-tutorial-finally-updated-for-0-6/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 05:45:46 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Sammy]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=466</guid>
		<description><![CDATA[The title really says it all but this has been a long time coming. Since the RenderContext changes in 0.6 there were some incompatibilities between the code in the tutorial and what actually worked. It wasn&#8217;t just an easy swap of method names &#8211; I spent some actual time today rewriting some big chunks of [...]]]></description>
			<content:encoded><![CDATA[	<p>The title really says it all but this has been a long time coming. Since the RenderContext changes in 0.6 there were some incompatibilities between the code in the tutorial and what actually worked. It wasn&#8217;t just an easy swap of method names &#8211; I spent some actual time today rewriting some big chunks of the first tutorial and adding an introduction to the RenderContext. The example app (<a href="http://github.com/quirkey/the_json_store" title="">The <span class="caps">JSON </span>Store</a>) was also updated.</p>

	<p>I&#8217;ve been thinking about part <span class="caps">III</span> and beyond as well, but thats for another day. I hope at least this fixes a lot of the confusion for people delving into Sammy for the first time.</p>

	<p><a href="http://code.quirkey.com/sammy/tutorials/" title="">Check out the new tutorials here.</a></p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2010/11/02/sammy-js-tutorial-finally-updated-for-0-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sammy 0.6: California Suite</title>
		<link>http://www.quirkey.com/blog/2010/09/02/sammy-0-6-california-suite/</link>
		<comments>http://www.quirkey.com/blog/2010/09/02/sammy-0-6-california-suite/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 13:18:12 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Sammy]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=453</guid>
		<description><![CDATA[It&#8217;s a couple months in the making, but I&#8217;m happy to say that Sammy.js 0.6 is finally here. Check out the HISTORY and the Changes. I&#8217;m calling this release the California Suite in honor of my move to the West Coast and the fact that I did most of this coding on the plane back [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://img.skitch.com/20100831-11assdyxnsmqepn2aftj5mu4kr.png" alt="" /></p>
<p>It&#8217;s a couple months in the making, but I&#8217;m happy to say that <a href="http://code.quirkey.com/sammy">Sammy.js</a> 0.6 is finally here. Check out the <a href="http://github.com/quirkey/sammy/blob/master/HISTORY.md"><span class="caps">HISTORY</span></a> and the <a href="http://github.com/quirkey/sammy/compare/v0.5.4...v0.6.0">Changes</a>. I&#8217;m calling this release the California Suite in honor of my move to the West Coast and the fact that I did most of this coding on the plane back and forth. There are some awesome big new features that I&#8217;ve been using for a little while now and I can say are a big improvement over previous releases.</p>
<p><a href="http://github.com/quirkey/sammy/tarball/v0.6.0">Download it!</a></p>
<p>Before I get to that, I want to mention that work is in full swing on a new Sammy.js website with more documentation and other great stuff. I even have a real logo which I hope to share soon (stickers, anyone?). Before the site launches, though, I set up a <a href="http://github.com/quirkey/sammy/wiki/">new GitHub wiki</a> so that sammy.js users and developers can share projects and code that they&#8217;ve been working on.</p>
<p>On to the features!</p>
<span id="more-453"></span>
<h3>Context! Context! Context!</h3>
<p>The biggest complaint and frustration that I heard from people working with Sammy was about dealing with rendering complex views on the client. If you&#8217;re doing full client side applications or any amount of client side templating you&#8217;ve felt the pain of deeply nested callbacks and complex workarounds for interpolating data in an asynchronous environment. It&#8217;s all like, render this template, wait, first I need the data, hold up, I cant even render that yet I need to get this other template first. Here&#8217;s a common example of what I&#8217;m talking about:</p>
<div class="highlight"><pre><span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;index.mustache&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">html</span><span class="p">)</span> <span class="p">{</span><br />
    <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#main&#39;</span><span class="p">).</span><span class="nx">html</span><span class="p">(</span><span class="nx">html</span><span class="p">);</span><br />
    <span class="nx">$</span><span class="p">.</span><span class="nx">getJSON</span><span class="p">(</span><span class="s1">&#39;items.json&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">items</span><span class="p">)</span> <span class="p">{</span><br />
      <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;item.mustache&#39;</span><span class="o">,</span> <span class="nx">items</span><span class="o">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">item</span><span class="o">,</span> <span class="nx">i</span><span class="p">)</span> <span class="p">{</span><br />
        <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#main ul&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">item</span><span class="p">);</span><br />
      <span class="p">});</span><br />
    <span class="p">});</span><br />
  <span class="p">));</span><br />
<span class="p">});</span><br />
</pre></div>
<p>It&#8217;s not just nested callback&#8217;s that are the pain &#8211; its the knowing (or not knowing) when a template will be there or not. It&#8217;s also trying to deal with fetching data and fetching templates within the same context without a unified <span class="caps">API</span>. After kind of examining how other people are doing this, I took some queues from jQuery&#8217;s <span class="caps">API</span> as well as &#8216;promise&#8217; style programming and <a href="http://sexyjs.com/">Sexy.js</a>. The result is <code>Sammy.RenderContext</code>. You create a <code>RenderContext</code> by calling one of three methods within a route/<code>EventContext</code> &#8211; <code>load()</code> <code>render()</code> or <code>partial()</code>. Once you have a every method you chain to it is guaranteed to execute in the order that you chain it <em>regardless of it synchronicity</em>. This means that you can put an <code>appendTo()</code> after a <code>load()</code> and the content won&#8217;t be appended until its fetched asynchronously from a remote location. The content from the previous method in the chain is also passed along so you don&#8217;t have to constantly pull out references. The code above, translated to the <em>new way</em> looks like:</p>
<div class="highlight"><pre><span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="s1">&#39;index.mustache&#39;</span><span class="p">)</span><br />
      <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="s1">&#39;#main&#39;</span><span class="p">)</span><br />
      <span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="s1">&#39;items.json&#39;</span><span class="p">)</span><br />
      <span class="p">.</span><span class="nx">renderEach</span><span class="p">(</span><span class="s1">&#39;item.mustache&#39;</span><span class="p">)</span><br />
      <span class="p">.</span><span class="nx">appendTo</span><span class="p">(</span><span class="s1">&#39;#main ul&#39;</span><span class="p">);</span><br />
<span class="p">});</span><br />
</pre></div>
<p>A wee bit nicer. Not only does it improve readability but it makes it much easier to do longer more involved client side templating without getting lost in a mire of order and context passing. RenderContext&#8217;s can also be invoked side by side in a single route for parallel execution of chains. Each chain is its own object and keeps its own state. I tried to keep the <span class="caps">API</span> concise but with just a few methods, I think most situations are covered:</p>
<div class="highlight"><pre><span class="nx">then</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">content</span><span class="o">,</span> <span class="nx">previous</span><span class="p">)</span> <span class="p">{})</span><br />
<span class="nx">next</span><span class="p">(</span><span class="nx">content</span><span class="p">);</span><br />
<span class="nx">wait</span><span class="p">();</span><br />
<span class="c">// Loading local or remote content</span><br />
<span class="nx">load</span><span class="p">(</span><span class="s1">&#39;item.template&#39;</span><span class="p">)</span><br />
<span class="nx">load</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.item&#39;</span><span class="p">))</span><br />
<span class="c">// rendering templates</span><br />
<span class="nx">interpolate</span><span class="p">(</span><span class="s1">&#39;item.template&#39;</span><span class="o">,</span> <span class="p">{})</span><br />
<span class="nx">interpolate</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.item&#39;</span><span class="p">)</span><span class="o">,</span> <span class="p">{})</span><br />
<span class="nx">render</span><span class="p">(</span><span class="s1">&#39;item.template&#39;</span><span class="o">,</span> <span class="p">{})</span><br />
<span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;item.template&#39;</span><span class="o">,</span> <span class="p">{})</span><br />
<span class="nx">collect</span><span class="p">(</span><span class="nx">items</span><span class="o">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">item</span><span class="o">,</span> <span class="nx">i</span><span class="p">)</span> <span class="p">{})</span><br />
<span class="nx">renderEach</span><span class="p">(</span><span class="s1">&#39;item.template&#39;</span><span class="o">,</span> <span class="nx">items</span><span class="p">)</span><br />
<span class="c">// <span class="caps">DOM</span> Manipulation</span><br />
<span class="nx">swap</span><span class="p">()</span><br />
<span class="nx">appendTo</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="nx">element</span><span class="p">))</span><br />
<span class="nx">prependTo</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="nx">element</span><span class="p">))</span><br />
<span class="nx">replace</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="nx">element</span><span class="p">))</span><br />
<span class="c">// Events</span><br />
<span class="nx">trigger</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="o">,</span> <span class="p">{})</span><br />
</pre></div>

<p>Along with the readability improvements, the <code>RenderContext</code> (specifically <code>load()</code>) allows for <span class="caps">DOM</span> style or pre-embedded templating. Meaning, templates don&#8217;t have to come from files, they can be <span class="caps">DOM</span> elements and embedded into <code>&lt;script&gt;</code> or hidden tags. This goes along with the two new templating engines added as well . . .</p>
<h3>Alchemy</h3>
<p>I thought I had this really novel idea. Why not use classes or other attributes of <span class="caps">DOM</span> elements to define how they&#8217;re tied to a <span class="caps">JSON</span> object? I worked on some prototypes and finally found a name and wrote some real code. It turns out, it was a pretty good idea, but also one that had been done before. 0.6 includes plugins for my own <code>Sammy.Meld</code> and the existing and by default more popular <a href="http://beebole.com/pure/">pure.js</a>.</p>
<p>The basic idea of both of these engines is that you take some data like this:</p>
<div class="highlight"><pre><span class="p">{</span><br />
  <span class="s2">&quot;post&quot;</span><span class="o">:</span> <span class="p">{</span><br />
    <span class="s2">&quot;title&quot;</span><span class="o">:</span> <span class="s2">&quot;My Post&quot;</span><span class="o">,</span><br />
    <span class="s2">&quot;body&quot;</span><span class="o">:</span> <span class="s2">&quot;Lorem ipsum dolor sit amet.&quot;</span><span class="o">,</span><br />
    <span class="s2">&quot;tags&quot;</span><span class="o">:</span> <span class="p">[</span><span class="s2">&quot;one&quot;</span><span class="o">,</span> <span class="s2">&quot;two&quot;</span><span class="o">,</span> <span class="s2">&quot;three&quot;</span><span class="p">]</span><span class="o">,</span><br />
    <span class="s2">&quot;meta&quot;</span><span class="o">:</span> <span class="p">{</span><br />
      <span class="s2">&quot;comments&quot;</span><span class="o">:</span> <span class="mi">5</span><span class="o">,</span><br />
      <span class="s2">&quot;time&quot;</span><span class="o">:</span> <span class="s2">&quot;Yesterday&quot;</span><br />
    <span class="p">}</span><br />
  <span class="p">}</span><br />
<span class="p">}</span><br />
</pre></div>
<p>And some <span class="caps">HTML</span> like this:</p>
<div class="highlight"><pre><span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;post&quot;</span><span class="nt">&gt;</span><br />
  <span class="nt">&lt;h2</span> <span class="na">class=</span><span class="s">&quot;title&quot;</span><span class="nt">&gt;&lt;/h2&gt;</span><br />
  <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;body&quot;</span><span class="nt">&gt;&lt;/div&gt;</span><br />
  <span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&quot;tags&quot;</span><span class="nt">&gt;&lt;/span&gt;</span><br />
  <span class="nt">&lt;ul</span> <span class="na">class=</span><span class="s">&quot;meta&quot;</span><span class="nt">&gt;</span><br />
    <span class="nt">&lt;li&gt;</span>Comments Count: <span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&quot;comments&quot;</span><span class="nt">&gt;&lt;/span&gt;&lt;/li&gt;</span><br />
    <span class="nt">&lt;li&gt;</span>Posted: <span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&quot;time&quot;</span><span class="nt">&gt;&lt;/span&gt;&lt;/li&gt;</span><br />
  <span class="nt">&lt;/ul&gt;</span><br />
<span class="nt">&lt;/div&gt;</span><br />
</pre></div>
<p>Meld them together and you should get something like:</p>
<div class="highlight"><pre><span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;post&quot;</span><span class="nt">&gt;</span><br />
  <span class="nt">&lt;h2</span> <span class="na">class=</span><span class="s">&quot;title&quot;</span><span class="nt">&gt;</span>My Post<span class="nt">&lt;/h2&gt;</span><br />
  <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;body&quot;</span><span class="nt">&gt;</span>Lorem ipsum dolor sit amet.<span class="nt">&lt;/div&gt;</span><br />
  <span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&quot;tags&quot;</span><span class="nt">&gt;</span>one<span class="nt">&lt;/span&gt;</span><br />
  <span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&quot;tags&quot;</span><span class="nt">&gt;</span>two<span class="nt">&lt;/span&gt;</span><br />
  <span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&quot;tags&quot;</span><span class="nt">&gt;</span>three<span class="nt">&lt;/span&gt;</span><br />
  <span class="nt">&lt;ul</span> <span class="na">class=</span><span class="s">&quot;meta&quot;</span><span class="nt">&gt;</span><br />
    <span class="nt">&lt;li&gt;</span>Comments Count: <span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&quot;comments&quot;</span><span class="nt">&gt;</span>5<span class="nt">&lt;/span&gt;&lt;/li&gt;</span><br />
    <span class="nt">&lt;li&gt;</span>Posted: <span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&quot;time&quot;</span><span class="nt">&gt;</span>Yesterday<span class="nt">&lt;/span&gt;&lt;/li&gt;</span><br />
  <span class="nt">&lt;/ul&gt;</span><br />
<span class="nt">&lt;/div&gt;</span><br />
</pre></div>
<p>There are some clear benefits to this over traditional tag style (mustache, ejs) style templating. Namely, its just <span class="caps">HTML</span>. This means that you can include it in the <span class="caps">DOM</span> on the initial render and not have to go fetch it from the server. It also means that a designer can just design it and even use <em>lorem ipsum</em> if you want, and you don&#8217;t have to go through and <em>add</em> the templating language. There are some downsides, too. <span class="caps">DOM</span> manipulation even with jQuery&#8217;s speed is pretty much always going to be slower then just text interpolation. I&#8217;m working on improving the speed of Meld though caching and faster manipulations, but it ain&#8217;t easy. The other big downside is that complicated iteration or template logic is pretty hard to do in this style. Pure tries to get around this by using a third element called <code>directives</code> which are further instructions on how to meld the data and the markup. I forgo this extra ability to configure in Meld in favor of very simple transformations (ul,ol = lists) and a much smaller file size (<em>uncompressed</em> meld is only 4K). I&#8217;ve been using Meld on some personal projects and hope to test its worth in a real production environment very soon. You can see more examples of it&#8217;s power <a href="http://github.com/quirkey/sammy/blob/master/test/test_sammy_meld.js">in the tests</a></p>
<h3>What&#8217;s next?</h3>
<p>I&#8217;m still pushing to get Sammy.js to 1.0 in the very near future. I really don&#8217;t think theres that much between here and there. I&#8217;ll mention that I&#8217;ve finally been seriously coding with node and server side js and I&#8217;m not that happy with the current state of routing libs there. Server side sammy? Maybe.</p>
<h3>More</h3>
<p>There were a lot of smaller bug fixes and improvements beyond Meld and the RenderContext so I definitely encourage checking out the <a href="http://github.com/quirkey/sammy/blob/master/HISTORY.md">full list</a> and making the upgrade soon. Big thanks as always to everyone who helped with the release. Go out and make some apps!</p>]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2010/09/02/sammy-0-6-california-suite/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Sammy is getting busy</title>
		<link>http://www.quirkey.com/blog/2010/04/30/sammy-is-getting-busy/</link>
		<comments>http://www.quirkey.com/blog/2010/04/30/sammy-is-getting-busy/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 15:24:18 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Press]]></category>
		<category><![CDATA[Sammy]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=436</guid>
		<description><![CDATA[This week has been filled with a bunch of great news in the Sammy.js department. First of all, Sammy v0.5.4 has been released. Nothing too major, but just excited with a bunch of new contributors involved and some strange and vexing bugs fixed. More interesting, I was interviewed by The Changelog Show. Wynn and Adam [...]]]></description>
			<content:encoded><![CDATA[	<p>This week has been filled with a bunch of great news in the <a href="http://code.quirkey.com/sammy" title="">Sammy.js</a> department. First of all, <a href="http://groups.google.com/group/sammyjs/browse_frm/thread/7b7972e63ec7dcc1" title="">Sammy v0.5.4 has been released.</a> Nothing too major, but just excited with a bunch of new contributors involved and some strange and vexing bugs fixed.</p>

	<p>More interesting, <a href="thechangelog.com/post/553380723/episode-0-2-2-sammy-js-with-aaron-quint" title="">I was interviewed by The Changelog Show.</a> <a href="http://twitter.com/pengwynn" title="">Wynn</a> and <a href="http://twitter.com/adamstac" title="">Adam</a> are awesome hosts, and we talked about a lot of fun things including a good deal about Sammy and JSConf. Since I didnt really get to talk too much about Sammy at JSConf, it was a great way to share my current thoughts and some stories of the origins of Sammy.js. This also lead into a nice mention on <a href="http://5by5.tv/devshow/7" title="">The Dev Show</a> yesterday.</p>

	<p>I haven&#8217;t mentioned it here either, but I&#8217;ve also been making some major upgrades to my Sammy presentation app, <a href="http://github.com/quirkey/swinger" title="">Swinger</a>. I added slide sorting, incremental lists, and a ton more. This also includes having a fully useable hosted version for people to play with at <a href="http://swinger.quirkey.com/" title="">http://swinger.quirkey.com/</a></p>

	<p>I&#8217;m very excited about where Sammy is going and even more excited as I&#8217;m using it almost every day and getting to contribute back to the project and think about the stumbling blocks as I use it.</p>

	<p>I already have a basic plan laid out for the next release which is mainly focused on re-writing the <code>partial()</code> and template handling to make chaining multiple templates much much easier. You can <a href="http://github.com/quirkey/sammy/tree/render-context" title="">follow the work I&#8217;m doing on it on github.</a> The current status is that it works and passes the basic tests, but theres still a bit to go in terms of <span class="caps">API</span> and usability. I&#8217;m going to write a more detailed post about it very soon.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2010/04/30/sammy-is-getting-busy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sammy 0.5: Something for Everyone</title>
		<link>http://www.quirkey.com/blog/2010/02/15/sammy-0-5-something-for-everyone/</link>
		<comments>http://www.quirkey.com/blog/2010/02/15/sammy-0-5-something-for-everyone/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 19:06:24 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Sammy]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=411</guid>
		<description><![CDATA[I&#8217;m pleased to announce the next major release of Sammy.js, 0.5.0. I&#8217;ll go over what I think are the most import changes, but you can check out the HISTORY or just cut to the chase and download it. jQuery 1.4.1 One of the big events I was waiting for in order to release this new [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/blog/uploads/sammy-something-for-everyone.jpg" alt="Something for everyone" /></p>
<p>I&#8217;m pleased to announce the next major release of <a href="http://code.quirkey.com/sammy">Sammy.js</a>, 0.5.0. I&#8217;ll go over what I think are the most import changes, but you can check out the <a href="http://github.com/quirkey/sammy/blob/master/HISTORY.md"><span class="caps">HISTORY</span></a> or just cut to the chase and <a href="http://github.com/quirkey/sammy/tarball/v0.5.0">download it</a>.</p>
<h3>jQuery 1.4.1</h3>
<p>One of the big events I was waiting for in order to release this new version was the <a href="http://jquery14.com">release of jQuery 1.4.1</a>. Besides being a good leap and jump faster then previous versions, the latest jQuery added support for cross-browser bubbling of the <code>submit</code> event. This might not sound like a big deal, but Sammy handles <code>post/put/delete</code> routes by binding to forms and their <code>submit</code> events. In previous versions of Sammy, if a form was dynamically added to the page (i.e. by a <code>partial</code> or <code>get</code> route), you (or the app) would fire a <code>changed</code> event, which would tell the app to search for all newly added forms and bind to their <code>submit</code> events. Using the power of jQuery 1.4.1, Sammy can now just listen for submit events that will bubble up to the applications element and from their dispatch the route. In general this is a lot cleaner and will make it easier for beginners as it just <em>works</em>.</p>
<h3>Chain of fools</h3>
<p>From user requests, and to fulfill my own desires, I&#8217;ve tried make Sammy more adaptable to different styles of coding/app creation. The first thing I realized why not make Sammy app definitions chain-able? It&#8217;s a style of development that jQuery developers are already used to, and it looks pretty swanky, too. With 0.5, all the app modifying methods are now chain-able:</p>
<div class="highlight"><pre>  <br />
<br />
<span class="c">// classic style:</span><br />
<span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">Sammy</span><span class="p">.</span><span class="nx">Mustache</span><span class="p">);</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">Sammy</span><span class="p">.</span><span class="nx">Session</span><span class="p">);</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">before</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="c">// &#8230;</span><br />
  <span class="p">});</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="c">// &#8230;</span><br />
  <span class="p">});</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="s1">&#39;run&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="c">// &#8230;</span><br />
  <span class="p">});</span><br />
  <br />
<span class="p">})</span><br />
<br />
<span class="c">// New chain style:</span><br />
<span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">()</span><br />
  <span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">Sammy</span><span class="p">.</span><span class="nx">Mustache</span><span class="p">)</span><br />
  <span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">Sammy</span><span class="p">.</span><span class="nx">Session</span><span class="p">)</span><br />
  <span class="p">.</span><span class="nx">before</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> <br />
    <span class="c">// .</span><br />
  <span class="p">})</span><br />
  <span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="c">// &#8230;</span><br />
  <span class="p">})</span><br />
  <span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="s1">&#39;run&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="c">// &#8230;</span><br />
  <span class="p">});</span><br />
    <br />
</pre></div>
<h3>Sammy()</h3>
<p>Once just a namespace, <code>Sammy()</code> is now a function (and its aliased to $.sammy). The <code>Sammy()</code> method provides access to the new Sammy.apps object and hence allows you to access the different Sammy applications you&#8217;ve added to the page without having to define additional global vars. Finding and extending is all based on @element_selector@s so those should be unique per-application. It also provides a quicker syntax for defining an app bound to an <code>element_selector</code>.</p>
<div class="highlight"><pre><span class="c">// Old way</span><br />
<span class="c">// we&#39;re forced to make app a global so we can access it </span><br />
<span class="c">// outside of this closure</span><br />
<span class="nx">app</span> <span class="o">=</span> <span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">element_selector</span> <span class="o">=</span> <span class="s1">&#39;#myapp&#39;</span><span class="o">;</span><br />
  <span class="c">//&#8230;</span><br />
<span class="p">})</span><br />
<span class="c">// equivalent to</span><br />
<span class="nx">app</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Sammy</span><span class="p">.</span><span class="nx">Application</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">element_selector</span> <span class="o">=</span> <span class="s1">&#39;#myapp&#39;</span><span class="o">;</span><br />
  <span class="c">//&#8230;</span><br />
<span class="p">});</span><br />
<br />
<span class="c">// <span class="caps">NEW</span> <span class="caps">WAY</span></span><br />
<span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="s1">&#39;#myapp&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <span class="c">//&#8230;</span><br />
<span class="p">});</span><br />
<span class="c">// equivalent to Sammy(&#39;#myapp&#39;, function() {})</span><br />
<br />
<span class="c">// No need to assign it, the app can be looked up by element selector</span><br />
<span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="s1">&#39;#myapp&#39;</span><span class="p">)</span> <span class="c">//=&gt; Sammy.Application</span><br />
</pre></div>
<p>There are some cool use-cases for this, including being able to iterate over all the Sammy apps in play and extend them.</p>
<h3><code>any</code> way you want it</h3>
<p>Sammy 0.5 adds the new <code>any</code> <em>pseudo</em>-verb which allows you to easily add a route that will match against any verb:</p>
<div class="highlight"><pre>  <br />
<span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">any</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;I&#39;m up for anything&quot;</span><span class="p">);</span><br />
  <span class="p">});</span><br />
  <br />
  <span class="c">// also equivalent</span><br />
  <span class="k">this</span><span class="p">.</span><span class="nx">route</span><span class="p">(</span><span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{});</span><br />
  <br />
<span class="p">});</span><br />
</pre></div>
<p>This was actually the first step of another way to define Sammy applications. The new <code>mapRoutes()</code> method allows you to define any number of routes as 2D Array.</p>
<div class="highlight"><pre><span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">runIndex</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;index.template&#39;</span><span class="p">);</span><br />
  <span class="p">};</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">mapRoutes</span><span class="p">([</span><br />
    <span class="c">// each element in the array represents the arguments sent to route()</span><br />
    <span class="p">[</span><span class="s1">&#39;get&#39;</span><span class="o">,</span> <span class="s1">&#39;#/user&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
      <span class="k">this</span><span class="p">.</span><span class="nx">partial</span><span class="p">(</span><span class="s1">&#39;user.template&#39;</span><span class="p">);</span><br />
    <span class="p">}]</span><span class="o">,</span><br />
    <span class="c">// leaving out the verb assumes the verb is &#39;any&#39;</span><br />
    <span class="p">[</span><span class="sr">/\/alert$/</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
      <span class="nx">alert</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">params</span><span class="p">[</span><span class="s1">&#39;alert&#39;</span><span class="p">]);</span><br />
    <span class="p">}]</span><span class="o">,</span><br />
    <span class="c">// passing a string instead of a callback assigns the method with that</span><br />
    <span class="c">// name from the application.</span><br />
    <span class="p">[</span><span class="s1">&#39;get&#39;</span><span class="o">,</span> <span class="s1">&#39;#/&#39;</span><span class="o">,</span> <span class="s1">&#39;runIndex&#39;</span><span class="p">]</span><br />
  <span class="p">]);</span><br />
  <br />
<span class="p">});</span><br />
</pre></div>
<p>I personally like the method syntax better, but there are some cool uses for this &#8211; You could even load your routes from multiple files and add them to the application using <span class="caps">JSON</span>.</p>
<h3>Filters</h3>
<p><code>before</code> filters are very useful for extracting common functionality out of your routes. However, I&#8217;ve found myself writing this pretty often:</p>
<div class="highlight"><pre><span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">before</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="c">// only run if the path is not the index</span><br />
    <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">path</span> <span class="o">!=</span> <span class="s1">&#39;#/&#39;</span><span class="p">)</span> <span class="p">{</span><br />
      <span class="c">//&#8230; do something</span><br />
    <span class="p">}</span><br />
  <span class="p">})</span><br />
  <br />
<span class="p">});</span><br />
</pre></div>
<p>Taking some hints from Rails, I&#8217;ve added options to <code>before</code> filters. The above example could be rewritten:</p>
<div class="highlight"><pre><span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">before</span><span class="p">({</span><span class="nx">except</span><span class="o">:</span> <span class="s1">&#39;#/&#39;</span><span class="p">}</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
    <span class="c">//&#8230; do something</span><br />
  <span class="p">})</span><br />
  <br />
<span class="p">});</span><br />
</pre></div>
<p>The filters can match against <code>path</code> (as a string or RegExp) and <code>verb</code> and you can define them in the positive (<code>only</code>) or negative (<code>except</code>). The method that does the matching is exposed as <code>contextMatchesOptions</code> so you can use it outside of <code>before()</code></p>
<p>I&#8217;ve also found myself doing a lot of wrapping entire route callbacks in an asynchronous check for something (usually a login). The new <code>around</code> filters make this easy. <code>around</code> takes a single argument which is a neatly packed function that contains the full execution path of the route being accessed. This includes additional filters and the route callback itself. This also means you can entirely halt the execution by never running the passed callback.</p>
<div class="highlight"><pre><span class="nx">$</span><span class="p">.</span><span class="nx">sammy</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
  <br />
  <span class="k">this</span><span class="p">.</span><span class="nx">around</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span><br />
    <span class="c">// `this` here is the Sammy.EventContext</span><br />
    <span class="c">// just like before, etc</span><br />
    <span class="nx">$</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/session&#39;</span><span class="o">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span><br />
      <span class="nx">callback</span><span class="p">();</span><br />
    <span class="p">});</span><br />
  <span class="p">});</span><br />
<br />
<span class="p">})</span><br />
</pre></div>
<h3>Lots more</h3>
<p>Theres actually a fair amount more to cover in Sammy 0.5, but I think I&#8217;ll be doing more short &#8216;Whats new&#8217; posts soon. Check the <a href="http://github.com/quirkey/sammy/blob/master/HISTORY.md"><span class="caps">HISTORY</span></a> for a full rundown of changes.</p>
<h3>Thanks</h3>
<p>Special thanks goes out to everyone who helped with ideas, commits and testing for this release including Lena Herrmann, Jinzhu, dpree, Jeff O&#8217;Connell, Todd Willey, Tim Caswell, and Frank Prößdorf (endor).</p>]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2010/02/15/sammy-0-5-something-for-everyone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sammy 0.3.0 Released: I gotta right to swing!</title>
		<link>http://www.quirkey.com/blog/2009/09/30/sammy-0-3-0-released-i-gotta-right-to-swing/</link>
		<comments>http://www.quirkey.com/blog/2009/09/30/sammy-0-3-0-released-i-gotta-right-to-swing/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 14:57:57 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Sammy]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=371</guid>
		<description><![CDATA[I&#8217;m very happy to announce the next major release of Sammy.js. I&#8217;ve been working on this for over a month and the result has been a lot more changes then I expected but over all a smaller, cleaner core code base. Here&#8217;s a quick run through of the biggest changes. See HISTORY or the Commits [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/blog/uploads/igottarighttoswing.jpg" alt="Sammy 0.3.0: I gotta right to swing!" /></p>


	<p>I&#8217;m very happy to announce the next major release of <a href="http://code.quirkey.com/sammy">Sammy.js.</a> I&#8217;ve been working on this for over a month and the result has been a lot more changes then I expected but over all a smaller, cleaner core code base. Here&#8217;s a quick run through of the biggest changes. See <a href="http://github.com/quirkey/sammy/blob/master/HISTORY"><span class="caps">HISTORY</span></a> or the <a href="http://github.com/quirkey/sammy/commits/master">Commits</a> for a full list and more detail.</p>
<span id="more-371"></span>
	<h3>Plugins</h3>

	<p>The biggest change, that resulted in a lot of little changes is <code>Sammy.Application#use()</code> which allows you to package and resuse application level code into &#8216;Plugins&#8217;. See the <a href="http://code.quirkey.com/sammy/docs/plugins.html">documentation on plugins for more detail.</a> This also marks the start of an official selection of plugins, with two as part of this release and more on the way.</p>

<p>The default template system that used $.srender internally has been extracted out into a plugin. To enable <em>almost</em> the exact same functionality:</p>

<pre class="textmate-source"><span class="source source_js source_js_jquery"><span class="comment comment_line comment_line_double-slash comment_line_double-slash_js"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_js">//</span> somewhere in your HTML (after sammy.js): 
</span><span class="comment comment_line comment_line_double-slash comment_line_double-slash_js"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_js">//</span> &lt;script src="plugins/sammy.template.js" type="text/javascript"&gt;&lt;/script&gt;
</span><span class="keyword keyword_operator keyword_operator_js">$</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>sammy<span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="storage storage_type storage_type_js">function</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">()</span> <span class="meta meta_brace meta_brace_curly meta_brace_curly_js">{</span>
  <span class="comment comment_line comment_line_double-slash comment_line_double-slash_js"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_js">//</span> include the Sammy.Template plugin
</span>  <span class="variable variable_language variable_language_js">this</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>use<span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span>Sammy<span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>Template<span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span>
  
<span class="meta meta_brace meta_brace_curly meta_brace_curly_js">}</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span></span></pre>

	<h3>Events</h3>

	<p>Sammy.Application&#8217;s bind() and trigger() methods now use jQuery&#8217;s namespacing to bind to Events. This means that Sammy.Application can now easily catch events that bubble to it like &#8216;click&#8217; or &#8216;focus&#8217;. The big awesomeness is that the callbacks for these bind() methods are always evaluated within a Sammy.EventContext so that even events triggered from outside the app can be handled in the same way as internal events.</p>

  <pre class="textmate-source"><span class="source source_js source_js_jquery"><span class="storage storage_type storage_type_js">var</span> app <span class="keyword keyword_operator keyword_operator_js">=</span> <span class="keyword keyword_operator keyword_operator_js">$</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>sammy<span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="storage storage_type storage_type_js">function</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">()</span> <span class="meta meta_brace meta_brace_curly meta_brace_curly_js">{</span>

    <span class="variable variable_language variable_language_js">this</span><span class="support support_function support_function_js support_function_js_jquery">.bind</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>custom-event<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="meta meta_delimiter meta_delimiter_object meta_delimiter_object_comma meta_delimiter_object_comma_js">, </span><span class="storage storage_type storage_type_js">function</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">()</span> <span class="meta meta_brace meta_brace_curly meta_brace_curly_js">{</span>
      <span class="comment comment_line comment_line_double-slash comment_line_double-slash_js"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_js">//</span> this == Sammy.EventContext
  </span>    <span class="support support_function support_function_js">alert</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>Custom Event<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span> <span class="keyword keyword_operator keyword_operator_js">+</span> <span class="variable variable_language variable_language_js">this</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>params<span class="meta meta_brace meta_brace_square meta_brace_square_js">[</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>wha<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="meta meta_brace meta_brace_square meta_brace_square_js">]</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span>
    <span class="meta meta_brace meta_brace_curly meta_brace_curly_js">}</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span>

  <span class="meta meta_brace meta_brace_curly meta_brace_curly_js">}</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span>

  <span class="comment comment_line comment_line_double-slash comment_line_double-slash_js"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_js">//</span> the app is by default bound to 'body'
  </span><span class="support support_class support_class_js support_class_js_jquery">$</span><span class="punctuation punctuation_section punctuation_section_class punctuation_section_class_js">(</span><span class="meta meta_selector meta_selector_jquery"><span class="punctuation punctuation_definition punctuation_definition_selector punctuation_definition_selector_begin punctuation_definition_selector_begin_js">'</span><span class="meta meta_selector meta_selector_css"><span class="entity entity_name entity_name_tag entity_name_tag_css">body</span></span><span class="punctuation punctuation_definition punctuation_definition_selector punctuation_definition_selector_end punctuation_definition_selector_end_js">'</span></span><span class="punctuation punctuation_section punctuation_section_class punctuation_section_class_js">)</span><span class="support support_function support_function_js support_function_js_jquery">.trigger</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>custom-event<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="meta meta_delimiter meta_delimiter_object meta_delimiter_object_comma meta_delimiter_object_comma_js">, </span><span class="meta meta_brace meta_brace_curly meta_brace_curly_js">{</span>wha: <span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>ZUH?!<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="meta meta_brace meta_brace_curly meta_brace_curly_js">}</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span>
  <span class="comment comment_line comment_line_double-slash comment_line_double-slash_js"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_js">//</span>=&gt; system alert ZUH?!
  </span></span></pre>

	<h3>Cleanup</h3>

	<p>With the advent of plugins, Sammy Core is now even smaller (8.9k minified). This is also possible because I&#8217;ve removed the former &#8216;classical&#8217; inheritence code in favor of prototypal inheritence, which is a big win in terms of cleanlieness and global scope leakage.</p>


	<h3>See Also</h3>


	<p>I mentioned this on twitter, but I&#8217;m working on some new tutorials and screencasts about Sammy. If you have ideas/suggestions, dont hesitate to let me know. The first one should be up next week. I&#8217;m going to try to do them bi-weekly, we&#8217;ll see how that goes <img src='http://www.quirkey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


	<p>Again, I&#8217;ve tried to be as thorough with inline <span class="caps">API</span> docs as I could so any changes should be in the clear. Thanks again to everyone who helped with this release and has supported Sammy recently!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2009/09/30/sammy-0-3-0-released-i-gotta-right-to-swing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introducing Sammy: The tiny but swingin&#8217; JavaScript Framework</title>
		<link>http://www.quirkey.com/blog/2009/05/15/introducing-sammy-the-tiny-but-swingin-javascript-framework/</link>
		<comments>http://www.quirkey.com/blog/2009/05/15/introducing-sammy-the-tiny-but-swingin-javascript-framework/#comments</comments>
		<pubDate>Fri, 15 May 2009 15:42:37 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Sammy]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=308</guid>
		<description><![CDATA[After a couple months of off-hours hacking, I present to you Sammy. Sammy is an easy to use JavaScript framework that allows you to build simple front end applications using &#8216;routes&#8217; and &#8216;events&#8217;. It&#8217;s also very tiny. Using the YUI Compression its only 7Kb. Get Started Watch a Screencast (iPhone) Read the Introduction Read the [...]]]></description>
			<content:encoded><![CDATA[	<p>After a couple months of off-hours hacking, I present to you <a href="http://code.quirkey.com/sammy" title="">Sammy.</a> Sammy is an easy to use JavaScript framework that allows you to build simple front end applications using &#8216;routes&#8217; and &#8216;events&#8217;. It&#8217;s also very tiny. Using the <span class="caps">YUI </span>Compression its only 7Kb.</p>

	<h3>Get Started</h3>

	<ul>
		<li><a href="http://s3.amazonaws.com/sammy-js/screencasts/sammy-screencasts-01/sammy-screencasts-01.mov" title="">Watch a Screencast</a> (<a href="http://s3.amazonaws.com/sammy-js/screencasts/sammy-screencasts-01/sammy-screencasts-01-iPhone.m4v" title="">iPhone</a>)</li>
		<li><a href="http://code.quirkey.com/sammy" title="">Read the Introduction</a></li>
		<li><a href="http://code.quirkey.com/sammy/docs/index.html" title="">Read the Docs</a></li>
		<li><a href="http://twitter.com/sammy_js" title="">Follow @sammy_js</a></li>
		<li><a href="http://groups.google.com/group/sammyjs" title="">Join the mailing list</a></li>
	</ul>

	<p><span id="more-308"></span></p>

	<h3>The Story</h3>

	<p>About three months ago, when I was knee deep in hacking and playing with <a href="http://sinatrarb.com" title="">Sinatra</a> I had this weird moment as I woke up one morning: &#8220;What if I could build Sinatra in JavaScript?&#8221; At that point it was just a challenge &#8211; I had just started doing almost full-time JS for a client and it seemed like a fun project.</p>

	<p>As I started to actually implement it (slowly in short spurts on the weekends), I realized that using the power of JavaScript&#8217;s closures and jQuery&#8217;s powerful event system, this could be something more then just a &#8216;clone&#8217;. It could actually be . . . useful!</p>

	<p>With that in mind, I set out to actually make is usable. I cleaned up the code, I wrote some <a href="http://github.com/quirkey/sammy/tree/master/examples" title="">example implementations</a>, and most importantly &#8211; I <a href="http://code.quirkey.com/sammy/docs/index.html" title="">documented the shit out of it.</a></p>

	<p>I&#8217;m pretty excited about it (can&#8217;t you tell?) especially about its possible uses for structuring applications on the front-end for <span class="caps">RES</span>Tful Databases and services. Embed it in a <a href="http://github.com/jchris/couchapp/tree" title="">CouchApp</a> to build an entire application in JavaScript while having access to a full range of documents/querying abilities.</p>

	<h3>The Future</h3>

	<p>I&#8217;m going to continue refining and adding examples. Please feel free to email me or contact me through github with questions/feedback.</p>

	<p>Happy Friday!</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2009/05/15/introducing-sammy-the-tiny-but-swingin-javascript-framework/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
<enclosure url="http://s3.amazonaws.com/sammy-js/screencasts/sammy-screencasts-01/sammy-screencasts-01.mov" length="197" type="video/quicktime" />
<enclosure url="http://s3.amazonaws.com/sammy-js/screencasts/sammy-screencasts-01/sammy-screencasts-01-iPhone.m4v" length="12437032" type="video/x-m4v" />
		</item>
		<item>
		<title>Sinatra: The Framework Within</title>
		<link>http://www.quirkey.com/blog/2009/03/04/sinatra-the-framework-within/</link>
		<comments>http://www.quirkey.com/blog/2009/03/04/sinatra-the-framework-within/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 23:16:08 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=236</guid>
		<description><![CDATA[Sinatra has been getting a lot of hype lately as the next great (micro)-framework. In writing apps, diving in, and contributing the reasons for its existence have become more clear. Sinatra is not just a toy or a neat trick, its the best way to create simple and non-obtrusive web interfaces to sit on top [...]]]></description>
			<content:encoded><![CDATA[	<p><img src="http://farm4.static.flickr.com/3267/2493099076_b09f525126.jpg" alt="" border="0" /><br />
Sinatra has been getting a lot of hype lately as the next great (micro)-framework. In writing apps, diving in, and contributing the reasons for its existence have become more clear. Sinatra is not just a toy or a neat trick, its the best way to create simple and non-obtrusive web interfaces to sit on top of a new or existing ruby project.<br />
<span id="more-236"></span><br />
Sinatra is less then a framework &#8211; it&#8217;s a web library. This isn&#8217;t a slap in the face &#8211; it&#8217;s truly a compliment. Sinatra&#8217;s size and portability make it extremely easy to incorporate to existing Ruby apps. I&#8217;m talking <span class="caps">BEYOND </span>Rails. I&#8217;m talking about command line tools, complex C bindings, you name it. Sinatra can be required and a script can be fashioned to give a dusty ol&#8217; code-base new life in a browser.</p>

	<p>I decided not to just preach and tried to take my own advice. What came out of my first attempt is <a href="http://code.quirkey.com/gembox" title="">gembox</a>. Gembox is a very light interface built on top of Ruby Gems. Download it, start it with:</p>

<pre>
$ gembox
</pre>

	<p>That&#8217;s it. Ruby Gems is great starting point because it has a well defined <span class="caps">API</span> and a huge user-base (rubygems users === ruby users). What it doens&#8217;t have is a great web interface. Just booting up this little app gives you a pretty (albiet currently shallow) interface to your gems. This app is tiny. I chose to split it out over multiple files, but with your app could have put this all in a single file and included it in your library&#8217;s name-space. It&#8217;s that easy.</p>

	<p>So here&#8217;s my pitch: Give your gems/libraries/code bundles beautiful web interfaces with minimal effort using Sinatra.</p>

	<p>I think gembox was a successful little experiment and over the next weeks I&#8217;ll be updating my gems with simple interfaces.</p>

	<p><em><br />
Currently, I&#8217;m in the running for a spot to speak at <a href="http://www.gogaruco.com" title="">GoGaRuCo.</a> I like the idea of the attendee&#8217;s being able to vote for what presentations to have at the conference, but I think having a truncated synopsis listed might not give me the best chance. So I&#8217;d like to try to explain what I plan to talk about a little further. If you like what you hear please <a href="http://vote.gogaruco.com" title="">vote!</a><br />
</em></p>

	<p>Photo Credit: <a href="http://flickr.com/photos/rnyk/2493099076/sizes/m/" title="">http://flickr.com/photos/rnyk/2493099076/</a></p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2009/03/04/sinatra-the-framework-within/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rails App Templates</title>
		<link>http://www.quirkey.com/blog/2009/02/16/rails-app-templates/</link>
		<comments>http://www.quirkey.com/blog/2009/02/16/rails-app-templates/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 16:00:31 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=222</guid>
		<description><![CDATA[Over the holidays I had my first experience contributing to Rails by adding test coverage and a bit of a refactor to Jeremy Mcanally&#8217;s awesome Rails templating feature. It&#8217;s finally going to be released as Part of Rails 2.3 (exciting!). Ryan Bates released a great Railscast with a detailed overview of templates. Ryan does a [...]]]></description>
			<content:encoded><![CDATA[	<p>Over the holidays I had my first experience contributing to Rails by <a href="http://github.com/rails/rails/commit/9fd35fc2d892393386ca9f522d25ba0bcb9c6764" title="">adding test coverage and a bit of a refactor</a> to <a href="http://github.com/rails/rails/commit/e8cc4b116c460c524961a07da92da3f323854c15" title="">Jeremy Mcanally&#8217;s awesome Rails templating feature.</a></p>

	<p>It&#8217;s finally <a href="http://weblog.rubyonrails.org/2009/2/1/rails-2-3-0-rc1-templates-engines-rack-metal-much-more" title="">going to be released as Part of Rails 2.3</a> (exciting!).</p>

	<p>Ryan Bates released a great <a href="http://railscasts.com/episodes/148-app-templates-in-rails-2-3" title="">Railscast with a detailed overview of templates.</a> Ryan does a great job as usual getting to the meat of the feature.</p>

	<p>If you&#8217;re interested, <a href="http://github.com/quirkey/halpers/tree/master" title="">I have my own Rails template as part of my &#8216;halpers&#8217;.</a> It installs jQuery and a couple of plugins and gems &#8211; including a <a href="http://github.com/quirkey/restful-authentication" title="">forked version of restful-authentication</a> that has a shoulda test suite and email of login based authentication. I hope you enjoy this feature as much as I do.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2009/02/16/rails-app-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QuirkeyCode</title>
		<link>http://www.quirkey.com/blog/2009/02/13/quirkeycode/</link>
		<comments>http://www.quirkey.com/blog/2009/02/13/quirkeycode/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 17:04:04 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=212</guid>
		<description><![CDATA[At the beginning of the week I put up a github page and used their awesome CNAME support to make QuirkeyCode. Somehow, I missed until now that it had been featured on the github blog. This is an overwhelming honor. Github is one of my favorite tools ever, and using their awesome API was stupid [...]]]></description>
			<content:encoded><![CDATA[	<p>At the beginning of the week I put up a github page and used their awesome <span class="caps">CNAME</span> support to make <a href="http://code.quirkey.com" title="">QuirkeyCode.</a></p>

	<p>Somehow, I missed until now that it <a href="http://github.com/blog/348-quirkeycode" title="">had been featured on the github blog.</a> This is an overwhelming honor. Github is one of my favorite tools ever, and using their awesome <span class="caps">API</span> was stupid simple and just another example of how awesome github is.</p>

	<p>Anyway, getting featured is a serious kick in the butt to get documentation together for all my different projects.</p>

	<p>Thanks, guys!</p>



 ]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2009/02/13/quirkeycode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BasecamPHP Updates</title>
		<link>http://www.quirkey.com/blog/2008/09/04/basecamphp-updates/</link>
		<comments>http://www.quirkey.com/blog/2008/09/04/basecamphp-updates/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 13:33:05 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=166</guid>
		<description><![CDATA[Over the past 2 years () since I put up my little basecamp API wrapper I&#8217;ve received a lot of great feedback and comments from other developers. In using it for their various projects they ran into some inevitable bugs and defects. Unfortunately, I haven&#8217;t been very responsible and didn&#8217;t compile the fixes into a [...]]]></description>
			<content:encoded><![CDATA[	<p>Over the past 2 years (<img src="!" alt="" border="0" />) <a href="http://www.quirkey.com/blog/2006/04/27/introducing-the-basecamp-php-wrapper/" title="">since I put up my little basecamp  <span class="caps">API</span> wrapper</a> I&#8217;ve received a lot of great feedback and comments from other developers. In using it for their various projects they ran into some inevitable bugs and defects. Unfortunately, I haven&#8217;t been very responsible and didn&#8217;t compile the fixes into a new release. In general I&#8217;m pretty much exclusively doing ruby these days so I&#8217;m not even really making use of the wrapper anymore. Thanks to github (<a href="http://www.quirkey.com/blog/2008/09/03/this-post-does-not-use-git-in-a-pun-as-a-replacement-for-get-ie-gitn-it/" title="">see previous post</a>) I now have a very easy way of putting up the library for not only easy download but for community development (woohoo!). I&#8217;ve already incorporated the changes and given credit to the astute developers responsible in the commit messages.</p>

	<p>Check it out: <strong><a href="http://github.com/quirkey/basecamphp/tree/master">http://github.com/quirkey/basecamphp/tree/master</a></strong></p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2008/09/04/basecamphp-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Scout: my new home away from home on the internet about my home</title>
		<link>http://www.quirkey.com/blog/2008/08/28/the-scout-my-new-home-away-from-home-on-the-internet-about-my-home/</link>
		<comments>http://www.quirkey.com/blog/2008/08/28/the-scout-my-new-home-away-from-home-on-the-internet-about-my-home/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 13:30:24 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[NYC]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/?p=159</guid>
		<description><![CDATA[Here&#8217;s the big reveal of the biggest thing I&#8217;ve been working on over the past forever: The Scout. There&#8217;s a lot to say about this, but my partner in the project, Tom Ran, already said it much more eloquently in an interview with psfk. I can, however, speak to the technical aspects of the project. [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://thescoutmag.com" title="The Scout"><img src="http://farm4.static.flickr.com/3009/2805181938_ab85b1aca8_o.jpg" width="500" height="366" alt="The Scout" /></a></p>

	<p>Here&#8217;s the big reveal of the biggest thing I&#8217;ve been working on over the past forever: <a href="http://thescoutmag.com" title="">The Scout.</a></p>

	<p>There&#8217;s a lot to say about this, but my partner in the project, <a href="http://friendandstranger.com" title="">Tom Ran,</a> already said it much more eloquently <a href="http://www.psfk.com/2008/08/the-scout-new-york-through-more-discerning-eyes.html" title="">in an interview with psfk.</a></p>

	<p>I can, however, speak to the technical aspects of the project. It is (of course??) running on Ruby on Rails. I can pat myself on the back about it&#8217;s very powerful but easy to use <span class="caps">CMS</span>. Were working on adding a lot more articles right now and the whole set up seems to be chugging along without a hitch.</p>

	<p>The whole project was a beautiful idea about a year ago but after a lot of lunch and dinner conversations I can finally say that it&#8217;s a reality.</p>

	<p>I learned a lot on the project and used it as an excuse to grok some new technologies (or at lest new to me) like the <a href="http://code.google.com/apis/maps/" title="">Google Maps <span class="caps">API</span>.</a></p>

	<p>Were hoping to continue to push our features and content in the coming weeks and months. To keep up:</p>

	<p>1. <a href="http://thescoutmag.com/info/subscribe" title="">Join the mailing list</a><br />
2. &#8220;follow the site&#8217;s <span class="caps">RSS </span>Feeds: <a href="http://thescoutmag.com/blog.xml" title="">Blog</a>, <a href="http://thescoutmag.com/retail.xml" title="">Retail</a>, <a href="http://thescoutmag.com/dining_bars.xml" title="">Dining/Bars</a>, <a href="http://thescoutmag.com/features.xml" title="">Features</a>, and <a href="http://thescoutmag.com/tours.xml" title="">Tours</a><br />
3. follow <a href="http://twitter.com/thescout" title="">thescout on twitter</a></p>

	<p>If you&#8217;re interested in contributing email info at the scout mag dot com.</p>

	<p>Were just so excited it&#8217;s real.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2008/08/28/the-scout-my-new-home-away-from-home-on-the-internet-about-my-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DRYing up Rails Flash with Flashdance</title>
		<link>http://www.quirkey.com/blog/2008/02/29/drying-up-rails-flash-with-flashdance/</link>
		<comments>http://www.quirkey.com/blog/2008/02/29/drying-up-rails-flash-with-flashdance/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 19:24:23 +0000</pubDate>
		<dc:creator>AQ</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[QuirkeyTools]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software/Scripts]]></category>

		<guid isPermaLink="false">http://www.quirkey.com/blog/2008/02/29/drying-up-rails-flash-with-flashdance/</guid>
		<description><![CDATA[The scenario: Its 3AM. You've been coding all day and youre just about ready to launch this sweet social networking app for steel workers who love to dance. One last thing - you need to replace all the crappy copy you stuck in to your 'flash' messages with real informative text. "sucesfil post" might make [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/tzofia/185003069/" target="_blank"><img src="http://farm1.static.flickr.com/73/185003069_af97784abe.jpg" alt="Flashdance" /></a></p>

<p><em>The scenario:</em> Its 3AM. You've been coding all day and youre just about ready to launch this sweet social networking app for steel workers who love to dance. One last thing - you need to replace all the crappy copy you stuck in to your 'flash' messages with <strong>real informative text</strong>. "sucesfil post" might make sense to you, but wont make sense to the blue collar guy doing the electric slide all over your server. You go to replace these warnings and feedback messages but theyre all over your code. <em>You think</em>: If Rails is so DRY and the business and display logic are all supposed to be separate, then why am I putting messages that will end up in my views all through my controllers?!</p>

<h3>Introducing Flashdance</h3>

<p>The get-the-view-out-of-the-controller-so-you-can-rest plugin.</p>

<p>Instead of all-up-in your controller files, messages are stored in a single YAML file:</p>

<pre class="textmate-source"><span class="source source_yaml"><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> in app/views/shared/flash.yml
</span>
<span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">all_is_good<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">This is great</span></span>
<span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">this_failed<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">This failed</span></span>
<span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">using_erb<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">you are an idiot, &lt;%= @email %&gt;</span></span>
<span class="meta meta_tag meta_tag_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">section</span><span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span>
</span>  <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">subsection<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">I'm nested</span></span>
<span class="meta meta_tag meta_tag_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">my_controller</span><span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span>
</span>  <span class="meta meta_tag meta_tag_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">my_action</span><span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span>
</span>    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">message<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">I'm soaking wet</span></span></span></pre>

<h4>Examples</h4>

<p>At its most unobtrusive:</p>

<pre class="textmate-source"><span class="source source_ruby source_ruby_rails"><span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> in your controller
</span>  <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">update</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> . . . booring part where record gets updated
</span>    flash<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>warning</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> flashdance<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>this_failed</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span>=&gt; This failed
</span>  <span class="keyword keyword_control keyword_control_ruby">end</span>
</span></pre>

<p>A little nicer:</p>

<pre class="textmate-source"><span class="source source_ruby source_ruby_rails"><span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">update</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> . . .
</span>    flash<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>message</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>all_is_good<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> YAML entries can be referred to by strings or symbols
</span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> equivalent to flash[:message] = "This is great"
</span>  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
  
<p>ERB is evaluated in the context of the controller so you can do fun things like:</p>
  
<pre class="textmate-source"><span class="source source_ruby source_ruby_rails">  <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">tell_off_the_spammer</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> . . .
</span>    <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>email</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>jon@example.com<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span>
    flash<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>warning</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>using_erb</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> equivalent to flash[:warning] = "you are an idiot, jon@example.com"
</span>  <span class="keyword keyword_control keyword_control_ruby">end</span>
</span></pre>  

<p>So what if your app is huge and you use these flash thingies all over the place? Your YAML file might get big and unreadable. Well, thats why you can nest! Nested sections are refered to by arrays.</p>

<pre class="textmate-source"><span class="source source_ruby source_ruby_rails">  <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">make_a_nest</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span>  . . .
</span>    flash<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>nest</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>section</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>subsection</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> equivalent to flash[:nest] = "I'm nested"
</span>  <span class="keyword keyword_control keyword_control_ruby">end</span>
</span></pre>
  
<p>Flashdance automatically checks for entries nested in the controller/action path where you call it from. And heres where you get splashed with that big bucket of water:</p>

<pre class="textmate-source"><span class="source source_ruby source_ruby_rails"><span class="meta meta_rails meta_rails_controller"><span class="meta meta_class meta_class_ruby"><span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">MyController<span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby"> <span class="punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby">&lt;</span> ApplicationController</span></span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">  <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> . . . 
</span>  
  <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">my_action</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">   <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> . . . where you dance your heart out
</span>   flash<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>message</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">   <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> equivalent to flash[:message] = "I'm soaking wet"
</span>  <span class="keyword keyword_control keyword_control_ruby">end</span>
</span><span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>

<h4>Install it</h4>

<p>From subversion:</p>

<pre>
./script/plugin install -x svn://svn.quirkey.com/quirkey_tools/trunk/flashdance
</pre>

<p>or Download: <a href="http://www.quirkey.com/downloads/quirkey_tools/flashdance.tar.gz">flashdance.tar.gz</a></p>

<p>You can email me at aaron at this domain for bug reports/comments/suggestions - and I'm looking to set up Trac or something else soon.</p>
<p></p>
<p><em>Photo credit: <a href="http://www.flickr.com/photos/tzofia/185003069/">http://www.flickr.com/photos/tzofia/185003069/</a></em>]]></content:encoded>
			<wfw:commentRss>http://www.quirkey.com/blog/2008/02/29/drying-up-rails-flash-with-flashdance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

