From f858b90b980e17545840880260230f1208fb284a Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Tue, 19 Mar 2024 11:59:07 +0000 Subject: [PATCH 1/5] add all json route --- applications/app/controllers/AllIndexController.scala | 4 ++-- applications/app/services/TagPagePicker.scala | 4 +++- applications/conf/routes | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/applications/app/controllers/AllIndexController.scala b/applications/app/controllers/AllIndexController.scala index 13e31f9aa2ea..d56f751bf97b 100644 --- a/applications/app/controllers/AllIndexController.scala +++ b/applications/app/controllers/AllIndexController.scala @@ -66,8 +66,6 @@ class AllIndexController( def all(path: String): Action[AnyContent] = Action.async { implicit request => - val edition = Edition(request) - if (ConfigAgent.shouldServeFront(path) || defaultEdition.isEditionalised(path)) { indexController.render(path)(request) } else { @@ -77,6 +75,8 @@ class AllIndexController( } } + def renderJson(path: String): Action[AnyContent] = indexController.render(path) + def allOn(path: String, day: String, month: String, year: String): Action[AnyContent] = Action.async { implicit request => val reqDate = requestedDate(s"$year/$month/$day") diff --git a/applications/app/services/TagPagePicker.scala b/applications/app/services/TagPagePicker.scala index b2f2a23299c3..9547b37ca405 100644 --- a/applications/app/services/TagPagePicker.scala +++ b/applications/app/services/TagPagePicker.scala @@ -10,7 +10,9 @@ import services.IndexPage object TagPagePicker extends GuLogging { def getTier(tagPage: IndexPage)(implicit request: RequestHeader): RenderType = { - lazy val participatingInTest = ActiveExperiments.isParticipating(DCRTagPages) +// lazy val participatingInTest = ActiveExperiments.isParticipating(DCRTagPages) + lazy val participatingInTest = true + val checks = dcrChecks(tagPage) val tier = decideTier( diff --git a/applications/conf/routes b/applications/conf/routes index aabf5e278630..745a2aa63fd6 100644 --- a/applications/conf/routes +++ b/applications/conf/routes @@ -91,7 +91,7 @@ GET /$path<.+>/latest/email.emailtxt GET /$path<.+>/$year<\d\d\d\d>/$month<\w\w\w>/$day<\d\d>/all controllers.AllIndexController.allOn(path, day, month, year) GET /$path<.+>/$year<\d\d\d\d>/$month<\w\w\w>/$day<\d\d>/altdate controllers.AllIndexController.altDate(path, day, month, year) GET /$path<.+>/all controllers.AllIndexController.all(path) - +GET /$path<.+>/all.json controllers.AllIndexController.renderJson(path) # Gallery paths GET /$path<[\w\d-]*(/[\w\d-]*)?/gallery/.*>/lightbox.json controllers.GalleryController.lightboxJson(path) From b72c0f3840147fb152127bb0a1a63f435d4a8998 Mon Sep 17 00:00:00 2001 From: Anna Beddow Date: Wed, 20 Mar 2024 11:29:30 +0000 Subject: [PATCH 2/5] Add renderjson for tag pages --- dev-build/conf/routes | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-build/conf/routes b/dev-build/conf/routes index 2f23c4c5c3a3..04de59aec65e 100644 --- a/dev-build/conf/routes +++ b/dev-build/conf/routes @@ -371,6 +371,7 @@ GET /$path<.+>/latest/email.emailtxt GET /$path<.+>/$year<\d\d\d\d>/$month<\w\w\w>/$day<\d\d>/all controllers.AllIndexController.allOn(path, day, month, year) GET /$path<.+>/$year<\d\d\d\d>/$month<\w\w\w>/$day<\d\d>/altdate controllers.AllIndexController.altDate(path, day, month, year) GET /$path<.+>/all controllers.AllIndexController.all(path) +GET /$path<.+>/all.json controllers.AllIndexController.renderJson(path) # Newspaper pages paths # gallery format (?) From 46ea616b0ccab672116e1e4e487d8f06306b8a5b Mon Sep 17 00:00:00 2001 From: Anna Beddow Date: Wed, 20 Mar 2024 11:29:41 +0000 Subject: [PATCH 3/5] Add pagination to model --- .../DotcomTagPagesRenderingDataModel.scala | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/app/model/dotcomrendering/DotcomTagPagesRenderingDataModel.scala b/common/app/model/dotcomrendering/DotcomTagPagesRenderingDataModel.scala index e57376dfbae7..5b34e3b74280 100644 --- a/common/app/model/dotcomrendering/DotcomTagPagesRenderingDataModel.scala +++ b/common/app/model/dotcomrendering/DotcomTagPagesRenderingDataModel.scala @@ -17,6 +17,7 @@ import model.PressedCollectionFormat.pressedContentFormat case class DotcomTagPagesRenderingDataModel( contents: Seq[PressedContent], + pagination: Option[common.Pagination], tags: Tags, date: DateTime, tzOverride: Option[DateTimeZone], @@ -40,6 +41,7 @@ object DotcomTagPagesRenderingDataModel { def writes(model: DotcomTagPagesRenderingDataModel) = { Json.obj( "contents" -> model.contents, + "pagination" -> model.pagination, "date" -> model.date.toString(), "tzOverride" -> model.tzOverride.map(_.toString), "previousAndNext" -> model.previousAndNext.map(previousAndNext => @@ -97,8 +99,14 @@ object DotcomTagPagesRenderingDataModel { } .getOrElse(Map.empty[String, EditionCommercialProperties]) + // `/all` tag pages have pagination in the metadata whilst for all other tag pages, pagination is in the tags. + val pagination = page.metadata.pagination.orElse { + page.tags.tags.headOption.flatMap(_.pagination) + } + DotcomTagPagesRenderingDataModel( contents = page.contents.map(_.faciaItem), + pagination = pagination, tags = page.tags, date = page.date, tzOverride = page.tzOverride, From c3e7f10db9d1032784981b057374b8bd3a40a127 Mon Sep 17 00:00:00 2001 From: Anna Beddow Date: Thu, 21 Mar 2024 09:19:57 +0000 Subject: [PATCH 4/5] Use active experiments for test --- applications/app/services/TagPagePicker.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/applications/app/services/TagPagePicker.scala b/applications/app/services/TagPagePicker.scala index 9547b37ca405..6d3c4db9099a 100644 --- a/applications/app/services/TagPagePicker.scala +++ b/applications/app/services/TagPagePicker.scala @@ -10,8 +10,7 @@ import services.IndexPage object TagPagePicker extends GuLogging { def getTier(tagPage: IndexPage)(implicit request: RequestHeader): RenderType = { -// lazy val participatingInTest = ActiveExperiments.isParticipating(DCRTagPages) - lazy val participatingInTest = true + lazy val participatingInTest = ActiveExperiments.isParticipating(DCRTagPages) val checks = dcrChecks(tagPage) From 44ffab24a2177be1bc84daf388f830f6f8bded01 Mon Sep 17 00:00:00 2001 From: Anna Beddow Date: Mon, 25 Mar 2024 09:40:45 +0000 Subject: [PATCH 5/5] Reorder routes to most -> least specific --- applications/conf/routes | 2 +- dev-build/conf/routes | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/conf/routes b/applications/conf/routes index 745a2aa63fd6..8a7b8f853f99 100644 --- a/applications/conf/routes +++ b/applications/conf/routes @@ -90,8 +90,8 @@ GET /$path<.+>/latest/email.emailjson GET /$path<.+>/latest/email.emailtxt controllers.LatestIndexController.latest(path) GET /$path<.+>/$year<\d\d\d\d>/$month<\w\w\w>/$day<\d\d>/all controllers.AllIndexController.allOn(path, day, month, year) GET /$path<.+>/$year<\d\d\d\d>/$month<\w\w\w>/$day<\d\d>/altdate controllers.AllIndexController.altDate(path, day, month, year) -GET /$path<.+>/all controllers.AllIndexController.all(path) GET /$path<.+>/all.json controllers.AllIndexController.renderJson(path) +GET /$path<.+>/all controllers.AllIndexController.all(path) # Gallery paths GET /$path<[\w\d-]*(/[\w\d-]*)?/gallery/.*>/lightbox.json controllers.GalleryController.lightboxJson(path) diff --git a/dev-build/conf/routes b/dev-build/conf/routes index 04de59aec65e..d87460931946 100644 --- a/dev-build/conf/routes +++ b/dev-build/conf/routes @@ -370,8 +370,8 @@ GET /$path<.+>/latest/email.emailjson GET /$path<.+>/latest/email.emailtxt controllers.LatestIndexController.latest(path) GET /$path<.+>/$year<\d\d\d\d>/$month<\w\w\w>/$day<\d\d>/all controllers.AllIndexController.allOn(path, day, month, year) GET /$path<.+>/$year<\d\d\d\d>/$month<\w\w\w>/$day<\d\d>/altdate controllers.AllIndexController.altDate(path, day, month, year) -GET /$path<.+>/all controllers.AllIndexController.all(path) GET /$path<.+>/all.json controllers.AllIndexController.renderJson(path) +GET /$path<.+>/all controllers.AllIndexController.all(path) # Newspaper pages paths # gallery format (?)