@guardian/atom-renderer v2.0.0
Atom Renderer (DEPRECATED)
Please note that this library has now been deprecated and is no longer maintained. You can of course continue to use any previously published versions but it is no longer receiving updates or bug fixes. You may want to look into using https://github.com/guardian/csnx/tree/main/libs/@guardian/atoms-rendering instead (note thats atoms-rendering vs atom-renderer in this legacy library)
A library that renders atoms from the content API into front-end code. It is written in javascript using type-checking from FlowJS, and wrapped in a Scala app.
To Install
Clone repo:
git clone git@github.com:guardian/atom-renderer.gitInstall node dependencies:
yarnInstall sbt dependencies
sbt compile. You need to have the pgp plugin installed globally.
Run FlowJS
Installing the node modules above should have installed what you need to run flow.
To check for any compile errors, run flow like this: yarn run flow
More information on Getting Started with Flow.
Build the app
Build the JS code:
yarn frontend&yarn appsBuild the Scala code:
sbt compile
Preview your changes
Locally
The utils project provides a convenience application to quickly preview the rendering of an atom. Just go in that project and run it, then hit http://localhost:8080. The app will ask you to select an atom type and type an atom ID, then will render it using the "article" rendering.
Note: you will need to set a value for the CAPI_TEST_KEY environment variable, e.g. in your .bash_profile, to be able to run the project locally.
In Frontend
You need to publish your changes to NPM as a new version of the Atom Renderer package. Then, you need to open the Guardian's Frontend app on your local machine, require the updated Atom Renderer package and run Frontend.
In Atom-Renderer:
Update
versioninpackage.jsonto something likeX.X.X-yourname.test.1Use the semver convention to increment the version number. The '-yourname.test.1' part on the end indicates that this is a version to be used for testing purposes, not for actual use.). Commit these changes.Build the frontend:
yarn frontendBuild the apps:
yarn appsMake sure you a) have an account on NPMjs. and b) it is added to the Guardian group on npm. Ensure your machine is logged into this account. If not, run:
npm adduserand sign inPublish your version to NPM:
npm publishThe version you just pushed should appear here: https://www.npmjs.com/package/@guardian/atom-rendererIn the (highly likely) scenario that you've made Scala code changes, that you'll want to test in Frontend (see below) you'll also need to publish your Scala changes locally. First, check that
atom-renderer/version.sbtis correct, i.e. make sure it ends with-SNAPSHOT, then runsbt +publishLocal(the+is significant for cross-compilation of Scala versions - seeproject/Dependencies.scalafor those) to add the updated library files to your local.ivy2/local/com.gu/cache. This'll be tagged with the same version as shown inatom-renderer/version.sbt.
In Frontend
In a new window open up Frontend. You need to have the Frontend app installed and set up with AWS credentials from Janus added. See how to do that here.
In a local branch, tell the app to use the latest version of the atom-renderer:
yarn add @guardian/atom-renderer@X.X.X-yourname.test.1 -W
Recompile the frontend with the new version of Atom Renderer added:
make compile-devRun the frontend code:
make watchOpen new terminal and run:
./sbtSwitch into the article project, this will let you see the atom page:
project articleRun it:
runYou should be able to preview all atoms on this page: http://localhost:9000/open-platform/blog/related-content Here live: https://www.theguardian.com/open-platform/blog/related-content
To Deploy
Publish the library to NPM
Publish the library to Maven
Update Frontend to reference the new versions.
To publish to Maven
Open the sbt interactive shell:
sbtCompile the code
compileRelease
releaseOnce the version has updated on Maven, go to the Frontend app, find the Dependencies.scala file and update the version number for Atom-Renderer. Run
./sbtto open the interactive console and thencompileto pull in the new dependency.
Adding a new Atom?
Make sure to add your new atom type in these two files in Atom-Renderer:
core/src/main/resources/__flow__/types/atoms.fjswebpack/atomTypes.js
Contact us in #journalism-team if you have problems with the repo / readme.
--
* Yarn is used in these instructions, but you can use npm if you prefer
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago