From f0b6c32a54d48abedea0200cc120abf1f40beb0c Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Sat, 14 Jun 2014 18:49:10 +0530 Subject: [PATCH] Location component splash view --- app/assets/stylesheets/osem.css | 14 ++++++++ app/views/admin/venue/venue_info.html.haml | 2 +- app/views/conference/_location.html.haml | 35 ++++++++++++++++++++ app/views/conference/show.html.haml | 5 ++- spec/views/conference/show.html.haml_spec.rb | 9 +++++ 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 app/views/conference/_location.html.haml diff --git a/app/assets/stylesheets/osem.css b/app/assets/stylesheets/osem.css index 41bde9ff..5b578615 100644 --- a/app/assets/stylesheets/osem.css +++ b/app/assets/stylesheets/osem.css @@ -91,3 +91,17 @@ body { #submissions { padding-bottom: 20px; } + +#location{ + background-repeat: no-repeat; + background-position: center center; + width: 100%; + min-height: 500px; + background-size: cover; + -webkit-background-size:cover; +} + +#location li{ + display: inline-block; + margin-right: 2em; +} diff --git a/app/views/admin/venue/venue_info.html.haml b/app/views/admin/venue/venue_info.html.haml index c576612c..84888003 100644 --- a/app/views/admin/venue/venue_info.html.haml +++ b/app/views/admin/venue/venue_info.html.haml @@ -5,7 +5,7 @@ = f.input :address, :input_html => {:rows => 1} = f.input :website = f.input :description, :input_html => { :rows => 10, :cols => 20 } - - if !@venue.photo.blank? + - unless @venue.photo.blank? = image_tag @venue.photo(:thumb) = f.input :photo = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/conference/_location.html.haml b/app/views/conference/_location.html.haml new file mode 100644 index 00000000..69d1e31f --- /dev/null +++ b/app/views/conference/_location.html.haml @@ -0,0 +1,35 @@ += content_for :splash_nav do + %li + %a{ href: '#location' } Location + + +%div.container.text-center + .div.row.col-md-12 + - unless @conference.venue.name.blank? + %h1 + %strong #{ @conference.venue.name } + - unless @conference.venue.address.blank? + %h2 + %strong #{ @conference.venue.address } + - unless @conference.venue.description.blank? + %p + %strong #{ @conference.venue.description } + %ul + - unless @conference.venue.address.blank? + %li + %b + = link_to 'View in Google Maps', "http://maps.google.com/maps?q=#{@conference.venue.address}", target: '_blank' + - unless @conference.venue.website.blank? + %li + %b + = link_to 'Visit Venue Website', @conference.venue.website, target: '_blank' + + +:javascript + $(document).ready(function(){ + var photo = "#{@conference.venue.photo}"; + if(photo) + { + $('#location').css('background-image', 'url('+photo+')'); + } + }); diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index 2ec6879c..311da44b 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -10,7 +10,10 @@ -unless @conference.call_for_papers.blank? %div#callforpapers = render 'call_for_papers' +-unless @conference.venue.blank? + %div#location + = render 'location' %div#sponsors = render 'sponsor' %div#social-media - = render 'social_media' \ No newline at end of file + = render 'social_media' diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index cb023e44..e2187680 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -16,6 +16,7 @@ describe 'conference/show.html.haml' do @sponsorship_level = @conference.sponsorship_levels.first @sponsorship_level.sponsors << create(:sponsor, sponsorship_level: @sponsorship_level, conference: @conference) + @conference.venue = create(:venue) assign :conference, @conference render end @@ -51,4 +52,12 @@ describe 'conference/show.html.haml' do expect(rendered).to include('http://www.google-example.com') expect(rendered).to include('http://youtu.be/rtyutut') end + + it 'renders location partial' do + expect(view).to render_template(partial: 'conference/_location') + expect(rendered).to include('Suse Office') + expect(rendered).to include('Maxfeldstrasse 5 \n90409 Nuremberg') + expect(rendered).to include('www.opensuse.org') + expect(rendered).to include('Lorem Ipsum Dolor') + end end