diff --git a/README.md b/README.md
index ceb5c1b53..5795bea1e 100644
--- a/README.md
+++ b/README.md
@@ -217,13 +217,19 @@ See https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
TWITTER_NAME
-Identifier of the Twitter account, for witch the last tweet will be displayed on the home page.
+Identifier of the Twitter account, from witch the last tweet will be fetched and displayed on the home page.
+It will also be used for [Twitter Card analytics](https://dev.twitter.com/cards/analytics).
TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN & TWITTER_ACCESS_TOKEN_SECRET
Keys and secrets to access the twitter API.
Retrieve them from https://apps.twitter.com
+ FACEBOOK_APP_ID
+
+This is optional. You can follow [this guide to get your personal App ID](https://developers.facebook.com/docs/apps/register).
+If you do so, you'll be able to customize and get statistics about project shares on Facebook.
+
Settings related to i18n
See the [Settings](#i18n-settings) section of the [Internationalization (i18n)](#i18n) paragraph for a detailed description of these parameters.
diff --git a/app/assets/javascripts/controllers/projects.coffee.erb b/app/assets/javascripts/controllers/projects.coffee.erb
index 4540e97b4..0e828e572 100644
--- a/app/assets/javascripts/controllers/projects.coffee.erb
+++ b/app/assets/javascripts/controllers/projects.coffee.erb
@@ -420,6 +420,8 @@ Application.Controllers.controller "ShowProjectController", ["$scope", "$state",
else
console.error _t('unauthorized_operation')
+
+
##
# Open a modal box containg a form that allow the end-user to signal an abusive content
# @param e {Object} jQuery event
@@ -455,4 +457,19 @@ Application.Controllers.controller "ShowProjectController", ["$scope", "$state",
growl.error(_t('an_error_occured_while_sending_your_report'))
]
+
+
+ ##
+ # 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.projects_show', {id: $scope.project.slug}, {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.projects_show', {id: $scope.project.slug}, {absolute: true}));
]
diff --git a/app/assets/stylesheets/app.buttons.scss b/app/assets/stylesheets/app.buttons.scss
index 49f97dd1c..5f8c187ad 100644
--- a/app/assets/stylesheets/app.buttons.scss
+++ b/app/assets/stylesheets/app.buttons.scss
@@ -2,7 +2,7 @@
.btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open > .btn-default.dropdown-toggle {
background-color: #f2f2f2;
-
+
}
.btn{
@@ -24,6 +24,30 @@
}
}
+.btn-facebook {
+ border: 1px solid #8b9dc3;
+ background-color: #3b5998;
+ color: white;
+
+ &:hover {
+ border: 1px solid #7d8fb4;
+ background-color: #394c89;
+ color: white;
+ }
+}
+
+.btn-twitter {
+ border: 1px solid #ccd6dd;
+ background-color: #55acee;
+ color: white;
+
+ &:hover {
+ border: 1px solid #bdc7ce;
+ background-color: #539fdf;
+ color: white;
+ }
+}
+
.btn-block {
padding-left: 12px;
diff --git a/app/assets/templates/projects/show.html.erb b/app/assets/templates/projects/show.html.erb
index 49688ef67..ef0593ee5 100644
--- a/app/assets/templates/projects/show.html.erb
+++ b/app/assets/templates/projects/show.html.erb
@@ -56,6 +56,11 @@
+
+
diff --git a/app/controllers/social_bot_controller.rb b/app/controllers/social_bot_controller.rb
index ad6fce3c3..e9ebed04f 100644
--- a/app/controllers/social_bot_controller.rb
+++ b/app/controllers/social_bot_controller.rb
@@ -1,8 +1,8 @@
class SocialBotController < ActionController::Base
def share
case request.original_fullpath
- when /=%2Fprojects%2F([\-0-9a-z]+)/
- @project = Project.friendly.find("#{$1}")
+ when /(=%2F|\/)projects(%2F|\/)([\-0-9a-z]+)/
+ @project = Project.friendly.find("#{$3}")
else
puts "unknown bot request : #{request.original_url}"
end
diff --git a/app/views/social_bot/share.html.erb b/app/views/social_bot/share.html.erb
index 7a10cc063..8a83212a8 100644
--- a/app/views/social_bot/share.html.erb
+++ b/app/views/social_bot/share.html.erb
@@ -5,11 +5,22 @@
+
+
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/application.yml.default b/config/application.yml.default
index 43f5245d1..723fb39b1 100644
--- a/config/application.yml.default
+++ b/config/application.yml.default
@@ -34,6 +34,8 @@ TWITTER_CONSUMER_SECRET: ''
TWITTER_ACCESS_TOKEN: ''
TWITTER_ACCESS_TOKEN_SECRET: ''
+FACEBOOK_APP_ID: ''
+
RAILS_LOCALE: 'fr'
MOMENT_LOCALE: 'fr'
SUMMERNOTE_LOCALE: 'fr-FR'
diff --git a/config/locales/app.public.en.yml b/config/locales/app.public.en.yml
index 8b59043c6..0d0c3d1d1 100644
--- a/config/locales/app.public.en.yml
+++ b/config/locales/app.public.en.yml
@@ -140,6 +140,8 @@ 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
diff --git a/config/locales/app.public.fr.yml b/config/locales/app.public.fr.yml
index c7fefb4f0..064c00894 100644
--- a/config/locales/app.public.fr.yml
+++ b/config/locales/app.public.fr.yml
@@ -140,6 +140,8 @@ 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
diff --git a/config/routes.rb b/config/routes.rb
index 79dc82c53..d0c1be896 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -20,8 +20,6 @@ Rails.application.routes.draw do
constraints :user_agent => /facebookexternalhit\/[0-9]|Twitterbot|Pinterest|Google.*snippet/ do
root :to => 'social_bot#share', as: :bot_root
- #TODO encode '#' in url with %23
- # button => https://www.facebook.com/share.php?u=$URL
end
## You can have the root of your site routed with "root"
diff --git a/config/secrets.yml b/config/secrets.yml
index f1a3bc140..c3b551ca7 100644
--- a/config/secrets.yml
+++ b/config/secrets.yml
@@ -35,6 +35,7 @@ development:
navinum_api_login: <%= ENV["NAVINUM_API_LOGIN"] %>
navinum_api_password: <%= ENV["NAVINUM_API_PASSWORD"] %>
log_level: <%= ENV["LOG_LEVEL"] %>
+ facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
test:
secret_key_base: 83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
@@ -61,6 +62,7 @@ test:
navinum_api_login:
navinum_api_password:
log_level: <%= ENV["LOG_LEVEL"] %>
+ facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
staging:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -94,6 +96,7 @@ staging:
navinum_api_login: <%= ENV["NAVINUM_API_LOGIN"] %>
navinum_api_password: <%= ENV["NAVINUM_API_PASSWORD"] %>
log_level: <%= ENV["LOG_LEVEL"] %>
+ facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
# Do not keep production secrets in the repository,
# instead read values from the environment.
@@ -130,3 +133,4 @@ production:
navinum_api_login: <%= ENV["NAVINUM_API_LOGIN"] %>
navinum_api_password: <%= ENV["NAVINUM_API_PASSWORD"] %>
log_level: <%= ENV["LOG_LEVEL"] %>
+ facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>