Commit 52c4785
Basic Live-Harness endpoint functionality
This is a tweaked version of the work done in #28417,
but built upon the refactors done in #28437, which
allows this implementation to be smaller.
In `LiveHarnessController.renderLiveHarness()`:
* The `ArticleController.mapAndRender()` & `InteractiveController.modelAndRender()`
methods introduced in #28437 are useful not only within those controllers, but also
more suitable for the work needed in `renderLiveHarness()`, meaning that each case
(`ContentType.Article` & `ContentType.Interactive`) can be handled much more concisely -
a single line each.
* We can avoid transforming the `JsResult` to an `Either`, and just match on
`JsSuccess`/`JsError` rather than `Right`/`Left`
* The `match` statement on the `Option[ContentType]` can be done slightly more concisely
using `collect` : https://www.scala-lang.org/api/2.13.18/scala/Option.html#collect[B](pf:PartialFunction[A,B]):Option[B]
In `LiveHarness`:
* The important code in `turnLocalAtomsIntoAtomBlocksAndElements()` - that makes an
`InteractiveAtom` or `BlockElement` out of a `LiveHarnessInteractiveAtom` - has moved
onto `LiveHarnessInteractiveAtom` itself (so all the references copying data from
`localAtom.xxx` fields become just references to `xxx` field itself)
* A fiddly bit of functionality - updating the `content` within a `ContentPage`, which
varies depending on whether it's a `ArticlePage` or `InteractivePage` - has been isolated
into a `PageUpdater` type class. This allows us to have much clearer code elsewhere -
without having to define a content-updating method for every single `ContentPage` type,
just the two we care about. Consequently, there's not a need for either of the two
`injectInteractiveAtomsIntoPage()` methods that used to exist - just a single `inject()`
method, which does the work of `addLocalAtomsToParent()` too.
* We use the handy `splitAt()` method to make a bit of code in `addLocalAtomsToParent()` a
bit smaller.
In `InteractiveController`:
* A small new `modelAndRenderHtml()` method is required, to match the behaviour from #28417
which short-circuits a lot of logic to ensure that `renderHtml()` is called.
Co-Authored-By: Jonathon Herbert <[email protected]>
Co-Authored-By: Frederick O'Brien <[email protected]>1 parent 217a205 commit 52c4785
File tree
5 files changed
+134
-6
lines changed- applications/app/controllers
- common/app/model/meta
- preview
- app
- controllers
- utils
- conf
5 files changed
+134
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
4 | 15 | | |
5 | 16 | | |
6 | | - | |
7 | | - | |
8 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
9 | 62 | | |
10 | 63 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
0 commit comments