Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show affiliate links on all eligible galleries #27071

Merged
merged 1 commit into from
Apr 29, 2024
Merged
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
1 change: 1 addition & 0 deletions applications/app/views/fragments/galleryBody.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
tagPaths = page.gallery.content.tags.tags.map(_.id),
firstPublishedDate = page.gallery.content.fields.firstPublicationDate,
pageUrl = request.uri,
contentType = "gallery",
)
)

Expand Down
1 change: 1 addition & 0 deletions applications/app/views/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ object GalleryCaptionCleaners {
appendDisclaimer = Some(isFirstRow && page.item.lightbox.containsAffiliateableLinks),
tags = page.gallery.content.tags.tags.map(_.id),
page.gallery.content.fields.firstPublicationDate,
contentType = "gallery",
),
)

Expand Down
1 change: 1 addition & 0 deletions article/app/views/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ object BodyProcessor {
showAffiliateLinks = article.content.fields.showAffiliateLinks,
tags = article.content.tags.tags.map(_.id),
publishedDate = article.content.fields.firstPublicationDate,
contentType = "article",
),
) ++
ListIf(true)(VideoEmbedCleaner(article))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ object DotcomRenderingUtils {
tagPaths = content.content.tags.tags.map(_.id),
firstPublishedDate = content.content.fields.firstPublicationDate,
pageUrl = content.metadata.id,
contentType = "article",
)
}

Expand Down
14 changes: 4 additions & 10 deletions common/app/views/support/HtmlCleaner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ case class AffiliateLinksCleaner(
appendDisclaimer: Option[Boolean] = None,
tags: List[String],
publishedDate: Option[DateTime],
contentType: String,
) extends HtmlCleaner
with GuLogging {

Expand All @@ -887,6 +888,7 @@ case class AffiliateLinksCleaner(
tags,
publishedDate,
pageUrl,
contentType,
)
) {
AffiliateLinksCleaner.replaceLinksInHtml(document, pageUrl, skimlinksId)
Expand Down Expand Up @@ -943,6 +945,7 @@ object AffiliateLinksCleaner {
tagPaths: List[String],
firstPublishedDate: Option[DateTime],
pageUrl: String,
contentType: String,
): Boolean = {
val publishedCutOffDate = new DateTime(2020, 8, 14, 0, 0)

Expand All @@ -964,15 +967,6 @@ object AffiliateLinksCleaner {
"fashion/2024/mar/17/beauty-spot-10-best-root-cover-ups",
"fashion/2024/apr/05/peptides-help-with-good-looking-skin-but-dont-expect-botox-in-a-bottle",
"fashion/2024/apr/13/sali-hughes-top-50-beauty-products-for-under-20-pounds",
"fashion/gallery/2024/mar/09/spring-in-your-step-10-menswear-trends-to-update-your-wardrobe-in-pictures",
"fashion/gallery/2024/mar/08/street-smart-what-to-wear-to-run-errands",
"fashion/gallery/2024/mar/09/the-edit-mens-sweatshirts-in-pictures",
"lifeandstyle/gallery/2024/jan/22/colourful-glass-furniture-from-vases-to-lampshades-in-pictures",
"lifeandstyle/gallery/2023/nov/27/cosy-bedding-in-pictures",
"fashion/gallery/2024/mar/24/we-love-fashion-fixes-for-the-week-ahead-in-pictures",
"fashion/gallery/2024/apr/06/we-love-fashion-fixes-for-the-week-ahead-in-pictures",
"fashion/gallery/2024/apr/05/instant-spark-what-to-wear-for-a-first-date",
"fashion/gallery/2024/mar/31/crossbody-carrier-18-of-the-best-handbags-in-pictures",
)

val urlIsInAllowList = affiliateLinksAllowList.contains(cleanedPageUrl)
Expand All @@ -983,7 +977,7 @@ object AffiliateLinksCleaner {
if (
!contentHasAlwaysOffTag(tagPaths, alwaysOffTags) && (firstPublishedDate.exists(
_.isBefore(publishedCutOffDate),
) || urlIsInAllowList)
) || urlIsInAllowList || contentType == "gallery")
) {
if (showAffiliateLinks.isDefined) {
showAffiliateLinks.contains(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List.empty,
oldPublishedDate,
deniedPageUrl,
"article",
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -42,6 +43,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List.empty,
oldPublishedDate,
deniedPageUrl,
"article",
) should be(true)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -53,6 +55,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List.empty,
oldPublishedDate,
deniedPageUrl,
"article",
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -64,6 +67,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List.empty,
oldPublishedDate,
deniedPageUrl,
"article",
) should be(true)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -75,6 +79,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List("bereavement"),
oldPublishedDate,
deniedPageUrl,
"article",
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -86,6 +91,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List("tech"),
oldPublishedDate,
deniedPageUrl,
"article",
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -97,6 +103,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List("tech"),
oldPublishedDate,
deniedPageUrl,
"article",
) should be(true)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -108,6 +115,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List("bereavement"),
oldPublishedDate,
deniedPageUrl,
"article",
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -119,6 +127,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List("tech"),
oldPublishedDate,
deniedPageUrl,
"article",
) should be(true)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -130,6 +139,19 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
List.empty,
newPublishedDate,
deniedPageUrl,
"article",
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
"film",
None,
supportedSections,
Set.empty,
Set.empty,
List.empty,
newPublishedDate,
deniedPageUrl,
"gallery",
) should be(true)
}
}
Loading