From d5e90d82b56697dcfa9b6b053257bfcc9b920126 Mon Sep 17 00:00:00 2001 From: Xavier Leune Date: Tue, 17 Nov 2026 16:10:47 +0100 Subject: [PATCH] =?UTF-8?q?Arr=C3=AAte=20de=20faire=20crawler=20les=20redi?= =?UTF-8?q?rections=20/joindin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chaque page vidéo expose un lien interne /talks/{id}-{slug}/joindin qui répond par une 302 vers joind.in : les robots suivent ainsi des centaines de liens sans valeur. Les liens générés (fiche talk, widget programme du blog, liste Algolia) portent désormais rel="nofollow" (ajouté à "noopener" dans la liste JS), et robots.txt interdit /talks/*/joindin pour tous les robots. --- htdocs/js/talk/list.js | 6 ++-- htdocs/robots.txt | 3 ++ templates/blog/program.html.twig | 2 +- templates/site/talks/show.html.twig | 4 +-- tests/behat/bootstrap/FeatureContext.php | 29 +++++++++++++++++++ tests/behat/features/PublicSite/Talks.feature | 14 +++++++++ 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/htdocs/js/talk/list.js b/htdocs/js/talk/list.js index c7b9b5bb8..2fa9f7052 100644 --- a/htdocs/js/talk/list.js +++ b/htdocs/js/talk/list.js @@ -104,8 +104,8 @@ search.addWidget( : '/images/no_video.jpg'; var links = ''; - var link = function (href, svg, label) { - return '' + icon(svg, 'size-3.5') + label + ''; }; @@ -117,7 +117,7 @@ search.addWidget( links += link(data.slides_url, ICONS.slides, 'Slides'); } if (typeof data.joindin_url !== 'undefined') { - links += link(data.joindin_url, ICONS.comments, 'Fiche joind.in'); + links += link(data.joindin_url, ICONS.comments, 'Fiche joind.in', 'noopener nofollow'); } return '' diff --git a/htdocs/robots.txt b/htdocs/robots.txt index 63f086d2b..4bcc59be8 100644 --- a/htdocs/robots.txt +++ b/htdocs/robots.txt @@ -83,3 +83,6 @@ User-agent: Timpibot # Target Disallow: / + +User-agent: * +Disallow: /talks/*/joindin diff --git a/templates/blog/program.html.twig b/templates/blog/program.html.twig index 5d60461a1..08e2584c6 100644 --- a/templates/blog/program.html.twig +++ b/templates/blog/program.html.twig @@ -64,7 +64,7 @@ {% if display_joindin_links and talk.talk.getJoindinUrl %}
{% endif %} diff --git a/templates/site/talks/show.html.twig b/templates/site/talks/show.html.twig index 15a0bc494..ed3eddc3c 100644 --- a/templates/site/talks/show.html.twig +++ b/templates/site/talks/show.html.twig @@ -159,7 +159,7 @@ { shown: talk.hasSlidesUrl, url: talk.getSlidesurl, icon: 'mingcute:presentation-1-fill', label: 'Slides' }, { shown: talk.hasBlogPostUrl, url: talk.getBlogPostUrl, icon: 'mingcute:rss-fill', label: 'Article de blog' }, { shown: talk.hasInterviewUrl, url: talk.getInterviewUrl, icon: 'mingcute:news-2-fill', label: 'Interview' }, - { shown: talk.hasJoindinId, url: talk.getJoindinUrl, icon: 'mingcute:message-3-fill', label: 'Fiche joind.in' }, + { shown: talk.hasJoindinId, url: talk.getJoindinUrl, icon: 'mingcute:message-3-fill', label: 'Fiche joind.in', rel: 'nofollow' }, { shown: talk.hasOpenfeedbackPath, url: talk.getOpenfeedbackUrl, icon: 'mingcute:message-3-fill', label: 'Fiche openfeedback.io' }, ]|filter(link => link.shown) %} @@ -167,7 +167,7 @@
{% for link in links %} - {{ link.label }} diff --git a/tests/behat/bootstrap/FeatureContext.php b/tests/behat/bootstrap/FeatureContext.php index 4b96c2a1e..7b1dbb66e 100644 --- a/tests/behat/bootstrap/FeatureContext.php +++ b/tests/behat/bootstrap/FeatureContext.php @@ -294,6 +294,35 @@ public function shouldSeeImage(string $source): void } } + /** + * Échoue aussi si aucun lien ne correspond, pour ne pas passer à vide. + * exemple: + * all links with href containing "/joindin" should have rel containing "nofollow" + */ + #[Then('/^all links with href containing "(?P(?:[^"]|\\")*)" should have rel containing "(?P(?:[^"]|\\")*)"$/')] + public function allLinksShouldHaveRel(string $href, string $rel): void + { + $links = $this->minkContext->getSession()->getPage()->findAll('css', sprintf('a[href*="%s"]', $href)); + + if ([] === $links) { + throw new ExpectationException( + sprintf('No link with href containing "%s" was found', $href), + $this->minkContext->getSession()->getDriver(), + ); + } + + foreach ($links as $link) { + $relTokens = preg_split('/\s+/', (string) $link->getAttribute('rel'), -1, PREG_SPLIT_NO_EMPTY); + + if (!in_array($rel, $relTokens, true)) { + throw new ExpectationException( + sprintf('The link "%s" has rel "%s", which does not contain "%s"', $link->getAttribute('href'), $link->getAttribute('rel'), $rel), + $this->minkContext->getSession()->getDriver(), + ); + } + } + } + #[Then('/^(?:|I )click on link with (class|id) "(?P(?:[^"]|\\")*)"$/')] public function clickOnLink(string $type, string $text): void { diff --git a/tests/behat/features/PublicSite/Talks.feature b/tests/behat/features/PublicSite/Talks.feature index db8a89bac..4432aa5ba 100644 --- a/tests/behat/features/PublicSite/Talks.feature +++ b/tests/behat/features/PublicSite/Talks.feature @@ -35,3 +35,17 @@ Feature: Site Public - Talks When I go to "/talks/?q=&hPP=7&idx=afup_talks&p=0&fR[event.title][0]=AFUP Day 2019 Lyon&fR[speakers.label][0]=Un Speaker" Then I should see "Les vidéos de Un Speaker" And the response should contain "" + + @reloadDbWithTestData + Scenario: Les liens vers joind.in d'un talk ne sont pas suivis par les robots + When I go to "/talks/1-jouons-tous-ensemble-a-un-petit-jeu" + Then I should see "Fiche joind.in" + And all links with href containing "/joindin" should have rel containing "nofollow" + + Scenario: Le robots.txt interdit le crawl des redirections joind.in + When I go to "/robots.txt" + Then the response should contain the html + """ + User-agent: * + Disallow: /talks/*/joindin + """