guardian/frontend — pull request #2586 by janua (2013-12-17 17:35:00+00:00)
Title: Sublinks model

This adds `sublinks` to the `Trail` model via the `FaciaFields` trait.

The meta data of an item has changed from a `Map[String, String]` to a `Map[String, JsValue]`. This exact thing is also done in the pull request by @stephanfowler in #2579.

We take out the sublinks of an item as a `Seq[ContentItem]`, which is what `getArticles` works on, and then we recursively call `getArticles` with the sublinks. This works even for a very long chain, but instead of doing that I have decided to break out of it by introducing `hasParent`. The inner call to itself will ensure that `hasParent=true` and it won't call itself anymore.
This **IS** a bit dirty. If you have any other suggestions to do this nicer then say! I was also thinking about having a repeat function that does not look up sublinks, which would mean cleaner code, but repeated.