From 032a10b14fc4d32a0925bf6cc55d5a587a14a71f Mon Sep 17 00:00:00 2001 From: Vladyslav Hrytsenko Date: Thu, 15 Aug 2024 17:27:55 +0300 Subject: [PATCH] updates to mogrt --- packages/nexrender-action-mogrt/README.md | 24 ++++++++++++++++++++--- packages/nexrender-action-mogrt/index.js | 4 ++-- packages/nexrender-action-mogrt/test.js | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/nexrender-action-mogrt/README.md b/packages/nexrender-action-mogrt/README.md index 43ae23ba..d21dca60 100644 --- a/packages/nexrender-action-mogrt/README.md +++ b/packages/nexrender-action-mogrt/README.md @@ -10,7 +10,8 @@ This plugin adds .mogrt support to Nexrender. 1. Set a .mogrt file as the `template.src` value 2. Add this module in predownload actions -3. Add any Essential Graphics parameters you want to change as `essentialParameters` +3. Add any Essential Graphics parameters you want to change as `params` +4. Use unique layer names in the .mogrt file to reference assets to leverage nexrender built-in asset substitution ```json @@ -19,13 +20,31 @@ This plugin adds .mogrt support to Nexrender. "src": "http://www.foo.com/template.mogrt", "composition": "will_be_ignored" }, + "assets": [ + { + "type": "image", + "src": "http://www.foo.com/image.png", + "layerName": "$ref-layer-1" + }, + { + "type": "image", + "src": "http://www.foo.com/image2.png", + "layerName": "$ref-layer-2" + } + ], "actions": { "predownload": [ { "module": "nexrender-action-mogrt-template", - "essentialParameters": { + "params": { "Title": "This should be the title", "Dropdown": 2, + "Group Name": { + "Some Name": "Some Value", + "Another Name": 123 + }, + "My First Image": "$ref-image-1", + "My Second Image": "$ref-image-2" "Scale": [50, 50], "Checkbox": true, "Point Control:": [30, 50], @@ -43,5 +62,4 @@ This plugin adds .mogrt support to Nexrender. * Any `template.src` without a .mogrt extension will be ignored * The value in `template.composition` will be ignored, as .mogrt files specify what composition to use on their own, but Nexrender requires one to be specified -* Media replacement through essential graphics isn't supported (yet), but normal asset injection with Nexrender will work * Invalid .mogrt files will cause an error diff --git a/packages/nexrender-action-mogrt/index.js b/packages/nexrender-action-mogrt/index.js index c13c82b6..e709500f 100644 --- a/packages/nexrender-action-mogrt/index.js +++ b/packages/nexrender-action-mogrt/index.js @@ -5,7 +5,7 @@ module.exports = async (job, settings, options, type) => { settings.logger = settings.logger ?? console; const jsxUrl = url.pathToFileURL(path.join(__dirname, 'applyEssentialValues.jsx')).toString(); if (type === 'predownload') { - if (typeof options.essentialParameters !== 'undefined') { + if (typeof options.params !== 'undefined') { job.assets.unshift({ src: jsxUrl, keyword: '_essential', @@ -13,7 +13,7 @@ module.exports = async (job, settings, options, type) => { parameters: [ { key: 'essentialParameters', - value: Object.assign({}, options.essentialParameters) + value: Object.assign({}, options.params) } ] }) diff --git a/packages/nexrender-action-mogrt/test.js b/packages/nexrender-action-mogrt/test.js index 30c72bb5..a84cfb98 100644 --- a/packages/nexrender-action-mogrt/test.js +++ b/packages/nexrender-action-mogrt/test.js @@ -16,7 +16,7 @@ describe("action/mogrt",() => { }, settings: {}, options: { - essentialParameters: { + params: { foo: 'bar', } },