mirror of
https://github.com/discourse/discourse.git
synced 2025-03-28 05:55:34 +08:00
FEATURE: add /conduct as an alias for /guidelines
This commit is contained in:
parent
9c6f77f9da
commit
6774b64aef
app
assets/javascripts/discourse/routes
controllers
config
spec/requests
@ -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" });
|
||||
|
3
app/assets/javascripts/discourse/routes/conduct.js.es6
Normal file
3
app/assets/javascripts/discourse/routes/conduct.js.es6
Normal file
@ -0,0 +1,3 @@
|
||||
import staticRouteBuilder from "discourse/lib/static-route-builder";
|
||||
|
||||
export default staticRouteBuilder("conduct");
|
@ -12,7 +12,7 @@ class StaticController < ApplicationController
|
||||
|
||||
def show
|
||||
return 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 < ApplicationController
|
||||
end
|
||||
|
||||
# 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\_\-]/, '')
|
||||
|
@ -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"
|
||||
|
@ -329,13 +329,15 @@ Discourse::Application.routes.draw do
|
||||
get "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"
|
||||
|
||||
|
@ -164,7 +164,7 @@ describe StaticController do
|
||||
SiteSetting.login_required = true
|
||||
end
|
||||
|
||||
['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" do
|
||||
get "/#{page_name}"
|
||||
expect(response).to redirect_to '/login'
|
||||
@ -174,9 +174,7 @@ describe StaticController do
|
||||
get "/#{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" do
|
||||
sign_in(Fabricate(:user))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user