mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 17:05:35 +08:00
FEATURE: add noindex header to badges, groups, and /my pages (#9736)
This commit is contained in:
parent
29842e682b
commit
07b728c5e5
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
class BadgesController < ApplicationController
|
class BadgesController < ApplicationController
|
||||||
skip_before_action :check_xhr, only: [:index, :show]
|
skip_before_action :check_xhr, only: [:index, :show]
|
||||||
|
after_action :add_noindex_header
|
||||||
|
|
||||||
def index
|
def index
|
||||||
raise Discourse::NotFound unless SiteSetting.enable_badges
|
raise Discourse::NotFound unless SiteSetting.enable_badges
|
||||||
|
@ -15,6 +15,7 @@ class GroupsController < ApplicationController
|
|||||||
|
|
||||||
skip_before_action :preload_json, :check_xhr, only: [:posts_feed, :mentions_feed]
|
skip_before_action :preload_json, :check_xhr, only: [:posts_feed, :mentions_feed]
|
||||||
skip_before_action :check_xhr, only: [:show]
|
skip_before_action :check_xhr, only: [:show]
|
||||||
|
after_action :add_noindex_header
|
||||||
|
|
||||||
TYPE_FILTERS = {
|
TYPE_FILTERS = {
|
||||||
my: Proc.new { |groups, user|
|
my: Proc.new { |groups, user|
|
||||||
|
@ -48,7 +48,7 @@ class UsersController < ApplicationController
|
|||||||
:admin_login,
|
:admin_login,
|
||||||
:confirm_admin]
|
:confirm_admin]
|
||||||
|
|
||||||
after_action :add_noindex_header, only: [:show]
|
after_action :add_noindex_header, only: [:show, :my_redirect]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
|
@ -17,6 +17,7 @@ describe BadgesController do
|
|||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
parsed = response.parsed_body
|
parsed = response.parsed_body
|
||||||
expect(parsed["badges"].length).to eq(Badge.enabled.count)
|
expect(parsed["badges"].length).to eq(Badge.enabled.count)
|
||||||
|
expect(response.headers['X-Robots-Tag']).to eq('noindex')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -364,6 +364,7 @@ describe GroupsController do
|
|||||||
|
|
||||||
expect(body['group']['id']).to eq(group.id)
|
expect(body['group']['id']).to eq(group.id)
|
||||||
expect(body['extras']["visible_group_names"]).to eq([group.name])
|
expect(body['extras']["visible_group_names"]).to eq([group.name])
|
||||||
|
expect(response.headers['X-Robots-Tag']).to eq('noindex')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as an admin' do
|
context 'as an admin' do
|
||||||
|
@ -2433,6 +2433,7 @@ describe UsersController do
|
|||||||
it "redirects if the user is not logged in" do
|
it "redirects if the user is not logged in" do
|
||||||
get "/my/wat.json"
|
get "/my/wat.json"
|
||||||
expect(response).to be_redirect
|
expect(response).to be_redirect
|
||||||
|
expect(response.headers['X-Robots-Tag']).to eq('noindex')
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the user is logged in" do
|
context "when the user is logged in" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user