Skip to content

Commit

Permalink
New image server.
Browse files Browse the repository at this point in the history
  • Loading branch information
waratuman committed Feb 25, 2013
1 parent 8c7a311 commit 3b91fc5
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.rdoc
Expand Up @@ -30,6 +30,7 @@ environment and want the photos to load.

#!ruby
MLS.asset_host = "assets.42floors.com"
MLS.image_host = "images.42floors.com"

== Bugs

Expand Down
6 changes: 5 additions & 1 deletion lib/mls.rb
Expand Up @@ -24,7 +24,7 @@ class MLS
API_VERSION = '0.1.0'

attr_reader :url, :user_agent
attr_writer :asset_host, :listing_amenities, :address_amenities
attr_writer :asset_host, :image_host, :listing_amenities, :address_amenities
attr_accessor :api_key, :auth_key, :logger

# Sets the API Token and Host of the MLS Server
Expand Down Expand Up @@ -58,6 +58,10 @@ def connection # TODO: testme
def asset_host # TODO: testme
@asset_host ||= get('/asset_host').body
end

def image_host # TODO: testme
@asset_host ||= get('/image_host').body
end

def listing_amenities
@listing_amenities ||= Yajl::Parser.new(:symbolize_keys => true)
Expand Down
4 changes: 2 additions & 2 deletions lib/mls/models/address.rb
Expand Up @@ -51,7 +51,7 @@ class MLS::Address < MLS::Resource
attr_accessor :listings, :listing_types, :photos, :videos

# should include an optional use address or no_image image
def avatar(size='100x200', protocol='http')
def avatar(size='100x200#', protocol='http')
params = {
:size => size,
:format => 'png',
Expand All @@ -61,7 +61,7 @@ def avatar(size='100x200', protocol='http')
}

if avatar_digest
"#{protocol}://#{MLS.asset_host}/photos/#{size}/#{avatar_digest}.jpg"
"#{protocol}://#{MLS.image_host}/#{avatar_digest}.jpg?s=#{URI.escape(size)}"
else
"#{protocol}://maps.googleapis.com/maps/api/streetview?" + params.map{|k,v| k.to_s + '=' + URI.escape(v.to_s) }.join('&')
end
Expand Down
4 changes: 2 additions & 2 deletions lib/mls/models/floorplan.rb
Expand Up @@ -12,8 +12,8 @@ def url(protocol='http')
"#{protocol}://#{MLS.asset_host}/floorplans/#{digest}/#{file_name}"
end

def avatar(size='150x100', protocol='http')
"#{protocol}://#{MLS.asset_host}/photos/#{size}/#{avatar_digest}.jpg"
def avatar(size='150x100#', protocol='http')
"#{protocol}://#{MLS.image_host}/#{avatar_digest}.jpg?s=#{URI.escape(size)}"
end

def self.create(attrs)
Expand Down
4 changes: 2 additions & 2 deletions lib/mls/models/flyer.rb
Expand Up @@ -12,8 +12,8 @@ def url(protocol='http')
"#{protocol}://#{MLS.asset_host}/flyers/#{digest}/#{file_name}"
end

def avatar(size='150x100', protocol='http')
"#{protocol}://#{MLS.asset_host}/photos/#{size}/#{avatar_digest}.jpg"
def avatar(size='150x100#', protocol='http')
"#{protocol}://#{MLS.image_host}/#{avatar_digest}.jpg?s=#{URI.escape(size)}"
end

def self.create(attrs)
Expand Down
4 changes: 2 additions & 2 deletions lib/mls/models/listing.rb
Expand Up @@ -69,9 +69,9 @@ class MLS::Listing < MLS::Resource
attr_accessor :address, :agents, :account, :photos, :flyer, :floorplan, :videos
attr_writer :amenities

def avatar(size='150x100', protocol='http')
def avatar(size='150x100#', protocol='http')
if avatar_digest
"#{protocol}://#{MLS.asset_host}/photos/#{size}/#{avatar_digest}.jpg"
"#{protocol}://#{MLS.image_host}/#{avatar_digest}.jpg?s=#{URI.escape(size)}"
else
address.avatar(size, protocol)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/mls/models/pdf.rb
Expand Up @@ -5,8 +5,8 @@ class MLS::PDF < MLS::Resource
property :file_url, String
property :type, String

def url(style='large', protocol='http')
"#{protocol}://#{MLS.asset_host}/#{type}s/#{style}/#{@digest}.jpg"
def url(style='700x467#', protocol='http')
"#{protocol}://#{MLS.image_host}/#{avatar_digest}.jpg?s=#{URI.escape(size)}"
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/mls/models/photo.rb
Expand Up @@ -12,8 +12,8 @@ class MLS::Photo < MLS::Resource
property :url_template, String
property :caption, String

def url(style='large', protocol='http')
"#{protocol}://#{MLS.asset_host}/photos/#{style}/#{@digest}.jpg"
def url(style='700x467#', protocol='http')
"#{protocol}://#{MLS.image_host}/#{digest}.jpg?s=#{URI.escape(style)}"
end

def self.create(attrs)
Expand Down
1 change: 0 additions & 1 deletion lib/mls/models/tour_request.rb
Expand Up @@ -64,7 +64,6 @@ def get_all_for_account

def find_by_token(token)
response = MLS.get("/tour_requests/#{token}")
puts response.body
MLS::TourRequest::Parser.parse(response.body)
end

Expand Down
2 changes: 1 addition & 1 deletion mls.gemspec
Expand Up @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)

Gem::Specification.new do |s|
s.name = "mls"
s.version = '0.2.35'
s.version = '0.2.36'
s.authors = ["James R. Bracy", "Jon Bracy"]
s.email = ["james@42floors.com"]
s.homepage = "http://mls.42floors.com"
Expand Down

0 comments on commit 3b91fc5

Please sign in to comment.