Permalink
Browse files

Add dir support to write_page

  • Loading branch information...
1 parent 3d21ed3 commit 578386f083987a6c05ddb38123886b276f2cbfcc @bootstraponline bootstraponline committed Nov 16, 2012
Showing with 6 additions and 7 deletions.
  1. +2 −4 lib/gollum/frontend/app.rb
  2. +4 −3 lib/gollum/wiki.rb
@@ -196,12 +196,10 @@ def wiki_new
page_dir = settings.wiki_options[:page_file_dir].to_s
path = clean_url(::File.join(page_dir, path)) unless path.start_with?(page_dir)
- # write_page is not directory aware so use wiki_options to emulate dir support.
- wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
- wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
+ wiki = wiki_new
begin
- wiki.write_page(name, format, params[:content], commit_message)
+ wiki.write_page(name, format, params[:content], commit_message, path)
redirect to("/#{clean_url(::File.join(path,name))}")
rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{e.message}"
View
@@ -282,10 +282,11 @@ def preview_page(name, data, format)
# :committer - Optional Gollum::Committer instance. If provided,
# assume that this operation is part of batch of
# updates and the commit happens later.
- #
+ # dir - The String subdirectory of the Gollum::Page without any
+ # prefix or suffix slashes (e.g. "foo/bar").
# Returns the String SHA1 of the newly written version, or the
# Gollum::Committer instance if this is part of a batch update.
- def write_page(name, format, data, commit = {})
+ def write_page(name, format, data, commit = {}, dir = '')
multi_commit = false
committer = if obj = commit[:committer]
@@ -297,7 +298,7 @@ def write_page(name, format, data, commit = {})
filename = Gollum::Page.cname(name)
- committer.add_to_index('', filename, format, data)
+ committer.add_to_index(dir, filename, format, data)
committer.after_commit do |index, sha|
@access.refresh

0 comments on commit 578386f

Please sign in to comment.