From 27f6d8ad73e7bf3559057e6305ba2a4d905fcb29 Mon Sep 17 00:00:00 2001 From: James Mason Date: Mon, 27 Nov 2017 20:04:54 -0800 Subject: [PATCH] Let's get serious about linting, folks. --- .haml-lint_todo.yml | 11 --- app/helpers/conference_helper.rb | 18 +++++ .../{_booths.html.haml => _booths.haml} | 6 +- app/views/conferences/_call_for_content.haml | 10 +-- .../conferences/_call_for_paper.html.haml | 30 -------- app/views/conferences/_call_for_papers.haml | 30 ++++++++ ...tracks.html.haml => _call_for_tracks.haml} | 12 ++-- .../{_footer.html.haml => _footer.haml} | 0 app/views/conferences/_header.haml | 30 ++++---- app/views/conferences/_highlights.haml | 7 +- .../{_lodging.html.haml => _lodging.haml} | 14 ++-- app/views/conferences/_program.haml | 33 +++++++++ app/views/conferences/_registration.haml | 34 +++++++++ app/views/conferences/_registration.html.haml | 33 --------- .../_schedule_splashpage.html.haml | 31 --------- app/views/conferences/_social_media.haml | 20 ++++++ app/views/conferences/_social_media.html.haml | 20 ------ .../{_sponsors.html.haml => _sponsors.haml} | 18 ++--- .../{_tickets.html.haml => _tickets.haml} | 8 +-- app/views/conferences/_tracks.haml | 5 +- app/views/conferences/_venue.haml | 44 ++++++++++++ app/views/conferences/_venue.html.haml | 38 ---------- .../{_venue_map.html.haml => _venue_map.haml} | 25 +++++-- ...arker.html.haml => _venue_map_marker.haml} | 0 app/views/conferences/show.html.haml | 30 ++++---- spec/helpers/conference_helper_spec.rb | 69 +++++++++++++++++++ 26 files changed, 341 insertions(+), 235 deletions(-) create mode 100644 app/helpers/conference_helper.rb rename app/views/conferences/{_booths.html.haml => _booths.haml} (81%) delete mode 100644 app/views/conferences/_call_for_paper.html.haml create mode 100644 app/views/conferences/_call_for_papers.haml rename app/views/conferences/{_call_for_tracks.html.haml => _call_for_tracks.haml} (54%) rename app/views/conferences/{_footer.html.haml => _footer.haml} (100%) rename app/views/conferences/{_lodging.html.haml => _lodging.haml} (76%) create mode 100644 app/views/conferences/_program.haml create mode 100644 app/views/conferences/_registration.haml delete mode 100644 app/views/conferences/_registration.html.haml delete mode 100644 app/views/conferences/_schedule_splashpage.html.haml create mode 100644 app/views/conferences/_social_media.haml delete mode 100644 app/views/conferences/_social_media.html.haml rename app/views/conferences/{_sponsors.html.haml => _sponsors.haml} (58%) rename app/views/conferences/{_tickets.html.haml => _tickets.haml} (73%) create mode 100644 app/views/conferences/_venue.haml delete mode 100644 app/views/conferences/_venue.html.haml rename app/views/conferences/{_venue_map.html.haml => _venue_map.haml} (53%) rename app/views/conferences/{_venue_map_marker.html.haml => _venue_map_marker.haml} (100%) create mode 100644 spec/helpers/conference_helper_spec.rb diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index b79ddc17..54b6d85d 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -121,20 +121,9 @@ linters: - "app/views/conference_registrations/_registration_info.html.haml" - "app/views/conference_registrations/_volunteer.html.haml" - "app/views/conference_registrations/show.html.haml" - - "app/views/conferences/_booths.html.haml" - - "app/views/conferences/_call_for_paper.html.haml" - "app/views/conferences/_conference_details.html.haml" - "app/views/conferences/_gallery.html.haml" - - "app/views/conferences/_lodging.html.haml" - - "app/views/conferences/_program.html.haml" - - "app/views/conferences/_registration.html.haml" - - "app/views/conferences/_schedule_splashpage.html.haml" - - "app/views/conferences/_sponsors.html.haml" - - "app/views/conferences/_tickets.html.haml" - - "app/views/conferences/_venue.html.haml" - - "app/views/conferences/_venue_map.html.haml" - "app/views/conferences/index.html.haml" - - "app/views/conferences/show.html.haml" - "app/views/devise/confirmations/new.html.haml" - "app/views/devise/ichain_sessions/new.html.haml" - "app/views/devise/ichain_sessions/new_test.html.haml" diff --git a/app/helpers/conference_helper.rb b/app/helpers/conference_helper.rb new file mode 100644 index 00000000..3909ce92 --- /dev/null +++ b/app/helpers/conference_helper.rb @@ -0,0 +1,18 @@ +module ConferenceHelper + # Return true if only call_for_papers or call_for_tracks is open + def one_call_open(conference) + conference.call_for_events.try(:open?) ^ + conference.call_for_tracks.try(:open?) + end + + # URL for sponsorship emails + def sponsorship_mailto(conference) + [ + 'mailto:', + conference.contact.sponsor_email, + '?subject=', + url_encode(conference.short_title), + '%20Sponsorship' + ].join + end +end diff --git a/app/views/conferences/_booths.html.haml b/app/views/conferences/_booths.haml similarity index 81% rename from app/views/conferences/_booths.html.haml rename to app/views/conferences/_booths.haml index 92bfbaae..87c6cac5 100644 --- a/app/views/conferences/_booths.html.haml +++ b/app/views/conferences/_booths.haml @@ -1,8 +1,8 @@ .row - .col-md-12.text-center - %h2 Booths + .col-md-12 + %h3.text-center Booths .row.row-centered - - @conference.confirmed_booths.each do |booth| + - conference.confirmed_booths.to_a.sort_by!(&:title).each do |booth| .col-md-2.col-sm-2.col-centered.col-top.booth %a.thumbnail{ href: '#', data: { toggle: 'modal', target: "#modal-booth-#{booth.id}" } } diff --git a/app/views/conferences/_call_for_content.haml b/app/views/conferences/_call_for_content.haml index 7f8703c4..4ad6c855 100644 --- a/app/views/conferences/_call_for_content.haml +++ b/app/views/conferences/_call_for_content.haml @@ -5,10 +5,10 @@ %section#call .container .row - - if @conference.call_for_events.try(:open?) ^ @conference.call_for_tracks.try(:open?) + - if one_call_open(conference) .col-md-3.col-sm-3.hidden-xs   - - if @conference.call_for_events.try(:open?) - = render 'call_for_paper' + - if conference.call_for_events.try(:open?) + = render 'call_for_papers', conference: conference .col-md-2.col-sm-2   - - if @conference.call_for_tracks.try(:open?) - = render 'call_for_tracks' + - if conference.call_for_tracks.try(:open?) + = render 'call_for_tracks', conference: conference diff --git a/app/views/conferences/_call_for_paper.html.haml b/app/views/conferences/_call_for_paper.html.haml deleted file mode 100644 index 09203e75..00000000 --- a/app/views/conferences/_call_for_paper.html.haml +++ /dev/null @@ -1,30 +0,0 @@ -- cache [@conference, @conference.call_for_events, @conference.confirmed_tracks, - '#splash#callforpapers'] do - .col-md-5.col-sm-5.text-center - %h2 - Call for Papers - %p.lead - We are now accepting proposals for sessions! - %p - - if @conference.event_types.any? - You can submit proposals for - %span.notranslate - = "#{event_types(@conference)}." - - if @conference.confirmed_tracks.any? - Proposals should fit in one of the - %span.notranslate - = "#{pluralize(@conference.confirmed_tracks.length, 'track')}:" - = "#{tracks(@conference)}." - - if @conference.call_for_events.try(:open?) - The submission period is open - %em.notranslate - = "#{date_string(@conference.call_for_events.start_date, - @conference.call_for_events.end_date)}." - %b - You have - = pluralize(@conference.call_for_events.remaining_days, 'day') - left! - %p.cta-button - = link_to "Submit your proposal now", - conference_program_proposals_path(@conference.short_title), - class: 'btn btn-success btn-lg text-center' diff --git a/app/views/conferences/_call_for_papers.haml b/app/views/conferences/_call_for_papers.haml new file mode 100644 index 00000000..8499f4ac --- /dev/null +++ b/app/views/conferences/_call_for_papers.haml @@ -0,0 +1,30 @@ +- cache [conference, conference.call_for_events, conference.confirmed_tracks, + '#splash#callforpapers'] do + .col-md-5.col-sm-5.text-center + %h2 + Call for Papers + %p.lead + We are now accepting proposals for sessions! + %p + - if conference.event_types.any? + You can submit proposals for + %span.notranslate + = event_types(conference) + '.' + - if conference.confirmed_tracks.any? + Proposals should fit in one of the + %span.notranslate + = pluralize(conference.confirmed_tracks.length, 'track') + ':' + = tracks(conference) + '.' + - if conference.call_for_events.try(:open?) + The submission period is open + %em.notranslate + = date_string(conference.call_for_events.start_date, + conference.call_for_events.end_date) + '.' + %b + You have + = pluralize(conference.call_for_events.remaining_days, 'day') + left! + %p.cta-button + = link_to "Submit your proposal now", + conference_program_proposals_path(conference.short_title), + class: 'btn btn-success btn-lg text-center' diff --git a/app/views/conferences/_call_for_tracks.html.haml b/app/views/conferences/_call_for_tracks.haml similarity index 54% rename from app/views/conferences/_call_for_tracks.html.haml rename to app/views/conferences/_call_for_tracks.haml index 092c2740..59681f71 100644 --- a/app/views/conferences/_call_for_tracks.html.haml +++ b/app/views/conferences/_call_for_tracks.haml @@ -1,4 +1,4 @@ -- cache [@conference, @conference.call_for_tracks, '#splash#callfortracks'] do +- cache [conference, conference.call_for_tracks, '#splash#callfortracks'] do .col-md-5.col-sm-5.text-center %h2 Call for Tracks @@ -7,14 +7,14 @@ %p Would you like to host a mini-summit, sub-conference, or hack space? The submission period for track requests is open - %em.notranslate - = "#{date_string(@conference.call_for_tracks.start_date, - @conference.call_for_tracks.end_date)}." + %em + = date_string(conference.call_for_tracks.start_date, + conference.call_for_tracks.end_date) + '.' %b You have - = pluralize(@conference.call_for_tracks.remaining_days, 'day') + = pluralize(conference.call_for_tracks.remaining_days, 'day') left! %p.cta-button = link_to("Submit your request for track", - conference_program_tracks_path(@conference.short_title), + conference_program_tracks_path(conference.short_title), class: 'btn btn-success btn-lg text-center') diff --git a/app/views/conferences/_footer.html.haml b/app/views/conferences/_footer.haml similarity index 100% rename from app/views/conferences/_footer.html.haml rename to app/views/conferences/_footer.haml diff --git a/app/views/conferences/_header.haml b/app/views/conferences/_header.haml index 3d68ff17..7a635ae7 100644 --- a/app/views/conferences/_header.haml +++ b/app/views/conferences/_header.haml @@ -1,32 +1,36 @@ -- cache [@conference, @conference.venue, '#splash#header'] do +- cache [conference, conference.venue, '#splash#header'] do #banner .container .row .col-md-8.col-md-offset-2#header .row .col-md-4 - = image_tag(@conference.picture_url, class: 'img-responsive img-center', id: 'splash-logo') if @conference.picture? + - if conference.picture? + = image_tag(conference.picture_url, + class: 'img-responsive img-center', + id: 'splash-logo') .col-md-8 %h1 - = @conference.title + = conference.title %h3 - - if @conference.start_date && @conference.end_date + - if conference.start_date && conference.end_date %span.date.text-nowrap - = date_string(@conference.start_date, @conference.end_date) - - if @conference.venue + = date_string(conference.start_date, conference.end_date) + - if conference.venue %span.venue.text-nowrap - - if @conference.venue.website - = sanitize link_to(@conference.venue.name, @conference.venue.website) + - if conference.venue.website + = sanitize link_to(conference.venue.name, + conference.venue.website) - else - = @conference.venue.city - - if @conference.venue.country_name != 'US' + = conference.venue.city + - if conference.venue.country_name != 'US' • - = @conference.venue.country_name + = conference.venue.country_name - - unless @conference.description.blank? + - unless conference.description.blank? %section#about .container .row .col-md-8.col-md-offset-2 %h3.text-center - = markdown(@conference.description) + = markdown(conference.description) diff --git a/app/views/conferences/_highlights.haml b/app/views/conferences/_highlights.haml index 0ea1eb99..6e610370 100644 --- a/app/views/conferences/_highlights.haml +++ b/app/views/conferences/_highlights.haml @@ -5,11 +5,12 @@ .row .col-md-12 .row.row-centered - - @conference.highlighted_events.each do |event| + - conference.highlighted_events.each do |event| - speaker = event.speakers_ordered.first .col-md-3.col-sm-3.col-centered.col-top.highlights - = link_to conference_program_proposal_path(@conference.short_title, event), - class: 'thumbnail' do + = link_to(conference_program_proposal_path(conference.short_title, + event), + class: 'thumbnail') do = image_tag speaker.gravatar_url(size: 300), class: ['img-responsive', 'img-circle'], title: speaker.name diff --git a/app/views/conferences/_lodging.html.haml b/app/views/conferences/_lodging.haml similarity index 76% rename from app/views/conferences/_lodging.html.haml rename to app/views/conferences/_lodging.haml index 4859b8f5..301dd142 100644 --- a/app/views/conferences/_lodging.html.haml +++ b/app/views/conferences/_lodging.haml @@ -2,25 +2,25 @@ %li %a.smoothscroll{ href: '#lodging' } Lodging -- cache [@conference.venue, @conference.lodgings, '#splash#lodging'] do +- cache [conference.venue, conference.lodgings, '#splash#lodging'] do %section#lodging .container .row .col-md-12.text-center %h2 Where to stay - - if @conference.venue + - if conference.venue in - = @conference.venue.city + = conference.venue.city %p.lead We recommend the following accommodations for your visit. .row.row-centered - - @conference.lodgings.each do |lodging| + - conference.lodgings.each do |lodging| .col-md-4.col-sm-4.col-centered.col-top .thumbnail - if lodging.picture? - -if lodging.website_link.present? + - if lodging.website_link.present? = link_to(lodging.website_link, class: 'thumbnail') do = image_tag lodging.picture.large.url, class: 'img-responsive img-lodging' @@ -29,7 +29,7 @@ class: 'img-responsive img-lodging' - else %p.text-center - -if lodging.website_link.present? + - if lodging.website_link.present? = link_to(lodging.website_link, class: 'thumbnail') do %i.fa.fa-home.fa-5x - else @@ -37,5 +37,5 @@ .caption %h3.text-center = lodging.name - -if lodging.description.present? + - if lodging.description.present? = markdown(lodging.description) diff --git a/app/views/conferences/_program.haml b/app/views/conferences/_program.haml new file mode 100644 index 00000000..67e058c7 --- /dev/null +++ b/app/views/conferences/_program.haml @@ -0,0 +1,33 @@ += content_for :splash_nav do + %li + %a.smoothscroll{ href: '#program' } Program + +- cache [@confererence, @conference.confirmed_tracks, + @conference.confirmed_booths,'#splash#program'] do + %section#program + .container + .row + .col-md-12 + %p.lead.text-center + %span.notranslate + = conference.title + has the most awesome program ever! + + - if conference.highlighted_events.any? + = render 'highlights', conference: conference + + - if conference.splashpage.include_tracks + - if conference.confirmed_tracks.any? + = render 'tracks', conference: conference + + - if conference.splashpage.include_booths + - if conference.confirmed_booths.any? + = render 'booths', conference: conference + + - if conference.program.try(:schedule_public?) + .row + .col-md-12 + %p.cta-button.text-center + = link_to(conference_schedule_path(conference.short_title), + class: 'btn btn-success btn-lg') do + Full Schedule diff --git a/app/views/conferences/_registration.haml b/app/views/conferences/_registration.haml new file mode 100644 index 00000000..f327344b --- /dev/null +++ b/app/views/conferences/_registration.haml @@ -0,0 +1,34 @@ += content_for :splash_nav do + %li + %a.smoothscroll{ href: '#registration' } Registration + +- cache [conference.registration_period, conference.tickets, + '#splash#registration'] do + %section#registration + .container + .row + .col-md-12.text-center + %h1 Registration + - if conference.registration_limit_exceeded? + %p + Sorry, the conference registration limit has exceeded + - elsif conference.tickets.empty? + %p.lead + Going to + = conference.short_title + is free of charge. + %p + We only ask you to register yourself before + = date_string(conference.registration_period.end_date) + so we can plan for the right amount of people. + %p.cta-button + - else + %p + The registration period is open + = date_string(conference.registration_period.start_date, + conference.registration_period.end_date) + - if conference.registration_open? + %p.cta-button + = link_to('Register Now', + new_conference_conference_registration_path(conference.short_title), + class: 'btn btn-lg btn-success') diff --git a/app/views/conferences/_registration.html.haml b/app/views/conferences/_registration.html.haml deleted file mode 100644 index b9b27f08..00000000 --- a/app/views/conferences/_registration.html.haml +++ /dev/null @@ -1,33 +0,0 @@ -= content_for :splash_nav do - %li - %a.smoothscroll{ href: '#registration' } Registration - -- cache [@conference.registration_period, @conference.tickets, '#splash#registration'] do - %section#registration - .container - .row - .col-md-12.text-center - %h1 Registration - - - if @conference.registration_limit_exceeded? - %p - Sorry, the conference registration limit has exceeded - - else - - if @conference.tickets.empty? - %p.lead - Going to - = @conference.short_title - is free of charge. - %p - We only ask you to register yourself before - = date_string(@conference.registration_period.end_date) - so we can plan for the right amount of people. - %p.cta-button - - else - %p - The registration period ends on - = date_string(@conference.registration_period.end_date) - %p.cta-button - = link_to(new_conference_conference_registration_path(@conference.short_title), - class: 'btn btn-lg btn-success') do - Register Now diff --git a/app/views/conferences/_schedule_splashpage.html.haml b/app/views/conferences/_schedule_splashpage.html.haml deleted file mode 100644 index 08958c94..00000000 --- a/app/views/conferences/_schedule_splashpage.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -= content_for :splash_nav do - %li - %a.smoothscroll{ href: '#program' } Program - -- cache [@confererence, @conference.confirmed_tracks, - @conference.confirmed_booths,'#splash#program'] do - %section#program - .container - .row - .col-md-12 - %p.lead.text-center - %span.notranslate - = @conference.title - has the most awesome program ever! - - - if @conference.highlighted_events.any? - = render 'highlights' - - - if @conference.splashpage.include_tracks && @conference.confirmed_tracks.any? - = render 'tracks' - - - if @conference.splashpage.include_booths && @conference.confirmed_booths.any? - = render 'booths' - - - if @conference.program.try(:schedule_public?) - .row - .col-md-12 - %p.cta-button.text-center - = link_to(conference_schedule_path(@conference.short_title), - class: 'btn btn-success btn-lg') do - Full Schedule diff --git a/app/views/conferences/_social_media.haml b/app/views/conferences/_social_media.haml new file mode 100644 index 00000000..d227c54a --- /dev/null +++ b/app/views/conferences/_social_media.haml @@ -0,0 +1,20 @@ +- cache [conference.contact, '#splash#social'] do + %section#social-media + .container + .row + .col-md-12.text-center + - unless conference.contact.facebook.blank? + = link_to "#{ conference.contact.facebook }" do + %i.fa.fa-facebook-square.fa-4x + - unless conference.contact.twitter.blank? + = link_to "#{ conference.contact.twitter }" do + %i.fa.fa-twitter.fa-4x + - unless conference.contact.instagram.blank? + = link_to "#{ conference.contact.instagram }" do + %i.fa.fa-instagram.fa-4x + - unless conference.contact.googleplus.blank? + = link_to "#{ conference.contact.googleplus }" do + %i.fa.fa-google-plus-square.fa-4x + - unless conference.contact.email.blank? + = mail_to "#{ conference.contact.email }" do + %i.fa.fa-envelope-o.fa-4x diff --git a/app/views/conferences/_social_media.html.haml b/app/views/conferences/_social_media.html.haml deleted file mode 100644 index 4d3a5c4f..00000000 --- a/app/views/conferences/_social_media.html.haml +++ /dev/null @@ -1,20 +0,0 @@ -- cache [@conference.contact, '#splash#social'] do - %section#social-media - .container - .row - .col-md-12.text-center - - unless @conference.contact.facebook.blank? - = link_to "#{ @conference.contact.facebook }" do - %i.fa.fa-facebook-square.fa-4x - - unless @conference.contact.twitter.blank? - = link_to "#{ @conference.contact.twitter }" do - %i.fa.fa-twitter.fa-4x - - unless @conference.contact.instagram.blank? - = link_to "#{ @conference.contact.instagram }" do - %i.fa.fa-instagram.fa-4x - - unless @conference.contact.googleplus.blank? - = link_to "#{ @conference.contact.googleplus }" do - %i.fa.fa-google-plus-square.fa-4x - - unless @conference.contact.email.blank? - = mail_to "#{ @conference.contact.email }" do - %i.fa.fa-envelope-o.fa-4x diff --git a/app/views/conferences/_sponsors.html.haml b/app/views/conferences/_sponsors.haml similarity index 58% rename from app/views/conferences/_sponsors.html.haml rename to app/views/conferences/_sponsors.haml index aa15ab5a..f75939f6 100644 --- a/app/views/conferences/_sponsors.html.haml +++ b/app/views/conferences/_sponsors.haml @@ -2,12 +2,12 @@ %li %a.smoothscroll{ href: '#sponsors' } Sponsors -- cache [@conference, @conference.sponsors, @conference.sponsorship_levels, - @conference.try(:call_for_sponsors), '#splash#sponsors'] do +- cache [conference, conference.sponsors, conference.sponsorship_levels, + conference.try(:call_for_sponsors), '#splash#sponsors'] do %section#sponsors .container - - @conference.sponsorship_levels.each do |sponsorship_level| - -if sponsorship_level.sponsors.any? + - conference.sponsorship_levels.each do |sponsorship_level| + - if sponsorship_level.sponsors.any? .row.text-center %h3 = sponsorship_level.title @@ -15,8 +15,8 @@ .row.row-centered - sponsorship_level.sponsors.each do |sponsor| .col-md-4.col-sm-4.col-centered.col-top - %a{ href: '#', - data: { toggle: 'modal', target: "#modal-sponsor-#{sponsor.id}" } } + %a{ href: '#', data: { toggle: 'modal', + target: "#modal-sponsor-#{sponsor.id}" } } = image_tag get_logo(sponsor), class: ['img-responsive', 'img-sponsor', "img-sponsor-#{sponsorship_level.position}"], @@ -24,11 +24,11 @@ - content_for :modals do = render 'modal_description', object: sponsor - - if @conference.call_for_sponsors.try(:open?) + - if conference.call_for_sponsors.try(:open?) .row .col-md-12 %p.text-muted.text-center %small - Want to sponsor #{@conference.short_title}? - = link_to("mailto: #{@conference.contact.sponsor_email}?subject=#{@conference.short_title}%20Sponsorship") do + Want to sponsor #{conference.short_title}? + = link_to(sponsorship_mailto(conference)) do Please contact us! diff --git a/app/views/conferences/_tickets.html.haml b/app/views/conferences/_tickets.haml similarity index 73% rename from app/views/conferences/_tickets.html.haml rename to app/views/conferences/_tickets.haml index a01ad676..ce4ca802 100644 --- a/app/views/conferences/_tickets.html.haml +++ b/app/views/conferences/_tickets.haml @@ -2,18 +2,18 @@ %li %a.smoothscroll{ href: '#tickets' } Tickets -- cache [@conference, @conference.tickets, '#splash#tickets'] do +- cache [conference, conference.tickets, '#splash#tickets'] do %section#tickets .container .row .col-md-12.text-center %h2 Support - =@conference.title + = conference.title .row.row-centered - - @conference.tickets.each do |ticket| + - conference.tickets.each do |ticket| .col-md-3.col-sm-3.col-centered.col-top - = link_to(conference_tickets_path(@conference.short_title), + = link_to(conference_tickets_path(conference.short_title), class: 'thumbnail') do .caption %h3.text-center diff --git a/app/views/conferences/_tracks.haml b/app/views/conferences/_tracks.haml index 1938ab0f..3dd8e628 100644 --- a/app/views/conferences/_tracks.haml +++ b/app/views/conferences/_tracks.haml @@ -1,9 +1,8 @@ .row .col-md-12 - %h3.text-center - Tracks + %h3.text-center Tracks .row.row-centered - - @conference.confirmed_tracks.to_a.sort_by!(&:name).each do |track| + - conference.confirmed_tracks.to_a.sort_by!(&:name).each do |track| .col-md-3.col-sm-3.col-centered.col-top.track .thumbnail .caption diff --git a/app/views/conferences/_venue.haml b/app/views/conferences/_venue.haml new file mode 100644 index 00000000..c88695ac --- /dev/null +++ b/app/views/conferences/_venue.haml @@ -0,0 +1,44 @@ += content_for :splash_nav do + %li + %a.smoothscroll{ href: '#venue' } Venue + +- cache [conference.venue, conference.venue.commercial, '#splash#venue'] do + %section#venue + - if conference.venue.location? + = render '/conferences/venue_map', conference: conference + - else + .container + .row + .col-md-6 + .thumbnail#venue-pic + - if commercial = conference.venue.commercial + .flexvideo{ id: "resource-content-#{commercial.id}" } + = render 'shared/media_item', + commercial: commercial + - elsif conference.venue.picture? + = image_tag conference.venue.picture.url, + title: conference.venue.name, class: "img-responsive" + - else + %p.text-center + %span.fa.fa-university.fa-5x + .caption + %h3.text-center + = conference.venue.name + - unless conference.venue.description.blank? + = markdown(conference.venue.description) + .col-md-6 + %h2 + = conference.venue.city + \/ + = conference.venue.country_name + %address + = conference.venue.street + %br + = conference.venue.postalcode + ',' + = conference.venue.city + %br + = conference.venue.country_name + - if conference.venue.website + %br + = sanitize link_to(h(conference.venue.website), + h(conference.venue.website)) diff --git a/app/views/conferences/_venue.html.haml b/app/views/conferences/_venue.html.haml deleted file mode 100644 index 0c7ef254..00000000 --- a/app/views/conferences/_venue.html.haml +++ /dev/null @@ -1,38 +0,0 @@ -= content_for :splash_nav do - %li - %a.smoothscroll{ href: '#venue' } Venue - -- cache [@conference.venue, @conference.venue.commercial, '#splash#venue'] do - %section#venue - -if @conference.venue.location? - = render '/conferences/venue_map' - -else - .container - .row - .col-md-6 - .thumbnail#venue-pic - - if @conference.venue.commercial.present? and @conference.venue.commercial.persisted? - .flexvideo{ id: "resource-content-#{@conference.venue.commercial.id}"} - = render partial: 'shared/media_item', locals: { commercial: @conference.venue.commercial } - - elsif @conference.venue.picture? - = image_tag @conference.venue.picture.url, alt: @conference.venue.name, class:"img-responsive" - - else - %p.text-center - %span.fa.fa-university.fa-5x - .caption - %h3.text-center - = @conference.venue.name - - unless @conference.venue.description.blank? - = markdown(@conference.venue.description) - .col-md-6 - %h2 - = "#{@conference.venue.city} / #{@conference.venue.country_name}" - %address - = @conference.venue.street - %br - = "#{@conference.venue.postalcode}, #{@conference.venue.city}" - %br - = @conference.venue.country_name - - if @conference.venue.website - %br - =link_to(h(@conference.venue.website), h(@conference.venue.website)).html_safe diff --git a/app/views/conferences/_venue_map.html.haml b/app/views/conferences/_venue_map.haml similarity index 53% rename from app/views/conferences/_venue_map.html.haml rename to app/views/conferences/_venue_map.haml index 708d5e46..e4e56ea3 100644 --- a/app/views/conferences/_venue_map.html.haml +++ b/app/views/conferences/_venue_map.haml @@ -1,16 +1,29 @@ -#map{style: "height: 500px;" } +#map{ style: "height: 500px;" } - content_for(:script_body) do + - marker = escape_javascript(render '/conferences/venue_map_marker', + venue: conference.venue) :javascript // create a map in the "map" div, set the view to a given place and zoom - var map = L.map('map', { scrollWheelZoom: false }).setView([#{@conference.venue.latitude.to_f + 0.05}, #{h(@conference.venue.longitude)}], 11); + var map = L.map('map', { scrollWheelZoom: false }).setView( + [ + #{conference.venue.latitude.to_f + 0.05}, + #{h(conference.venue.longitude)} + ], 11); // add an OpenStreetMap tile layer L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', + attribution: 'Map data © \ + OpenStreetMap contributors, \ + CC-BY-SA, \ + Imagery © Mapbox', maxZoom: 18 }).addTo(map); - // add a marker in the given location, attach some popup content to it and open the popup - L.marker([#{h @conference.venue.latitude}, #{h @conference.venue.longitude}]).addTo(map) - .bindPopup("#{escape_javascript(render '/conferences/venue_map_marker', venue: @conference.venue)}") + // add a marker in the given location, attach some popup content to it + // and open the popup + L.marker([ + #{h conference.venue.latitude}, + #{h conference.venue.longitude} + ]).addTo(map) + .bindPopup("#{marker}") .openPopup(); // Turn scrollwheel on when user clicks map.on('focus', function(e) { diff --git a/app/views/conferences/_venue_map_marker.html.haml b/app/views/conferences/_venue_map_marker.haml similarity index 100% rename from app/views/conferences/_venue_map_marker.html.haml rename to app/views/conferences/_venue_map_marker.haml diff --git a/app/views/conferences/show.html.haml b/app/views/conferences/show.html.haml index 3905b3a4..ac0fc854 100644 --- a/app/views/conferences/show.html.haml +++ b/app/views/conferences/show.html.haml @@ -12,33 +12,35 @@ #splash // header/description - = render 'header' + = render 'header', conference: @conference // attendance/registration - - if @conference.splashpage.include_registrations && @conference.registration_open? - = render 'registration' - - if @conference.splashpage.include_tickets && @conference.tickets.any? && @conference.pending? - = render 'tickets' + - if @conference.splashpage.include_registrations + - if @conference.registration_open? + = render 'registration', conference: @conference + - if @conference.splashpage.include_tickets && @conference.tickets.any? + = render 'tickets', conference: @conference // calls for content, or program - if @conference.splashpage.include_cfp - = render 'call_for_content' + = render 'call_for_content', conference: @conference - if @conference.splashpage.include_program - = render 'schedule_splashpage' + = render 'program', conference: @conference // geo - if @conference.splashpage.include_venue && @conference.venue - = render 'venue' + = render 'venue', conference: @conference - if @conference.splashpage.include_lodgings && @conference.lodgings.any? - = render 'lodging' + = render 'lodging', conference: @conference // sponsorship - if @conference.splashpage.include_sponsors - = render 'sponsors' + = render 'sponsors', conference: @conference // footer - - if @conference.splashpage.include_social_media && @conference.contact.has_social_media? - = render 'social_media' + - if @conference.splashpage.include_social_media + - if @conference.contact.has_social_media? + = render 'social_media', conference: @conference = render 'footer' = yield :modals @@ -47,7 +49,9 @@ - content_for :script_head do :javascript var triangle_tcs = tinycolor("#{h(@conference.color)}").monochromatic(); - var triangle_colors = triangle_tcs.map(function(t) { return t.toHexString(); }); + var triangle_colors = triangle_tcs.map(function(t) { + return t.toHexString(); + }); $(function () { $(document).ready(function() { var triangle_width = document.body.clientWidth; diff --git a/spec/helpers/conference_helper_spec.rb b/spec/helpers/conference_helper_spec.rb new file mode 100644 index 00000000..2ed5517e --- /dev/null +++ b/spec/helpers/conference_helper_spec.rb @@ -0,0 +1,69 @@ +require 'spec_helper' + +describe ConferenceHelper, type: :helper do + let!(:conference) { create(:conference) } + let!(:contact) { create(:contact, conference: conference) } + + describe '#one_call_open' do + it 'is falsey if neither call is open' do + expect(one_call_open(conference)).to be_falsey + end + + it 'is truthy if call_for_papers is open' do + create( + :cfp, + program: conference.program, + cfp_type: 'events', + start_date: conference.start_date, + end_date: conference.end_date + ) + + expect(one_call_open(conference)).to be_truthy + end + + it 'is truthy if call_for_tracks is open' do + create( + :cfp, + program: conference.program, + cfp_type: 'tracks', + start_date: conference.start_date, + end_date: conference.end_date + ) + + expect(one_call_open(conference)).to be_truthy + end + + it 'is falsey if both calls are open' do + create( + :cfp, + program: conference.program, + cfp_type: 'events', + start_date: conference.start_date, + end_date: conference.end_date + ) + create( + :cfp, + program: conference.program, + cfp_type: 'tracks', + start_date: conference.start_date, + end_date: conference.end_date + ) + + expect(one_call_open(conference)).to be_falsey + end + end + + describe '#sponsorship_mailto' do + it 'constructs a mailto URL' do + expect(sponsorship_mailto(conference)).to match 'mailto:' + end + + it 'points to the conference sponsor address' do + expect(sponsorship_mailto(conference)).to match contact.sponsor_email + end + + it 'includes a conference identifier' do + expect(sponsorship_mailto(conference)).to match conference.short_title + end + end +end