diff --git a/README.md b/README.md index c266ceda..e29c5790 100644 --- a/README.md +++ b/README.md @@ -413,7 +413,7 @@ By default, internal wiki links are all absolute from the root. To specify a dif wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki") -Note that base_path just modifies the links. To map gollum to a non-root location, use `map` in config.ru. See [#532](https://github.com/github/gollum/issues/532). +Note that base_path just modifies the links. To map gollum to a non-root location, use `map` in config.ru. See [#532](https://github.com/github/gollum/issues/532). `bin/gollum` now includes a simple map based on base path. > :base_path - String base path for all Wiki links. > diff --git a/bin/gollum b/bin/gollum index 8b45d356..38ce38cd 100755 --- a/bin/gollum +++ b/bin/gollum @@ -141,5 +141,31 @@ else require cfg end - Precious::App.run!(options) + base_path = wiki_options[:base_path] + + if wiki_options[:base_path].nil? + Precious::App.run!(options) + else + require 'rack' + + class MapGollum + def initialize base_path + @mg = Rack::Builder.new do + map '/' do + run Proc.new { [ 302, {'Location'=> "/#{base_path}" }, [] ] } + end + + map "/#{base_path}" do + run Precious::App + end + end + end + + def call(env) + @mg.call(env) + end + end + # Rack::Handler does not work with Ctrl + C. Use Rack::Server instead. + Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port']).start + end end