A platform for community discussion. Free, open, simple.
FEATURE: add /conduct as an alias for /guidelines
Neil Lalonde6774b64aef54
diff --git a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 b/app/assets/javascripts/discourse/routes/app-route-map.js.es6index 30dd8fc7552..1e2e6ad3381 100644--- a/app/assets/javascripts/discourse/routes/app-route-map.js.es6+++ b/app/assets/javascripts/discourse/routes/app-route-map.js.es6@@ -181,6 +181,7 @@ export default function() {this.route("privacy", { path: "/privacy" });this.route("guidelines", { path: "/guidelines" });this.route("rules", { path: "/rules" });+ this.route("conduct", { path: "/conduct" });this.route("new-topic", { path: "/new-topic" });this.route("new-message", { path: "/new-message" });diff --git a/app/assets/javascripts/discourse/routes/conduct.js.es6 b/app/assets/javascripts/discourse/routes/conduct.js.es6new file mode 100644index 00000000000..c3eb7577120--- /dev/null+++ b/app/assets/javascripts/discourse/routes/conduct.js.es6@@ -0,0 +1,3 @@+import staticRouteBuilder from "discourse/lib/static-route-builder";++export default staticRouteBuilder("conduct");diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rbindex 43b4a851ab7..bd6b2e5dde4 100644--- a/app/controllers/static_controller.rb+++ b/app/controllers/static_controller.rb@@ -12,7 +12,7 @@ class StaticController < ApplicationControllerdef showreturn redirect_to(path '/') if current_user && (params[:id] == 'login' || params[:id] == 'signup')- if SiteSetting.login_required? && current_user.nil? && ['faq', 'guidelines', 'rules'].include?(params[:id])+ if SiteSetting.login_required? && current_user.nil? && ['faq', 'guidelines'].include?(params[:id])return redirect_to path('/login')end@@ -31,7 +31,7 @@ class StaticController < ApplicationControllerend# The /guidelines route ALWAYS shows our FAQ, ignoring the faq_url site setting.- @page = 'faq' if @page == 'guidelines' || @page == 'rules'+ @page = 'faq' if @page == 'guidelines'# Don't allow paths like ".." or "/" or anything hacky like that@page.gsub!(/[^a-z0-9\_\-]/, '')diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 74c6ad113e3..c9c0c7d9f17 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -231,6 +231,7 @@ en:privacy: "Privacy"tos: "Terms of Service"rules: "Rules"+ conduct: "Code of Conduct"mobile_view: "Mobile View"desktop_view: "Desktop View"you: "You"diff --git a/config/routes.rb b/config/routes.rbindex c46c943ca65..a99df2769c3 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -329,13 +329,15 @@ Discourse::Application.routes.draw doget "login" => "static#show", id: "login", constraints: { format: /(json|html)/ }get "password-reset" => "static#show", id: "password_reset", constraints: { format: /(json|html)/ }get "faq" => "static#show", id: "faq", constraints: { format: /(json|html)/ }- get "guidelines" => "static#show", id: "guidelines", as: 'guidelines', constraints: { format: /(json|html)/ }- get "rules" => "static#show", id: "rules", as: 'rules', constraints: { format: /(json|html)/ }get "tos" => "static#show", id: "tos", as: 'tos', constraints: { format: /(json|html)/ }get "privacy" => "static#show", id: "privacy", as: 'privacy', constraints: { format: /(json|html)/ }get "signup" => "static#show", id: "signup", constraints: { format: /(json|html)/ }get "login-preferences" => "static#show", id: "login", constraints: { format: /(json|html)/ }+ %w{guidelines rules conduct}.each do |faq_alias|+ get faq_alias => "static#show", id: "guidelines", as: faq_alias, constraints: { format: /(json|html)/ }+ end+get "my/*path", to: 'users#my_redirect'get "user_preferences" => "users#user_preferences_redirect"diff --git a/spec/requests/static_controller_spec.rb b/spec/requests/static_controller_spec.rbindex 37a0f4ce6d0..b3613bea94f 100644--- a/spec/requests/static_controller_spec.rb+++ b/spec/requests/static_controller_spec.rb@@ -164,7 +164,7 @@ describe StaticController doSiteSetting.login_required = trueend- ['faq', 'guidelines', 'rules'].each do |page_name|+ ['faq', 'guidelines', 'rules', 'conduct'].each do |page_name|it "#{page_name} page redirects to login page for anon" doget "/#{page_name}"expect(response).to redirect_to '/login'@@ -174,9 +174,7 @@ describe StaticController doget "/#{page_name}"expect(response).to redirect_to '/login'end- end- ['faq', 'guidelines', 'rules'].each do |page_name|it "#{page_name} page loads for logged in user" dosign_in(Fabricate(:user))