diff --git a/db/migrations/20261117090000_add_description_to_articles.php b/db/migrations/20261117090000_add_description_to_articles.php new file mode 100644 index 000000000..4bf0752db --- /dev/null +++ b/db/migrations/20261117090000_add_description_to_articles.php @@ -0,0 +1,22 @@ +table('afup_site_article') + ->addColumn('description', 'string', [ + 'limit' => 255, + 'null' => true, + 'default' => null, + 'after' => 'chapeau', + ]) + ->save() + ; + } +} diff --git a/db/seeds/SiteRubrique.php b/db/seeds/SiteRubrique.php index f2d2a9b95..c384d2972 100644 --- a/db/seeds/SiteRubrique.php +++ b/db/seeds/SiteRubrique.php @@ -16,6 +16,13 @@ public function run(): void 'nom' => "Actualités", 'etat' => 1, ], + [ + 'id' => Rubrique::ID_RUBRIQUE_ASSOCIATION, + 'id_parent' => 0, + 'nom' => "Association", + 'raccourci' => 'association', + 'etat' => 1, + ], ]; $table = $this->table('afup_site_rubrique'); diff --git a/db/seeds/Users.php b/db/seeds/Users.php index e4d57b391..1795f3f38 100644 --- a/db/seeds/Users.php +++ b/db/seeds/Users.php @@ -29,6 +29,7 @@ public function run(): void 'prenom' => 'Raoul', 'email' => 'raoul.dupont@mycorp.fr', 'raison_sociale' => 'MyCorp', + 'description' => "MyCorp développe des applications PHP sur mesure & accompagne les équipes dans leurs migrations.", 'siret' => '4445451', 'adresse' => '12 cours Hopper', 'code_postal' => '69001', diff --git a/sources/AppBundle/Site/Entity/Article.php b/sources/AppBundle/Site/Entity/Article.php index 8dc86d085..d4c7dc62f 100644 --- a/sources/AppBundle/Site/Entity/Article.php +++ b/sources/AppBundle/Site/Entity/Article.php @@ -31,6 +31,9 @@ class Article #[ORM\Column(type: 'text', nullable: true)] public ?string $chapeau = null; + #[ORM\Column(length: 255, nullable: true)] + public ?string $description = null; + #[ORM\Column(type: 'text', nullable: true)] public ?string $contenu = null; diff --git a/sources/AppBundle/Site/Form/ArticleType.php b/sources/AppBundle/Site/Form/ArticleType.php index 641c87cbf..c8d86ea78 100644 --- a/sources/AppBundle/Site/Form/ArticleType.php +++ b/sources/AppBundle/Site/Form/ArticleType.php @@ -86,6 +86,20 @@ public function buildForm(FormBuilderInterface $builder, array $options): void new Assert\Type('string'), ], ]) + ->add('description', TextareaType::class, [ + 'label' => 'Description', + 'required' => false, + 'help' => 'Résumé affiché par les moteurs de recherche (155 caractères conseillés). ' + . 'Si ce champ est vide, le début du contenu est utilisé.', + 'attr' => [ + 'maxlength' => 255, + 'rows' => 3, + ], + 'constraints' => [ + new Assert\Length(max: 255), + new Assert\Type('string'), + ], + ]) ->add('image', FileType::class, [ 'label' => 'Image de couverture', 'required' => false, diff --git a/templates/admin/association/membership/register.html.twig b/templates/admin/association/membership/register.html.twig index b129a27e4..776e4d94d 100644 --- a/templates/admin/association/membership/register.html.twig +++ b/templates/admin/association/membership/register.html.twig @@ -3,6 +3,8 @@ {% block page_title %}Formulaire d'inscription à l'AFUP{% endblock %} +{% block description %}Formulaire d'adhésion individuelle à l'AFUP : créez votre compte de membre pour soutenir la communauté PHP francophone.{% endblock %} + {% block content %}

{{ "Formulaire d'inscription à l'AFUP"|trans }}

