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