Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
552 views
in Technique[技术] by (71.8m points)

routes - How to properly mount github's gollum wiki inside a Rails App?

I'm trying to provide a gollum based wiki for my app by mounting it as a rack application inside my routes.rb file:

require 'gollum/frontend/app'

#Gollun config

gollum_path = Rails.root
Precious::App.set(:gollum_path, gollum_path)
Precious::App.set(:wiki_options, {:universal_toc => false})

TestWiki::Application.routes.draw do
  mount Precious::App, :at => "wiki"
end

The wiki is supposed to run at '/wiki' but everytime a go to this url it redirects me to /wiki/create/Home, and after a create a page it redirects me to /wiki/wiki/page_name.
Am I missing some option? is this even possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'll share with you what I did to get it working just now. I actually started with your code above and tweaked it until I got it sorted. If you're still hacking on it, maybe it'll work for you.

In Gemfile:

gem 'gollum'

In routes.rb:

require 'gollum/app'

YourApplication::Application.routes.draw do
  Precious::App.set(:gollum_path, Rails.root.join('wiki').to_s)
  Precious::App.set(:default_markup, :markdown) # set your favorite markup language
  Precious::App.set(:wiki_options, {:universal_toc => false})
  mount Precious::App, at: 'wiki'
end

Then, and this is the most important part, create and initialize the wiki directory:

~/Sites/ams$ mkdir wiki
~/Sites/ams$ cd wiki
~/Sites/ams/wiki$ ls
~/Sites/ams/wiki$ git init .
Initialized empty Git repository in /Users/xxx/Sites/ams/wiki/.git/

Shut down the server, bundle install, restart the server, and hit /wiki.

Good Luck.

Edit 2014-11-06: The latest release of gollum has a slightly different directory structure than at the time of the original writing. I've updated the routes.rb sample to match the latest gollum and rails.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...