Skip to content

Commit

Permalink
Provide DCAR JSON for galleries (#27612)
Browse files Browse the repository at this point in the history
Currently, when requesting JSON for a gallery, `forceDCR` is ignored. This is because the request has to be categorised as a "remote render" for DCAR JSON to be provided. However, this JSON is provided by frontend, not DCAR, so it's not accurate to call it a "remote render".

This change creates a separate case, apart from the "remote render" logic, to handle DCAR JSON for galleries.
  • Loading branch information
JamieB-gu authored Nov 19, 2024
1 parent 3ed38ee commit badc416
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions applications/app/controllers/GalleryController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class GalleryController(
lookup(path, index, isTrail) flatMap {
case Right((model, _)) if model.gallery.content.isExpired =>
Future.successful(RenderOtherStatus(Gone)) // TODO - delete this line after switching to new content api
case Right((model, blocks)) if request.isJson && request.forceDCR =>
val pageType = PageType(model, request, context)

Future.successful(
common.renderJson(getDCRJson(model, pageType, blocks), model).as("application/json"),
)
case Right((model, blocks)) if GalleryPicker.getTier(model) == RemoteRender =>
remoteRender(model, blocks)
case Right((model, _)) => Future.successful(renderGallery(model))
Expand All @@ -48,18 +54,13 @@ class GalleryController(
request: RequestHeader,
) = {
val pageType = PageType(model, request, context)
if (request.isJson) {
Future.successful(
common.renderJson(getDCRJson(model, pageType, blocks), model).as("application/json"),
)
} else {
remoteRenderer.getGallery(
wsClient,
model,
pageType,
blocks,
)
}

remoteRenderer.getGallery(
wsClient,
model,
pageType,
blocks,
)
}

def lightboxJson(path: String): Action[AnyContent] =
Expand Down

0 comments on commit badc416

Please sign in to comment.