Add JSON output to the highlights endpoint

Summary

Adds a JSON representation of the highlights feed at /highlights.json, so the CDLI mobile app can fetch the "Highlights" content directly instead of scraping the HTML page. The existing /highlights web page is unchanged, the JSON behaviour is fully gated behind JSON requests

What changed

  • PostingsController::highlights() - for JSON requests, each posting's artifact is reduced to just the fields the app needs (id + the single main displayable asset), and the serialize view option is set so CakePHP's JsonView renders the feed.
  • _pickMainAsset() (new private helper) - selects the artifact's main image using the same priority as the website: jpg > non-jpg, whole artifact > detail, photo > lineart; returns nothing when no suitable jpg photo/lineart exists.
  • Posting entity - adds a $jsonSchema (following the existing per-entity convention) listing the fields exposed in JSON: id, title, body, artifact_id, publish_start, artifact.

Example response

GET /highlights.json

[
  {
    "id": 187,
    "artifact_id": 273210,
    "title": "The Flood Tablet",
    "body": "<p>A Mesopotamian tale of a great flood…</p>",
    "publish_start": "2022-07-17T10:29:56+00:00",
    "artifact": {
      "id": 273210,
      "artifact_assets": [
        { "id": 152860, "path": "dl/photo/P273210.jpg" }
      ]
    }
  }
]

Checklist:

  • My pull request has a descriptive title (not a vague title like "Update index.md").
  • My pull request targets the phoenix/develop branch of the repository.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

AI Declaration:

  • This pull request was created without any contribution from a generative AI.
  • I have used AI to write a small part of the code.
  • I have used AI to write the majority/all of the code.
  • I have used AI writing the description of this pull request.

Merge request reports

Loading
Loading