Replies: 2 comments 1 reply
-
|
I put together a "proof of concept" branch over the last 10% day, which might illustrate what I have in mind a bit better: https://github.com/guardian/dotcom-rendering/tree/dblatcher/stand-alone-pages |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
This definitely has raised some interesting questions around adding new routes to DCR. We'll close this discussion, but should probably open up a discussion on how we do this in a simpler way in future. Most of the implementation can be seen in this PR and it's corresponding frontend PR. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Could we migrate the all newsletters page from Frontend to DCR?
The "all newsletters" page is currently rendered by Frontend as a static page. The newsletters team have a new design to implement next quarter and rendering through Frontend in the same way is unlikely to be maintainable. Our preference would be to render the new version of the page through DCR so we can:
DCR doesn't currently have a pattern for rendering "stand alone" pages (IE pages which are neither articles or fronts) so we are looking to get some input if doing this is feasible and how to approach it.
Optimistic, over-simplified plan
Currently, DCR express App renders Article pages and Fronts pages (in development) using
renderFrontandrenderArticlefunctions (which usearticleToHtmlandfrontToHtml). Both recieve data from frontend, of the typesFEArticleTypeandFEFrontType, which act as page models.To follow this pattern, and re-use much of the utility code used for Articles and Fronts, we could:
NewslettersPageModeltype, withconfig,nav,footeretc data included in theFEArticleTypetypesrenderNewslettersPagefunction, that would use anewslettersToHtmlfunctionNewslettersPageModelas a propNewslettersPageModelas a json payload and post it to the new route and render the returned HTML instead of constructing the page with Scala.Suggested page model type definition
Current Newsletters page flow
link
sequenceDiagram participant Client participant Frontend participant Newsletters API Frontend-->>Newsletters API: request Newsletters data Newsletters API-->>Frontend: return Newsletters data note right of Frontend: updated hourly Frontend->>Frontend: Cache Newsletters data Client->>Frontend: Request[/email-newsletters] Frontend->>Frontend: Get Newsletters data from cache Frontend->>Frontend: Compile static HTML page from multiple scala files Frontend->>Client: Response[HTML]Proposed Newsletters page flow
link
sequenceDiagram participant Client participant Frontend participant Newsletters API participant DCR Frontend-->>Newsletters API: request Newsletters data Newsletters API-->>Frontend: return Newsletters data note right of Frontend: updated hourly Frontend->>Frontend: Cache Newsletters data Client->>Frontend: Request[/email-newsletters] Frontend->>Frontend: Get Newsletters data from cache Frontend->>DCR: post Newsletters page data rect rgb(230, 230, 230) note left of DCR: [new server function] DCR->>DCR: Render Page Contents to string note right of DCR: [new Component(s)] note right of DCR: includes Nav and Footer rect rgb(200, 200, 200) DCR->>DCR: extract CSS and expedited islands DCR->>DCR: build required scripts DCR->>DCR: make WindowGuardian data DCR->>DCR: wrap page contents, scripts etc in pageTemplate end end DCR->>Frontend: return HTML string Frontend->>Client: Response[HTML]Refactor opportunities / offshoot idea
If we keep the data and functionality that is specific to the newsletters page separate from the general page information, it could acts a template for similar 'stand alone' pages. A generic render to HTML function might have a structure like this:
From this discussion there was a ticket to migrate the existing https://www.theguardian.com/help/accessibility-help page to DCR. If this is still required, it could potentially build off the Newsletters page work.
The
populatePageTemplatefunction would replicate many of the steps withinarticleToHtml(see the steps in the dark box in the diagrams below). Potentially,articleToHtmlandfrontToHtmlcould be refactored to use this 'page type agnostic' function and reduce duplication.DCR article page flow (simplified)
sequenceDiagram participant Client Client->>Frontend: Request[article page URL] participant Frontend participant CAPI participant DCR Frontend->>CAPI: request article data CAPI->>Frontend: return CAPI data Frontend->>Frontend: CAPI data to DCR format Frontend->>DCR: post DCR article data DCR->>DCR: enhanceCAPIType rect rgb(230, 230, 230) note left of DCR: articleToHtml DCR->>DCR: Render Page Contents to string note right of DCR: ArticlePage component note right of DCR: includes Nav and Footer rect rgb(200, 200, 200) DCR->>DCR: extract CSS and expedited islands DCR->>DCR: build required scripts DCR->>DCR: make WindowGuardian data DCR->>DCR: wrap page contents, scripts etc in pageTemplate end end DCR->>Frontend: return HTML string Frontend->>Client: Response[HTML]DCR article fronts page flow (simplified, in development)
sequenceDiagram participant Client Client->>Frontend: Request[article fronts URL] participant Frontend participant Facia participant DCR Frontend->>Facia: request front data Facia->>Frontend: return front data Frontend->>DCR: post DCR front data DCR->>DCR: enhanceFront rect rgb(230, 230, 230) note left of DCR: frontToHtml DCR->>DCR: Render Page Contents to string note right of DCR: FrontPage component note right of DCR: includes Nav and Footer rect rgb(200, 200, 200) DCR->>DCR: extract CSS and expedited islands DCR->>DCR: build required scripts DCR->>DCR: make WindowGuardian data DCR->>DCR: wrap page contents, scripts etc in pageTemplate end end DCR->>Frontend: return HTML string Frontend->>Client: Response[HTML]Beta Was this translation helpful? Give feedback.
All reactions