UX: Redirect /faq, /rules, /conduct to /guidelines (#27592)

This commit is contained in:
Jan Cernik 2024-06-25 08:11:54 -03:00 committed by GitHub
parent fd2713e904
commit 867b3822f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,6 +36,14 @@ class StaticController < ApplicationController
return redirect_to path("/login")
end
rename_faq = SiteSetting.experimental_rename_faq_to_guidelines
if rename_faq
redirect_paths = %w[/rules /conduct]
redirect_paths << "/faq" if SiteSetting.faq_url.blank?
return redirect_to(path("/guidelines")) if redirect_paths.include?(request.path)
end
map = DEFAULT_PAGES.deep_merge(CUSTOM_PAGES)
@page = params[:id]
@ -58,16 +66,23 @@ class StaticController < ApplicationController
@topic = Topic.find_by_id(SiteSetting.get(topic_id))
raise Discourse::NotFound unless @topic
page_name =
if @page == "faq"
rename_faq ? "guidelines" : "faq"
else
@page
end
title_prefix =
if I18n.exists?("js.#{@page}")
I18n.t("js.#{@page}")
if I18n.exists?("js.#{page_name}")
I18n.t("js.#{page_name}")
else
@topic.title
end
@title = "#{title_prefix} - #{SiteSetting.title}"
@body = @topic.posts.first.cooked
@faq_overridden = !SiteSetting.faq_url.blank?
@experimental_rename_faq_to_guidelines = SiteSetting.experimental_rename_faq_to_guidelines
@experimental_rename_faq_to_guidelines = rename_faq
render :show, layout: !request.xhr?, formats: [:html]
return