listing.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. <!-- Bouton édition pour les admins -->
  203. {% if user.is_staff %}
  204. <a href="/admin/blog/blog/{{item.id}}/change/"
  205. class="btn btn-sm btn-warning"
  206. target="_blank"
  207. title="Modifier cet article">
  208. <i class="fas fa-edit"></i> Éditer
  209. </a>
  210. {% endif %}
  211. </div>
  212. <span class="text-muted">
  213. <i class="far fa-eye"></i> {{item.b_reading}}
  214. </span>
  215. </div>
  216. </div>
  217. </div>
  218. </article>
  219. {% endfor %}
  220. {% else %}
  221. <div class="alert alert-info">
  222. <i class="fas fa-info-circle"></i> Aucun article trouvé.
  223. </div>
  224. {% endif %}
  225. {% endblock %}
  226. {% block right_panel %}
  227. {% if page.p_right != "" %}
  228. <div class="card" style="background-color: rgba(250,250,250,0.88);" >
  229. <div class="card-body">
  230. <form action="" method="get">
  231. <div class="row align-items-center">
  232. <div class="col-lg-8 col-sm-12">
  233. {{page.blog_search|crispy}}
  234. </div>
  235. <div class="col mt-sm-1">
  236. <input type="submit" class="btn btn-success w-100" value="Rechercher">
  237. </div>
  238. </div>
  239. </form>
  240. <hr>
  241. {% if page.blog_art.paginator.num_pages != 1 %}
  242. <nav aria-label="Pagination">
  243. <ul class="pagination justify-content-center flex-wrap">
  244. <!-- Bouton Précédent -->
  245. {% if page.blog_art.has_previous %}
  246. <li class="page-item">
  247. <a class="page-link" href="?page={{ page.blog_art.previous_page_number }}" aria-label="Précédent">
  248. <i class="fas fa-chevron-left"></i>
  249. </a>
  250. </li>
  251. {% else %}
  252. <li class="page-item disabled">
  253. <span class="page-link"><i class="fas fa-chevron-left"></i></span>
  254. </li>
  255. {% endif %}
  256. <!-- Toujours afficher la page 1 -->
  257. {% if page.blog_art.number == 1 %}
  258. <li class="page-item active">
  259. <span class="page-link">1</span>
  260. </li>
  261. {% else %}
  262. <li class="page-item">
  263. <a class="page-link" href="?page=1">1</a>
  264. </li>
  265. {% endif %}
  266. <!-- Ellipse si on est loin du début -->
  267. {% if page.blog_art.number > 4 %}
  268. <li class="page-item disabled">
  269. <span class="page-link">...</span>
  270. </li>
  271. {% endif %}
  272. <!-- Pages autour de la page actuelle -->
  273. {% for num in page.blog_art.paginator.page_range %}
  274. {% if num > 1 and num < page.blog_art.paginator.num_pages %}
  275. {% if num >= page.blog_art.number|add:"-2" and num <= page.blog_art.number|add:"2" %}
  276. {% if num == page.blog_art.number %}
  277. <li class="page-item active">
  278. <span class="page-link">{{ num }}</span>
  279. </li>
  280. {% else %}
  281. <li class="page-item">
  282. <a class="page-link" href="?page={{ num }}">{{ num }}</a>
  283. </li>
  284. {% endif %}
  285. {% endif %}
  286. {% endif %}
  287. {% endfor %}
  288. <!-- Ellipse si on est loin de la fin -->
  289. {% if page.blog_art.number < page.blog_art.paginator.num_pages|add:"-3" %}
  290. <li class="page-item disabled">
  291. <span class="page-link">...</span>
  292. </li>
  293. {% endif %}
  294. <!-- Toujours afficher la dernière page (si elle existe et n'est pas 1) -->
  295. {% if page.blog_art.paginator.num_pages > 1 %}
  296. {% if page.blog_art.number == page.blog_art.paginator.num_pages %}
  297. <li class="page-item active">
  298. <span class="page-link">{{ page.blog_art.paginator.num_pages }}</span>
  299. </li>
  300. {% else %}
  301. <li class="page-item">
  302. <a class="page-link" href="?page={{ page.blog_art.paginator.num_pages }}">{{ page.blog_art.paginator.num_pages }}</a>
  303. </li>
  304. {% endif %}
  305. {% endif %}
  306. <!-- Bouton Suivant -->
  307. {% if page.blog_art.has_next %}
  308. <li class="page-item">
  309. <a class="page-link" href="?page={{ page.blog_art.next_page_number }}" aria-label="Suivant">
  310. <i class="fas fa-chevron-right"></i>
  311. </a>
  312. </li>
  313. {% else %}
  314. <li class="page-item disabled">
  315. <span class="page-link"><i class="fas fa-chevron-right"></i></span>
  316. </li>
  317. {% endif %}
  318. </ul>
  319. </nav>
  320. <hr>
  321. {% endif %}
  322. <p class="card-text">{{page.p_right|safe}}</p>
  323. <h4> <i class="fas fa-tags"></i> Les Catégories </h4>
  324. <p class="card-text">
  325. {% for cat in page.blog_cat %}
  326. <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>
  327. {% endfor %}
  328. {% if page.blog_filter == True %}
  329. <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>
  330. {% else %}
  331. <a href="{% url 'blog_tag' 'all' %}" class="btn btn-dark mb-2" tabindex="-1" role="button" aria-disabled="true">Tous les articles</a>
  332. {% endif %}
  333. </p>
  334. <h4> <i class="fas fa-bomb"></i> Les articles les plus consulté </h4>
  335. <p class="card-text">
  336. {% for item in page.blog_top10 %}
  337. <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>
  338. {% endfor %}
  339. </p>
  340. {% if page.retour %}
  341. <p class="card-text">
  342. <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>
  343. </p>
  344. {% endif %}
  345. </div>
  346. </div>
  347. {% endif %}
  348. {% endblock %}