drop in redirect image url for urls blocked on petpages
This commit is contained in:
parent
8bf9872fbe
commit
374e85f9d0
4 changed files with 39 additions and 10 deletions
|
@ -41,16 +41,27 @@ class ItemsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@item = Item.find params[:id]
|
@item = Item.find params[:id]
|
||||||
|
|
||||||
@trading_closet_hangers_by_owned = {
|
respond_to do |format|
|
||||||
true => @item.closet_hangers.owned_trading.newest.includes(:user),
|
format.html do
|
||||||
false => @item.closet_hangers.wanted_trading.newest.includes(:user)
|
|
||||||
}
|
|
||||||
|
|
||||||
if user_signed_in?
|
@trading_closet_hangers_by_owned = {
|
||||||
@current_user_hangers = [true, false].map do |owned|
|
true => @item.closet_hangers.owned_trading.newest.includes(:user),
|
||||||
hanger = current_user.closet_hangers.find_or_initialize_by_item_id_and_owned(@item.id, owned)
|
false => @item.closet_hangers.wanted_trading.newest.includes(:user)
|
||||||
hanger.quantity ||= 1
|
}
|
||||||
hanger
|
|
||||||
|
if user_signed_in?
|
||||||
|
@current_user_hangers = [true, false].map do |owned|
|
||||||
|
hanger = current_user.closet_hangers.find_or_initialize_by_item_id_and_owned(@item.id, owned)
|
||||||
|
hanger.quantity ||= 1
|
||||||
|
hanger
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
format.gif do
|
||||||
|
expires_in 1.month
|
||||||
|
redirect_to @item.thumbnail_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,6 +73,21 @@ module ClosetHangersHelper
|
||||||
item.name.gsub(/ on/i, ' o<b></b>n')
|
item.name.gsub(/ on/i, ' o<b></b>n')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
PETPAGE_IMAGE_URL_BLACKLIST = %w(window. ondrop)
|
||||||
|
def petpage_item_thumbnail_url(item)
|
||||||
|
url = item.thumbnail_url
|
||||||
|
|
||||||
|
# If the URL includes any of the blacklisted terms, use our redirect URL
|
||||||
|
PETPAGE_IMAGE_URL_BLACKLIST.each do |term|
|
||||||
|
if url.include?(term)
|
||||||
|
url = item_url(item, :format => :gif)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
url
|
||||||
|
end
|
||||||
|
|
||||||
def public_perspective?
|
def public_perspective?
|
||||||
@public_perspective
|
@public_perspective
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%div.dti-item
|
%div.dti-item
|
||||||
= image_tag hanger.item.thumbnail_url, :alt => nil, :class => 'dti-item-thumbnail'
|
= image_tag petpage_item_thumbnail_url(hanger.item), :alt => nil, :class => 'dti-item-thumbnail'
|
||||||
- if hanger.item.nc?
|
- if hanger.item.nc?
|
||||||
= image_tag nc_icon_url, :alt => 'NC', :class => 'dti-item-nc', :title => 'This is an NC Mall item'
|
= image_tag nc_icon_url, :alt => 'NC', :class => 'dti-item-nc', :title => 'This is an NC Mall item'
|
||||||
%span= petpage_item_name hanger.item
|
%span= petpage_item_name hanger.item
|
||||||
|
|
|
@ -39,5 +39,8 @@ module OpenneoImpressItems
|
||||||
|
|
||||||
# Configure sensitive parameters which will be filtered from the log file.
|
# Configure sensitive parameters which will be filtered from the log file.
|
||||||
config.filter_parameters << :password
|
config.filter_parameters << :password
|
||||||
|
|
||||||
|
Mime::Type.register "image/gif", :gif
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue