noodlehaus/dispatch — pull request #4 by martinaglv (2013-03-13 15:02:14+00:00)
Title: Enabling dispatch to work from subfolders

First I want to congratulate you on this awesome small library!

I chose it as the basis for a simple markdown powered blog system, that I am about to release soon. However I needed a specific piece of functionality that wasn't possible without ugly hacks - the ability to run dispatch in a subfolder (say **/blog/**). So I extended dispatch with two new functions and a new config setting:

* `site.url` - this config setting is optional and holds the URL of the site. It powers the below two functions.
* `site_path()` - returns the relative path from the root of the domain name. It is used in the _dispatch()_ function to strip away the unnecessary parts of the URL so the routing works properly.
* `site_url()` - returns the URL of the site (always with a trailing slash). It comes handy in templates.