convert $path global to a gollum_path sinatra setting
This commit is contained in:
+3
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user