From 54e141489a55a209b3c833bc5afab449e47ef600 Mon Sep 17 00:00:00 2001 From: Pierre de Lacroix Date: Thu, 28 Sep 2017 00:48:28 +0200 Subject: [PATCH] Add noindex meta tag for invisible shops and staging environment --- app/controllers/enterprises_controller.rb | 6 +++++- app/views/layouts/darkswarm.html.haml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 83c6f6e6c0..451e60ceb4 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -7,7 +7,7 @@ class EnterprisesController < BaseController # These prepended filters are in the reverse order of execution prepend_before_filter :set_order_cycles, :require_distributor_chosen, :reset_order, only: :shop - before_filter :check_stock_levels, only: :shop + before_filter :check_stock_levels, :set_noindex_meta_tag, only: :shop before_filter :clean_permalink, only: :check_permalink before_filter :enable_embedded_shopfront @@ -85,4 +85,8 @@ class EnterprisesController < BaseController order_cycle_options = OrderCycle.active.with_distributor(distributor) order.order_cycle = order_cycle_options.first if order_cycle_options.count == 1 end + + def set_noindex_meta_tag + @noindex_meta_tag = true unless current_distributor.visible? + end end diff --git a/app/views/layouts/darkswarm.html.haml b/app/views/layouts/darkswarm.html.haml index c702848e89..c612388071 100644 --- a/app/views/layouts/darkswarm.html.haml +++ b/app/views/layouts/darkswarm.html.haml @@ -5,6 +5,8 @@ %meta{property: "og:title", content: content_for?(:title) ? yield(:title) : t(:title)} %meta{property: "og:description", content: content_for?(:description) ? yield(:description) : t(:site_meta_description)} %meta{property: "og:image", content: content_for?(:image) ? yield(:image) : ContentConfig.logo.url} + - if !Rails.env.production? || @noindex_meta_tag + %meta{name: "robots", content: "noindex"} %title= content_for?(:title) ? "#{yield(:title)} - #{t(:title)}".html_safe : "#{t(:welcome_to)} #{t(:title)}" - if Rails.env.production? = favicon_link_tag