Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: Add tags to config routes #162

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## Unreleased

## [2.1.1] - 2024-12-09

- [#162](https://github.com/os2display/display-templates/pull/162)
- Added option to build main config files with a tag from DEPLOYMENT_BUILD_TAG.

## [2.1.0] - 2024-10-23

- [#158](https://github.com/os2display/display-templates/pull/158)
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
Contains base templates for OS2Display.
See [https://github.com/os2display/display-docs/blob/main/templates.md](https://github.com/os2display/display-docs/blob/main/templates.md) for a description of how to create templates.

## Release

When creating a release the config files should be built with a tag in the config routes.

Follow the instructions below. Replace `<TAG>` with the given tag.

1. Create the release branch: release/<TAG>
2. Build the js and config files with tags in main config files.
```shell
docker compose run --rm --env DEPLOYMENT_BUILD_TAG=<TAG> node yarn build
```
3. Update CHANGELOG with the new tag.
4. When ready merge release branch in main.
5. Tag the release in main
6. Merge main in develop

## Develop

To enable easy development of templates, the supplied docker-compose setup serves a page where the
Expand Down Expand Up @@ -89,7 +105,7 @@ Override "main" base URL only:
docker compose run --rm --env DEPLOYMENT_BUILD_BASE_URL_MAIN="http://$(docker compose port nginx 80)/build/" node yarn build
```

The default behavoir is equivalent to
The default behavior is equivalent to

```sh
docker compose run --rm \
Expand Down
6 changes: 3 additions & 3 deletions build/book-review-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FP2SME0ENTXWF362XHM6Z1B4",
"description": "Skabelon til anmeldelser.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/book-review.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/book-review-admin.json?ts=1723805672543",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/book-review-schema.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/book-review.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/book-review-admin.json",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/book-review-schema.json",
"assets": [],
"options": {},
"content": {}
Expand Down
6 changes: 3 additions & 3 deletions build/calendar-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FRJPF4XATRN8PBZ35XN84PS6",
"description": "Mulighed for at vise et kalenderfeed.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/calendar.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/calendar-admin.json?ts=1723805672543",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/calendar-schema.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/calendar.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/calendar-admin.json",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/calendar-schema.json",
"assets": [],
"options": {},
"content": {}
Expand Down
4 changes: 2 additions & 2 deletions build/contacts-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"id": "01FPZ19YEHX7MQ5Q6ZS0WK0VEA",
"description": "Skabelon til kontakter.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/contacts.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/contacts-admin.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/contacts.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/contacts-admin.json",
"schema": "",
"assets": [],
"options": {},
Expand Down
4 changes: 2 additions & 2 deletions build/iframe-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"id": "01FQBJQ2M3544ZKAADPWBXHY71",
"description": "Skabelon til iFrame.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/iframe.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/iframe-admin.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/iframe.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/iframe-admin.json",
"schema": "",
"assets": [],
"options": {},
Expand Down
6 changes: 3 additions & 3 deletions build/image-text-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FP2SNGFN0BZQH03KCBXHKYHG",
"description": "Mulighed for at sætte billede og tekst, med forskellige visninger.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/image-text.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/image-text-admin.json?ts=1723805672543",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/image-text-schema.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/image-text.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/image-text-admin.json",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/image-text-schema.json",
"assets": [],
"options": {},
"content": {}
Expand Down
6 changes: 3 additions & 3 deletions build/instagram-feed-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FTZC0RKJYHG4JVZG5K709G46",
"description": "Mulighed for at vise instagram indhold.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/instagram-feed.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/instagram-feed-admin.json?ts=1723805672543",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/instagram-feed-schema.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/instagram-feed.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/instagram-feed-admin.json",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/instagram-feed-schema.json",
"assets": [],
"options": {},
"content": {}
Expand Down
6 changes: 3 additions & 3 deletions build/poster-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FWJZQ25A1868V63CWYYHQFKQ",
"description": "Mulighed for at vise plakat indhold.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/poster.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/poster-admin.json?ts=1723805672543",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/poster-schema.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/poster.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/poster-admin.json",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/poster-schema.json",
"assets": [],
"options": {},
"content": {}
Expand Down
6 changes: 3 additions & 3 deletions build/rss-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FQC300GGWCA7A8H0SXY6P9FG",
"description": "Mulighed for at vise et rss feed.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/rss.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/rss-admin.json?ts=1723805672543",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/rss-schema.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/rss.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/rss-admin.json",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/rss-schema.json",
"assets": [],
"options": {},
"content": {}
Expand Down
6 changes: 3 additions & 3 deletions build/slideshow-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FP2SNSC9VXD10ZKXQR819NS9",
"description": "Skabelon til slideshow af billeder med forskellige effekter",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/slideshow.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/slideshow-admin.json?ts=1723805672543",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/slideshow-schema.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/slideshow.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/slideshow-admin.json",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/slideshow-schema.json",
"assets": [],
"options": {},
"content": {}
Expand Down
6 changes: 3 additions & 3 deletions build/table-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FQBJFKM0YFX1VW5K94VBSNCP",
"description": "Skabelon til tabel.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/table.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/table-admin.json?ts=1723805672543",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/table-schema.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/table.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/table-admin.json",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/table-schema.json",
"assets": [],
"options": {},
"content": {}
Expand Down
4 changes: 2 additions & 2 deletions build/travel-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"id": "01FZD7K807VAKZ99BGSSCHRJM6",
"description": "Skabelon til rejseplanen.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/travel.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/travel-admin.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/travel.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/travel-admin.json",
"schema": "",
"assets": [],
"options": {},
Expand Down
6 changes: 3 additions & 3 deletions build/video-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FQBJFKM0YFX1VW5K94VBSNCC",
"description": "Skabelon til video.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/video.js?ts=1723805672543",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/video-admin.json?ts=1723805672543",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/video-schema.json?ts=1723805672543",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/video.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/video-admin.json",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/video-schema.json",
"assets": [],
"options": {},
"content": {}
Expand Down
4 changes: 2 additions & 2 deletions build/vimeo-player-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"id": "01FQBJQ2M3544ZKAADPWBXHY17",
"description": "Skabelon til Vimeo Video.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/vimeo-player.js?ts=1727091804576",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/vimeo-player-admin.json?ts=1727091804576",
"component": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/vimeo-player.js",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/refs/tags/2.1.1/build/vimeo-player-admin.json",
"schema": "",
"assets": [],
"options": {},
Expand Down
31 changes: 22 additions & 9 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,35 @@ const transformConfig = (type) => (content) => {
const config = JSON.parse(content.toString());

// Base build URL with trailing slash.
const baseUrl = (
type === "develop"
? process.env.DEPLOYMENT_BUILD_BASE_URL_DEVELOP ??
process.env.DEPLOYMENT_BUILD_BASE_URL ??
"https://raw.githubusercontent.com/os2display/display-templates/develop/build/"
: process.env.DEPLOYMENT_BUILD_BASE_URL_MAIN ??
process.env.DEPLOYMENT_BUILD_BASE_URL ??
"https://raw.githubusercontent.com/os2display/display-templates/main/build/"
).replace(/\/*$/, "/");
let baseUrl;

if (type === "develop") {
baseUrl =
process.env.DEPLOYMENT_BUILD_BASE_URL_DEVELOP ??
process.env.DEPLOYMENT_BUILD_BASE_URL ??
"https://raw.githubusercontent.com/os2display/display-templates/develop/build/";
} else if (process.env.DEPLOYMENT_BUILD_TAG) {
baseUrl = `https://raw.githubusercontent.com/os2display/display-templates/refs/tags/${process.env.DEPLOYMENT_BUILD_TAG}/build/`;
} else {
baseUrl =
process.env.DEPLOYMENT_BUILD_BASE_URL_MAIN ??
process.env.DEPLOYMENT_BUILD_BASE_URL ??
"https://raw.githubusercontent.com/os2display/display-templates/main/build/";
}

baseUrl.replace(/\/*$/, "/");

const processPath = (processablePath) => {
const buildPath = processablePath.replace(
"https://display-templates.local.itkdev.dk/build/",
""
);

if (process.env.DEPLOYMENT_BUILD_TAG && type === "main") {
const url = new URL(buildPath, baseUrl);
return url.toString();
}

try {
const url = new URL(buildPath, baseUrl);
url.searchParams.set("ts", timestamp);
Expand Down
Loading