Permalink
Browse files

More work on #491

@teohm pointed out that add_to_index in gollum/committer.rb already appends @wiki.page_file_dir
  • Loading branch information...
1 parent 2a607e2 commit ddf4378dfebb26c722f911fa4693e1fe33c3333d @bootstraponline bootstraponline committed Dec 19, 2012
Showing with 5 additions and 12 deletions.
  1. +5 −12 lib/gollum/frontend/app.rb
View
@@ -181,7 +181,8 @@ def wiki_new
page = wikip.page
if page
- redirect to("/#{page.escaped_url_path}")
+ page_dir = settings.wiki_options[:page_file_dir].to_s
+ redirect to("/#{clean_url(::File.join(page_dir, page.escaped_url_path))}")
else
mustache :create
end
@@ -191,18 +192,13 @@ def wiki_new
name = params[:page].to_url
path = sanitize_empty_params(params[:path]) || ''
format = params[:format].intern
-
- # ensure pages are created in page_file_dir
- page_dir = settings.wiki_options[:page_file_dir].to_s
-
- path = clean_url(path)
- path = path.sub(page_dir, '') if path.start_with?(page_dir)
-
wiki = wiki_new
begin
wiki.write_page(name, format, params[:content], commit_message, path)
- redirect to("/#{clean_url(::File.join(path,name))}")
+
+ page_dir = settings.wiki_options[:page_file_dir].to_s
+ redirect to("/#{clean_url(::File.join(page_dir, path, name))}")
rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{e.message}"
mustache :error
@@ -347,9 +343,6 @@ def show_page_or_file(fullpath)
path = extract_path(fullpath) || '/'
wiki = wiki_new
- page_dir = settings.wiki_options[:page_file_dir].to_s
- path = ::File.join(page_dir, path) unless path.start_with?(page_dir)
-
if page = wiki.paged(name, path, exact = true)
@page = page
@name = name

0 comments on commit ddf4378

Please sign in to comment.