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

Release 46.3.1 #91

Merged
merged 16 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tv2media/inews-gateway",
"version": "46.2.0",
"version": "46.3.0",
"description": "",
"main": "dist/index.js",
"contributors": [
Expand All @@ -24,7 +24,7 @@
"start:dev": "cross-env NODE_ENV=development node ./dist",
"start:local": "cross-env NODE_ENV=local node ./dist",
"info": "npm-scripts-info",
"build": "trash dist && yarn test && yarn build:main",
"build": "trash dist && yarn build:main",
"build:dev": "trash dist && yarn build:main",
"buildstart": "yarn build && yarn start",
"buildstart:dev": "yarn build:dev && DEV=true yarn start",
Expand Down Expand Up @@ -72,10 +72,10 @@
},
"license": "MIT",
"dependencies": {
"@sofie-automation/blueprints-integration": "npm:@tv2media/[email protected]",
"@sofie-automation/server-core-integration": "npm:@tv2media/[email protected]",
"@sofie-automation/blueprints-integration": "npm:@tv2media/[email protected]",
"@sofie-automation/server-core-integration": "npm:@tv2media/[email protected]",
"@sofie-automation/shared-lib": "npm:@tv2media/[email protected]",
"@tv2media/logger": "^1.2.4",
"@sofie-automation/shared-lib": "npm:@tv2media/[email protected]",
"@types/dotenv": "^6.1.1",
"@types/xml2js": "^0.4.4",
"async-mutex": "^0.3.1",
Expand All @@ -86,13 +86,14 @@
"lodash.clonedeep": "^4.5.0",
"tslib": "^2.0.0",
"underscore": "^1.9.1",
"xml2js": "^0.4.19",
"xml2js": "^0.6",
"yargs": "^16.2.0"
},
"resolutions": {
"minimist": "^1.2.3",
"set-value": "^4.0.1",
"ansi-regex": "^5.0.1"
"ansi-regex": "^5.0.1",
"http-cache-semantics": ">=4.1.1"
},
"devDependencies": {
"@types/jest": "^24.0.11",
Expand All @@ -111,7 +112,7 @@
"open-cli": "^6.0.1",
"prettier": "2.1.2",
"standard-version": "^9.0.0",
"trash-cli": "^3.0.0",
"trash-cli": "^5.0.0",
"ts-jest": "^26.4.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.18.0",
Expand Down
1 change: 1 addition & 0 deletions src/@types/inews/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ declare module 'inews' {
cumeTime?: string // number
backTime?: string // @number (seconds since midnight)
layout?: string
skema?: string
}

interface INewsMetaData {
Expand Down
55 changes: 0 additions & 55 deletions src/classes/RundownManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,64 +120,9 @@ export class RundownManager {

this._logger?.debug(`Queue: ${queueName} Story: ${isFile(storyFile) ? storyFile.storyName : storyFile.file}`)

this.generateCuesFromLayoutField(story)
return story
}

public generateCuesFromLayoutField(story: INewsStory): void {
if (!story.fields.layout) {
return
}
this.addDesignLayoutCueToStory(story)
this.addDesignBgCueToStory(story)
}

private addDesignLayoutCueToStory(story: INewsStory): void {
const cueIndex = this.addCueToStory(story, 'DESIGN_LAYOUT')
this.addLinkToStory(story, cueIndex)
}

/**
* Adds a new link to the story that references the cue at the 'cueIndex'
*/
private addLinkToStory(story: INewsStory, cueIndex: number): void {
const lines = story.body!.split('<p>')
const primaryCueIndex = lines.findIndex((line) => !!line.match(/<pi>(.*?)<\/pi>/i))
story.body =
primaryCueIndex > 0
? this.insertLinkAfterFirstPrimaryCue(lines, primaryCueIndex, cueIndex)
: story.body!.concat(`<p><\a idref="${cueIndex}"></a></p>`)
}

private insertLinkAfterFirstPrimaryCue(lines: string[], typeIndex: number, layoutCueIndex: number): string {
const throughPrimaryCueHalf = lines.slice(0, typeIndex + 1)
const afterPrimaryCueHalf = lines.slice(typeIndex + 1, lines.length)
return this.reassembleBody([
...throughPrimaryCueHalf,
`<\a idref="${layoutCueIndex}"></a></p>\r\n`,
...afterPrimaryCueHalf,
])
}

private reassembleBody(lines: string[]): string {
return lines.reduce((previousValue, currentValue) => {
return `${previousValue}<p>${currentValue}`
})
}

/**
* Adds a cue to the story. Returns the index of the newly added cue.
*/
private addCueToStory(story: INewsStory, cueKey: string): number {
story.cues.push([`${cueKey}=${story.fields.layout!.toUpperCase()}`])
return story.cues.length - 1
}

private addDesignBgCueToStory(story: INewsStory): void {
const cueIndex = this.addCueToStory(story, 'DESIGN_BG')
this.addLinkToStory(story, cueIndex)
}

/**
* Downloads a segment from iNews with a given file name (externalId).
* @param queueName Rundown to download from.
Expand Down
117 changes: 0 additions & 117 deletions src/classes/__tests__/RundownManager.spec.ts

This file was deleted.

Loading
Loading