Skip to content

Commit

Permalink
Merge pull request #153 from os2display/feature/1342-update-rejseplan…
Browse files Browse the repository at this point in the history
…s-template-to-remove-hack-yay

Feature/1342 update rejseplans template to remove hack yay
  • Loading branch information
sinejespersen authored Jun 3, 2024
2 parents b813767 + f82c3b4 commit 1c7297a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- [#153](https://github.com/os2display/display-templates/pull/153)
- Replace the temporary rejseplans "hack" with an actual solution.

## [2.0.0] - 2024-04-09

- [#151](https://github.com/os2display/display-templates/pull/151)
Expand Down
4 changes: 2 additions & 2 deletions build/travel-config-develop.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/develop/build/travel.js?ts=1705317070424",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/travel-admin.json?ts=1705317070424",
"component": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/travel.js?ts=1716881579494",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/travel-admin.json?ts=1716881579494",
"schema": "",
"assets": [],
"options": {},
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=1705317070424",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/travel-admin.json?ts=1705317070424",
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/travel.js?ts=1716881579494",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/travel-admin.json?ts=1716881579494",
"schema": "",
"assets": [],
"options": {},
Expand Down
2 changes: 1 addition & 1 deletion build/travel.js

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,14 +1000,16 @@ const slides = [
},
},
content: {
numberOfJourneys: 3,
numberOfJourneys: 13,
station: [
{
name: "Skelbækvej v rådhuset",
x: "9420345",
y: "55023889",
id: "751434104",
},
{ id: "751434104", name: "Kollund Kro" },
{ id: "503000201", name: "Kollund Kro" },
{ id: "53014", name: "Rolighedsvej" },
{ id: "44061", name: "Roløkke (Oddevej)" },
{ id: "3342", name: "Rolfsvej (Esrumvej)" },
{ id: "3269", name: "Rolfsvej (Esrumvej)" },
{ id: "41565", name: "Rolfsvej (Maribovej)" },
{ id: "813041802", name: "Rolykkevej (Sæbygårdvej / Sæby)" },
],
iframeTitle: "Titel til iframe",
title: "Overskrift",
Expand Down
18 changes: 1 addition & 17 deletions src/travel/travel.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,12 @@ function Travel({ slide, content, run, slideDone, executionId }) {
// Rich text input sanitized
const sanitizedtext = text ? parse(DOMPurify.sanitize(text, {})) : "";

// This is a shameful hack, hopefully temporarily, to combat the fact that the station-api
// only returns a station in _one direction_, instead of both
// After meeting*s* about this, we have concluded that the ids follow a pattern, where the last character
// in the string is defining which direction, and can be anything from 0-9.
// So, here we replace the last character of the id with 0-9, and then the rejseplan-api disregards ids that
// are not connected to a station (we hope).
const getStationIds = () => {
if (!(station instanceof Array) || station.length === 0) {
return "";
}

let ids = "";
const idWithMissingLastCharacter = station[0].id.substring(
0,
station[0].id.length - 1
);

[...Array(10).keys()].forEach((i) => {
ids += `${idWithMissingLastCharacter}${i}@`;
});

return ids;
return station.reduce((carry, { id }) => `${carry}${id}@`, "");
};

const imageStyle = {};
Expand Down

0 comments on commit 1c7297a

Please sign in to comment.