Gollum via Rack - gollum/gollum GitHub Wiki
You can also run gollum with any rack-compatible server by placing this config.ru
file inside your wiki repository. This allows you to utilize any Rack middleware like Rack::Auth, OmniAuth, etc.
#!/usr/bin/env ruby
require 'rubygems'
require 'gollum/app'
gollum_path = File.expand_path(File.dirname(__FILE__)) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO
wiki_options = {:universal_toc => false}
Precious::App.set(:gollum_path, gollum_path)
Precious::App.set(:default_markup, :markdown) # set your favorite markup language
Precious::App.set(:wiki_options, wiki_options)
run Precious::App
The options hash
The options available for the :wiki_options
hash mostly correspond to the arguments used when running gollum from the command line, but there are some small exceptions. See here for a list of available options.
--base-path
option
The The --base-path
option has no equivalent in the options hash. This is because base path is implemented as a piece of middleware. If you want to use base_path
with your config.ru
setup, use the Precious::MapGollum
class instead of Precious::App
as your app
:
# config.ru
require 'rubygems'
require 'gollum/app'
sub_dir = 'my-www-sub-folder'
Precious::App.set :wiki_options, { base_path: sub_dir } # this does nothing but helps remembering this setting
run Precious::MapGollum.new(sub_dir)
Setting author info and commit notes using middleware
You can customize the author info (name and email) used to save commits, as well as adding git notes to commits, inside a Rack middleware. To do this, your middleware needs to modify the session
Hash inside the Rack request as illustrated below:
session['gollum.author'] = {
:name => "Bilbo",
:email => "[email protected]",
}
session['gollum.note'] = "My commit note"
Note that authentication solutions like OmniGollum and gollum-auth (see here) offer support for setting author info out of the box.
You could also use the Sinatra before
method inside a config.ru
or config.rb
to set author info and commit notes:
class Precious::App
before do
session['gollum.author'] = {
:name => "Bilbo",
:email => "[email protected]",
}
session['gollum.note'] = "My commit note"
end
end