How to Serve a Static File from toto


Also, How to Use Google Apps with toto

Context: Google Apps, toto, dorothy, plain HTML

I am using the toto blog engine to publish the Polyglot Programmers of Austin site because I have always wanted blogging to comprise nothing more than text files and source control. (toto is nearly so.) dorothy is the toto template I forked for the site.

I am using Google Apps to get a calendar and an email address at my domain. To make the email address work, I had to prove to Google that I control the domain, which you do by uploading a special file from Google to the root of your website.

Problem: Requesting the HTML file returns a 404

When I naïvely deployed the Google Apps domain-verification file to my heroku site, the verification did not work. Navigating to the url of the file returned a 404, file-not-found error. I needed to get toto out of the way, tell it that this file was outside its purview, do a Jedi mind trick and get the file simply to be served as if it were not Ruby.

Solution: Add to the list of static files in config.ru

Open the dorothy template’s config.ru configuration file and find the “Rack::Static” declaration. That collection lists the files and directories that should be served as static content, without interpretation. Within the brackets, add to that array of urls an entry for the Google Apps file. Surround it with single quotes. Precede it with a slash, to indicate it lives in the root of the directory. Mine looks like this:

use Rack::Static, :urls => [‘/css’, ‘/js’, ‘/images’, ‘/favicon.ico’, ‘/myGoogleFile.html’], :root => ‘public’

Put the file itself into the /public folder, since the Rack::Static statement specifies that “public” is the root of the site. (See it at the end, there?)

Commit config.ru and the Google Apps file to your git repository, then push them to heroku.

git push heroku master

Yay!

The post you don’t want to read on the topic I don’t want to write about