Merge pull request #422 from nature/sidebar_rendering_in_subfolders
Sidebar rendering in subfolders.
This commit is contained in:
@@ -298,9 +298,8 @@ module Precious
|
||||
def show_page_or_file(fullpath)
|
||||
path = extract_path(fullpath)
|
||||
name = extract_name(fullpath)
|
||||
# This breaks headers, footers, and sidebars.
|
||||
# wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||
|
||||
if page = wiki.page(name)
|
||||
@page = page
|
||||
|
||||
+4
-2
@@ -434,7 +434,9 @@ module Gollum
|
||||
end
|
||||
|
||||
# Loads a sub page. Sub page names (footers, headers, sidebars) are prefixed with
|
||||
# an underscore to distinguish them from other Pages.
|
||||
# an underscore to distinguish them from other Pages. If there is not one within
|
||||
# the current directory, starts walking up the directory tree to try and find one
|
||||
# within parent directories.
|
||||
#
|
||||
# name - String page name.
|
||||
#
|
||||
@@ -447,7 +449,7 @@ module Gollum
|
||||
|
||||
dirs = self.path.split('/')
|
||||
dirs.pop
|
||||
map = @wiki.tree_map_for(@wiki.ref)
|
||||
map = @wiki.tree_map_for(@wiki.ref, true)
|
||||
while !dirs.empty?
|
||||
if page = find_page_in_tree(map, name, dirs.join('/'))
|
||||
page.parent_page = self
|
||||
|
||||
+8
-2
@@ -682,10 +682,16 @@ module Gollum
|
||||
# listing is cached based on its actual commit SHA.
|
||||
#
|
||||
# ref - A String ref that is either a commit SHA or references one.
|
||||
# ignore_page_file_dir - Boolean, if true, searches all files within the git repo, regardless of dir/subdir
|
||||
#
|
||||
# Returns an Array of BlobEntry instances.
|
||||
def tree_map_for(ref)
|
||||
@access.tree(ref)
|
||||
def tree_map_for(ref, ignore_page_file_dir=false)
|
||||
if ignore_page_file_dir && !@page_file_dir.nil?
|
||||
@root_access ||= GitAccess.new(path, nil, @repo_is_bare)
|
||||
@root_access.tree(ref)
|
||||
else
|
||||
@access.tree(ref)
|
||||
end
|
||||
rescue Grit::GitRuby::Repository::NoSuchShaFound
|
||||
[]
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
x��MJ1F]ї)jя0S��ю4�(шZ№�Te&�ю1Ѓ8Ї7�pїёСуНPж55PNпД*j�z�AFђбЋ�ЬDVѓЂ&c�Ul�јi8S��G�IцХpф0KдQмb�В>�в�и0аЅ�J�'Њ��zЫђwLз}љнЧ�Rо�ВоУЈЭш4Ђбp�#тап^йфМе?<2Уkњ��%чУsЎec8гQ�*|ІоvipbЉ;�ЅќИzю{bёTП№�\і
|
||||
@@ -0,0 +1,2 @@
|
||||
x��ֻNֳ0EYח+fjַ�₪±„H°Fג&™כײjWֱֶ׳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Я┐У
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
b0de6e794dfdc7ef3400e894225bfe23308aae5c
|
||||
629aa678272b017a4d136d35e77ac94d80b08dc2
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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']
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user