social_share.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. {% load static %}
  2. <!-- Composant de partage social -->
  3. <div class="social-share-container">
  4. <h5 class="social-share-title">
  5. <i class="fas fa-share-alt"></i> Partager cet article
  6. </h5>
  7. <div class="social-share-buttons">
  8. <!-- Twitter/X -->
  9. <a href="https://twitter.com/intent/tweet?text={{ article_title|urlencode }}&url={{ article_url }}"
  10. target="_blank"
  11. rel="noopener noreferrer"
  12. class="social-btn social-btn-twitter"
  13. title="Partager sur Twitter">
  14. <i class="fab fa-twitter"></i>
  15. <span class="social-btn-text">Twitter</span>
  16. </a>
  17. <!-- Facebook -->
  18. <a href="https://www.facebook.com/sharer/sharer.php?u={{ article_url }}"
  19. target="_blank"
  20. rel="noopener noreferrer"
  21. class="social-btn social-btn-facebook"
  22. title="Partager sur Facebook">
  23. <i class="fab fa-facebook-f"></i>
  24. <span class="social-btn-text">Facebook</span>
  25. </a>
  26. <!-- LinkedIn -->
  27. <a href="https://www.linkedin.com/sharing/share-offsite/?url={{ article_url }}"
  28. target="_blank"
  29. rel="noopener noreferrer"
  30. class="social-btn social-btn-linkedin"
  31. title="Partager sur LinkedIn">
  32. <i class="fab fa-linkedin-in"></i>
  33. <span class="social-btn-text">LinkedIn</span>
  34. </a>
  35. <!-- WhatsApp -->
  36. <a href="https://wa.me/?text={{ article_title|urlencode }}%20{{ article_url }}"
  37. target="_blank"
  38. rel="noopener noreferrer"
  39. class="social-btn social-btn-whatsapp"
  40. title="Partager sur WhatsApp">
  41. <i class="fab fa-whatsapp"></i>
  42. <span class="social-btn-text">WhatsApp</span>
  43. </a>
  44. <!-- Reddit -->
  45. <a href="https://reddit.com/submit?url={{ article_url }}&title={{ article_title|urlencode }}"
  46. target="_blank"
  47. rel="noopener noreferrer"
  48. class="social-btn social-btn-reddit"
  49. title="Partager sur Reddit">
  50. <i class="fab fa-reddit-alien"></i>
  51. <span class="social-btn-text">Reddit</span>
  52. </a>
  53. <!-- Email -->
  54. <a href="mailto:?subject={{ article_title|urlencode }}&body=J'ai%20trouvé%20cet%20article%20intéressant%20:%20{{ article_url }}"
  55. class="social-btn social-btn-email"
  56. title="Partager par email">
  57. <i class="fas fa-envelope"></i>
  58. <span class="social-btn-text">Email</span>
  59. </a>
  60. <!-- Copier le lien -->
  61. <button onclick="copyToClipboard('{{ article_url }}')"
  62. class="social-btn social-btn-copy"
  63. title="Copier le lien">
  64. <i class="fas fa-link"></i>
  65. <span class="social-btn-text">Copier</span>
  66. </button>
  67. </div>
  68. <!-- Message de confirmation pour la copie -->
  69. <div id="copy-notification" class="copy-notification">
  70. <i class="fas fa-check-circle"></i> Lien copié !
  71. </div>
  72. </div>
  73. <style>
  74. /* Container principal */
  75. .social-share-container {
  76. background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  77. border-radius: 15px;
  78. padding: 25px;
  79. margin: 30px 0;
  80. box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  81. }
  82. .social-share-title {
  83. font-size: 1.2rem;
  84. font-weight: 600;
  85. color: #2c3e50;
  86. margin-bottom: 20px;
  87. text-align: center;
  88. }
  89. .social-share-title i {
  90. margin-right: 8px;
  91. color: #3498db;
  92. }
  93. /* Grille de boutons */
  94. .social-share-buttons {
  95. display: grid;
  96. grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  97. gap: 12px;
  98. }
  99. /* Style des boutons */
  100. .social-btn {
  101. display: flex;
  102. align-items: center;
  103. justify-content: center;
  104. padding: 12px 16px;
  105. border: none;
  106. border-radius: 10px;
  107. font-size: 0.95rem;
  108. font-weight: 600;
  109. text-decoration: none;
  110. color: white;
  111. transition: all 0.3s ease;
  112. cursor: pointer;
  113. box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  114. }
  115. .social-btn:hover {
  116. transform: translateY(-3px);
  117. box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  118. color: white;
  119. text-decoration: none;
  120. }
  121. .social-btn i {
  122. font-size: 1.2rem;
  123. margin-right: 8px;
  124. }
  125. /* Couleurs spécifiques par réseau */
  126. .social-btn-twitter {
  127. background: linear-gradient(135deg, #1DA1F2 0%, #0d8bd9 100%);
  128. }
  129. .social-btn-facebook {
  130. background: linear-gradient(135deg, #1877F2 0%, #0d5dbf 100%);
  131. }
  132. .social-btn-linkedin {
  133. background: linear-gradient(135deg, #0077B5 0%, #005885 100%);
  134. }
  135. .social-btn-whatsapp {
  136. background: linear-gradient(135deg, #25D366 0%, #1da851 100%);
  137. }
  138. .social-btn-reddit {
  139. background: linear-gradient(135deg, #FF4500 0%, #cc3700 100%);
  140. }
  141. .social-btn-email {
  142. background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
  143. }
  144. .social-btn-copy {
  145. background: linear-gradient(135deg, #6c5ce7 0%, #5849c9 100%);
  146. }
  147. /* Notification de copie */
  148. .copy-notification {
  149. display: none;
  150. position: fixed;
  151. bottom: 30px;
  152. right: 30px;
  153. background: #2ecc71;
  154. color: white;
  155. padding: 15px 25px;
  156. border-radius: 10px;
  157. box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  158. font-weight: 600;
  159. z-index: 9999;
  160. animation: slideIn 0.3s ease;
  161. }
  162. .copy-notification i {
  163. margin-right: 8px;
  164. }
  165. @keyframes slideIn {
  166. from {
  167. transform: translateX(400px);
  168. opacity: 0;
  169. }
  170. to {
  171. transform: translateX(0);
  172. opacity: 1;
  173. }
  174. }
  175. /* Responsive */
  176. @media (max-width: 768px) {
  177. .social-share-buttons {
  178. grid-template-columns: repeat(2, 1fr);
  179. }
  180. .social-btn-text {
  181. display: inline;
  182. }
  183. .copy-notification {
  184. bottom: 20px;
  185. right: 20px;
  186. font-size: 0.9rem;
  187. padding: 12px 20px;
  188. }
  189. }
  190. @media (max-width: 480px) {
  191. .social-share-container {
  192. padding: 20px 15px;
  193. margin: 20px 0;
  194. }
  195. .social-share-buttons {
  196. grid-template-columns: 1fr;
  197. gap: 10px;
  198. }
  199. .social-btn {
  200. padding: 14px;
  201. font-size: 1rem;
  202. }
  203. }
  204. </style>
  205. <script>
  206. // Fonction pour copier le lien dans le presse-papiers
  207. function copyToClipboard(url) {
  208. // Méthode moderne avec l'API Clipboard
  209. if (navigator.clipboard && window.isSecureContext) {
  210. navigator.clipboard.writeText(url).then(function() {
  211. showCopyNotification();
  212. }).catch(function(err) {
  213. console.error('Erreur lors de la copie:', err);
  214. fallbackCopyToClipboard(url);
  215. });
  216. } else {
  217. // Fallback pour les navigateurs plus anciens
  218. fallbackCopyToClipboard(url);
  219. }
  220. }
  221. // Méthode alternative de copie
  222. function fallbackCopyToClipboard(text) {
  223. const textArea = document.createElement("textarea");
  224. textArea.value = text;
  225. textArea.style.position = "fixed";
  226. textArea.style.left = "-999999px";
  227. document.body.appendChild(textArea);
  228. textArea.focus();
  229. textArea.select();
  230. try {
  231. document.execCommand('copy');
  232. showCopyNotification();
  233. } catch (err) {
  234. console.error('Erreur lors de la copie:', err);
  235. alert('Impossible de copier le lien automatiquement. Veuillez le copier manuellement.');
  236. }
  237. document.body.removeChild(textArea);
  238. }
  239. // Afficher la notification de copie
  240. function showCopyNotification() {
  241. const notification = document.getElementById('copy-notification');
  242. notification.style.display = 'block';
  243. setTimeout(function() {
  244. notification.style.display = 'none';
  245. }, 3000);
  246. }
  247. </script>