Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thumbnail_url property for Mapit Places #245

Merged
merged 1 commit into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/mapit/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ def state
end
end

def thumbnail_url
if File.exist?("public/images/thumbnails/#{pombola_slug}.jpg")
"/images/thumbnails/#{pombola_slug}.jpg"
else
'/images/place-250x250.png'
end
end

def url
"#{baseurl}#{pombola_slug}/"
end
Expand Down
Binary file added public/images/thumbnails/abia.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/adamawa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/akwa-ibom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/anambra.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/bauchi-state.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/bayelsa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/benue.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/borno.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/cross-river.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/delta.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/ebonyi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/edo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/ekiti.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/enugu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/gombe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/imo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/jigawa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/kaduna.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/kano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/katsina.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/kebbi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/kogi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/kwara.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/lagos.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/thumbnails/nasarawa-state.jpg
Binary file added public/images/thumbnails/niger.jpg
Binary file added public/images/thumbnails/ogun.jpg
Binary file added public/images/thumbnails/ondo.jpg
Binary file added public/images/thumbnails/osun.jpg
Binary file added public/images/thumbnails/oyo.jpg
Binary file added public/images/thumbnails/plateau.jpg
Binary file added public/images/thumbnails/rivers.jpg
Binary file added public/images/thumbnails/sokoto.jpg
Binary file added public/images/thumbnails/taraba.jpg
Binary file added public/images/thumbnails/yobe.jpg
Binary file added public/images/thumbnails/zamfara.jpg
28 changes: 28 additions & 0 deletions tests/mapit/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,34 @@
end
end

describe 'area with no thumbnail image' do
let(:place) do
Mapit::Place.new(
mapit_area_data: area_with_no_parent,
pombola_slug: 'gwagwaladakuje',
baseurl: '/baseurl/'
)
end

it 'has default "pin" thumbnail_url' do
place.thumbnail_url.must_equal('/images/place-250x250.png')
end
end

describe 'area with thumbnail image' do
let(:place) do
Mapit::Place.new(
mapit_area_data: area_with_no_parent,
pombola_slug: 'federal-capital-territory',
baseurl: '/baseurl/'
)
end

it 'has custom image thumbnail_url' do
place.thumbnail_url.must_equal('/images/thumbnails/federal-capital-territory.jpg')
end
end

def area_with_parent
parsed_mapit_data_for_area_type('FED').values.first
end
Expand Down
2 changes: 1 addition & 1 deletion views/places.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<li class="media">
<div class="media-left">
<a href="<%= place.url %>">
<img class="media-object" src="/images/place-250x250.png" alt="default image for places">
<img class="media-object" src="<%= place.thumbnail_url %>" alt="">
</a>
</div>
<div class="media-body">
Expand Down