From d53cc3b436302e719d172c17b30b27bd6a18b52d Mon Sep 17 00:00:00 2001 From: robotscissors Date: Tue, 15 May 2018 21:21:00 -0700 Subject: [PATCH] Add support for twitter cards and facebook shares Added missing image url as well as created twitter card. validated both with twitter validator and facebook validator. All passed. Need to check to see if no image is selected, what is outcome. --- app/controllers/conferences_controller.rb | 2 ++ app/views/conferences/show.html.haml | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index b9cdc238..d068083b 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -28,6 +28,8 @@ class ConferencesController < ApplicationController redirect_to admin_conference_splashpage_path(@conference.short_title) && return end + @image_url = "#{request.protocol}#{request.host}#{@conference.picture}" + if splashpage.include_cfp cfps = @conference.program.cfps @call_for_events = cfps.find { |call| call.cfp_type == 'events' } diff --git a/app/views/conferences/show.html.haml b/app/views/conferences/show.html.haml index c2355dd4..6ccccd0f 100644 --- a/app/views/conferences/show.html.haml +++ b/app/views/conferences/show.html.haml @@ -3,13 +3,19 @@ %meta{ property: "og:site_name", content: (ENV['OSEM_NAME'] || 'OSEM') } %meta{ property: "og:description", content: @conference.description } %meta{ property: "og:url", content: conference_url(@conference.short_title) } + %meta{ property: "twitter:card", content: "summary_large_image" } + %meta{ property: "twitter:image", content: @image_url } + %meta{ property: "twitter:title", content: (@conference.title) } + %meta{ property: "twitter:description", content: @conference.description } - if @conference.picture? - %meta{ property: "og:image", content: @conference.picture_url } - %meta{ property: "og:image:secure_url", content: @conference.picture_url } + %meta{ property: "og:image", content: @image_url } + %meta{ property: "og:image:secure_url", content: @image_url } + = content_for :title do = @conference.title + #splash - if @conference.code_of_conduct.present? = render 'code_of_conduct', organization: @conference.organization @@ -50,6 +56,7 @@ sponsorship_levels: @sponsorship_levels, sponsors: @sponsors + -# footer - if @conference.splashpage.include_social_media - if @conference.contact.has_social_media?