Change path lookup to support abrev paths
This commit is contained in:
+32
-15
@@ -560,6 +560,7 @@ module Precious
|
||||
wiki = wiki_new
|
||||
@results = wiki.tree_list
|
||||
|
||||
|
||||
if path
|
||||
@path = Pathname.new(path).cleanpath.to_s
|
||||
check_path = wiki.page_file_dir ? ::File.join(wiki.page_file_dir, @path, '/') : "#{@path}/"
|
||||
@@ -624,26 +625,42 @@ module Precious
|
||||
end
|
||||
end
|
||||
|
||||
def show_page_or_file(fullpath)
|
||||
wiki = wiki_new
|
||||
if page = wiki.page(fullpath)
|
||||
@page = page
|
||||
@name = page.filename_stripped
|
||||
@content = page.formatted_data
|
||||
@upload_dest = find_upload_dest(Pathname.new(fullpath).cleanpath.to_s)
|
||||
def folder_exists(path, wiki)
|
||||
paths = wiki.tree_list
|
||||
return paths.any? { |item| item.path.start_with?(path) }
|
||||
end
|
||||
|
||||
# Extensions and layout data
|
||||
@editable = true
|
||||
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
||||
@h1_title = wiki.h1_title
|
||||
@bar_side = wiki.bar_side
|
||||
@allow_uploads = wiki.allow_uploads
|
||||
@navbar = true
|
||||
mustache :page
|
||||
def show_page(page, fullpath, wiki)
|
||||
@page = page
|
||||
@name = page.filename_stripped
|
||||
@content = page.formatted_data
|
||||
@upload_dest = find_upload_dest(Pathname.new(fullpath).cleanpath.to_s)
|
||||
|
||||
# Extensions and layout data
|
||||
@editable = true
|
||||
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
||||
@h1_title = wiki.h1_title
|
||||
@bar_side = wiki.bar_side
|
||||
@allow_uploads = wiki.allow_uploads
|
||||
@navbar = true
|
||||
return mustache :page
|
||||
end
|
||||
|
||||
def show_page_or_file(fullpath)
|
||||
wiki = wiki_new
|
||||
|
||||
if fullpath[-1] != '/' ? page = wiki.page(fullpath) : false
|
||||
show_page(page, fullpath, wiki)
|
||||
elsif page = wiki.page("#{fullpath}/#{wiki.index_page}")
|
||||
show_page(page, fullpath, wiki)
|
||||
elsif page = wiki.page("#{fullpath}/#{File.basename(fullpath)}")
|
||||
show_page(page, fullpath, wiki)
|
||||
elsif file = wiki.file(fullpath, wiki.ref, true)
|
||||
show_file(file)
|
||||
elsif @redirects_enabled && redirect_path = wiki.redirects[fullpath]
|
||||
redirect to("#{encodeURIComponent(redirect_path)}?redirected_from=#{encodeURIComponent(fullpath)}")
|
||||
elsif folder_exists(fullpath, wiki)
|
||||
redirect to("/gollum/overview/#{clean_url(encodeURIComponent(fullpath))}")
|
||||
else
|
||||
if @allow_editing && @user_authed
|
||||
path = fullpath[-1] == '/' ? "#{fullpath}#{wiki.index_page}" : fullpath # Append default index page if no page name is supplied
|
||||
|
||||
Reference in New Issue
Block a user