Skip to content

Commit 0c8278a

Browse files
committed
5316: coding standards markdown
1 parent b686c83 commit 0c8278a

File tree

1 file changed

+61
-72
lines changed

1 file changed

+61
-72
lines changed

README.md

Lines changed: 61 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ At the core of OS2Display is an API that clients communicate with. All data runs
3636
It includes an Admin for creating content and a Client for displaying the content.
3737

3838
The structure is that slides are the content element of the system. Each slide is based on a Template with content
39-
added. The slides are gathered into playlists. Playlists are then added to screens.
40-
A screen is the connection between a physical device and the content.
39+
added. The slides are gathered into playlists. Playlists are then added to screens. A screen is the connection between a
40+
physical device and the content.
4141

4242
```mermaid
4343
flowchart LR
@@ -90,14 +90,13 @@ Architectural decisions are recorded in `docs/adr`.
9090

9191
## Versioning
9292

93-
We use [SemVer](http://semver.org/) for versioning.
94-
For the versions available, see the
95-
[tags on this repository](https://github.com/os2display/display-api-service/tags).
93+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this
94+
repository](https://github.com/os2display/display-api-service/tags).
9695

9796
## Technologies
9897

99-
The API is written in PHP project, built with [Symfony](https://symfony.com/) and
100-
[API Platform](https://api-platform.com/).
98+
The API is written in PHP project, built with [Symfony](https://symfony.com/) and [API
99+
Platform](https://api-platform.com/).
101100

102101
The Admin and Client are written in javascript and [React](https://react.dev/) and built with [Vite](https://vite.dev/).
103102

@@ -186,13 +185,13 @@ The API is stateless except for the `/v2/authentication` routes.
186185

187186
## Authentication
188187

189-
Authentication is achieved through `/v2/authentication/token` for the `/admin`
190-
and through `/v2/authentication/screen` for the `/client`.
188+
Authentication is achieved through `/v2/authentication/token` for the `/admin` and through `/v2/authentication/screen`
189+
for the `/client`.
191190

192191
## Tenants
193192

194-
Content is connected to a Tenant. A user is in x tenants.
195-
This allows for maintaining multiple content silos in the same installation.
193+
Content is connected to a Tenant. A user is in x tenants. This allows for maintaining multiple content silos in the same
194+
installation.
196195

197196
You can add a new tenant:
198197

@@ -211,16 +210,13 @@ It is also possible to configure if a tenants should support interactive slides.
211210

212211
## OIDC providers
213212

214-
At the present two possible oidc providers are implemented: 'internal' and 'external'.
215-
These work differently.
213+
At the present two possible oidc providers are implemented: 'internal' and 'external'. These work differently.
216214

217-
The internal provider is expected to handle both authentication and authorization.
218-
Any users logging in through the internal will be granted access based on the
219-
tenants/roles provided.
215+
The internal provider is expected to handle both authentication and authorization. Any users logging in through the
216+
internal will be granted access based on the tenants/roles provided.
220217

221-
The external provider only handles authentication. A user logging in through the
222-
external provider will not be granted access automatically, but will be challenged
223-
to enter an activation (invite) code to verify access.
218+
The external provider only handles authentication. A user logging in through the external provider will not be granted
219+
access automatically, but will be challenged to enter an activation (invite) code to verify access.
224220

225221
See `docs/feed/openid-connect.md` for environment variables for OpenID Connect configuration.
226222

@@ -234,20 +230,17 @@ The claim keys needed are set in the env variables:
234230
- `INTERNAL_OIDC_CLAIM_EMAIL`
235231
- `INTERNAL_OIDC_CLAIM_GROUPS`
236232

237-
The value of the claim with the name that is defined in the env variable `INTERNAL_OIDC_CLAIM_GROUPS` is mapped to
238-
the user's access to tenants in `App\Security\AzureOidcAuthenticator`. The claim field should consist of an array of
239-
names that should follow the following structure `<TENANT_NAME><ROLE_IN_TENANT>`.
240-
`<ROLE_IN_TENANT>` can be `Admin` or `Redaktoer` (editor).
241-
E.g. `Example1Admin` will map to the tenant with name `Example1` with `ROLE_ADMIN`.
242-
If the tenant does not exist it will be created when the user logs in.
233+
The value of the claim with the name that is defined in the env variable `INTERNAL_OIDC_CLAIM_GROUPS` is mapped to the
234+
user's access to tenants in `App\Security\AzureOidcAuthenticator`. The claim field should consist of an array of names
235+
that should follow the following structure `<TENANT_NAME><ROLE_IN_TENANT>`. `<ROLE_IN_TENANT>` can be `Admin` or
236+
`Redaktoer` (editor). E.g. `Example1Admin` will map to the tenant with name `Example1` with `ROLE_ADMIN`. If the tenant
237+
does not exist it will be created when the user logs in.
243238

244239
### External
245240

246-
The external oidc provider takes only the claim defined in the env variable
247-
OIDC_EXTERNAL_CLAIM_ID, hashes it and uses this hash as providerId for the user.
248-
When a user logs in with this provider, it is initially not in any tenant.
249-
To be added to a tenant the user has to use an activation code a
250-
ROLE_EXTERNAL_USER_ADMIN has created.
241+
The external oidc provider takes only the claim defined in the env variable OIDC_EXTERNAL_CLAIM_ID, hashes it and uses
242+
this hash as providerId for the user. When a user logs in with this provider, it is initially not in any tenant. To be
243+
added to a tenant the user has to use an activation code a ROLE_EXTERNAL_USER_ADMIN has created.
251244

252245
## JWT Auth
253246

@@ -263,8 +256,7 @@ Then create a local test user if needed:
263256
docker compose exec phpfpm bin/console app:user:add
264257
```
265258

