From 99995f7364323e18f9c451881d665b5da4191c55 Mon Sep 17 00:00:00 2001 From: rick Date: Mon, 23 Aug 2010 16:16:39 -0700 Subject: [PATCH] convert $path global to a gollum_path sinatra setting --- bin/gollum | 5 +++-- lib/gollum/frontend/app.rb | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/gollum b/bin/gollum index 1aea84f9..9a7fd9af 100755 --- a/bin/gollum +++ b/bin/gollum @@ -38,7 +38,7 @@ end # Read command line options into `options` hash opts.parse! -$path = ARGV[0] || Dir.pwd +gollum_path = ARGV[0] || Dir.pwd if options['irb'] require 'irb' @@ -67,9 +67,10 @@ if options['irb'] end require 'gollum' - wiki = Gollum::Wiki.new $path + wiki = Gollum::Wiki.new gollum_path IRB.start_session binding else require 'gollum/frontend/app' + Precious::App.set :gollum_path, gollum_path Precious::App.run!(options) end diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index e4cb0991..f7c1f4c9 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -12,6 +12,7 @@ module Precious dir = File.dirname(File.expand_path(__FILE__)) # We want to serve public assets for now + set :public, "#{dir}/public" set :static, true @@ -40,7 +41,7 @@ module Precious get '/edit/:name' do @name = params[:name] - wiki = Gollum::Wiki.new($path) + wiki = Gollum::Wiki.new(settings.gollum_path) if page = wiki.page(@name) @page = page @content = page.raw_data @@ -52,7 +53,7 @@ module Precious post '/edit/:name' do name = params[:name] - wiki = Gollum::Wiki.new($path) + wiki = Gollum::Wiki.new(settings.gollum_path) page = wiki.page(name) format = params[:format].intern name = params[:rename] if params[:rename] @@ -64,7 +65,7 @@ module Precious post '/create/:name' do name = params[:page] - wiki = Gollum::Wiki.new($path) + wiki = Gollum::Wiki.new(settings.gollum_path) format = params[:format].intern @@ -80,13 +81,13 @@ module Precious post '/preview' do format = params['wiki_format'] data = params['text'] - wiki = Gollum::Wiki.new($path) + wiki = Gollum::Wiki.new(settings.gollum_path) wiki.preview_page("Preview", data, format).formatted_data end get '/history/:name' do @name = params[:name] - wiki = Gollum::Wiki.new($path) + wiki = Gollum::Wiki.new(settings.gollum_path) @page = wiki.page(@name) @page_num = [params[:page].to_i, 1].max @versions = @page.versions :page => @page_num @@ -108,7 +109,7 @@ module Precious get '/compare/:name/:version_list' do @name = params[:name] @versions = params[:version_list].split(/\.{2,3}/) - wiki = Gollum::Wiki.new($path) + wiki = Gollum::Wiki.new(settings.gollum_path) @page = wiki.page(@name) diffs = wiki.repo.diff(@versions.first, @versions.last, @page.path) @diff = diffs.first @@ -117,7 +118,7 @@ module Precious get %r{/(.+?)/([0-9a-f]{40})} do name = params[:captures][0] - wiki = Gollum::Wiki.new($path) + wiki = Gollum::Wiki.new(settings.gollum_path) if page = wiki.page(name, params[:captures][1]) @page = page @name = name @@ -133,7 +134,7 @@ module Precious end def show_page_or_file(name) - wiki = Gollum::Wiki.new($path) + wiki = Gollum::Wiki.new(settings.gollum_path) if page = wiki.page(name) @page = page @name = name