diff --git a/bin/gollum b/bin/gollum
index 924144a1..3f98a988 100755
--- a/bin/gollum
+++ b/bin/gollum
@@ -72,6 +72,10 @@ opts = OptionParser.new do |opts|
opts.on("--show-all", "Shows all files in file view. By default only valid pages are shown.") do
wiki_options[:show_all] = true
end
+
+ opts.on("--collapse-tree", "Collapse file view tree. By default, expanded tree is shown.") do
+ wiki_options[:collapse_tree] = true
+ end
end
# Read command line options into `options` hash
diff --git a/lib/gollum/file_view.rb b/lib/gollum/file_view.rb
index 7617c61b..c47eac96 100644
--- a/lib/gollum/file_view.rb
+++ b/lib/gollum/file_view.rb
@@ -8,9 +8,10 @@ module Gollum
# common use cases:
# set pages to wiki.pages and show_all to false
# set pages to wiki.pages + wiki.files and show_all to true
- def initialize pages, show_all = false
+ def initialize pages, options = {}
@pages = pages
- @show_all = show_all
+ @show_all = options[:show_all] || false
+ @checked = "checked" unless options[:collapse_tree]
end
def enclose_tree string
@@ -30,7 +31,7 @@ module Gollum
def new_sub_folder path
<<-HTML
-
+
HTML
end
@@ -87,7 +88,7 @@ module Gollum
url = url_for_page page
html += <<-HTML
-
-
+
- #{name}
diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb
index a44729e9..b6e33d72 100644
--- a/lib/gollum/frontend/app.rb
+++ b/lib/gollum/frontend/app.rb
@@ -332,7 +332,7 @@ module Precious
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
show_all = settings.wiki_options[:show_all]
# if showing all files include wiki.files
- @results = show_all ? Gollum::FileView.new(wiki.pages + wiki.files, show_all).render_files :
+ @results = show_all ? Gollum::FileView.new(wiki.pages + wiki.files, settings.wiki_options).render_files :
Gollum::FileView.new(wiki.pages).render_files
@ref = wiki.ref
mustache :file_view, { :layout => false }
diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb
index 58051690..26bef0ba 100644
--- a/lib/gollum/wiki.rb
+++ b/lib/gollum/wiki.rb
@@ -154,6 +154,9 @@ module Gollum
# :ref - String the repository ref to retrieve pages from
# :ws_subs - Array of chars to sub for ws in filenames.
# :mathjax - Set to false to disable mathjax.
+ # :show_all - Show all files in file view, not just valid pages.
+ # Default: false
+ # :collapse_tree - Start with collapsed file view. Default: false
#
# Returns a fresh Gollum::Repo.
def initialize(path, options = {})
@@ -181,6 +184,7 @@ module Gollum
@universal_toc = options.fetch(:universal_toc, false)
@mathjax = options[:mathjax] || false
@show_all = options[:show_all] || false
+ @collapse_tree = options[:collapse_tree] || false
end
# Public: check whether the wiki's git repo exists on the filesystem.