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

Add all json route for tag pages #26991

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions applications/app/controllers/AllIndexController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions applications/app/services/TagPagePicker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ object TagPagePicker extends GuLogging {

def getTier(tagPage: IndexPage)(implicit request: RequestHeader): RenderType = {
lazy val participatingInTest = ActiveExperiments.isParticipating(DCRTagPages)

val checks = dcrChecks(tagPage)

val tier = decideTier(
Expand Down
2 changes: 1 addition & 1 deletion applications/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go above GET /$path<.+>/all controllers.AllIndexController.all(path) otherwise it will always be missed ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# Gallery paths
GET /$path<[\w\d-]*(/[\w\d-]*)?/gallery/.*>/lightbox.json controllers.GalleryController.lightboxJson(path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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 =>
Expand Down Expand Up @@ -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)
}

abeddow91 marked this conversation as resolved.
Show resolved Hide resolved
DotcomTagPagesRenderingDataModel(
contents = page.contents.map(_.faciaItem),
pagination = pagination,
tags = page.tags,
date = page.date,
tzOverride = page.tzOverride,
Expand Down
1 change: 1 addition & 0 deletions dev-build/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -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)
abeddow91 marked this conversation as resolved.
Show resolved Hide resolved

# Newspaper pages paths
# gallery format (?)
Expand Down
Loading