Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Deploy A Free, Ruby Powered Blog In 5 Minutes with Toto and Heroku

By Peter Cooper / February 5, 2010

heroku-dog.gif Toto (GitHub repo) is a new lightweight Ruby and Rack-based blogging engine designed specifically for "hackers" by Alexis Sellier. Content is managed entirely through Git - so everything is version controlled - and articles are stored as text files with embedded YAML metadata. At only 300 lines, it's easy to hack to your own taste, too.

Alexis has decided to push Toto by demonstrating how easy it is to deploy - for free - on the Heroku platform. You can literally get a blog up on Heroku within 5 minutes, even if you haven't already got a Heroku account (I just tried it).

How To Do It

Here are the basic steps:

  • Sign up for an account at Heroku.com - all you have to do is provide an e-mail address, validate it, then enter a password.
  • gem install heroku
  • git clone git://github.com/cloudhead/dorothy.git your-blog-dir
  • cd your-blog-dir
  • heroku create
  • Use the URL returned by heroku create and add a line in to the Toto::Server.new block in config.ru like: set :url, 'http://your.heroku.url.here'
  • git commit -am "Added URL"
  • git push heroku master
  • You're live!

It's that simple - I just tried it (see http://furious-fire-87.heroku.com for a live demo)! Beyond this stage, you need to check out Toto's documentation and actually add some posts to your Toto install, customize the template, and what not.

If you're interested in lightweight systems like Toto, check out Scanty and Jekyll (which includes a blog-like system but at heart is designed to cope with full sites).

Comments

  1. Mike says:

    I did this last night on my site and it was pretty simple.

    I've actually got it integrated into an existing rails site, and that was pretty straight forward too.

    Basic steps are:

    1.) create a folder in the root of your rails app for the blog...mkdir blog
    2.) copy the articles and templates directory (and sub directories) from the dorothy example app over to that directory.
    3.) Create a config.ru in your rails root.
    4.) Fill in the rails root as appropriate. Mine looks like this:

    #config.ru
    require 'toto'
    require 'config/environment.rb'
    
    use Rack::Static, :urls => ['/stylesheets', '/javascripts', '/images', '/favicon.ico'], :root => 'public'
    use Rack::ShowExceptions
    use Rack::CommonLogger
    
    # Run application
    toto = Toto::Server.new do
      Toto::Paths = {
        :templates => "blog/templates",
        :pages => "blog/templates/pages",
        :articles => "blog/articles"
      }
    
      set :title, "My Blog"
      set :date, lambda {|now| now.strftime("%B #{now.day.ordinal} %Y") }
      set :summary,   :max => 500
      set :root, "blog"
      if RAILS_ENV != 'production'
        set :url, "http://localhost:9292/blog/"
      else
        set :url, "http://my-blog.heroku.com/blog/"
      end
    end
    
    app = Rack::Builder.new do
    	use Rack::CommonLogger
    
    	map '/blog' do
    		run toto
    	end
    
    	map '/' do
    		use Rails::Rack::Static
    		run ActionController::Dispatcher.new
    	end
    end.to_app
    
    run app

    5.) Add the toto and rdiscount gems to your .gems manifest or to your bundler gem file for heroku.

    Then just deploy it to heroku and you should be good to go!

    Enjoy.

  2. Peter Cooper says:

    Awesome comment - just a shame WP cuts out the spacing, etc. I might try wrapping the code bits in PRE tags to see if it works..

  3. cloudhead says:

    Just updated dorothy (the default template), to default to article.path instead of article.url, for links — this should make the `set :url` step optional.

  4. Dmitry says:

    I've been playing around with toto for a bit now (cloudhead has shared with me the first few versions) and liked it so much I've decided to migrate my main blog over -- http://www.usabilitypost.com (DNS was only recently updated, so you may or may not see the toto version of the blog, I'm using OpenDNS and it loads the new site. You can tell if it's toto by the Disqus comments)

    Migrated from WordPress without much pain. Extracted over 100 articles to text files and imported thousands of comments over to disqus (using their import plugin) and have just finished setting it up. Runs insanely fast on Heroku due to caching. Absolutely loving it. No need for WordPress ever again :)

  5. Lee Smith says:

    This is just freakin cool...heroku is pretty slick too.

  6. Omnipresent says:

    what if you want to add stuff like SYNTAX highlighting

  7. hyperbolist says:

    @omnipresent: The most effortless option I found is to use gist.github.com's embed feature. Another reasonable option is rack-coderay http://github.com/webficient/rack-coderay which gives you a bit more flexibility.

    But there are probably many other solutions as well.

  8. Peter Cooper says:

    You could just hack support straight in to Toto, if you wanted. Fork it, add it, and see if the creator would like to pull it back - or not :-) The "syntax" gem would be good for this if you were focusing mainly on Ruby.

  9. jimbob2000 says:

    Does it write the blog for me too? Where can I get a gem for that?

  10. Peter Cooper says:

    jimbob: You want http://railstips.org/blog/archives/2007/04/29/lorem-ispum/ or http://github.com/glejeune/lipsum

  11. svs says:

    I have a similar one I call blu.rb (except it's based off sinatra) It provides git backend, arbitrary layouts on any individual post, rss feeds and site update through post-commit hooks. I'm currently running http://prole.in off of blu.rb as well as this site http://vivekrajagopalan.com

    It still needs to add caching and there are some loose ends that need to be tied up but it's working quite well for me as a blogging engine.

    More info here http://prole.in/blog/A+Proletarian+Blogging+Engine.erb

  12. Alex says:

    Getting fairly tough to find a RELIABLE open source server these days! Thanks for the post! Fortunately, I found a GREAT company to use!

  13. Hallison Batista says:

    Great! But before the Dorothy's dog was coded, Postview has born (http://github.com/hallison/postview). Try a demo in http://postview.heroku.com/.

    Actualy, I'm working in a big refactor for v1.0.0.

Other Posts to Enjoy

Twitter Mentions