""" Script de vérification SEO pour le blog Django Execute ce script pour vérifier que toutes les améliorations SEO sont en place Usage: python check_seo.py """ import sys import os from pathlib import Path def check_file_exists(filepath, description): """Vérifie qu'un fichier existe""" if Path(filepath).exists(): print(f"✅ {description}: {filepath}") return True else: print(f"❌ MANQUANT: {description}: {filepath}") return False def check_file_contains(filepath, search_string, description): """Vérifie qu'un fichier contient une chaîne""" try: with open(filepath, 'r', encoding='utf-8') as f: content = f.read() if search_string in content: print(f"✅ {description}") return True else: print(f"❌ ABSENT: {description}") return False except FileNotFoundError: print(f"❌ FICHIER INTROUVABLE: {filepath}") return False except Exception as e: print(f"❌ ERREUR: {description} - {e}") return False def main(): print("🔍 Vérification des améliorations SEO du blog\n") print("=" * 60) results = [] # 1. Vérifier les nouveaux fichiers print("\n1️⃣ FICHIERS CRÉÉS") print("-" * 60) results.append(check_file_exists("blog/seo_helpers.py", "Helper SEO")) results.append(check_file_exists("blog/templates/blog/seo_meta.html", "Template métadonnées SEO")) results.append(check_file_exists("blog/templates/blog/breadcrumbs.html", "Template breadcrumbs")) # 2. Vérifier les imports dans views.py print("\n2️⃣ IMPORTS DANS LES VUES") print("-" * 60) results.append(check_file_contains( "blog/views.py", "from blog.seo_helpers import SEOMetadata", "Import SEOMetadata" )) results.append(check_file_contains( "blog/views.py", "import json", "Import json pour Schema.org" )) # 3. Vérifier l'utilisation dans blog_play print("\n3️⃣ INTÉGRATION DANS blog_play()") print("-" * 60) results.append(check_file_contains( "blog/views.py", "seo_helper = SEOMetadata", "Initialisation SEOMetadata dans blog_play" )) results.append(check_file_contains( "blog/views.py", "page.breadcrumbs", "Génération des breadcrumbs" )) results.append(check_file_contains( "blog/views.py", "prefetch_related", "Optimisation des requêtes" )) # 4. Vérifier l'intégration dans blog_index print("\n4️⃣ INTÉGRATION DANS blog_index()") print("-" * 60) results.append(check_file_contains( "blog/views.py", "seo = seo_helper.get_listing_metadata", "Métadonnées pour listing" )) # 5. Vérifier le sitemap print("\n5️⃣ CONFIGURATION SITEMAP") print("-" * 60) results.append(check_file_exists("blog/sitemaps.py", "Sitemap Django")) results.append(check_file_contains( "blog/sitemaps.py", "BlogSitemap", "Classe BlogSitemap" )) results.append(check_file_contains( "blog/sitemaps.py", "protocol = 'https'", "Protocol HTTPS dans sitemap" )) # 6. Vérifier robots.txt print("\n6️⃣ ROBOTS.TXT") print("-" * 60) results.append(check_file_exists("static/robots.txt", "Fichier robots.txt")) results.append(check_file_contains( "static/robots.txt", "Sitemap: https://www.duhaz.fr/sitemap.xml", "Référence au sitemap" )) # Résumé print("\n" + "=" * 60) total = len(results) passed = sum(results) failed = total - passed print(f"\n📊 RÉSUMÉ") print("-" * 60) print(f"✅ Tests réussis: {passed}/{total}") print(f"❌ Tests échoués: {failed}/{total}") if failed == 0: print("\n🎉 PARFAIT! Toutes les améliorations SEO sont en place!") print("\n📋 PROCHAINES ÉTAPES:") print(" 1. Mettre à jour core/templates/base.html") print(" 2. Ajouter les breadcrumbs dans listing.html et read.html") print(" 3. Tester avec Google Rich Results Test") print(" 4. Consulter AMELIORATION_SEO.md pour plus de détails") return 0 else: print("\n⚠️ Certaines améliorations sont manquantes.") print(" Consultez AMELIORATION_SEO.md pour les instructions complètes.") return 1 if __name__ == "__main__": sys.exit(main())