Skip to content

Commit

Permalink
Merge pull request #27708 from guardian/gl/flex-gen-visible-stories
Browse files Browse the repository at this point in the history
Set maximum number of stories in a flexible general container
  • Loading branch information
Georges-GNM authored Jan 22, 2025
2 parents 1ab4a23 + de4da5f commit 025bfef
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
6 changes: 5 additions & 1 deletion common/app/layout/slices/ContainerDefinition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ object ContainerDefinition {
customCssClasses = Set.empty,
)

def fromContainer(container: Container, items: Seq[PressedContent]): Option[ContainerDefinition] =
def fromContainer(
container: Container,
items: Seq[PressedContent],
): Option[ContainerDefinition] = {
container match {
case Dynamic(dynamicContainer) =>
dynamicContainer.containerDefinitionFor(items.map(Story.fromFaciaContent))
Expand All @@ -32,6 +35,7 @@ object ContainerDefinition {
case _ =>
None
}
}

/** Fast container that looks good for the number of items provided */
def fastForNumberOfItems(n: Int): ContainerDefinition =
Expand Down
18 changes: 0 additions & 18 deletions common/app/layout/slices/FlexibleContainers.scala

This file was deleted.

5 changes: 4 additions & 1 deletion common/app/layout/slices/FlexibleGeneral.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ object FlexibleGeneral extends FlexibleContainer {
}
}

override protected def standardSlices(storiesIncludingBackfill: Seq[Story], firstSlice: Option[Slice]): Seq[Slice] = {
override protected def standardSlices(
storiesIncludingBackfill: Seq[Story],
firstSlice: Option[Slice],
): Seq[Slice] = {

storiesIncludingBackfill.length match {
case 0 => Nil
Expand Down
5 changes: 4 additions & 1 deletion common/app/layout/slices/FlexibleSpecial.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ object FlexibleSpecial extends FlexibleContainer {
}
}

override protected def standardSlices(storiesIncludingBackfill: Seq[Story], firstSlice: Option[Slice]): Seq[Slice] = {
override protected def standardSlices(
storiesIncludingBackfill: Seq[Story],
firstSlice: Option[Slice],
): Seq[Slice] = {

storiesIncludingBackfill.length match {
case 0 => Nil
Expand Down
7 changes: 7 additions & 0 deletions facia-press/app/frontpress/FapiFrontPress.scala
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ trait FapiFrontPress extends EmailFrontPress with GuLogging {
case "scrollable/highlights" => 6
// scrollable small and medium containers are capped at 8 stories
case "scrollable/small" | "scrollable/medium" => 8
// flexible general containers are capped at the maxItemsToDisplay value (set in the config tool)
// In the event the field isn't populated, the fallback cap is 9 stories
case "flexible/general" =>
collection.collectionConfig.displayHints match {
case Some(displayHints) => displayHints.maxItemsToDisplay.getOrElse(9)
case None => 9
}
// other container types should be capped at a maximum number of stories set in the app config
case _ => Math.min(Configuration.facia.collectionCap, storyCountTotal)
}
Expand Down

0 comments on commit 025bfef

Please sign in to comment.