<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>johnreilly.github.com</title>
 <link href="http://johnreilly.github.com/atom.xml" rel="self"/>
 <link href="http://johnreilly.github.com/"/>
 <updated>2010-04-15T08:36:05-07:00</updated>
 <id>http://johnreilly.github.com/</id>
 <author>
   <name>John Reilly</name>
   <email>jr@trms.com</email>
 </author>
 
 
 <entry>
   <title>Building the Depot App</title>
   <link href="http://johnreilly.github.com/2009/04/12/building-the-depot-app.html"/>
   <updated>2009-04-12T00:00:00-07:00</updated>
   <id>http://johnreilly.github.com/2009/04/12/building-the-depot-app</id>
   <content type="html">&lt;img src='http://pragprog.com/images/covers/190x228/rails3.jpg' style='float:right; margin:10px' /&gt;
&lt;p&gt;I got my copy of &lt;a href='http://pragprog.com/titles/rails3/agile-web-development-with-rails'&gt;AWDwR (v3)&lt;/a&gt; a couple weeks ago, and thought it might be fun to run through building their sample &amp;#8220;Depot&amp;#8221; application. Gotta keep your chops up somehow, right?&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s actually been pretty useful so far&amp;#8230; For example, I had forgotten there was a nifty &lt;code&gt;cycle()&lt;/code&gt; helper available for doing zebra-striped rows in your views.&lt;/p&gt;

&lt;p&gt;I usually get a queasy feeling any time I&amp;#8217;m working on something that isn&amp;#8217;t under version control, plus I figured that someone might get some use out of a nicely tagged/branched Depot repo. So, as I&amp;#8217;m working my way through it, I&amp;#8217;ve been using &lt;a href='http://git-scm.org'&gt;git&lt;/a&gt; to tag each task and its related iterations, and I&amp;#8217;ve created branches for each of the &amp;#8220;suggested exercises&amp;#8221; (aka &amp;#8220;playtime&amp;#8221;) at the end of each task.&lt;/p&gt;

&lt;p&gt;Of course, I&amp;#8217;ve been pushing the repo to GitHub all the while. You can find it here: &lt;a href='http://github.com/johnreilly/depot'&gt;http://github.com/johnreilly/depot&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m sure a million identical Depot projects exist here on GitHub (I didn&amp;#8217;t even bother searching), but that&amp;#8217;s not the point. It&amp;#8217;s just a fun little instructive project for myself.&lt;/p&gt;

&lt;p&gt;Hopefully, the act of posting about it will be incentive enough to finish it. :)&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Jekyll and Webrick</title>
   <link href="http://johnreilly.github.com/2008/12/19/jekyll-and-webrick.html"/>
   <updated>2008-12-19T00:00:00-08:00</updated>
   <id>http://johnreilly.github.com/2008/12/19/jekyll-and-webrick</id>
   <content type="html">&lt;span class='post_date'&gt;19 Dec 2008&lt;/span&gt;
&lt;p&gt;Jekyll is pretty rad. But don&amp;#8217;t take my word for it. &lt;a href='http://github.com/mojombo/jekyll'&gt;Check it out&lt;/a&gt; for yourself. It&amp;#8217;s also what powers the &lt;a href='http://github.com/blog/272-github-pages'&gt;GitHub Pages&lt;/a&gt; feature which was rolled out a day or so ago. Being a GitHub fanboy, I of course wanted in on this as soon as possible.&lt;/p&gt;

&lt;p&gt;So, I created this site, and in doing so, learned how Jekyll does its thing. As I started to build the site, I discovered that site that Jekyll generates was somewhat difficult to preview locally. Here&amp;#8217;s a stylesheet I was including in my main layout (the layout that applies to all pages in the site):&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='html'&gt;&lt;span class='nt'&gt;&amp;lt;link&lt;/span&gt; &lt;span class='na'&gt;rel=&lt;/span&gt;&lt;span class='s'&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span class='na'&gt;href=&lt;/span&gt;&lt;span class='s'&gt;&amp;quot;/css/style.css&amp;quot;&lt;/span&gt; 
      &lt;span class='na'&gt;type=&lt;/span&gt;&lt;span class='s'&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span class='na'&gt;media=&lt;/span&gt;&lt;span class='s'&gt;&amp;quot;screen&amp;quot;&lt;/span&gt; &lt;span class='na'&gt;charset=&lt;/span&gt;&lt;span class='s'&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span class='nt'&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;In particular notice the &lt;code&gt;href&lt;/code&gt; attribute; it&amp;#8217;s referencing a css file relative to the site root.&lt;/p&gt;

&lt;p&gt;When any page is requested on the server, it will look for the style.css file here: &lt;code&gt;http://johnreilly.github.com/css/style.css&lt;/code&gt;. Doesn&amp;#8217;t matter where on the server the page is, it will always trace back to the root, then look in the css directory, etc. Perfect.&lt;/p&gt;

