Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions htdocs/js/talk/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ search.addWidget(
: '/images/no_video.jpg';

var links = '';
var link = function (href, svg, label) {
return '<a href="' + href + '" target="_blank" rel="noopener"'
var link = function (href, svg, label, rel) {
return '<a href="' + href + '" target="_blank" rel="' + (rel || 'noopener') + '"'
+ ' class="inline-flex items-center gap-1.5 rounded-lg bg-afup-100 px-2 py-1 text-xs font-medium text-afup-500 hover:bg-afup-500 hover:text-white">'
+ icon(svg, 'size-3.5') + label + '</a>';
};
Expand All @@ -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 ''
Expand Down
3 changes: 3 additions & 0 deletions htdocs/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ User-agent: Timpibot

# Target
Disallow: /

User-agent: *
Disallow: /talks/*/joindin
2 changes: 1 addition & 1 deletion templates/blog/program.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
{% if display_joindin_links and talk.talk.getJoindinUrl %}
<div>
<div class="banner-button-container">
<a href="https://afup.org{{ talk.talk.getJoindinUrl }}" class="banner-button basis-primary-background">Commenter sur joind.in</a>
<a href="https://afup.org{{ talk.talk.getJoindinUrl }}" rel="nofollow" class="banner-button basis-primary-background">Commenter sur joind.in</a>
</div>
</div>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions templates/site/talks/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@
{ 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) %}

{% if links|length %}
<twig:Card:Section title="Ressources">
<div class="flex flex-col gap-2">
{% for link in links %}
<twig:Button variant="secondary" as="a" href="{{ link.url }}"
<twig:Button variant="secondary" as="a" href="{{ link.url }}" :rel="link.rel ?? false"
class="flex w-full items-center justify-start gap-2">
<twig:ux:icon name="{{ link.icon }}" class="size-4 shrink-0" />
{{ link.label }}
Expand Down
29 changes: 29 additions & 0 deletions tests/behat/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<href>(?:[^"]|\\")*)" should have rel containing "(?P<rel>(?:[^"]|\\")*)"$/')]
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<text>(?:[^"]|\\")*)"$/')]
public function clickOnLink(string $type, string $text): void
{
Expand Down
14 changes: 14 additions & 0 deletions tests/behat/features/PublicSite/Talks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<link rel=\"canonical\" href=\"https://apachephptest:80/talks/?fR%5Bspeakers.label%5D%5B0%5D=Un%20Speaker\" />"

@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
"""
Loading