Fork me on GitHub

Running nanoc on Heroku

Intrigued by the recent rise in popularity of the nanoc library, I decided to start porting my homepage over from Rails to using nanoc. However I wasn't too sure what would be the best way to push my site to Heroku. nanoc comprises of a folder that contains your site configuration, layout, content and the static output from the website.

I did initially think about putting a Git repository in the output folder and simply pushing the output folder to Heroku. What about my layouts and content though? Do I put them under a separate repository? It felt overkill to use two repositories for one website.

I then found this post by Jamie Iniesta that describes how he created the Euruko 2009 site using nanoc. Towards the end of the post, Jamie describes how he used a Rack configuration file to determine how files should be served from the site's nanoc folder.

Instead of pushing just the output folder, I could now push the my whole nanoc folder as one repository and serve only the files from the output folder for my homepage.

Using a Rack configuration file, we redirect incoming requests for pages to include the standard index.html that all pages in nanoc are called, and then use Rack::Static to tell Heroku that we want to serve all static assets from the root of the output folder.

We also include an empty app at the bottom should there be any problems with the site.

nanoc has been a great little library to use for generating a static site and the ability to push to Heroku makes deployment so easy. I've only managed to scratch the surface with nanoc though but I'm looking to add more content to my homepage over the next few months so that I can dig deeper into using nanoc.

 

Snippets #59

  1. My top 7 RSpec best practices - I'm still using Test::Unit and Factory Girl, but might need to add RSpec to my toolkit as well.
  2. Rack::Shell - A console for any Rack based ruby web application.

Snippets #47

  1. 21 Rack Middleware to Turbocharge Your Ruby Webapps - An amazing collection of some of the best Rack middleware.
  2. Flash message conductor - A nicer pattern for handling flash messages in your Rails apps.
  3. Plan to write big software - and you have already lost - As an ERP developer who usually works on big projects, I tend to find that most projects I work on are already just big software.

Snippets #46

  1. Big Old Rails Template - Mike Gunderloy has been updating his Rails template again and this time supports deployment to your Heroku account and also allows you to duplicate the repository to GitHub.
  2. My Tools of the Trade - 2009 - Mike Gunderloy shares his tools of the trade as a Rails developer. Great insight into how what a  successful Rails developer uses.
  3. WindyCityRails 2009 - Video's from this year's one day conference in Chicago, have been uploaded and are ready for viewing.
  4. Unicorn! - GitHub share their experiences with the Rack HTTP server.
  5. Lookin' on Up ... To the East Side - John Nunemaker has been getting back to basics with inheritance and mixins. If your a beginner to Ruby, then the code here is great to follow through.

Snippets #39

  1. Ruby Version Manager: Easily Multiple Ruby Versions At Once - An amazing and simple way of switching between different version of Ruby.
  2. Using Searchlogic to combine named scopes with 'OR' - Searchlogic gets a new feature to combine named scopes.
  3. Shotgun - Automatically reloads your Rack or Sinatra application on each request. I tried this out last night while working on a Sinatra application and it worked a treat.