From 578386f083987a6c05ddb38123886b276f2cbfcc Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Fri, 16 Nov 2012 16:43:43 -0700 Subject: [PATCH] Add dir support to write_page --- lib/gollum/frontend/app.rb | 6 ++---- lib/gollum/wiki.rb | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 73e22630..7a9d2a91 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -196,12 +196,10 @@ module Precious 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}" diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 4e70f547..51d505f6 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -282,10 +282,11 @@ module Gollum # :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 @@ module Gollum 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