diff --git a/applications/app/services/TagPagePicker.scala b/applications/app/services/TagPagePicker.scala index 3a96103aa103..64c27f7ff325 100644 --- a/applications/app/services/TagPagePicker.scala +++ b/applications/app/services/TagPagePicker.scala @@ -10,9 +10,7 @@ import services.IndexPage object TagPagePicker extends GuLogging { def getTier(tagPage: IndexPage)(implicit request: RequestHeader): RenderType = { - lazy val isSwitchedOn = DCRTagPages.isSwitchedOn; - - val checks = dcrChecks(tagPage) + lazy val isSwitchedOn = DCRTagPages.isSwitchedOn val tier = decideTier( request.isRss, @@ -20,31 +18,19 @@ object TagPagePicker extends GuLogging { request.forceDCROff, request.forceDCR, isSwitchedOn, - dcrCouldRender(checks), ) - logTier(tagPage, isSwitchedOn, dcrCouldRender(checks), checks, tier) + logTier(tagPage, isSwitchedOn, tier) tier } - private def dcrCouldRender(checks: Map[String, Boolean]): Boolean = { - checks.values.forall(identity) - } - - private def dcrChecks(tagPage: IndexPage): Map[String, Boolean] = { - Map( - ("isNotTagCombiner", !tagPage.page.isInstanceOf[TagCombiner]), - ) - } - private def decideTier( isRss: Boolean, isJson: Boolean, forceDCROff: Boolean, forceDCR: Boolean, isSwitchedOn: Boolean, - dcrCouldRender: Boolean, ): RenderType = { if (isRss) LocalRender else if (isJson) { @@ -53,28 +39,22 @@ object TagPagePicker extends GuLogging { else LocalRender } else if (forceDCROff) LocalRender else if (forceDCR) RemoteRender - else if (dcrCouldRender && isSwitchedOn) RemoteRender + else if (isSwitchedOn) RemoteRender else LocalRender } private def logTier( tagPage: IndexPage, isSwitchedOn: Boolean, - dcrCouldRender: Boolean, - checks: Map[String, Boolean], tier: RenderType, )(implicit request: RequestHeader): Unit = { val tierReadable = if (tier == RemoteRender) "dotcomcomponents" else "web" - val checksToString = checks.map { case (key, value) => - (key, value.toString) - } val properties = Map( "isSwitchedOn" -> isSwitchedOn.toString, - "dcrCouldRender" -> dcrCouldRender.toString, "isTagPage" -> "true", "tier" -> tierReadable, - ) ++ checksToString + ) DotcomFrontsLogger.logger.logRequest(s"tag front executing in $tierReadable", properties, tagPage) } diff --git a/applications/conf/routes b/applications/conf/routes index 2566e55c2afc..47c6f9a4fbd9 100644 --- a/applications/conf/routes +++ b/applications/conf/routes @@ -137,6 +137,7 @@ GET /$path<[\w\d-]*(/[\w\d-]*)?(/[\w\d-]*)?>.json GET /$path<[\w\d-]*(/[\w\d-]*)?(/[\w\d-]*)?> controllers.IndexController.render(path) # Tag combiners +GET /$leftSide<[^+]+>+*rightSide.json controllers.IndexController.renderCombiner(leftSide, rightSide) GET /$leftSide<[^+]+>+*rightSide controllers.IndexController.renderCombiner(leftSide, rightSide) # Google site verification diff --git a/applications/test/IndexControllerTest.scala b/applications/test/IndexControllerTest.scala index 91c7e1f786ed..02cdb53d8826 100644 --- a/applications/test/IndexControllerTest.scala +++ b/applications/test/IndexControllerTest.scala @@ -149,12 +149,12 @@ import play.api.libs.ws.WSClient it should "resolve uk-news combiner pages" in { val result = indexController.renderCombiner("uk-news/series/writlarge", "law/trial-by-jury")( - TestRequest("/uk-news/series/writlarge+law/trial-by-jury"), + TestRequest("/uk-news/series/writlarge+law/trial-by-jury?dcr=false"), ) status(result) should be(200) val result2 = indexController.renderCombiner("uk-news/the-northerner", "blackpool")( - TestRequest("/uk-news/the-northerner+blackpool"), + TestRequest("/uk-news/the-northerner+blackpool?dcr=false"), ) status(result2) should be(200) } diff --git a/applications/test/common/CombinerFeatureTest.scala b/applications/test/common/CombinerFeatureTest.scala index bcb6406e6511..137df0b60e4f 100644 --- a/applications/test/common/CombinerFeatureTest.scala +++ b/applications/test/common/CombinerFeatureTest.scala @@ -19,7 +19,7 @@ import scala.jdk.CollectionConverters._ Given("I visit a combiner page") - goTo("/world/iraq+tone/comment") { browser => + goTo("/world/iraq+tone/comment?dcr=false") { browser => import browser._ val trails = $(".fc-slice__item") Then("I should see content tagged with both tags") @@ -31,7 +31,7 @@ import scala.jdk.CollectionConverters._ Given("I visit a combiner page") - goTo("/science+technology/apple") { browser => + goTo("/science+technology/apple?dcr=false") { browser => import browser._ val trails = $(".fromage, .fc-slice__item, .linkslist__item") Then("I should see content tagged with both the section and the tag") @@ -44,7 +44,7 @@ import scala.jdk.CollectionConverters._ Given("I visit a combiner page with tags in the same section") - goTo("/books/jkrowling+harrypotter") { browser => + goTo("/books/jkrowling+harrypotter?dcr=false") { browser => import browser._ val trails = $(".fromage, .fc-slice__item, .linkslist__item") Then("I should see content tagged with both tags") @@ -57,7 +57,7 @@ import scala.jdk.CollectionConverters._ Given("I visit a combiner page with a series tag in the same seciton") goTo( - "/lifeandstyle/series/quick-and-healthy-recipes+series/hugh-fearnley-whittingstall-quick-and-healthy-lunches", + "/lifeandstyle/series/quick-and-healthy-recipes+series/hugh-fearnley-whittingstall-quick-and-healthy-lunches?dcr=false", ) { browser => import browser._ val trails = $(".fromage, .fc-slice__item, .linkslist__item") diff --git a/common/app/model/meta.scala b/common/app/model/meta.scala index 65668b298c79..b08869d260da 100644 --- a/common/app/model/meta.scala +++ b/common/app/model/meta.scala @@ -559,12 +559,25 @@ case class TagCombiner( private val webTitle: String = webTitleOverrides.getOrElse(id, s"${leftTag.name} + ${rightTag.name}") + val javascriptConfigOverrides: Map[String, JsValue] = Map( + ("keywords", JsString(List(leftTag.properties.webTitle, rightTag.properties.webTitle).mkString(","))), + ("keywordIds", JsString(List(leftTag.id, rightTag.id).mkString(","))), + ( + "references", + JsArray( + (leftTag.properties.references ++ rightTag.properties.references).map(ref => Reference.toJavaScript(ref.id)), + ), + ), + ) + override val metadata: MetaData = MetaData.make( id = id, section = leftTag.metadata.section, webTitle = webTitle, pagination = pagination, description = Some(DotcomContentType.TagIndex.name), + javascriptConfigOverrides = javascriptConfigOverrides, + isFront = true, commercial = Some( // We only use the left tag for CommercialProperties CommercialProperties( diff --git a/common/app/services/repositories.scala b/common/app/services/repositories.scala index 6a73603e413b..f2a038c12034 100644 --- a/common/app/services/repositories.scala +++ b/common/app/services/repositories.scala @@ -80,7 +80,15 @@ trait Index extends ConciergeRepository { val tag2 = findTag(head.item, secondTag) if (tag1.isDefined && tag2.isDefined) { val page = TagCombiner(s"$leftSide+$rightSide", tag1.get, tag2.get, pagination(response)) - Right(IndexPage(page, contents = trails, tags = Tags(Nil), date = DateTime.now, tzOverride = None)) + Right( + IndexPage( + page, + contents = trails, + tags = Tags(List(tag1.get, tag2.get)), + date = DateTime.now, + tzOverride = None, + ), + ) } else { Left(NotFound) } diff --git a/docs/06-features-and-components/02-trail-images.md b/docs/06-features-and-components/01-trail-images.md similarity index 100% rename from docs/06-features-and-components/02-trail-images.md rename to docs/06-features-and-components/01-trail-images.md diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/01-README.md b/docs/06-features-and-components/02-The-Interactive-Librarian/01-README.md similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/01-README.md rename to docs/06-features-and-components/02-The-Interactive-Librarian/01-README.md diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/01-interactive-urls b/docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/01-interactive-urls similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/01-interactive-urls rename to docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/01-interactive-urls diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/02-making.txt b/docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/02-making.txt similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/02-making.txt rename to docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/02-making.txt diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/03.interactive-urls.txt b/docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/03.interactive-urls.txt similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/03.interactive-urls.txt rename to docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/03.interactive-urls.txt diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/04-originals-pressing b/docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/04-originals-pressing similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/04-originals-pressing rename to docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/04-originals-pressing diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/05-original-pressing-failures.txt b/docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/05-original-pressing-failures.txt similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/02-Batch-01/05-original-pressing-failures.txt rename to docs/06-features-and-components/02-The-Interactive-Librarian/02-Batch-01/05-original-pressing-failures.txt diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/02-interactive-migration.md b/docs/06-features-and-components/02-The-Interactive-Librarian/02-interactive-migration.md similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/02-interactive-migration.md rename to docs/06-features-and-components/02-The-Interactive-Librarian/02-interactive-migration.md diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/03-Batch-02/06-cleaning b/docs/06-features-and-components/02-The-Interactive-Librarian/03-Batch-02/06-cleaning similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/03-Batch-02/06-cleaning rename to docs/06-features-and-components/02-The-Interactive-Librarian/03-Batch-02/06-cleaning diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/03-Batch-02/07-cleaning-failures.txt b/docs/06-features-and-components/02-The-Interactive-Librarian/03-Batch-02/07-cleaning-failures.txt similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/03-Batch-02/07-cleaning-failures.txt rename to docs/06-features-and-components/02-The-Interactive-Librarian/03-Batch-02/07-cleaning-failures.txt diff --git a/docs/06-features-and-components/04-The-Interactive-Librarian/03-Batch-02/08-pascal-message-to-the-team.png b/docs/06-features-and-components/02-The-Interactive-Librarian/03-Batch-02/08-pascal-message-to-the-team.png similarity index 100% rename from docs/06-features-and-components/04-The-Interactive-Librarian/03-Batch-02/08-pascal-message-to-the-team.png rename to docs/06-features-and-components/02-The-Interactive-Librarian/03-Batch-02/08-pascal-message-to-the-team.png diff --git a/docs/06-features-and-components/03-tag-combiners.md b/docs/06-features-and-components/03-tag-combiners.md new file mode 100644 index 000000000000..9c739a395d96 --- /dev/null +++ b/docs/06-features-and-components/03-tag-combiners.md @@ -0,0 +1,14 @@ +# Tag combiners + +At the Guardian, we have three sorts of index pages. + +1. Front pages - curated by editorial staff using the [fronts tool](https://github.com/guardian/facia-tool). + - eg. +2. Tag pages - automatically generated to contain the most recent content with the given tag. + - eg. + - If a tag shares a URL with a curated front, its tag page can always be accessed by adding a `/all` to the end. + - eg. +3. Tag combiner pages - a special sort of tag page, that finds all content that has both of two tags. Simply add a `+` between the two tag paths. + - Sounds sort of niche, but it is useful - there are tags for film content, and for reviews, but there is no single tag for _film reviews_, but it would be handy to have a link to such a tag page for people who are looking for the latest reviews, and might want to skip the rest of our film-related content. + - eg. + - There's some more ideas of what you can use these for in this blog post which accompanied the initial development: diff --git a/docs/06-features-and-components/03-font-loader-route.md b/docs/99-archives/font-loader-route.md similarity index 100% rename from docs/06-features-and-components/03-font-loader-route.md rename to docs/99-archives/font-loader-route.md diff --git a/docs/README.md b/docs/README.md index 87f19943c998..e7fe1baaf51e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -57,7 +57,7 @@ - [Non-refreshable line items](05-commercial/04-non-refreshable-line-items.md) ## [Features and components](06-features-and-components/) -- [How are trail pictures picked in Frontend?](06-features-and-components/02-trail-images.md) +- [How are trail pictures picked in Frontend?](06-features-and-components/01-trail-images.md) - [theguardian.com/font-loader](06-features-and-components/03-font-loader-route.md) ## [Performance](07-performance/)