Compare commits

..

1 Commits

+4 -21
View File
@@ -560,7 +560,6 @@ 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}/"
@@ -625,12 +624,9 @@ module Precious
end end
end end
def folder_exists(path, wiki) def show_page_or_file(fullpath)
paths = wiki.tree_list wiki = wiki_new
return paths.any? { |item| item.path.start_with?(path) } if page = wiki.page(fullpath)
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
@@ -643,24 +639,11 @@ 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
return mustache :page 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