Compare commits

...

2 Commits

Author SHA1 Message Date
restitux 211445907c Merge branch 'autoredirect-v5.3.0-dev' into wiki.ohea.xyz-dev 2023-01-17 18:57:31 -07:00
restitux e750090244 Add new wip autoredirect code 2023-01-17 18:50:52 -07:00
+40 -1
View File
@@ -626,7 +626,41 @@ module Precious
def show_page_or_file(fullpath)
wiki = wiki_new
if page = wiki.page(fullpath)
# check if folders exists
contents = wiki.tree_list
print contents
entry = contents.detect do |entry|
Gollum::File::path_match(fullpath, entry)
end
print entry
#if path
# @path = Pathname.new(path).cleanpath.to_s
# check_path = wiki.page_file_dir ? ::File.join(wiki.page_file_dir, @path, '/') : "#{@path}/"
# @results.select! {|result| result.path.start_with?(check_path) }
#end
#@results.sort_by! {|result| result.name.downcase}
#elsif fullpath[-1] == '/' ? Gollum::Page.valid_page_name?(fullpath) : false
if page = fullpath[-1] != '/' ? wiki.page("#{fullpath}/#{wiki.index_page}") : false
@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
mustache :page
elsif page = wiki.page(fullpath)
@page = page
@name = page.filename_stripped
@content = page.formatted_data
@@ -644,6 +678,11 @@ module Precious
show_file(file)
elsif @redirects_enabled && redirect_path = wiki.redirects[fullpath]
redirect to("#{encodeURIComponent(redirect_path)}?redirected_from=#{encodeURIComponent(fullpath)}")
elsif entry
# check if the folder fullpath exists
# if so, redirect to overview
#
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