Include full path in file view href.
This commit is contained in:
@@ -15,7 +15,7 @@ module Gollum
|
||||
|
||||
def new_page page
|
||||
name = page.name
|
||||
url = page.filename_stripped
|
||||
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
||||
%Q( <li class="file"><a href="#{url}">#{name}</a></li>\n)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<ol class="tree">
|
||||
<li class="file"><a href="0">0</a></li>
|
||||
<li class="file"><a href="./0">0</a></li>
|
||||
</ol>
|
||||
@@ -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="folder0/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="folder1/1">1</a></li>
|
||||
</ol>
|
||||
@@ -1,13 +1,13 @@
|
||||
<ol class="tree">
|
||||
<li class="file"><a href="root">root</a></li>
|
||||
<li class="file"><a href="./root">root</a></li>
|
||||
<li>
|
||||
<label>folder0</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="0">0</a></li>
|
||||
<li class="file"><a href="folder0/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="folder1/1">1</a></li>
|
||||
</ol>
|
||||
@@ -8,13 +8,13 @@
|
||||
<li>
|
||||
<label>folder2</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="0">0</a></li>
|
||||
<li class="file"><a href="folder0/folder1/folder2/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="folder0/folder1/folder3/1">1</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
@@ -24,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="folder4/2">2</a></li>
|
||||
</ol>
|
||||
+14
-24
@@ -57,56 +57,46 @@ def read file
|
||||
end
|
||||
|
||||
# For creating expected files.
|
||||
# write name, actual
|
||||
def write file, content
|
||||
File.open(@@test_path + file + '.txt', 'w') do | f |
|
||||
f.write content
|
||||
end
|
||||
end
|
||||
|
||||
def check name, pages_array
|
||||
pages = FakePages.new pages_array
|
||||
expected = read name
|
||||
actual = view pages
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
||||
# Test Notes
|
||||
# root files must be before any folders.
|
||||
# Home.md => file at root folder
|
||||
# docs/sanitization.md => file within folder
|
||||
context 'file_view' do
|
||||
test 'one file' do
|
||||
pages = FakePages.new [ '0.md' ]
|
||||
expected = read '1_file'
|
||||
actual = view pages
|
||||
assert_equal expected, actual
|
||||
check '1_file', [ '0.md' ]
|
||||
end
|
||||
|
||||
test 'one folder' do
|
||||
pages = FakePages.new [ 'folder0/' ]
|
||||
expected = read '1_folder'
|
||||
actual = view pages
|
||||
assert_equal expected, actual
|
||||
check '1_folder', [ 'folder0/' ]
|
||||
end
|
||||
|
||||
test 'one file with one folder' do
|
||||
pages = FakePages.new [ 'folder0/0.md' ]
|
||||
expected = read '1_file_1_folder'
|
||||
actual = view pages
|
||||
assert_equal expected, actual
|
||||
check '1_file_1_folder', [ 'folder0/0.md' ]
|
||||
end
|
||||
|
||||
test 'two files with two folders' do
|
||||
pages = FakePages.new [ 'folder0/0.md', 'folder1/1.md' ]
|
||||
expected = read '2_files_2_folders'
|
||||
actual = view pages
|
||||
assert_equal expected, actual
|
||||
check '2_files_2_folders', [ 'folder0/0.md', 'folder1/1.md' ]
|
||||
end
|
||||
|
||||
test 'two files with two folders and one root file' do
|
||||
pages = FakePages.new [ 'root.md', 'folder0/0.md', 'folder1/1.md' ]
|
||||
expected = read '2_files_2_folders_1_root'
|
||||
actual = view pages
|
||||
assert_equal expected, actual
|
||||
check '2_files_2_folders_1_root', [ 'root.md', 'folder0/0.md', 'folder1/1.md' ]
|
||||
end
|
||||
|
||||
test 'nested folders' do
|
||||
pages = FakePages.new [ 'folder0/folder1/folder2/0.md', 'folder0/folder1/folder3/1.md', 'folder4/2.md' ]
|
||||
expected = read 'nested_folders'
|
||||
actual = view pages
|
||||
assert_equal expected, actual
|
||||
check 'nested_folders', [ 'folder0/folder1/folder2/0.md', 'folder0/folder1/folder3/1.md', 'folder4/2.md' ]
|
||||
end
|
||||
end # context
|
||||
|
||||
Reference in New Issue
Block a user