Refactor page url generation.
Avoid appending './' to urls.
This commit is contained in:
@@ -15,7 +15,7 @@ module Gollum
|
||||
|
||||
def new_page page
|
||||
name = page.name
|
||||
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
||||
url = url_for_page page
|
||||
%Q( <li class="file"><a href="#{url}">#{name}</a></li>\n)
|
||||
end
|
||||
|
||||
@@ -38,6 +38,12 @@ module Gollum
|
||||
HTML
|
||||
end
|
||||
|
||||
def url_for_page page
|
||||
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
||||
url = url[2..-1] if url[0,2] == './'
|
||||
url
|
||||
end
|
||||
|
||||
def render_files
|
||||
html = ''
|
||||
count = @pages.size
|
||||
@@ -65,7 +71,7 @@ module Gollum
|
||||
if (count - folder_start == 1)
|
||||
page = @pages[ folder_start ]
|
||||
name = page.name
|
||||
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
||||
url = url_for_page page
|
||||
html += <<-HTML
|
||||
<li>
|
||||
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" checked />
|
||||
|
||||
@@ -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,7 +2,7 @@
|
||||
<li>
|
||||
<label>.</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="./folder0">folder0</a></li>
|
||||
<li class="file"><a href="folder0">folder0</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
@@ -1,5 +1,5 @@
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user