Introduction des tags opengraph dans l'entête (compatibilité FB)

This commit is contained in:
Jean-Marie Favreau 2024-08-21 14:18:56 +02:00
parent cb889df131
commit a09fecfd11
56 changed files with 90 additions and 71 deletions

View File

@ -552,6 +552,21 @@ class Event(models.Model):
else:
return recurrences[0]
def get_image_url(self):
if self.local_image and hasattr(self.local_image, "url"):
try:
return self.local_image.url
except:
pass
if self.image:
return self.image
else:
return None
def has_image_url(self):
return self.get_image_url() is not None
# return a copy of the current object for each recurrence between first an last date (included)
def get_recurrences_between(self, firstdate, lastdate):
if not self.has_recurrences():

View File

@ -1,7 +1,7 @@
{% extends "agenda_culturel/page.html" %}
{% load static %}
{% block title %}Importation manuelle{% endblock %}
{% block title %}{% block og_title %}Importation manuelle{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Supprimer {{ object.title }}{% endblock %}
{% block title %}{% block og_title %}Supprimer {{ object.title }}{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Règles de catégorisation{% endblock %}
{% block title %}{% block og_title %}Règles de catégorisation{% endblock %}{% endblock %}
{% load utils_extra %}
{% load cat_extra %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Supprimer la règle de catégorisation {{ object.pk }}{% endblock %}
{% block title %}{% block og_title %}Supprimer la règle de catégorisation {{ object.pk }}{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,7 +1,7 @@
{% extends "agenda_culturel/page.html" %}
{% load static %}
{% block title %}Règle de catéorisation{% endblock %}
{% block title %}{% block og_title %}Règle de catéorisation{% endblock %}{% endblock %}
{% block entete_header %}
<script src="/static/admin/js/vendor/jquery/jquery.js"></script>

View File

@ -6,7 +6,7 @@
{% load tag_extra %}
{% block title %}Appliquer les catégorisations{% endblock %}
{% block title %}{% block og_title %}Appliquer les catégorisations{% endblock %}{% endblock %}
{% block entete_header %}
<script src="/static/admin/js/vendor/jquery/jquery.js"></script>

View File

@ -1,7 +1,7 @@
{% extends "agenda_culturel/page.html" %}
{% load static %}
{% block title %}Contact{% endblock %}
{% block title %}{% block og_title %}Contact{% endblock %}{% endblock %}
{% block entete_header %}
<script>window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';</script>

View File

@ -1,7 +1,7 @@
{% extends "agenda_culturel/page.html" %}
{% load static %}
{% block title %}Message de contact : {{ obj.subject }}{% endblock %}
{% block title %}{% block og_title %}Message de contact : {{ obj.subject }}{% endblock %}{% endblock %}
{% block entete_header %}
<script>window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';</script>

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Derniers messages de contact reçus{% endblock %}
{% block title %}{% block og_title %}Derniers messages de contact reçus{% endblock %}{% endblock %}
{% load utils_extra %}
{% load cat_extra %}

View File

@ -3,7 +3,7 @@
{% load utils_extra %}
{% load event_extra %}
{% block title %}Événements possiblement dupliqués{% endblock %}
{% block title %}{% block og_title %}Événements possiblement dupliqués{% endblock %}{% endblock %}
{% load cat_extra %}
{% block entete_header %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}
{% block title %}{% block og_title %}
{% if status == "published" %}
Publier l'événement {{ event.title }}
{% elif status == "draft" %}
@ -8,7 +8,7 @@ Déplacer l'événement {{ event.title }} dans les brouillons
{% elif status == "trash" %}
Mettre l'événement {{ event.title }} à la corbeille
{% endif %}
{% endblock %}
{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Supprimer {{ object.title }}{% endblock %}
{% block title %}{% block og_title %}Supprimer {{ object.title }}{% endblock %}{% endblock %}
{% block content %}

View File

@ -2,7 +2,7 @@
{% load static %}
{% block title %}
{% block title %}{% block og_title %}
{% if object %}
Édition de l'événement {{ object.title }} ({{ object.start_day }})
{% else %}
@ -12,7 +12,7 @@
Ajouter un événement
{% endif %}
{% endif %}
{% endblock %}
{% endblock %}{% endblock %}
{% block entete_header %}
<script src="{% url 'jsi18n' %}"></script>

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Ajouter un événement{% endblock %}
{% block title %}{% block og_title %}Ajouter un événement{% endblock %}{% endblock %}
{% load cat_extra %}

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block title %}Modérer {{ object.title }}{% endblock %}
{% block title %}{% block og_title %}Modérer {{ object.title }}{% endblock %}{% endblock %}

View File

@ -3,7 +3,7 @@
{% load utils_extra %}
{% load event_extra %}
{% block title %}Événements possiblement dupliqués{% endblock %}
{% block title %}{% block og_title %}Événements possiblement dupliqués{% endblock %}{% endblock %}
{% load cat_extra %}
{% block entete_header %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Importer un événement{% endblock %}
{% block title %}{% block og_title %}Importer un événement{% endblock %}{% endblock %}
{% load static %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Importer un ensemble d'événements{% endblock %}
{% block title %}{% block og_title %}Importer un ensemble d'événements{% endblock %}{% endblock %}
{% load static %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Importations par lot{% endblock %}
{% block title %}{% block og_title %}Importations par lot{% endblock %}{% endblock %}
{% load utils_extra %}
{% load cat_extra %}

View File

@ -3,7 +3,7 @@
{% load utils_extra %}
{% load event_extra %}
{% block title %}Fusionner les événements dupliqués{% endblock %}
{% block title %}{% block og_title %}Fusionner les événements dupliqués{% endblock %}{% endblock %}
{% load cat_extra %}
{% block entete_header %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Derniers événements soumis{% endblock %}
{% block title %}{% block og_title %}Derniers événements soumis{% endblock %}{% endblock %}
{% load cat_extra %}
{% block entete_header %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Supprimer la réponse #{{ object.pk }}{% endblock %}
{% block title %}{% block og_title %}Supprimer la réponse #{{ object.pk }}{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,7 +1,7 @@
{% extends "agenda_culturel/page.html" %}
{% load static %}
{% block title %}{% if form.instance.pk %}Modification{% else %}Création{% endif %} d'une réponse de modération{% endblock %}
{% block title %}{% block og_title %}{% if form.instance.pk %}Modification{% else %}Création{% endif %} d'une réponse de modération{% endblock %}{% endblock %}
{% block entete_header %}
<script>window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';</script>

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Supprimer la question #{{ object.pk }}{% endblock %}
{% block title %}{% block og_title %}Supprimer la question #{{ object.pk }}{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Question de modération #{{ object.pk }}{% endblock %}
{% block title %}{% block og_title %}Question de modération #{{ object.pk }}{% endblock %}{% endblock %}
{% load tag_extra %}
{% load utils_extra %}

View File

@ -2,9 +2,9 @@
{% load static %}
{% block title %}
{% block title %}{% block og_title %}
{% if form.instance.pk %}Modification{% else %}Création{% endif %} d'une question de modération
{% endblock %}
{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Questions de modération{% endblock %}
{% block title %}{% block og_title %}Questions de modération{% endblock %}{% endblock %}
{% load utils_extra %}
{% load cat_extra %}

View File

@ -15,9 +15,9 @@
<script src="{% static 'js/filters.js' %}"></script>
{% endblock %}
{% block title %}
{% block title %}{% block og_title %}
{{ day | date:"l j F Y"|frdate }}
{% endblock %}
{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,10 +1,13 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}{{ object.title }}{% endblock %}
{% load cat_extra %}
{% load utils_extra %}
{% block title %}{% block og_title %}{{ event.title }}{% endblock %}{% endblock %}
{% block og_image %}{% if event.has_image_url %}{{ event.get_image_url }}{% else %}{{ block.super }}{% endif %}{% endblock %}
{% block og_description %}{% if event.description %}{{ event.description |truncatewords:20|linebreaks }}{% else %}{{ block.super }}{% endif %}{% endblock %}
{% block entete_header %}
{% css_categories %}
{% endblock %}

View File

@ -16,9 +16,9 @@
<script src="{% static 'js/filters.js' %}"></script>
{% endblock %}
{% block title %}
{% block title %}{% block og_title %}
{{ calendar.firstdate | date:"F o" }}
{% endblock %}
{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Import récurrent #{{ object.pk }}{% endblock %}
{% block title %}{% block og_title %}Import récurrent #{{ object.pk }}{% endblock %}{% endblock %}
{% load cat_extra %}
{% load utils_extra %}

View File

@ -9,9 +9,9 @@
{% load static_content_extra %}
{% block title %}
{% block title %}{% block og_title %}
{{ title }}
{% endblock %}
{% endblock %}{% endblock %}
{% block fluid %}{% endblock %}

View File

@ -1,7 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% load i18n %}
{% load cat_extra %}
@ -16,9 +15,7 @@
<script src="{% static 'js/filters.js' %}"></script>
{% endblock %}
{% block title %}
Semaine du {{ calendar.calendar_days_list.0.date|date|frdate }}
{% endblock %}
{% block title %}{% block og_title %}Semaine du {{ calendar.calendar_days_list.0.date|date|frdate }}{% endblock %}{% endblock %}
{% block content %}

View File

@ -5,8 +5,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pommes de lune — {% block title %}{% endblock %}</title>
{% load static %}
<meta property="og:title" content="Pommes de lune — {% block og_title %}{% endblock %}" />
<meta property="og:description" content="{% block og_description %}Événements culturels à Clermont-Ferrand et aux environs{% endblock %}" />
<meta property="og:image" content="{% block og_image %}{% static 'images/capture.png' %}{% endblock %}" />
<meta property="og:url" content="{{ request.build_absolute_uri }}" />
{% if debug %}
<link rel="icon" type="image/svg+xml" href="{% static 'images/favicon-dev.svg' %}">
{% else %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Supprimer {{ object.name }}{% endblock %}
{% block title %}{% block og_title %}Supprimer {{ object.name }}{% endblock %}{% endblock %}
{% block fluid %}{% endblock %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}#{{ object.name }}{% endblock %}
{% block title %}{% block og_title %}#{{ object.name }}{% endblock %}% endblock %}
{% load tag_extra %}
{% load utils_extra %}

View File

@ -1,9 +1,9 @@
{% extends "agenda_culturel/page.html" %}
{% load static %}
{% block title %}
{% block title %}{% block og_title %}
{% if form.instance.pk %}Modification{% else %}Création{% endif %} d'un lieu
{% endblock %}
{% endblock %}{% endblock %}
{% load cat_extra %}
{% block entete_header %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Lieux{% endblock %}
{% block title %}{% block og_title %}Lieux{% endblock %}{% endblock %}
{% load utils_extra %}
{% load static %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Administration des lieux{% endblock %}
{% block title %}{% block og_title %}Administration des lieux{% endblock %}{% endblock %}
{% load utils_extra %}
{% load cat_extra %}

View File

@ -2,7 +2,7 @@
{% load static %}
{% block title %}Ajouter un lieu à {{ object.title }}{% endblock %}
{% block title %}{% block og_title %}Ajouter un lieu à {{ object.title }}{% endblock %}{% endblock %}
{% load cat_extra %}

View File

@ -2,7 +2,7 @@
{% load utils_extra %}
{% block title %}Événements sans lieu{% endblock %}
{% block title %}{% block og_title %}Événements sans lieu{% endblock %}{% endblock %}
{% load cat_extra %}
{% block entete_header %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Supprimer {{ object.title }}{% endblock %}
{% block title %}{% block og_title %}Supprimer {{ object.title }}{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,7 +1,7 @@
{% extends "agenda_culturel/page.html" %}
{% load static %}
{% block title %}Importation récurrente{% endblock %}
{% block title %}{% block og_title %}Importation récurrente{% endblock %}{% endblock %}
{% block entete_header %}
<script src="/static/admin/js/vendor/jquery/jquery.js"></script>

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Importations récurrentes{% endblock %}
{% block title %}{% block og_title %}Importations récurrentes{% endblock %}{% endblock %}
{% load utils_extra %}
{% load cat_extra %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Lancer tous les imports{% endblock %}
{% block title %}{% block og_title %}Lancer tous les imports{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Lancer l'import #{{ object.pk }}{% endblock %}
{% block title %}{% block og_title %}Lancer l'import #{{ object.pk }}{% endblock %}{% endblock %}
{% block content %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Rechercher un événement{% endblock %}
{% block title %}{% block og_title %}Rechercher un événement{% endblock %}{% endblock %}
{% load utils_extra %}
{% load tag_extra %}

View File

@ -3,7 +3,7 @@
{% load utils_extra %}
{% load event_extra %}
{% block title %}{% if user.is_authenticated %}Marquer comme doublon{% else %}Signaler comme doublon{% endif %}{% endblock %}
{% block title %}{% block og_title %}{% if user.is_authenticated %}Marquer comme doublon{% else %}Signaler comme doublon{% endif %}{% endblock %}{% endblock %}
{% load cat_extra %}
{% block entete_header %}

View File

@ -20,9 +20,9 @@
</p>
</header>
{% if event.image or event.local_image %}
{% if event.has_image_url %}
<article class='illustration'>
<img src="{% if event.local_image %}{{ event.local_image.url }}{% else %}{{ event.image }}{% endif %}" alt="{{ event.image_alt }}" />
<img src="{{ event.get_image_url }}" alt="{{ event.image_alt }}" />
</article>
{% endif %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Modifier {{ object.name }}{% endblock %}
{% block title %}{% block og_title %}Modifier {{ object.name }}{% endblock %}{% endblock %}
{% block entete_header %}
{% load static %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Les événements {{ tag }}{% endblock %}
{% block title %}{% block og_title %}Les événements {{ tag }}{% endblock %}{% endblock %}
{% load cat_extra %}

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Toutes les étiquettes{% endblock %}
{% block title %}{% block og_title %}Toutes les étiquettes{% endblock %}{% endblock %}
{% load cat_extra %}

View File

@ -1,6 +1,7 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Merci !{% endblock %}
{% block title %}{% block og_title %}Merci !{% endblock %}{% endblock %}
{% block og_image %}{% static 'images/merci.svg' %}{% endblock %}
{% load utils_extra %}
{% load static %}

View File

@ -9,10 +9,9 @@
{% load static_content_extra %}
{% block title %}
Y'a un pépin ({{ error }})
{% endblock %}
{% block title %}{% block og_title %}Y'a un pépin ({{ error }}){% endblock %}{% endblock %}
{% block og_description %}On a rencontré un pépin en cherchant la page que tu as demandée !{% endblock %}
{% block og_image %}{% static 'images/pommes.svg' %}{% endblock %}
{% block content %}
@ -21,7 +20,7 @@ Y'a un pépin ({{ error }})
<h1>Y'a un pépin (erreur {{ error }})</h1>
</header>
<div class="grid two-columns-2">
<p>On a rencontré un pépin en cherchant la page que tu as demandé&nbsp;! N'hésites pas à <a href="{% url 'contact' %}">nous signaler
<p>On a rencontré un pépin en cherchant la page que tu as demandée&nbsp;! N'hésites pas à <a href="{% url 'contact' %}">nous signaler
tout ça</a> si tu penses qu'il y a un bug dans la compote.</p>
<div class="image"><img src="{% static 'images/pommes.svg' %}" alt="quelques pommes et leur pépins" /></div>
</div>

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page.html" %}
{% block title %}Connexion{% endblock %}
{% block title %}{% block og_title %}Connexion{% endblock %}{% endblock %}
{% block content %}
<h1>Connexion</h1>