Compare commits

..

6 Commits

Author SHA1 Message Date
bootstraponline 2af164ee9e Release 2.4.7 2012-12-20 18:11:44 -07:00
bootstraponline 9227f0a195 Fix tests
File names do not have spaces.
2012-12-20 18:08:21 -07:00
bootstraponline f18330b494 Fix #611 2012-12-20 18:02:26 -07:00
bootstraponline bb32339ab4 Fix spaces in dir #611 2012-12-20 17:45:39 -07:00
bootstraponline ddf4378dfe More work on #491
@teohm pointed out that add_to_index in gollum/committer.rb already appends @wiki.page_file_dir
2012-12-18 20:07:24 -07:00
bootstraponline 2a607e209b Fix #491 2012-12-18 19:01:43 -07:00
7 changed files with 21 additions and 18 deletions
+2 -2
View File
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 1.8.7" s.required_ruby_version = ">= 1.8.7"
s.name = 'gollum' s.name = 'gollum'
s.version = '2.4.6' s.version = '2.4.7'
s.date = '2012-12-18' s.date = '2012-12-20'
s.rubyforge_project = 'gollum' s.rubyforge_project = 'gollum'
s.summary = "A simple, Git-powered wiki." s.summary = "A simple, Git-powered wiki."
+1 -1
View File
@@ -28,7 +28,7 @@ require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
$KCODE = 'U' if RUBY_VERSION[0,3] == '1.8' $KCODE = 'U' if RUBY_VERSION[0,3] == '1.8'
module Gollum module Gollum
VERSION = '2.4.6' VERSION = '2.4.7'
def self.assets_path def self.assets_path
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__)) ::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
+4
View File
@@ -85,6 +85,10 @@ module Gollum
# #
# Returns nothing (modifies the Index in place). # Returns nothing (modifies the Index in place).
def add_to_index(dir, name, format, data, allow_same_ext = false) def add_to_index(dir, name, format, data, allow_same_ext = false)
# spaces must be dashes
dir.gsub!(' ', '-')
name.gsub!(' ', '-')
path = @wiki.page_file_name(name, format) path = @wiki.page_file_name(name, format)
dir = '/' if dir.strip.empty? dir = '/' if dir.strip.empty?
+5 -10
View File
@@ -181,7 +181,8 @@ module Precious
page = wikip.page page = wikip.page
if 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 else
mustache :create mustache :create
end end
@@ -191,16 +192,13 @@ module Precious
name = params[:page].to_url name = params[:page].to_url
path = sanitize_empty_params(params[:path]) || '' path = sanitize_empty_params(params[:path]) || ''
format = params[:format].intern 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(::File.join(page_dir, path)) unless path.start_with?(page_dir)
wiki = wiki_new wiki = wiki_new
begin begin
wiki.write_page(name, format, params[:content], commit_message, path) 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 rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{e.message}" @message = "Duplicate page: #{e.message}"
mustache :error mustache :error
@@ -345,9 +343,6 @@ module Precious
path = extract_path(fullpath) || '/' path = extract_path(fullpath) || '/'
wiki = wiki_new 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) if page = wiki.paged(name, path, exact = true)
@page = page @page = page
@name = name @name = name
+1 -1
View File
@@ -420,7 +420,7 @@ module Gollum
path = cname[0..slash] path = cname[0..slash]
page = @wiki.paged(name, path) page = @wiki.paged(name, path)
else else
page = @wiki.paged(cname, '/') page = @wiki.paged(cname, '/') || @wiki.page(cname)
end end
if page if page
+4
View File
@@ -287,6 +287,10 @@ module Gollum
# Returns the String SHA1 of the newly written version, or the # Returns the String SHA1 of the newly written version, or the
# Gollum::Committer instance if this is part of a batch update. # Gollum::Committer instance if this is part of a batch update.
def write_page(name, format, data, commit = {}, dir = '') def write_page(name, format, data, commit = {}, dir = '')
# spaces must be dashes
name.gsub!(' ', '-')
dir.gsub!(' ', '-')
multi_commit = false multi_commit = false
committer = if obj = commit[:committer] committer = if obj = commit[:committer]
+4 -4
View File
@@ -305,7 +305,7 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do
assert_equal :textile, @wiki.page("Samwise Gamgee").format assert_equal :textile, @wiki.page("Samwise Gamgee").format
assert_equal "h1. Samwise Gamgee2", @wiki.page("Samwise Gamgee").raw_data assert_equal "h1. Samwise Gamgee2", @wiki.page("Samwise Gamgee").raw_data
assert_equal "Samwise Gamgee.textile", @wiki.page("Samwise Gamgee").filename assert_equal "Samwise-Gamgee.textile", @wiki.page("Samwise Gamgee").filename
end end
test "update page with format change, verify non-canonicalization of filename, where filename contains Whitespace" do test "update page with format change, verify non-canonicalization of filename, where filename contains Whitespace" do
@@ -317,7 +317,7 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do
assert_equal :textile, @wiki.page("Samwise Gamgee").format assert_equal :textile, @wiki.page("Samwise Gamgee").format
assert_equal "h1. Samwise Gamgee", @wiki.page("Samwise Gamgee").raw_data assert_equal "h1. Samwise Gamgee", @wiki.page("Samwise Gamgee").raw_data
assert_equal "Samwise Gamgee.textile", @wiki.page("Samwise Gamgee").filename assert_equal "Samwise-Gamgee.textile", @wiki.page("Samwise Gamgee").filename
end end
test "update page with name change, verify canonicalization of filename, where filename contains Whitespace" do test "update page with name change, verify canonicalization of filename, where filename contains Whitespace" do
@@ -424,8 +424,8 @@ context "Wiki sync with working directory (filename contains whitespace)" do
test "update a page with same name and different format" do test "update a page with same name and different format" do
page = @wiki.page("Samwise Gamgee") page = @wiki.page("Samwise Gamgee")
@wiki.update_page(page, page.name, :textile, "What we need is a few good taters.", commit_details) @wiki.update_page(page, page.name, :textile, "What we need is a few good taters.", commit_details)
assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Samwise Gamgee.textile")) assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Samwise-Gamgee.textile"))
assert !File.exist?(File.join(@path, "Samwise Gamgee.mediawiki")) assert !File.exist?(File.join(@path, "Samwise-Gamgee.mediawiki"))
end end
test "update a page with different name and different format" do test "update a page with different name and different format" do