Fix #559
This commit is contained in:
@@ -83,11 +83,12 @@ module Precious
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
@base_url = url('/', false).chomp('/')
|
@base_url = url('/', false).chomp('/')
|
||||||
settings.wiki_options.merge!({ :base_path => @base_url }) unless settings.wiki_options.has_key? :base_path
|
# above will detect base_path when it's used with map in a config.ru
|
||||||
|
settings.wiki_options.merge!({ :base_path => @base_url })
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/' do
|
get '/' do
|
||||||
redirect File.join(settings.wiki_options[:page_file_dir].to_s,settings.wiki_options[:base_path].to_s, 'Home')
|
redirect ::File.join(@base_url,'Home')
|
||||||
end
|
end
|
||||||
|
|
||||||
# path is set to name if path is nil.
|
# path is set to name if path is nil.
|
||||||
@@ -192,20 +193,13 @@ module Precious
|
|||||||
path = '' if path.nil?
|
path = '' if path.nil?
|
||||||
format = params[:format].intern
|
format = params[:format].intern
|
||||||
|
|
||||||
page_dir = File.join(settings.wiki_options[:page_file_dir].to_s,
|
|
||||||
settings.wiki_options[:base_path].to_s)
|
|
||||||
# Home is a special case.
|
|
||||||
path = '' if name.downcase == 'home'
|
|
||||||
|
|
||||||
page_dir = File.join(page_dir, path)
|
|
||||||
|
|
||||||
# write_page is not directory aware so use wiki_options to emulate dir support.
|
# write_page is not directory aware so use wiki_options to emulate dir support.
|
||||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => page_dir })
|
wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
|
||||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
wiki.write_page(name, format, params[:content], commit_message)
|
wiki.write_page(name, format, params[:content], commit_message)
|
||||||
redirect to("/#{clean_url(CGI.escape(::File.join(page_dir,name)))}")
|
redirect to("/#{clean_url(CGI.escape(::File.join(path,name)))}")
|
||||||
rescue Gollum::DuplicatePageError => e
|
rescue Gollum::DuplicatePageError => e
|
||||||
@message = "Duplicate page: #{e.message}"
|
@message = "Duplicate page: #{e.message}"
|
||||||
mustache :error
|
mustache :error
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ context "Frontend" do
|
|||||||
post "/create", :content => 'abc', :page => name,
|
post "/create", :content => 'abc', :page => name,
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
|
|
||||||
|
follow_redirect!
|
||||||
|
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
|
|
||||||
@wiki.clear_cache
|
@wiki.clear_cache
|
||||||
|
|||||||
Reference in New Issue
Block a user