diff --git a/templates/admin/site/article_form.html.twig b/templates/admin/site/article_form.html.twig index 9dae5c96e..cdcdbd8ad 100644 --- a/templates/admin/site/article_form.html.twig +++ b/templates/admin/site/article_form.html.twig @@ -51,6 +51,7 @@
+ {{ form_row(form.description) }} {{ form_row(form.raccourci) }} {{ form_row(form.rubrique) }} {{ form_row(form.datePublication) }} diff --git a/templates/site/become_member.html.twig b/templates/site/become_member.html.twig index a79244646..6a5938752 100644 --- a/templates/site/become_member.html.twig +++ b/templates/site/become_member.html.twig @@ -3,6 +3,8 @@ {% block title %}Devenir membre de l'AFUP{% endblock %} +{% block description %}Adhérez à l'AFUP en tant que particulier ou entreprise pour soutenir la communauté PHP francophone : Forum PHP, AFUP Day, antennes, mentorat.{% endblock %} + {% block content %} {% set membership_benefits = [ diff --git a/templates/site/cms_page/display.html.twig b/templates/site/cms_page/display.html.twig index 869fddbbd..519cf99fe 100644 --- a/templates/site/cms_page/display.html.twig +++ b/templates/site/cms_page/display.html.twig @@ -3,6 +3,9 @@ {% block title %}{{ article.titre }} - AFUP{% endblock %} +{# Description saisie dans l'admin, à défaut le début du contenu. #} +{% block description %}{{ (article.description ?: article.contenu|markdown_to_html)|meta_description }}{% endblock %} + {% block content %}

{{ article.titre }}

diff --git a/templates/site/company_membership/adhesion_entreprise.html.twig b/templates/site/company_membership/adhesion_entreprise.html.twig index 0ada2403d..b3beec2b8 100644 --- a/templates/site/company_membership/adhesion_entreprise.html.twig +++ b/templates/site/company_membership/adhesion_entreprise.html.twig @@ -3,6 +3,8 @@ {% block page_title %}Adhésion entreprise à l'AFUP{% endblock %} +{% block description %}Formulaire d'adhésion à l'AFUP réservé aux entreprises : créez le compte de votre société pour soutenir l'association et la communauté PHP française.{% endblock %} + {% block content %}

{{ "Adhésion entreprise à l'AFUP"|trans }}

diff --git a/templates/site/company_public_profile.html.twig b/templates/site/company_public_profile.html.twig index feb3d1668..94c5a6e9d 100644 --- a/templates/site/company_public_profile.html.twig +++ b/templates/site/company_public_profile.html.twig @@ -10,6 +10,8 @@ {% block title %}{{ company_member.companyName }} est adhérente à l'AFUP{% endblock %} +{% block description %}{{ (company_member.description ?: company_member.companyName ~ " est une entreprise adhérente à l'AFUP et soutient la communauté PHP française.")|meta_description }}{% endblock %} + {% set logo_url = path('company_public_profile_logo', {id : company_member.id, slug: company_member.slug }) %} {% block metas %} diff --git a/templates/site/company_public_profile_list.html.twig b/templates/site/company_public_profile_list.html.twig index bf56324ea..ff6c8c066 100644 --- a/templates/site/company_public_profile_list.html.twig +++ b/templates/site/company_public_profile_list.html.twig @@ -10,6 +10,8 @@ {% block title %}Les entreprises adhérentes à l'AFUP{% endblock %} +{% block description %}Les entreprises adhérentes à l'AFUP, qui soutiennent l'association et la communauté PHP française : présentation, site web et antennes de rattachement.{% endblock %} + {% block content %}
diff --git a/templates/site/meetups/list.html.twig b/templates/site/meetups/list.html.twig index 2ef712c56..38e11ccd8 100644 --- a/templates/site/meetups/list.html.twig +++ b/templates/site/meetups/list.html.twig @@ -3,6 +3,8 @@ {% block title %}Les meetups des antennes de l'AFUP{% endblock %} +{% block description %}Les meetups organisés par les antennes locales de l'AFUP partout en France : prochains rendez-vous et événements passés de la communauté PHP.{% endblock %} + {% block javascripts %} {{ parent() }} {# `defer` obligatoire : ce bloc est rendu dans le , sans lui instantsearch diff --git a/templates/site/news/display.html.twig b/templates/site/news/display.html.twig index c44b87e46..a59618ed4 100644 --- a/templates/site/news/display.html.twig +++ b/templates/site/news/display.html.twig @@ -18,7 +18,8 @@ {% block title %}{{ article.titre }} - AFUP{% endblock %} -{% block description %}{{ (article.chapeau ?: article.contenu)|markdown_to_html|meta_description }}{% endblock %} +{# Description saisie dans l'admin, à défaut le chapeau ou le début du contenu. #} +{% block description %}{{ (article.description ?: (article.chapeau ?: article.contenu)|markdown_to_html)|meta_description }}{% endblock %} {% block content %} diff --git a/tests/behat/features/Admin/Site/AdminSiteArticles.feature b/tests/behat/features/Admin/Site/AdminSiteArticles.feature index a35fc2155..8d5c10a1a 100644 --- a/tests/behat/features/Admin/Site/AdminSiteArticles.feature +++ b/tests/behat/features/Admin/Site/AdminSiteArticles.feature @@ -29,6 +29,7 @@ Feature: Administration - Partie Site And I fill in "article[titre]" with "Le titre de l'article" And I fill in "article[chapeau]" with "Le chapeau de l'article" And I fill in "article[contenu]" with "Le contenu de l'article" + And I fill in "article[description]" with "La description de l'article" And I fill in "article[raccourci]" with "url-article" And I select "Actualités" from "article[rubrique]" And I select "9" from "article[position]" @@ -43,6 +44,7 @@ Feature: Administration - Partie Site Then I should see "Le titre de l'article" Then I should see "Le chapeau de l'article" Then I should see "Le contenu de l'article" + And the meta description should be "La description de l'article" # modification d'un article When I follow "Administration" @@ -198,3 +200,36 @@ Feature: Administration - Partie Site # l'image n'est plus affichée sur la page publique When I go to "/news/17-url-article-illustre" Then I should not see a "article main figure img" element + + @reloadDbWithTestData + Scenario: Description d'une page CMS, avec repli sur le début du contenu + Given I am logged in as admin and on the Administration + And I follow "Articles" + When I follow "Ajouter" + Then I should see "Ajouter un article" + And I fill in "article[titre]" with "Les statuts" + And I fill in "article[contenu]" with "Les **statuts** de l'association, adoptés en assemblée générale." + And I fill in "article[description]" with "Les statuts de l'AFUP & leur historique." + And I fill in "article[raccourci]" with "statuts" + And I select "Association" from "article[rubrique]" + And I select "En ligne" from "article[etat]" + And I press "Ajouter" + Then I should see "Liste des articles" + + # la description saisie est la meta description de la page + When I go to "/p/17-statuts" + Then I should see "Les statuts" + And the meta description should be "Les statuts de l'AFUP & leur historique." + + # la description est éditable + When I follow "Administration" + And I follow "Articles" + And I follow "modifier_17" + Then the "article[description]" field should contain "Les statuts de l'AFUP & leur historique." + When I fill in "article[description]" with "" + And I press "Modifier" + Then I should see "L'article Les statuts a été modifié" + + # sans description, la meta description reprend le début du contenu, sans Markdown + When I go to "/p/17-statuts" + Then the meta description should be "Les statuts de l'association, adoptés en assemblée générale." diff --git a/tests/behat/features/Admin/Site/AdminSiteRubriques.feature b/tests/behat/features/Admin/Site/AdminSiteRubriques.feature index 9a53bc31a..d262c8971 100644 --- a/tests/behat/features/Admin/Site/AdminSiteRubriques.feature +++ b/tests/behat/features/Admin/Site/AdminSiteRubriques.feature @@ -24,7 +24,7 @@ Feature: Administration - Partie Site Then I should see "Liste des rubriques" And the ".content table" element should contain "Évènement" # modification d'une rubrique - When I follow "modifier_10" + When I follow "modifier_86" Then I should see "Modifier une rubrique" When I fill in "rubrique[nom]" with "Évènements" And I press "Modifier" @@ -35,10 +35,10 @@ Feature: Administration - Partie Site Then I should see "Liste des articles" When I follow "Ajouter" Then I should see "Ajouter un article" - Then The "article[rubrique]" field should only contain the follow values '["Actualités", "Évènements"]' + Then The "article[rubrique]" field should only contain the follow values '["Actualités", "Association", "Évènements"]' # suppression d'une rubrique When I follow "Rubriques" - And I follow "supprimer_10" + And I follow "supprimer_86" Then I should see "Liste des rubriques" But the ".content table" element should not contain "Évènements" diff --git a/tests/behat/features/PublicSite/MetaDescriptions.feature b/tests/behat/features/PublicSite/MetaDescriptions.feature new file mode 100644 index 000000000..6961e02d7 --- /dev/null +++ b/tests/behat/features/PublicSite/MetaDescriptions.feature @@ -0,0 +1,32 @@ +Feature: Site Public - Meta descriptions des gabarits + + @reloadDbWithTestData + Scenario: Meta description de la liste des entreprises adhérentes + Given I am on "/profile/company" + Then the meta description should be "Les entreprises adhérentes à l'AFUP, qui soutiennent l'association et la communauté PHP française : présentation, site web et antennes de rattachement." + + @reloadDbWithTestData + Scenario: Meta description d'une entreprise tirée de sa description + Given I am on "/profile/company/1-mycorp" + Then the meta description should be "MyCorp développe des applications PHP sur mesure & accompagne les équipes dans leurs migrations." + + @reloadDbWithTestData + Scenario: Meta description d'une entreprise sans description + Given I am on "/profile/company/2-helios-aerospace" + Then the meta description should be "Helios Aerospace est une entreprise adhérente à l'AFUP et soutient la communauté PHP française." + + Scenario: Meta description de la liste des meetups + Given I am on "/meetups/" + Then the meta description should be "Les meetups organisés par les antennes locales de l'AFUP partout en France : prochains rendez-vous et événements passés de la communauté PHP." + + Scenario: Meta description de la page « Devenir membre » + Given I am on "/association/devenir-membre" + Then the meta description should be "Adhérez à l'AFUP en tant que particulier ou entreprise pour soutenir la communauté PHP francophone : Forum PHP, AFUP Day, antennes, mentorat." + + Scenario: Meta description du formulaire d'adhésion particulier + Given I am on "/association/adherer/particulier" + Then the meta description should be "Formulaire d'adhésion individuelle à l'AFUP : créez votre compte de membre pour soutenir la communauté PHP francophone." + + Scenario: Meta description du formulaire d'adhésion entreprise + Given I am on "/association/adherer/entreprise" + Then the meta description should be "Formulaire d'adhésion à l'AFUP réservé aux entreprises : créez le compte de votre société pour soutenir l'association et la communauté PHP française."