266-
You can now obtain a token by sending a `POST` request to the
267-
`/v2/authentication/token` endpoint:
259+
You can now obtain a token by sending a `POST` request to the `/v2/authentication/token` endpoint:
268260

269261
```curl
270262
curl --location --request 'POST' \
@@ -316,9 +308,8 @@ See the `docker-compose.override.yml` playwright entry and the version imported
316308

317309
#### Testing on the built files
318310

319-
This project includes a test script that handles building assets, running
320-
Playwright tests, and stops and starts the node container. This script tests the
321-
_built_ files. This is the approach the GitHub Action uses.
311+
This project includes a test script that handles building assets, running Playwright tests, and stops and starts the
312+
node container. This script tests the _built_ files. This is the approach the GitHub Action uses.
322313

323314
```shell
324315
task test:frontend-built
@@ -330,9 +321,8 @@ or
330321
./scripts/test {TEST-PATH}
331322
```
332323

333-
TEST-PATH is optional, and is the specific test file or directory to run like
334-
`admin`/`client`/`template` or a specific file, e.g. `admin-app.spec.js`. If
335-
TEST-PATH is omitted, all tests will run.
324+
TEST-PATH is optional, and is the specific test file or directory to run like `admin`/`client`/`template` or a specific
325+
file, e.g. `admin-app.spec.js`. If TEST-PATH is omitted, all tests will run.
336326

337327
#### Testing on local machine
338328

@@ -364,8 +354,8 @@ task generate:api-spec
364354

365355
This will generate `public/api-spec-v2.json` and `public/api-spec-v2.yaml`.
366356

367-
This generated API specification is used to generate
368-
[Redux Toolkit RTK Query](https://redux-toolkit.js.org/rtk-query/overview) code for interacting with the API.
357+
This generated API specification is used to generate [Redux Toolkit RTK
358+
Query](https://redux-toolkit.js.org/rtk-query/overview) code for interacting with the API.
369359

370360
To generate the Redux Toolkit RTK Query code, run the following command:
371361

@@ -400,8 +390,8 @@ TRACK_SCREEN_INFO_UPDATE_INTERVAL_SECONDS=300
400390
###< App ###
401391
```
402392

