Merge pull request #556 from adiknoth/fileview
Documentation and usability enhancement of recent fileview fix
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
<li>
|
||||
<label>#{path}</label> <input type="checkbox" checked />
|
||||
<label>#{path}</label> <input type="checkbox" #{@checked} />
|
||||
<ol>
|
||||
HTML
|
||||
end
|
||||
@@ -87,7 +88,7 @@ module Gollum
|
||||
url = url_for_page page
|
||||
html += <<-HTML
|
||||
<li>
|
||||
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" checked />
|
||||
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
|
||||
<ol>
|
||||
<li class="file"><a href="#{url}">#{name}</a></li>
|
||||
</ol>
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user