File View: Add option to collapse file trees.

For potentially large repositories, starting with a collapsed tree may
be beneficial.
This commit is contained in:
Adrian Knoth
2012-10-23 14:25:43 +02:00
parent ed2254ff9f
commit 00bcbbf72b
+5 -4
View File
@@ -8,9 +8,10 @@ module Gollum
# common use cases: # common use cases:
# set pages to wiki.pages and show_all to false # set pages to wiki.pages and show_all to false
# set pages to wiki.pages + wiki.files and show_all to true # set pages to wiki.pages + wiki.files and show_all to true
def initialize pages, show_all = false def initialize pages, options = {}
@pages = pages @pages = pages
@show_all = show_all @show_all = options[:show_all] || false
@checked = "checked" unless options[:collapse_tree]
end end
def enclose_tree string def enclose_tree string
@@ -30,7 +31,7 @@ module Gollum
def new_sub_folder path def new_sub_folder path
<<-HTML <<-HTML
<li> <li>
<label>#{path}</label> <input type="checkbox" checked /> <label>#{path}</label> <input type="checkbox" #{@checked} />
<ol> <ol>
HTML HTML
end end
@@ -87,7 +88,7 @@ module Gollum
url = url_for_page page url = url_for_page page
html += <<-HTML html += <<-HTML
<li> <li>
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" checked /> <label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
<ol> <ol>
<li class="file"><a href="#{url}">#{name}</a></li> <li class="file"><a href="#{url}">#{name}</a></li>
</ol> </ol>