403-
- APP_ACTIVATION_CODE_EXPIRE_INTERVAL: Specifies how long an external user activation code should live.
404-
The format of the interval should follow <https://www.php.net/manual/en/dateinterval.construct.php>.
393+
- APP_ACTIVATION_CODE_EXPIRE_INTERVAL: Specifies how long an external user activation code should live. The format of
394+
the interval should follow <https://www.php.net/manual/en/dateinterval.construct.php>.
405395

406396
**Default**: 2 days.
407397

@@ -428,17 +418,17 @@ ADMIN_ENHANCED_PREVIEW=false
428418
###< Admin configuration ###
429419
```
430420

431-
- ADMIN_REJSEPLANEN_APIKEY: An API key accessing Rejseplanen API used for Travel template.
432-
See [https://labs.rejseplanen.dk/](https://labs.rejseplanen.dk/) for information about acquiring an API key.
421+
- ADMIN_REJSEPLANEN_APIKEY: An API key accessing Rejseplanen API used for Travel template. See
422+
[https://labs.rejseplanen.dk/](https://labs.rejseplanen.dk/) for information about acquiring an API key.
433423

434424
**Default**: Not set.
435425

436426
- ADMIN_SHOW_SCREEN_STATUS: Should the status of the screen be shown in the Admin (true|false)?
437427

438428
**Default**: Disabled.
439429

440-
- ADMIN_TOUCH_BUTTON_REGIONS: Should the option of setting a button name for a slide be enabled in the Admin?
441-
This option is used by the Client if a region is configured to be a "touch-buttons" region.
430+
- ADMIN_TOUCH_BUTTON_REGIONS: Should the option of setting a button name for a slide be enabled in the Admin? This
431+
option is used by the Client if a region is configured to be a "touch-buttons" region.
442432

443433
**Default**: Disabled.
444434

@@ -473,9 +463,9 @@ ADMIN_ENHANCED_PREVIEW=false
473463
**Default**: Username and password login option is enabled.
474464

475465
- ADMIN_ENHANCED_PREVIEW: Should the enhanced preview mode be active (true|false)? When enabled, previews will be
476-
handled by iFraming in the Client app. This will allow the option of previewing playlists and screens.
477-
If disabled, only slides can be previewed. This will be with the "live" method. This preview is not as precise.
478-
See [Preview mode in the Client](#preview-mode-in-the-client).
466+
handled by iFraming in the Client app. This will allow the option of previewing playlists and screens. If disabled,
467+
only slides can be previewed. This will be with the "live" method. This preview is not as precise. See [Preview mode
468+
in the Client](#preview-mode-in-the-client).
479469

480470
**Default**: Disabled.
481471

@@ -516,9 +506,8 @@ CLIENT_DEBUG=false
516506

517507
**Default**: 1 m. and 30 s.
518508

519-
- CLIENT_COLOR_SCHEME: Which colour scheme should be enabled? Should be a json object as string.
520-
This is used to signal how changes to darkmode are handled.
521-
Options are:
509+
- CLIENT_COLOR_SCHEME: Which colour scheme should be enabled? Should be a json object as string. This is used to signal
510+
how changes to darkmode are handled. Options are:
522511
- Not set - will use the browsers prefers-color-scheme setting.
523512
- '{"type":"library","lat":56.0,"lng":10.0}' - In this case the change to darkmode is handled with a library that
524513
activates darkmode according to sunrise/sunset of the location given by the longitude/latitude (lat/lng).
@@ -602,10 +591,10 @@ classDiagram
602591

603592
## Online check for Client
604593

605-
If the client does not have internet when starting, it cannot load the assets needed for the Client.
606-
The `public/client/online-check` has been added to handle this.
607-
The folder contains an `index.html`, that checks connectivity before redirecting to `/client`.
608-
If this index.html is cached in the browser the online check page can load without internet.
594+
If the client does not have internet when starting, it cannot load the assets needed for the Client. The
595+
`public/client/online-check` has been added to handle this. The folder contains an `index.html`, that checks
596+
connectivity before redirecting to `/client`. If this index.html is cached in the browser the online check page can load
597+
without internet.
609598

610599
To use this, set the starting path of the Client to `/client/online-check`.
611600

@@ -638,8 +627,8 @@ This feature is used in the Admin for displaying previews of slides, playlists a
638627

639628
## Screen status
640629

641-
Screen status consists of 2 elements. Tracking latest request from a screen client.
642-
This data is collected and exposed through the API.
630+
Screen status consists of 2 elements. Tracking latest request from a screen client. This data is collected and exposed
631+
through the API.
643632

644633
The other part is in the admin where the data can be exposed to the user.
645634

@@ -659,8 +648,8 @@ ADMIN_SHOW_SCREEN_STATUS=true
659648

660649
In the list view of screens, there is a column called "Status".
661650

662-
This column shows the status of the connection of a "screen" in the administration and an
663-
actual "machine" running the screen data.
651+
This column shows the status of the connection of a "screen" in the administration and an actual "machine" running the
652+
screen data.
664653

665654
This status can be:
666655

@@ -671,8 +660,8 @@ This status can be:
671660

672661
### Screen edit view
673662

674-
In the screen edit view, the "Tilkobling" section shows the status of the connection between the
675-
screen entity and a machine running the screen data.
663+
In the screen edit view, the "Tilkobling" section shows the status of the connection between the screen entity and a
664+
machine running the screen data.
676665

677666
The status can be:
678667

@@ -688,8 +677,8 @@ Furthermore, the section "Tilkobling" will show the following data:
688677
* Kodeudgivelsestidspunkt: 17/6 2024 17:26
689678
```
690679

