From e6c419c7e057ddab2bd033b84af36c4087a0bc1b Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 26 Jul 2011 18:56:14 -0400 Subject: [PATCH] give user paths a canonical tag --- app/helpers/application_helper.rb | 4 ++++ app/views/closet_hangers/index.html.haml | 2 ++ app/views/contributions/index.html.haml | 4 ++++ app/views/items/show.html.haml | 3 +-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index dd5a1f82..b253f37f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -29,6 +29,10 @@ module ApplicationHelper content_tag(:div, html, :class => 'campaign-progress-wrapper') end + def canonical_path(resource) + content_for :meta, tag(:link, :rel => 'canonical', :href => url_for(resource)) + end + def flashes raw(flash.inject('') do |html, pair| key, value = pair diff --git a/app/views/closet_hangers/index.html.haml b/app/views/closet_hangers/index.html.haml index 5bd84a10..92c26f57 100644 --- a/app/views/closet_hangers/index.html.haml +++ b/app/views/closet_hangers/index.html.haml @@ -9,6 +9,8 @@ - else - title "#{@user.name}'s Items" +- canonical_path user_closet_hangers_path(@user) + - content_for :before_flashes do #closet-hangers-contact - if public_perspective? diff --git a/app/views/contributions/index.html.haml b/app/views/contributions/index.html.haml index 95bd7de2..7de1fd3a 100644 --- a/app/views/contributions/index.html.haml +++ b/app/views/contributions/index.html.haml @@ -1,4 +1,7 @@ - title 'Recent Contributions' +- if @user + - canonical_path user_contributions_path(@user) + %ul.buttons - if @user %li= link_to 'Recent Contributions', contributions_path, :class => 'button' @@ -15,3 +18,4 @@ = will_paginate @contributions %ul.contributions= render @contributions = will_paginate @contributions + diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index 2cb6576c..28845458 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -1,6 +1,5 @@ - title @item.name -- content_for :meta do - %link{:rel => 'canonical', :href => url_for(@item)} +- canonical_path @item - cache "items_show_#{@item.id}_main_content" do %header#item-header