mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
ability to share events on social networks twitter & fb
This commit is contained in:
parent
26d5e5e42c
commit
bd54ad8158
@ -371,6 +371,22 @@ Application.Controllers.controller "ShowEventController", ["$scope", "$state", "
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Return the URL allowing to share the current project on the Facebook social network
|
||||
##
|
||||
$scope.shareOnFacebook = ->
|
||||
'https://www.facebook.com/share.php?u='+$state.href('app.public.events_show', {id: $scope.event.id}, {absolute: true}).replace('#', '%23')
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Return the URL allowing to share the current project on the Twitter social network
|
||||
##
|
||||
$scope.shareOnTwitter = ->
|
||||
'https://twitter.com/intent/tweet?url='+encodeURIComponent($state.href('app.public.events_show', {id: $scope.event.id}, {absolute: true}));
|
||||
|
||||
|
||||
|
||||
### PRIVATE SCOPE ###
|
||||
|
||||
##
|
||||
|
@ -39,6 +39,12 @@
|
||||
<p ng-bind-html="event.description | breakFilter"></p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center" id="social-share">
|
||||
<a ng-href="{{shareOnFacebook()}}" target="_blank" class="btn btn-facebook btn-lg m-t"><i class="fa fa-facebook m-r"></i> {{ 'share_on_facebook' | translate }}</a>
|
||||
<a ng-href="{{shareOnTwitter()}}" target="_blank" class="btn btn-twitter btn-lg m-t"><i class="fa fa-twitter m-r"></i> {{ 'share_on_twitter' | translate }}</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-12 col-lg-4">
|
||||
|
@ -3,6 +3,10 @@ class SocialBotController < ActionController::Base
|
||||
case request.original_fullpath
|
||||
when /(=%2F|\/)projects(%2F|\/)([\-0-9a-z]+)/
|
||||
@project = Project.friendly.find("#{$3}")
|
||||
render :project, status: :ok
|
||||
when /(=%2F|\/)events(%2F|\/)([0-9]+)/
|
||||
@event = Event.find("#{$3}".to_i)
|
||||
render :event, status: :ok
|
||||
else
|
||||
puts "unknown bot request : #{request.original_url}"
|
||||
end
|
||||
|
@ -63,4 +63,9 @@ class EventImageUploader < CarrierWave::Uploader::Base
|
||||
def filename
|
||||
"#{model.class.to_s.underscore}.#{file.extension}" if original_filename
|
||||
end
|
||||
|
||||
# return an array like [width, height]
|
||||
def dimensions
|
||||
::MiniMagick::Image.open(file.file)[:dimensions]
|
||||
end
|
||||
end
|
||||
|
26
app/views/social_bot/event.html.erb
Normal file
26
app/views/social_bot/event.html.erb
Normal file
@ -0,0 +1,26 @@
|
||||
<% image = @event.event_image.attachment.medium %>
|
||||
<% width, height = image.dimensions %>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%= I18n.locale %>">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<!-- Facebook Open Graph -->
|
||||
<meta property="og:title" content="<%= @event.title %>"/>
|
||||
<meta property="og:description" content="<%= @event.description %>"/>
|
||||
<meta property="og:image" content="<%= root_url+image.url %>"/>
|
||||
<meta property="og:image:width" content="<%= width%>" />
|
||||
<meta property="og:image:height" content="<%=height%>" />
|
||||
<meta property="fb:app_id" content="<%= Rails.application.secrets.facebook_app_id%>" />
|
||||
<meta property="og:url" content="<%= root_url+'#!/events/'+@event.id.to_s %>" />
|
||||
|
||||
<!-- Twitter Cards-->
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:site" content="<%= ENV['TWITTER_NAME'] %>">
|
||||
<meta name="twitter:title" content="<%= @event.title %>">
|
||||
<meta name="twitter:description" content="<%= @event.description %>">
|
||||
<meta name="twitter:image" content="<%= root_url+image.url %>">
|
||||
|
||||
</head>
|
||||
</html>
|
@ -2,7 +2,7 @@
|
||||
<% width, height = image.dimensions %>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%= I18n.locale %>" ng-app="application" class="app">
|
||||
<html lang="<%= I18n.locale %>">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -140,8 +140,6 @@ en:
|
||||
projects_show:
|
||||
# details of a projet
|
||||
project_description: "Project description"
|
||||
share_on_facebook: "Share on Facebook"
|
||||
share_on_twitter: "Share on Twitter"
|
||||
by_name: "By {{NAME}}" # angular interpolation
|
||||
posted_on_: "Posted on"
|
||||
CAD_file_to_download: "{COUNT, plural, =0{No CAD files} =1{CAD file to download} other{CAD files to download}}" # messageFormat interpolation
|
||||
|
@ -140,8 +140,6 @@ fr:
|
||||
projects_show:
|
||||
# détails d'un projet
|
||||
project_description: "Description du projet"
|
||||
share_on_facebook: "Partager sur Facebook"
|
||||
share_on_twitter: "Partager sur Twitter"
|
||||
by_name: "Par {{NAME}}" # angular interpolation
|
||||
posted_on_: "posté le"
|
||||
CAD_file_to_download: "{COUNT, plural, =0{Aucun fichier CAO} =1{Fichier CAO à télécharger} other{Fichiers CAO à télécharger}}" # messageFormat interpolation
|
||||
|
@ -98,6 +98,8 @@ en:
|
||||
filter: 'Filter'
|
||||
confirm_payment_of_html: "{ROLE, select, admin{Payment on site} other{Pay}}: {AMOUNT}" # messageFormat interpolation (context: confirm my payment of $20.00)
|
||||
export_is_running_you_ll_be_notified_when_its_ready: "Export is running. You'll be notified when it's ready."
|
||||
share_on_facebook: "Share on Facebook"
|
||||
share_on_twitter: "Share on Twitter"
|
||||
|
||||
messages:
|
||||
you_will_lose_any_unsaved_modification_if_you_quit_this_page: "You will lose any unsaved modification if you quit this page"
|
||||
|
@ -98,6 +98,8 @@ fr:
|
||||
filter: 'Filtre'
|
||||
confirm_payment_of_html: "{ROLE, select, admin{Paiement sur place} other{Payer}} : {AMOUNT}" # messageFormat interpolation (contexte : valider mon paiement de 20,00 €)
|
||||
export_is_running_you_ll_be_notified_when_its_ready: "L'export est en cours. Vous serez notifié lorsqu'il sera prêt."
|
||||
share_on_facebook: "Partager sur Facebook"
|
||||
share_on_twitter: "Partager sur Twitter"
|
||||
|
||||
messages:
|
||||
you_will_lose_any_unsaved_modification_if_you_quit_this_page: "Vous perdrez les modifications non enregistrées si vous quittez cette page"
|
||||
|
Loading…
x
Reference in New Issue
Block a user