From 87141572620aa6ca21829b7dc1cda25f13bc703f Mon Sep 17 00:00:00 2001 From: restitux Date: Fri, 7 Oct 2022 16:40:29 -0600 Subject: [PATCH 1/2] Add redirect to index page if path ends in / --- lib/gollum/app.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index f6008d13..8de3bfbd 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -625,7 +625,10 @@ module Precious def show_page_or_file(fullpath) wiki = wiki_new - if page = wiki.page(fullpath) + if page = fullpath[-1] != '/' ? wiki.page("#{fullpath}/#{wiki.index_page}") : false + redirect_path = "#{fullpath}/#{wiki.index_page}" + redirect to("#{encodeURIComponent(redirect_path)}") + elsif page = wiki.page(fullpath) @page = page @name = page.filename_stripped @content = page.formatted_data -- 2.52.0 From 0615815fa2d772ca160588cf924d4299477bb0f7 Mon Sep 17 00:00:00 2001 From: restitux Date: Fri, 7 Oct 2022 17:10:33 -0600 Subject: [PATCH 2/2] Change redirect to just return page --- lib/gollum/app.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 8de3bfbd..0522387c 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -626,8 +626,21 @@ module Precious def show_page_or_file(fullpath) wiki = wiki_new if page = fullpath[-1] != '/' ? wiki.page("#{fullpath}/#{wiki.index_page}") : false - redirect_path = "#{fullpath}/#{wiki.index_page}" - redirect to("#{encodeURIComponent(redirect_path)}") + @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 + #redirect_path = "#{fullpath}/#{wiki.index_page}" + #redirect to("#{encodeURIComponent(redirect_path)}") elsif page = wiki.page(fullpath) @page = page @name = page.filename_stripped -- 2.52.0