Change path lookup to support abrev paths
This commit is contained in:
+21
-4
@@ -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,9 +625,12 @@ 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) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_page(page, fullpath, wiki)
|
||||||
@page = page
|
@page = page
|
||||||
@name = page.filename_stripped
|
@name = page.filename_stripped
|
||||||
@content = page.formatted_data
|
@content = page.formatted_data
|
||||||
@@ -639,11 +643,24 @@ module Precious
|
|||||||
@bar_side = wiki.bar_side
|
@bar_side = wiki.bar_side
|
||||||
@allow_uploads = wiki.allow_uploads
|
@allow_uploads = wiki.allow_uploads
|
||||||
@navbar = true
|
@navbar = true
|
||||||
mustache :page
|
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