Skip to content

Commit

Permalink
Merge pull request #26727 from guardian/sa-affiliate-disclaimer-dcr-m…
Browse files Browse the repository at this point in the history
…odel

Lift affiliate links disclaimer out of page elements
  • Loading branch information
SiAdcock authored Dec 5, 2023
2 parents cbdef27 + 24fa444 commit 1ed566d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
11 changes: 11 additions & 0 deletions common/app/model/dotcomrendering/DotcomRenderingDataModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import play.api.libs.json._
import play.api.mvc.RequestHeader
import services.NewsletterData
import views.support.{CamelCase, ContentLayout, JavaScriptPage}
import views.html.fragments.affiliateLinksDisclaimer
// -----------------------------------------------------------------
// DCR DataModel
// -----------------------------------------------------------------
Expand All @@ -40,6 +41,7 @@ case class DotcomRenderingDataModel(
version: Int,
headline: String,
standfirst: String,
affiliateLinksDisclaimer: Option[String],
webTitle: String,
mainMediaElements: List[PageElement],
main: String,
Expand Down Expand Up @@ -121,6 +123,7 @@ object DotcomRenderingDataModel {
"version" -> model.version,
"headline" -> model.headline,
"standfirst" -> model.standfirst,
"affiliateLinksDisclaimer" -> model.affiliateLinksDisclaimer,
"webTitle" -> model.webTitle,
"mainMediaElements" -> model.mainMediaElements,
"main" -> model.main,
Expand Down Expand Up @@ -545,6 +548,13 @@ object DotcomRenderingDataModel {

val selectedTopics = topicResult.map(topic => Seq(Topic(topic.`type`, topic.name)))

def getAffiliateLinksDisclaimer(shouldAddAffiliateLinks: Boolean) = {
if (shouldAddAffiliateLinks) {
Some(affiliateLinksDisclaimer("article").body)
} else {
None
}
}
DotcomRenderingDataModel(
author = author,
badge = Badges.badgeFor(content).map(badge => DCRBadge(badge.seriesTag, badge.imageUrl)),
Expand Down Expand Up @@ -598,6 +608,7 @@ object DotcomRenderingDataModel {
showBottomSocialButtons = ContentLayout.showBottomSocialButtons(content),
slotMachineFlags = request.slotMachineFlags,
standfirst = TextCleaner.sanitiseLinks(edition)(content.fields.standfirst.getOrElse("")),
affiliateLinksDisclaimer = getAffiliateLinksDisclaimer(shouldAddAffiliateLinks),
starRating = content.content.starRating,
subMetaKeywordLinks = content.content.submetaLinks.keywords.map(SubMetaLink.apply),
subMetaSectionLinks =
Expand Down
39 changes: 21 additions & 18 deletions common/app/views/fragments/affiliateLinksDisclaimer.scala.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
@(contentType: String)


@articleDisclaimer() = {
@(contentType: String) @articleDisclaimer() = {
<p><em><sup>
This article contains affiliate links, which means we may earn a small commission if a reader clicks through and
makes a purchase. All our journalism is independent and is in no way influenced by any advertiser or commercial initiative.
By clicking on an affiliate link, you accept that third-party cookies will be set.
<a href="https://www.theguardian.com/info/2017/nov/01/reader-information-on-affiliate-links" data-link-name="in body link" class="u-underline">More information</a>.
The Guardian’s product and service reviews are independent and are
in no way influenced by any advertiser or commercial initiative. We
will earn a commission from the retailer if you buy something
through an affiliate link.
<a
href="https://www.theguardian.com/info/2017/nov/01/reader-information-on-affiliate-links"
data-link-name="in body link"
class="u-underline"
>Learn more</a
>.
</sup></em></p>
}

@galleryDisclaimer() = {
<br><em>This article contains affiliate links, which means we may earn a small commission if a reader clicks through and
makes a purchase. All our journalism is independent and is in no way influenced by any advertiser or commercial initiative.
By clicking on an affiliate link, you accept that third-party cookies will be set.
<a href="https://www.theguardian.com/info/2017/nov/01/reader-information-on-affiliate-links">More information</a>.
} @galleryDisclaimer() = {
<br><em>
The Guardian’s product and service reviews are independent and are in no
way influenced by any advertiser or commercial initiative. We will earn a
commission from the retailer if you buy something through an affiliate link.
<a
href="https://www.theguardian.com/info/2017/nov/01/reader-information-on-affiliate-links"
>Learn more</a
>.
</em>
}

@{contentType match {
} @{contentType match {
case "gallery" => galleryDisclaimer()
case "article" => articleDisclaimer()
case _ => Html("")
Expand Down

0 comments on commit 1ed566d

Please sign in to comment.