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