Permalink
Browse files

Define default map as suggested on #460

Base path now sets a default map without having to use an external config.ru.
  • Loading branch information...
bootstraponline committed Oct 15, 2012
1 parent 1b952b6 commit fa97b57a966b2b88c9ad82ff2f889eb162704212
Showing with 28 additions and 2 deletions.
  1. +1 −1 README.md
  2. +27 −1 bin/gollum
View
@@ -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.
>
View
@@ -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

0 comments on commit fa97b57

Please sign in to comment.