&lt;p&gt;But this didn&amp;#8217;t work out so well when I was previewing the generated site on my local computer. Since I didn&amp;#8217;t have any sort of webserver configured to look at the site directory, I was just opening the generated files directly in a browser. Something along the lines of &lt;code&gt;file:///Users/john/src/site/_site/index.html&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Problem. Since the stylesheet link was looking from the root of the server, it couldn&amp;#8217;t find any stylesheets when I was using file://. This becomes particularly troublesome once you start nesting pages in directories, as Jekyll does for blog posts. I suppose I could use absolute paths to assets already uploaded to the server, but that&amp;#8217;s no help when you&amp;#8217;re building or changing the css locally.&lt;/p&gt;

&lt;p&gt;So, long story short, to preview the generated site correctly, it really needed to be served up via a real web server.&lt;/p&gt;

&lt;p&gt;As I considered configuring an apache virtual host to serve up the directory, I started thinking, wouldn&amp;#8217;t it be easier if Jekyll could do this for me? I&amp;#8217;d much rather have it fire up a web server pointed to the generated site directory whenever I ask for it.&lt;/p&gt;

&lt;p&gt;Enter the greatness that is GitHub. After a &lt;a href='http://github.com/johnreilly/jekyll'&gt;fork&lt;/a&gt; and a &lt;a href='http://github.com/johnreilly/jekyll/commit/9ecbfb2253e11f5cb0364e24d4f13595efdd20b6'&gt;commit&lt;/a&gt; or &lt;a href='http://github.com/johnreilly/jekyll/commit/6bfaa6bac05cf734b9cb9d850998f2f4a0a8b987'&gt;two&lt;/a&gt;, I had my own copy of Jekyll that happily launches a &lt;a href='http://www.ruby-doc.org/stdlib/libdoc/webrick/rdoc/'&gt;WEBrick&lt;/a&gt; server whenever you pass it the &lt;code&gt;--server&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;The whole thing really shines when combined with the &lt;code&gt;--auto&lt;/code&gt; option:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='nv'&gt;$ &lt;/span&gt;jekyll --auto --server              
&lt;span class='o'&gt;[&lt;/span&gt;2008-12-19 18:58:43&lt;span class='o'&gt;]&lt;/span&gt; INFO  WEBrick 1.3.1
&lt;span class='o'&gt;[&lt;/span&gt;2008-12-19 18:58:43&lt;span class='o'&gt;]&lt;/span&gt; INFO  ruby 1.8.6 &lt;span class='o'&gt;(&lt;/span&gt;2008-03-03&lt;span class='o'&gt;)&lt;/span&gt; &lt;span class='o'&gt;[&lt;/span&gt;universal-darwin9.0&lt;span class='o'&gt;]&lt;/span&gt;
&lt;span class='o'&gt;[&lt;/span&gt;2008-12-19 18:58:43&lt;span class='o'&gt;]&lt;/span&gt; INFO  WEBrick::HTTPServer#start: &lt;span class='nv'&gt;pid&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;9707 &lt;span class='nv'&gt;port&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;4000
Auto-regenerating enabled: . -&amp;gt; ./_site
&lt;span class='o'&gt;[&lt;/span&gt;2008-12-19 18:58:43&lt;span class='o'&gt;]&lt;/span&gt; regeneration: 12 files changed
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;As you can see, Jekyll is monitoring for and regenerating the changes as you make them, and at the same time, WEBrick is purring along serving up your site. Load up &lt;code&gt;http://localhost:4000/&lt;/code&gt; to see your site. The turnaround time is quick, feels a lot like rails.&lt;/p&gt;

&lt;p&gt;Find my fork of Jekyll &lt;a href='http://github.com/johnreilly/jekyll'&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: Right now, it&amp;#8217;s hard coded to run on port 4000, simply because I was too lazy to figure out how to pass in a &lt;code&gt;port&lt;/code&gt; option. Maybe I&amp;#8217;ll change that someday, maybe someone else will. For now, it&amp;#8217;s working great for me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why WEBrick?&lt;/strong&gt; I didn&amp;#8217;t feel like including mongrel as a gem dependency. Everyone&amp;#8217;s got WEBrick installed, and there&amp;#8217;s no need for this to be a speed demon, so why not pick the easiest option?&lt;/p&gt;
&lt;div class='post_comments'&gt;
  &lt;script type='text/javascript'&gt;var disqus_url = &quot;http://johnreilly.github.com/2008/12/19/jekyll-and-webrick.html&quot;; var disqus_title =&quot;Jekyll and Webrick&quot;;&lt;/script&gt;
  &lt;div id='disqus_thread' /&gt;&lt;script src='http://disqus.com/forums/johnreilly-github/embed.js' type='text/javascript' /&gt;
  &lt;a href='http://disqus.com' class='dsq-brlink'&gt;blog comments powered by &lt;span class='logo-disqus'&gt;Disqus&lt;/span&gt;&lt;/a&gt;
&lt;/div&gt;&lt;div class='signature'&gt;-johnreilly&lt;/div&gt;</content>
 </entry>
 
 
</feed>