From 3b7f1588900030f2325858a3b30a550996cfb1ba Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 20 May 2011 20:23:37 -0400 Subject: [PATCH] cache just content on items, not action, so we can still use title and canonical --- app/controllers/items_controller.rb | 12 +++--- app/views/items/show.html.haml | 65 +++++++++++++++-------------- app/views/layouts/items.html.haml | 1 + 3 files changed, 40 insertions(+), 38 deletions(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 9b26b2e0..961dd770 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -1,7 +1,6 @@ class ItemsController < ApplicationController before_filter :set_query - caches_action :show, :layout => false - + def index if params.has_key?(:q) begin @@ -35,11 +34,11 @@ class ItemsController < ApplicationController end end end - + def show @item = Item.find params[:id] end - + def needed if params[:color] && params[:species] @pet_type = PetType.find_by_color_id_and_species_id( @@ -54,10 +53,11 @@ class ItemsController < ApplicationController @pet_name = params[:name] render :layout => 'application' end - + private - + def set_query @query = params[:q] end end + diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index b64f4c32..83c04220 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -2,42 +2,43 @@ - content_for :meta do %link{:rel => 'canonical', :href => url_for(@item)} -%header - = image_tag @item.thumbnail_url, :id => 'item-thumbnail' - %div - %h2#item-name= @item.name - = nc_icon_for(@item) - - unless @item.rarity.blank? - == Rarity: #{@item.rarity_index} (#{@item.rarity}) - %a.button{:href => neoitems_url_for(@item)} NeoItems +- cache "items_show_#{@item.id}_main_content" do + %header + = image_tag @item.thumbnail_url, :id => 'item-thumbnail' + %div + %h2#item-name= @item.name + = nc_icon_for(@item) + - unless @item.rarity.blank? + == Rarity: #{@item.rarity_index} (#{@item.rarity}) + %a.button{:href => neoitems_url_for(@item)} NeoItems -%p= @item.description + %p= @item.description -#item-zones - %p - %strong Occupies: - = list_zones @item.occupied_zones, :uncertain_label - %p - %strong Restricts: - - if @item.restricted_zones.empty? - None - - else - = list_zones @item.restricted_zones + #item-zones + %p + %strong Occupies: + = list_zones @item.occupied_zones, :uncertain_label + %p + %strong Restricts: + - if @item.restricted_zones.empty? + None + - else + = list_zones @item.restricted_zones -#item-preview-header - %h3 Preview - %a#customize-more.button{:href => '/'} Customize more + #item-preview-header + %h3 Preview + %a#customize-more.button{:href => '/'} Customize more -#item-preview - #item-preview-species= standard_species_images_for(@item) - #item-preview-error - #item-preview-swf - Javascript and Flash are required to preview wearables. Sorry! + #item-preview + #item-preview-species= standard_species_images_for(@item) + #item-preview-error + #item-preview-swf + Javascript and Flash are required to preview wearables. Sorry! -:javascript - var CURRENT_ITEM_ZONES_RESTRICT = #{@item.zones_restrict.inspect}, - IMPRESS_HOST = #{RemoteImpressHost.inspect}; + :javascript + var CURRENT_ITEM_ZONES_RESTRICT = #{@item.zones_restrict.inspect}, + IMPRESS_HOST = #{RemoteImpressHost.inspect}; -= include_javascript_libraries :jquery, :swfobject -= javascript_include_tag 'items/show' + = include_javascript_libraries :jquery, :swfobject + = javascript_include_tag 'items/show' diff --git a/app/views/layouts/items.html.haml b/app/views/layouts/items.html.haml index 6e04e5c3..0f186779 100644 --- a/app/views/layouts/items.html.haml +++ b/app/views/layouts/items.html.haml @@ -9,3 +9,4 @@ = submit_tag 'Search', :name => nil = yield = render :file => 'layouts/application' +