1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

ability to share trainings on social medias

This commit is contained in:
Sylvain 2018-01-09 15:09:48 +01:00
parent 290b2ad513
commit 679ccfec99
3 changed files with 38 additions and 0 deletions

View File

@ -2,6 +2,7 @@
## next release
- Ability to share trainings on social medias
- Fix a bug: a reminder notification were sent for canceled reservations
- Fix a bug: sharing an event on facebook has HTML tags in the description

View File

@ -7,6 +7,9 @@ class SocialBotController < ActionController::Base
when /(=%2F|\/)events(%2F|\/)([0-9]+)/
@event = Event.find("#{$3}".to_i)
render :event, status: :ok
when /(=%2F|\/)trainings(%2F|\/)([\-0-9a-z_]+)/
@training = Training.friendly.find("#{$3}")
render :training, status: :ok
else
puts "unknown bot request : #{request.original_url}"
end

View File

@ -0,0 +1,34 @@
<%
if @training.training_image
image = @training.training_image.attachment.medium
width, height = image.dimensions
end
%>
<!DOCTYPE html>
<html lang="<%= I18n.locale %>">
<head>
<meta charset="utf-8">
<!-- Facebook Open Graph -->
<meta property="og:title" content="<%= @training.name %>"/>
<meta property="og:description" content="<%= strip_tags(@training.description) %>"/>
<% if @training.training_image %>
<meta property="og:image" content="<%= root_url+image.url %>"/>
<meta property="og:image:width" content="<%= width%>" />
<meta property="og:image:height" content="<%=height%>" />
<% end %>
<meta property="fb:app_id" content="<%= Rails.application.secrets.facebook_app_id%>" />
<meta property="og:url" content="<%= root_url+'#!/trainings/'+@training.slug %>" />
<!-- Twitter Cards-->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="<%= ENV['TWITTER_NAME'] %>">
<meta name="twitter:title" content="<%= @training.name %>">
<meta name="twitter:description" content="<%= strip_tags(@training.description) %>">
<% if @training.training_image %>
<meta name="twitter:image" content="<%= root_url+image.url %>">
<% end %>
</head>
</html>