691-
This shows when the latest communication has occured, what client version the machine is running,
692-
and the time of client code release.
680+
This shows when the latest communication has occured, what client version the machine is running, and the time of client
681+
code release.
693682

694683
## Feeds
695684

@@ -802,8 +791,8 @@ It is possible to include custom templates in your installation.
802791

803792
### Location
804793

805-
Custom templates should be placed in the folder `assets/shared/custom-templates/`.
806-
This folder is in `.gitignore` so the contents will not be added to the git repository.
794+
Custom templates should be placed in the folder `assets/shared/custom-templates/`. This folder is in `.gitignore` so the
795+
contents will not be added to the git repository.
807796

808797
How you populate this folder with your custom templates is up to you:
809798

@@ -835,9 +824,9 @@ The `.jsx` should expose the following functions:
835824

836825
For an example of a custom template see `assets/shared/custom-templates-example/`.
837826

838-
The slide is responsible for signaling that it is done executing.
839-
This is done by calling the slideDone() function. If the slide should just run for X milliseconds then you can use the
840-
BaseSlideExecution class to handle this. See the example for this approach.
827+
The slide is responsible for signaling that it is done executing. This is done by calling the slideDone() function. If
828+
the slide should just run for X milliseconds then you can use the BaseSlideExecution class to handle this. See the
829+
example for this approach.
841830

842831
#### custom-template-name.json
843832

@@ -854,7 +843,8 @@ The `.json` should include:
854843

855844
##### Admin Form not set in json
856845

857-
It is possible to create an interactive admin form in a `.jsx`-file. As described above with renderSlide, when a template has a custom `.jsx` admin form, it needs to implement a `renderAdminForm` function in the base file.
846+
It is possible to create an interactive admin form in a `.jsx`-file. As described above with renderSlide, when a
847+
template has a custom `.jsx` admin form, it needs to implement a `renderAdminForm` function in the base file.
858848

859849
- renderAdminForm(formStateObject, onChange, handleMedia, mediaData) - Should return the JSX for the admin form.
860850
- slideContent: The slide data object from the admin, could e.g. contain a title `slideContent["title"]`
@@ -910,8 +900,7 @@ If you think the template could be used by other, consider contributing the temp
910900

911901
## Screen Layouts
912902

913-
A screen layout is a setting that defines how a screen is divided into different regions.
914-
A layout consists of a grid.
903+
A screen layout is a setting that defines how a screen is divided into different regions. A layout consists of a grid.
915904

916905
The grid regions are created from the number of rows and columns selected for the given layout. The regions are named
917906

0 commit comments

Comments
 (0)