listing.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. {% extends 'base_no_card.html' %}
  2. {% load crispy_forms_tags %}
  3. {% load static %}
  4. {% block exted_menu %}
  5. {% for cat in page.blog_cat %}
  6. <li class="nav-item"><a class="nav-link" href="{% url 'blog_tag' cat.cb_titre_slgify %}">{{cat.cb_titre}}</a></li>
  7. {% endfor %}
  8. <li class="nav-item"><a class="nav-link" href="{% url 'blog_tag' 'all' %}">Tous les articles</a></li>
  9. {% endblock %}
  10. {% block main %}
  11. <style>
  12. /* Style pour les articles avec miniatures à gauche */
  13. .article-card {
  14. background-color: rgba(250,250,250,0.88);
  15. border-radius: 8px;
  16. overflow: hidden;
  17. margin-bottom: 1.5rem;
  18. box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  19. transition: box-shadow 0.3s ease;
  20. }
  21. .article-card:hover {
  22. box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  23. }
  24. /* Pagination - Style gris foncé */
  25. .pagination .page-link {
  26. color: #343a40;
  27. border-color: #343a40;
  28. background-color: white;
  29. font-weight: 500;
  30. }
  31. .pagination .page-link:hover {
  32. color: white;
  33. background-color: #343a40;
  34. border-color: #343a40;
  35. }
  36. .pagination .page-item.active .page-link {
  37. background-color: #343a40;
  38. border-color: #343a40;
  39. color: white;
  40. }
  41. .pagination .page-item.disabled .page-link {
  42. color: #6c757d;
  43. background-color: #e9ecef;
  44. border-color: #dee2e6;
  45. }
  46. .article-row {
  47. display: flex;
  48. flex-direction: row;
  49. align-items: stretch;
  50. }
  51. .article-image-container {
  52. position: relative;
  53. width: 280px;
  54. min-width: 280px;
  55. overflow: hidden;
  56. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  57. }
  58. .article-image-container::after {
  59. content: '';
  60. position: absolute;
  61. top: 0;
  62. right: 0;
  63. bottom: 0;
  64. width: 60px;
  65. background: linear-gradient(to right, rgba(250,250,250,0) 0%, rgba(250,250,250,0.88) 100%);
  66. pointer-events: none;
  67. }
  68. .article-image-container img {
  69. width: 100%;
  70. height: 100%;
  71. object-fit: cover;
  72. object-position: center;
  73. display: block;
  74. }
  75. .article-image-placeholder {
  76. width: 100%;
  77. height: 100%;
  78. display: flex;
  79. align-items: center;
  80. justify-content: center;
  81. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  82. color: white;
  83. font-size: 2rem;
  84. font-weight: bold;
  85. }
  86. .article-content {
  87. flex: 1;
  88. padding: 1.5rem;
  89. display: flex;
  90. flex-direction: column;
  91. }
  92. .article-title {
  93. font-size: 1.5rem;
  94. font-weight: 700;
  95. color: #1a202c;
  96. margin-bottom: 1rem;
  97. text-decoration: none;
  98. }
  99. .article-title:hover {
  100. color: #667eea;
  101. }
  102. .article-description {
  103. color: #4a5568;
  104. line-height: 1.6;
  105. margin-bottom: 1rem;
  106. flex: 1;
  107. }
  108. .article-footer {
  109. display: flex;
  110. align-items: center;
  111. justify-content: space-between;
  112. padding-top: 1rem;
  113. border-top: 1px solid #e2e8f0;
  114. font-size: 0.9rem;
  115. color: #718096;
  116. }
  117. .article-meta {
  118. display: flex;
  119. align-items: center;
  120. gap: 0.5rem;
  121. flex-wrap: wrap;
  122. }
  123. .article-category {
  124. display: inline-block;
  125. padding: 0.5rem 1rem;
  126. background: #343a40;
  127. color: white;
  128. border-radius: 4px;
  129. font-size: 0.9rem;
  130. font-weight: 500;
  131. text-decoration: none;
  132. transition: background 0.2s;
  133. border: none;
  134. }
  135. .article-category:hover {
  136. background: #23272b;
  137. color: white;
  138. text-decoration: none;
  139. }
  140. /* Responsive */
  141. @media (max-width: 768px) {
  142. .article-row {
  143. flex-direction: column;
  144. }
  145. .article-image-container {
  146. width: 100%;
  147. height: 200px;
  148. }
  149. .article-image-container::after {
  150. top: auto;
  151. bottom: 0;
  152. left: 0;
  153. right: 0;
  154. width: 100%;
  155. height: 40px;
  156. background: linear-gradient(to bottom, rgba(250,250,250,0) 0%, rgba(250,250,250,0.88) 100%);
  157. }
  158. .article-content {
  159. padding: 1rem;
  160. }
  161. .article-title {
  162. font-size: 1.3rem;
  163. }
  164. }
  165. </style>
  166. {% if page.blog_art %}
  167. {% for item in page.blog_art %}
  168. <article class="article-card">
  169. <div class="article-row">
  170. <!-- Miniature à gauche -->
  171. <div class="article-image-container">
  172. {% if item.b_description_img %}
  173. <a href="{% url 'blog_play' item.b_titre_slugify %}">
  174. <img src="{{item.b_description_img}}" alt="{{item.b_titre}}">
  175. </a>
  176. {% else %}
  177. <div class="article-image-placeholder">
  178. <i class="fas fa-file-alt"></i>
  179. </div>
  180. {% endif %}
  181. </div>
  182. <!-- Contenu à droite -->
  183. <div class="article-content">
  184. <a href="{% url 'blog_play' item.b_titre_slugify %}" class="article-title text-decoration-none">
  185. <h2 class="article-title">{{item.b_titre}}</h2>
  186. </a>
  187. <div class="article-description">
  188. {{item.b_description|safe|truncatewords_html:40}}
  189. </div>
  190. <div class="article-footer">
  191. <div class="article-meta">
  192. <span>
  193. <i class="far fa-clock"></i> {{item.b_publdate|timesince}}
  194. </span>
  195. {% if item.b_cat.all %}
  196. {% for cat in item.b_cat.all %}
  197. <a href="{% url 'blog_tag' cat.cb_titre_slgify %}" class="article-category">
  198. {{ cat.cb_titre }}
  199. </a>
  200. {% endfor %}
  201. {% endif %}
  202. </div>
  203. <span class="text-muted">
  204. <i class="far fa-eye"></i> {{item.b_reading}}
  205. </span>
  206. </div>
  207. </div>
  208. </div>
  209. </article>
  210. {% endfor %}
  211. {% else %}
  212. <div class="alert alert-info">
  213. <i class="fas fa-info-circle"></i> Aucun article trouvé.
  214. </div>
  215. {% endif %}
  216. {% endblock %}
  217. {% block right_panel %}
  218. {% if page.p_right != "" %}
  219. <div class="card" style="background-color: rgba(250,250,250,0.88);" >
  220. <div class="card-body">
  221. <form action="" method="get">
  222. <div class="row align-items-center">
  223. <div class="col-lg-8 col-sm-12">
  224. {{page.blog_search|crispy}}
  225. </div>
  226. <div class="col mt-sm-1">
  227. <input type="submit" class="btn btn-success w-100" value="Rechercher">
  228. </div>
  229. </div>
  230. </form>
  231. <hr>
  232. {% if page.blog_art.paginator.num_pages != 1 %}
  233. <nav aria-label="Pagination">
  234. <ul class="pagination justify-content-center flex-wrap">
  235. <!-- Bouton Précédent -->
  236. {% if page.blog_art.has_previous %}
  237. <li class="page-item">
  238. <a class="page-link" href="?page={{ page.blog_art.previous_page_number }}" aria-label="Précédent">
  239. <i class="fas fa-chevron-left"></i>
  240. </a>
  241. </li>
  242. {% else %}
  243. <li class="page-item disabled">
  244. <span class="page-link"><i class="fas fa-chevron-left"></i></span>
  245. </li>
  246. {% endif %}
  247. <!-- Toujours afficher la page 1 -->
  248. {% if page.blog_art.number == 1 %}
  249. <li class="page-item active">
  250. <span class="page-link">1</span>
  251. </li>
  252. {% else %}
  253. <li class="page-item">
  254. <a class="page-link" href="?page=1">1</a>
  255. </li>
  256. {% endif %}
  257. <!-- Ellipse si on est loin du début -->
  258. {% if page.blog_art.number > 4 %}
  259. <li class="page-item disabled">
  260. <span class="page-link">...</span>
  261. </li>
  262. {% endif %}
  263. <!-- Pages autour de la page actuelle -->
  264. {% for num in page.blog_art.paginator.page_range %}
  265. {% if num > 1 and num < page.blog_art.paginator.num_pages %}
  266. {% if num >= page.blog_art.number|add:"-2" and num <= page.blog_art.number|add:"2" %}
  267. {% if num == page.blog_art.number %}
  268. <li class="page-item active">
  269. <span class="page-link">{{ num }}</span>
  270. </li>
  271. {% else %}
  272. <li class="page-item">
  273. <a class="page-link" href="?page={{ num }}">{{ num }}</a>
  274. </li>
  275. {% endif %}
  276. {% endif %}
  277. {% endif %}
  278. {% endfor %}
  279. <!-- Ellipse si on est loin de la fin -->
  280. {% if page.blog_art.number < page.blog_art.paginator.num_pages|add:"-3" %}
  281. <li class="page-item disabled">
  282. <span class="page-link">...</span>
  283. </li>
  284. {% endif %}
  285. <!-- Toujours afficher la dernière page (si elle existe et n'est pas 1) -->
  286. {% if page.blog_art.paginator.num_pages > 1 %}
  287. {% if page.blog_art.number == page.blog_art.paginator.num_pages %}
  288. <li class="page-item active">
  289. <span class="page-link">{{ page.blog_art.paginator.num_pages }}</span>
  290. </li>
  291. {% else %}
  292. <li class="page-item">
  293. <a class="page-link" href="?page={{ page.blog_art.paginator.num_pages }}">{{ page.blog_art.paginator.num_pages }}</a>
  294. </li>
  295. {% endif %}
  296. {% endif %}
  297. <!-- Bouton Suivant -->
  298. {% if page.blog_art.has_next %}
  299. <li class="page-item">
  300. <a class="page-link" href="?page={{ page.blog_art.next_page_number }}" aria-label="Suivant">
  301. <i class="fas fa-chevron-right"></i>
  302. </a>
  303. </li>
  304. {% else %}
  305. <li class="page-item disabled">
  306. <span class="page-link"><i class="fas fa-chevron-right"></i></span>
  307. </li>
  308. {% endif %}
  309. </ul>
  310. </nav>
  311. <hr>
  312. {% endif %}
  313. <p class="card-text">{{page.p_right|safe}}</p>
  314. <h4> <i class="fas fa-tags"></i> Les Catégories </h4>
  315. <p class="card-text">
  316. {% for cat in page.blog_cat %}
  317. <a href="{% url 'blog_tag' cat.cb_titre_slgify %}" class="btn btn-dark mb-2" tabindex="-1" role="button" aria-disabled="true">{{cat.cb_titre}}</a>
  318. {% endfor %}
  319. {% if page.blog_filter == True %}
  320. <a href="{% url 'blog_index' %}" class="btn btn-danger mb-2" tabindex="-1" role="button" aria-disabled="true"><i class="fas fa-filter text-white"></i> Retirer les filtres</a>
  321. {% else %}
  322. <a href="{% url 'blog_tag' 'all' %}" class="btn btn-dark mb-2" tabindex="-1" role="button" aria-disabled="true">Tous les articles</a>
  323. {% endif %}
  324. </p>
  325. <h4> <i class="fas fa-bomb"></i> Les articles les plus consulté </h4>
  326. <p class="card-text">
  327. {% for item in page.blog_top10 %}
  328. <i class="far fa-play-circle"></i> <a class="text-dark" data-bs-toggle="tooltip" data-bs-placement="top" title="{{item.b_titre}}" href="{% url 'blog_play' item.b_titre_slugify %}">{{item.b_titre|truncatechars:40}}</a><br>
  329. {% endfor %}
  330. </p>
  331. {% if page.retour %}
  332. <p class="card-text">
  333. <a href="{% url page.retour %}" class="btn btn-dark mb-2" tabindex="-1" role="button" aria-disabled="true"><i class="fas fa-undo-alt"></i> Retour</a>
  334. </p>
  335. {% endif %}
  336. </div>
  337. </div>
  338. {% endif %}
  339. {% endblock %}