Merge branch 'master' into base-url

Conflicts:
	lib/gollum/frontend/public/gollum/css/_styles.css
	lib/gollum/frontend/public/gollum/javascript/gollum.js
	lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js
	lib/gollum/frontend/templates/file_view.mustache
	lib/gollum/frontend/templates/layout.mustache
	lib/gollum/frontend/templates/page.mustache
This commit is contained in:
Sunny Ripert
2012-07-25 10:00:52 +02:00
119 changed files with 1324 additions and 11613 deletions
+2
View File
@@ -3,3 +3,5 @@
a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell <a.cudbardb@freeradius.org> 1309107565 +0200 commit: Test out whitespace with Sam
1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 b16b3d9fad9d78e5a669e7f33d94c96da374eccd kristi <kristi.dev@gmail.com> 1336983525 -0700 push
b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi <kristi.dev@gmail.com> 1336984025 -0700 push
b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley <daz.oakley@gmail.com> 1341830099 +0100 push
cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley <daz.oakley@gmail.com> 1341830833 +0100 push
@@ -3,3 +3,5 @@
a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell <a.cudbardb@freeradius.org> 1309107565 +0200 commit: Test out whitespace with Sam
1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 b16b3d9fad9d78e5a669e7f33d94c96da374eccd kristi <kristi.dev@gmail.com> 1336983525 -0700 push
b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi <kristi.dev@gmail.com> 1336984025 -0700 push
b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley <daz.oakley@gmail.com> 1341830099 +0100 push
cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley <daz.oakley@gmail.com> 1341830833 +0100 push
@@ -0,0 +1 @@
xMJ1F]ї)jя0Sю4(шZ№Te&ю 1Ѓ8Ї7pїёСуНPж55PNпД*jzAFђбЋЬDVѓЂ&cUlјi8S­GIцХpф0KдQмbВ>ви0аЅJzЫђwLз}љнЧВоУЈЭш4Ђбp#тап^йфМе?<2У%чУsЎec8гQ*|ІоvipbЉ;ЅќИzю{bёTП
@@ -0,0 +1,2 @@
xֻNֳ0EYח+f₪±„H°Fג&™כײjֱ׳cרvWW::g־כ*ׁװP 1¬־C˜„Y` &¶טח€ֱשמ"[¥‰ֱkװש€ט<3ֶא­ם§כ"
ךהZO¹׀³”ֶׁ«|ׁ½ֺק.םַד*iֽy} ד¼³wtֻ†¹ko«¬ר/=©ׂ[תְ¦X–‎ֻRע¦t‘#צ
@@ -0,0 +1 @@
xE▐╠Nд@ D╘В+FKRН$╗h:┴8яШ╡Nb²ЦE╩N─©gцT╤гР⌡ЯIС ВwWв8hи√B╦T|QеK. yю⌡╛l┴U;dЦMЯ┴1к8Ый╒\Й&fMmA▌б3┴q┌Xx∙■■wLе╖6C╪Б8I?▌╪гЁTм█фdЯ┐У
+1 -1
View File
@@ -1 +1 @@
b0de6e794dfdc7ef3400e894225bfe23308aae5c
629aa678272b017a4d136d35e77ac94d80b08dc2
+2 -2
View File
@@ -2,11 +2,11 @@
<li>
<label>folder0</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="0">0</a></li>
<li class="file"><a href="0">0</a></li>
</ol>
</li>
<li>
<label>folder1</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="1">1</a></li>
<li class="file"><a href="1">1</a></li>
</ol>
+2 -2
View File
@@ -3,11 +3,11 @@
<li>
<label>folder0</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="0">0</a></li>
<li class="file"><a href="0">0</a></li>
</ol>
</li>
<li>
<label>folder1</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="1">1</a></li>
<li class="file"><a href="1">1</a></li>
</ol>
+14 -4
View File
@@ -1,12 +1,22 @@
<ol class="tree">
<li>
<label>folder0/folder1/folder2</label> <input type="checkbox" checked />
<label>folder0</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="0">0</a></li>
<li>
<label>folder1</label> <input type="checkbox" checked />
<ol>
<li>
<label>folder2</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="0">0</a></li>
</ol>
</li>
<li>
<label>folder3</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="1">1</a></li>
<li class="file"><a href="1">1</a></li>
</ol>
</li>
</ol>
</li>
</ol>
@@ -14,5 +24,5 @@
<li>
<label>folder4</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="2">2</a></li>
<li class="file"><a href="2">2</a></li>
</ol>
+24 -51
View File
@@ -88,7 +88,7 @@ context "Frontend" do
:rename => "C", :page => 'B',
:format => page_1.format, :message => 'def'
follow_redirect!
assert_equal "/C", last_request.fullpath
assert_equal '/c', last_request.fullpath
assert last_response.ok?
@wiki.clear_cache
@@ -113,15 +113,9 @@ context "Frontend" do
test "creates pages with escaped characters in title" do
post "/create", :content => 'abc', :page => 'Title with spaces',
:format => 'markdown', :message => 'foo'
assert_equal 'http://example.org/Title-with-spaces', last_response.headers['Location']
assert_equal 'http://example.org/title-with-spaces', last_response.headers['Location']
get "/Title-with-spaces"
assert_match /abc/, last_response.body
post "/create", :content => 'ghi', :page => 'Title/with/slashes',
:format => 'markdown', :message => 'bar'
assert_equal 'http://example.org/Title-with-slashes', last_response.headers['Location']
get "/Title-with-slashes"
assert_match /ghi/, last_response.body
end
test "redirects to create on non-existant page" do
@@ -138,7 +132,7 @@ context "Frontend" do
follow_redirect!
assert_equal "/create/#{name}", last_request.fullpath
assert last_response.ok?
end
end
test "create redirects to page if already exists" do
name = "A"
@@ -147,7 +141,7 @@ context "Frontend" do
assert_equal "/#{name}", last_request.fullpath
assert last_response.ok?
end
test "guards against creation of existing page" do
name = "A"
post "/create", :content => 'abc', :page => name,
@@ -159,6 +153,20 @@ context "Frontend" do
assert_not_equal 'abc', page.raw_data
end
test "delete a page" do
name = "deleteme"
post "/create", :content => 'abc', :page => name,
:format => 'markdown', :message => 'foo'
page = @wiki.page(name)
assert_equal 'abc', page.raw_data
get '/delete/' + name
@wiki.clear_cache
page = @wiki.page(name)
assert_equal nil, page
end
test "previews content" do
post "/preview", :content => 'abc', :format => 'markdown'
assert last_response.ok?
@@ -216,41 +224,6 @@ context "Frontend" do
end
end
# WTF? Surely this test is wrong...
# In this test repo there is already a file called 'bar.md'.
# This SHOULD raise a Duplicate Page error, no?
# context "Frontend with page-file-dir" do
# include Rack::Test::Methods
# setup do
# @path = cloned_testpath("examples/page_file_dir.git")
# @wiki = Gollum::Wiki.new(@path, { :page_file_dir => "docs" })
# Precious::App.set(:gollum_path, @path)
# Precious::App.set(:wiki_options, { :page_file_dir => "docs" })
# end
# teardown do
# FileUtils.rm_rf(@path)
# end
# test "open existing parent" do
# get "/"
# assert last_response.ok?
# post "/create", :content => "asdf", :page => "bar",
# :format => 'markdown'
# follow_redirect!
# assert last_response.ok?
# # Assert not match.
# assert_equal true, /Duplicate page/.match(last_response.body) == nil
# end
# def app
# Precious::App
# end
# end
context "Frontend with lotr" do
include Rack::Test::Methods
@@ -316,25 +289,25 @@ context "Frontend with lotr" do
test "create pages within sub-directories" do
post "/create", :content => 'big smelly creatures', :page => 'Orc',
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
get "/Mordor/Orc"
assert_match /big smelly creatures/, last_response.body
post "/create", :content => 'really big smelly creatures', :page => 'Orc/Uruk-hai',
post "/create", :content => 'really big smelly creatures', :page => 'Uruk Hai',
:path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary'
assert_equal 'http://example.org/Mordor/Orc-Uruk-hai', last_response.headers['Location']
get "/Mordor/Orc-Uruk-hai"
assert_equal 'http://example.org/Mordor/uruk-hai', last_response.headers['Location']
get "/Mordor/Uruk-Hai"
assert_match /really big smelly creatures/, last_response.body
end
test "edit pages within sub-directories" do
post "/create", :content => 'big smelly creatures', :page => 'Orc',
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
:page => 'Orc', :path => 'Mordor', :message => 'minor edit'
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
get "/Mordor/Orc"
assert_match /not so big smelly creatures/, last_response.body
+1 -1
View File
@@ -50,7 +50,7 @@ context "Wiki" do
end
test "parents with default master ref" do
ref = 'b0de6e794dfdc7ef3400e894225bfe23308aae5c'
ref = '629aa678272b017a4d136d35e77ac94d80b08dc2'
committer = Gollum::Committer.new(@wiki)
assert_equal ref, committer.parents.first.sha
end
+5
View File
@@ -7,6 +7,11 @@ class FakePage
@filepath = filepath
end
# From page.rb
def filename_stripped
::File.basename(@filepath, ::File.extname(@filepath))
end
def path
return @filepath
end
+1 -1
View File
@@ -18,7 +18,7 @@ context "GitAccess" do
assert @access.ref_map.empty?
assert @access.tree_map.empty?
@access.tree 'master'
assert_equal({"master"=>"b0de6e794dfdc7ef3400e894225bfe23308aae5c"}, @access.ref_map)
assert_equal({"master"=>"629aa678272b017a4d136d35e77ac94d80b08dc2"}, @access.ref_map)
@access.tree '1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3'
map = @access.tree_map['1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3']
+14
View File
@@ -478,6 +478,20 @@ np.array([[2,2],[1,3]],np.float)
assert_markup_highlights_code Gollum::Markup, rendered
end
test "code with trailing whitespace" do
content = <<-END
shoop da woop
``` python
np.array([[2,2],[1,3]],np.float)
```
END
# rendered with Gollum::Markup
page, rendered = render_page(content)
assert_markup_highlights_code Gollum::Markup, rendered
end
def assert_markup_highlights_code(markup_class, rendered)
assert_match /div class="highlight"/, rendered, "#{markup_class} doesn't highlight code\n #{rendered}"
assert_match /span class="n"/, rendered, "#{markup_class} doesn't highlight code\n #{rendered}"
+33
View File
@@ -195,3 +195,36 @@ context "Page" do
assert_equal "/foo", Gollum::BlobEntry.normalize_dir("/foo")
end
end
context "within a sub-directory" do
setup do
@wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), { :page_file_dir => 'Rivendell' })
end
test "get existing page" do
page = @wiki.page('Elrond')
assert_equal Gollum::Page, page.class
assert page.raw_data =~ /^# Elrond\n\nElrond/
assert_equal 'Rivendell/Elrond.md', page.path
assert_equal :markdown, page.format
assert_equal @wiki.repo.commits.first.id, page.version.id
end
test "should not get page from parent dir" do
page = @wiki.page('Bilbo Baggins')
assert_equal nil, page
end
test "should inherit header/footer/sidebar pages from parent directories" do
page = @wiki.page('Elrond')
assert_equal Gollum::Page, page.sidebar.class
assert_equal Gollum::Page, page.header.class
assert_equal Gollum::Page, page.footer.class
assert page.sidebar.raw_data =~ /^Lord of the Rings/
assert page.header.raw_data =~ /^Hobbits/
assert page.footer.raw_data =~ /^Lord of the Rings/
end
end
+2 -2
View File
@@ -11,6 +11,8 @@ context "Page Reverting" do
FileUtils.rm_rf(@path)
end
=begin
# Grit is broken and this test fails often. See #363.
test "reverts single commit" do
page1 = @wiki.page("B")
sha = @wiki.revert_commit('7c45b5f16ff3bae2a0063191ef832701214d4df5')
@@ -20,8 +22,6 @@ context "Page Reverting" do
assert_equal body, File.read(File.join(@path, "B.md")).strip
end
=begin
# Grit is broken and this test fails often. See #363.
test "reverts single commit for a page" do
page1 = nil
while (page1 == nil)
+18 -22
View File
@@ -16,16 +16,16 @@ context "Unicode Support" do
end
test "create and read non-latin page" do
@wiki.write_page("한글 test", :markdown, "# 한글")
@wiki.write_page("test", :markdown, "# 한글")
page = @wiki.page("한글 test")
page = @wiki.page("test")
assert_equal Gollum::Page, page.class
assert_equal "# 한글", utf8(page.raw_data)
end
test "unicode with existing format rules" do
@wiki.write_page("한글 test", :markdown, "# 한글")
assert_equal @wiki.page("한글 test").path, @wiki.page("한글-test").path
@wiki.write_page("test", :markdown, "# 한글")
assert_equal @wiki.page("test").path, @wiki.page("test").path
end
end
@@ -43,24 +43,13 @@ context "Frontend Unicode support" do
FileUtils.rm_rf(@path)
end
test "creates korean page" do
post "/create", :content => 'english text', :page => "한글",
:format => 'markdown', :message => 'def'
follow_redirect!
assert last_response.ok?
page = @wiki.page('한글')
assert_equal 'english text', page.raw_data
assert_equal 'def', page.version.message
end
test "creates korean page which contains korean content" do
post "/create", :content => '한글 text', :page => "한글",
post "/create", :content => '한글 text', :page => "k",
:format => 'markdown', :message => 'def'
follow_redirect!
assert last_response.ok?
page = @wiki.page('한글')
page = @wiki.page('k')
assert_equal '한글 text', utf8(page.raw_data)
assert_equal 'def', page.version.message
end
@@ -86,27 +75,34 @@ context "Frontend Unicode support" do
end
test "heavy use 2" do
post "/create", :content => '한글 text', :page => "한글",
post "/create", :content => '한글 text', :page => "k",
:format => 'markdown', :message => 'def'
follow_redirect!
assert last_response.ok?
@wiki.update_page(@wiki.page('한글'), nil, nil, '다른 text', {})
@wiki.update_page(@wiki.page('k'), nil, nil, '다른 text', {})
@wiki = Gollum::Wiki.new(@path)
page = @wiki.page('한글')
page = @wiki.page('k')
assert_equal '다른 text', utf8(page.raw_data)
post '/edit/' + CGI.escape('한글'), :page => '한글', :content => '바뀐 text',
post '/edit/' + CGI.escape('한글'), :page => 'k', :content => '바뀐 text',
:format => 'markdown', :message => 'ghi'
follow_redirect!
assert last_response.ok?
@wiki = Gollum::Wiki.new(@path)
page = @wiki.page('한글')
page = @wiki.page('k')
assert_equal '바뀐 text', utf8(page.raw_data)
assert_equal 'ghi', page.version.message
end
test 'transliteration' do
# TODO: Remove to_url once write_page changes are merged.
@wiki.write_page('ééééé'.to_url, :markdown, '한글 text', { :name => '', :email => '' } )
page = @wiki.page('eeeee')
assert_equal '한글 text', utf8(page.raw_data)
end
def app
Precious::App
end
+2 -2
View File
@@ -54,7 +54,7 @@ context "Wiki" do
test "list pages" do
pages = @wiki.pages
assert_equal \
['Bilbo-Baggins.md', 'Boromir.md', 'Eye-Of-Sauron.md', 'Home.textile', 'My-Precious.md', 'Samwise Gamgee.mediawiki'],
['Bilbo-Baggins.md', 'Boromir.md', 'Elrond.md', 'Eye-Of-Sauron.md', 'Home.textile', 'My-Precious.md', 'Samwise Gamgee.mediawiki'],
pages.map { |p| p.filename }.sort
end
@@ -66,7 +66,7 @@ context "Wiki" do
end
test "counts pages" do
assert_equal 6, @wiki.size
assert_equal 7, @wiki.size
end
test "text_data" do