From 63a1f878069806b8df8ca4a193c7c05782491ec3 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 7 May 2014 11:21:37 -0400 Subject: [PATCH] Use topic excerpts and category desriptions in meta description tags for crawlers --- app/controllers/list_controller.rb | 1 + app/controllers/topics_controller.rb | 1 + app/views/layouts/application.html.erb | 2 +- app/views/layouts/crawler.html.erb | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index 24bc618b86a..58d894e2e2c 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -252,6 +252,7 @@ class ListController < ApplicationController end @category = Category.query_category(slug_or_id, parent_category_id) + @description_meta = @category.description guardian.ensure_can_see!(@category) diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index a802ec86725..4db5bdeab1a 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -373,6 +373,7 @@ class TopicsController < ApplicationController respond_to do |format| format.html do + @description_meta = @topic_view.topic.excerpt store_preloaded("topic_#{@topic_view.topic.id}", MultiJson.dump(topic_view_serializer)) end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f72ff5126dd..3f47d40e07f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,7 +4,7 @@ <%= content_for?(:title) ? yield(:title) + ' - ' + SiteSetting.title : SiteSetting.title %> - + <%- if SiteSetting.enable_escaped_fragments? %> diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erb index b8904b685f1..db93fa15d49 100644 --- a/app/views/layouts/crawler.html.erb +++ b/app/views/layouts/crawler.html.erb @@ -4,7 +4,7 @@ <%= content_for?(:title) ? yield(:title) + ' - ' + SiteSetting.title : SiteSetting.title %> - + <%= canonical_link_tag %>