Skip to content

Commit

Permalink
disabled Yahoo BOSS images
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Skomoroch committed Aug 1, 2011
1 parent 725ec23 commit d959669
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
52 changes: 30 additions & 22 deletions app/models/page.rb
Expand Up @@ -123,31 +123,39 @@ def news_snippet


def picture
boss = BOSSMan::Search.images(self.title, { :filter => "-porn"})
if boss.totalhits.to_i > 0
result = boss.results[0]
url = result.thumbnail_url
else
url = "White_square_with_question_mark.png"
end
## TODO: Yahoo Boss is deprecated, switch to Bing API
# boss = BOSSMan::Search.images(self.title, { :filter => "-porn"})
# if boss.totalhits.to_i > 0
# result = boss.results[0]
# url = result.thumbnail_url
# else
# url = "White_square_with_question_mark.png"
# end
url = "White_square_with_question_mark.png"
end

def picture_size(desired_height)
boss = BOSSMan::Search.images(self.title, { :filter => "-porn"})
if boss.totalhits.to_i > 0
result = boss.results[0]
height = result.thumbnail_height.to_i
width = result.thumbnail_width.to_i
width_scale_factor = 1.0*desired_height/height
new_width = width_scale_factor*width
"#{new_width.to_i}x#{desired_height.to_i}"
else
height = 120
width = 120
width_scale_factor = 1.0*desired_height/height
new_width = width_scale_factor*width
"#{new_width.to_i}x#{desired_height.to_i}"
end
## TODO: Yahoo Boss is deprecated, switch to Bing API
# boss = BOSSMan::Search.images(self.title, { :filter => "-porn"})
# if boss.totalhits.to_i > 0
# result = boss.results[0]
# height = result.thumbnail_height.to_i
# width = result.thumbnail_width.to_i
# width_scale_factor = 1.0*desired_height/height
# new_width = width_scale_factor*width
# "#{new_width.to_i}x#{desired_height.to_i}"
# else
# height = 120
# width = 120
# width_scale_factor = 1.0*desired_height/height
# new_width = width_scale_factor*width
# "#{new_width.to_i}x#{desired_height.to_i}"
# end
height = 120
width = 120
width_scale_factor = 1.0*desired_height/height
new_width = width_scale_factor*width
"#{new_width.to_i}x#{desired_height.to_i}"
end


Expand Down
18 changes: 9 additions & 9 deletions db/schema.rb
Expand Up @@ -11,6 +11,15 @@

ActiveRecord::Schema.define(:version => 20100316042802) do

create_table "backup_hourly_trends", :force => true do |t|
t.float "hourly_trend"
t.integer "page_id"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "backup_hourly_trends", ["page_id", "hourly_trend"], :name => "hourly_trend_index"

create_table "companies", :force => true do |t|
t.integer "page_id"
t.datetime "created_at"
Expand Down Expand Up @@ -98,15 +107,6 @@

add_index "new_hourly_timelines", ["page_id"], :name => "hourly_timelines_page_index"

create_table "new_hourly_trends", :force => true do |t|
t.float "hourly_trend"
t.integer "page_id"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "new_hourly_trends", ["page_id", "hourly_trend"], :name => "hourly_trend_index"

create_table "new_pages", :force => true do |t|
t.string "url"
t.string "title"
Expand Down

0 comments on commit d959669

Please sign in to comment.