From cad44bfd247272ea8c11764d3b65dfd6a1b2b224 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 1 May 2025 12:43:58 -0300 Subject: data: #things/commentary-entry -> #things/content --- package.json | 2 +- .../composite/things/commentary-entry/index.js | 1 - .../things/commentary-entry/withWebArchiveDate.js | 41 ---------------------- src/data/composite/things/content/index.js | 1 + .../composite/things/content/withWebArchiveDate.js | 41 ++++++++++++++++++++++ src/data/things/content.js | 2 +- 6 files changed, 44 insertions(+), 44 deletions(-) delete mode 100644 src/data/composite/things/commentary-entry/index.js delete mode 100644 src/data/composite/things/commentary-entry/withWebArchiveDate.js create mode 100644 src/data/composite/things/content/index.js create mode 100644 src/data/composite/things/content/withWebArchiveDate.js diff --git a/package.json b/package.json index d19da806..9c29254b 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "#composite/things/art-tag": "./src/data/composite/things/art-tag/index.js", "#composite/things/artist": "./src/data/composite/things/artist/index.js", "#composite/things/artwork": "./src/data/composite/things/artwork/index.js", - "#composite/things/commentary-entry": "./src/data/composite/things/commentary-entry/index.js", + "#composite/things/content": "./src/data/composite/things/content/index.js", "#composite/things/contribution": "./src/data/composite/things/contribution/index.js", "#composite/things/flash": "./src/data/composite/things/flash/index.js", "#composite/things/flash-act": "./src/data/composite/things/flash-act/index.js", diff --git a/src/data/composite/things/commentary-entry/index.js b/src/data/composite/things/commentary-entry/index.js deleted file mode 100644 index 091bae1a..00000000 --- a/src/data/composite/things/commentary-entry/index.js +++ /dev/null @@ -1 +0,0 @@ -export {default as withWebArchiveDate} from './withWebArchiveDate.js'; diff --git a/src/data/composite/things/commentary-entry/withWebArchiveDate.js b/src/data/composite/things/commentary-entry/withWebArchiveDate.js deleted file mode 100644 index 3aaa4f64..00000000 --- a/src/data/composite/things/commentary-entry/withWebArchiveDate.js +++ /dev/null @@ -1,41 +0,0 @@ -import {input, templateCompositeFrom} from '#composite'; - -import {raiseOutputWithoutDependency} from '#composite/control-flow'; - -export default templateCompositeFrom({ - annotation: `withWebArchiveDate`, - - outputs: ['#webArchiveDate'], - - steps: () => [ - { - dependencies: ['annotation'], - - compute: (continuation, {annotation}) => - continuation({ - ['#dateText']: - annotation - ?.match(/https?:\/\/web.archive.org\/web\/([0-9]{8,8})[0-9]*\//) - ?.[1] ?? - null, - }), - }, - - raiseOutputWithoutDependency({ - dependency: '#dateText', - output: input.value({['#webArchiveDate']: null}), - }), - - { - dependencies: ['#dateText'], - compute: (continuation, {['#dateText']: dateText}) => - continuation({ - ['#webArchiveDate']: - new Date( - dateText.slice(0, 4) + '/' + - dateText.slice(4, 6) + '/' + - dateText.slice(6, 8)), - }), - }, - ], -}); diff --git a/src/data/composite/things/content/index.js b/src/data/composite/things/content/index.js new file mode 100644 index 00000000..091bae1a --- /dev/null +++ b/src/data/composite/things/content/index.js @@ -0,0 +1 @@ +export {default as withWebArchiveDate} from './withWebArchiveDate.js'; diff --git a/src/data/composite/things/content/withWebArchiveDate.js b/src/data/composite/things/content/withWebArchiveDate.js new file mode 100644 index 00000000..3aaa4f64 --- /dev/null +++ b/src/data/composite/things/content/withWebArchiveDate.js @@ -0,0 +1,41 @@ +import {input, templateCompositeFrom} from '#composite'; + +import {raiseOutputWithoutDependency} from '#composite/control-flow'; + +export default templateCompositeFrom({ + annotation: `withWebArchiveDate`, + + outputs: ['#webArchiveDate'], + + steps: () => [ + { + dependencies: ['annotation'], + + compute: (continuation, {annotation}) => + continuation({ + ['#dateText']: + annotation + ?.match(/https?:\/\/web.archive.org\/web\/([0-9]{8,8})[0-9]*\//) + ?.[1] ?? + null, + }), + }, + + raiseOutputWithoutDependency({ + dependency: '#dateText', + output: input.value({['#webArchiveDate']: null}), + }), + + { + dependencies: ['#dateText'], + compute: (continuation, {['#dateText']: dateText}) => + continuation({ + ['#webArchiveDate']: + new Date( + dateText.slice(0, 4) + '/' + + dateText.slice(4, 6) + '/' + + dateText.slice(6, 8)), + }), + }, + ], +}); diff --git a/src/data/things/content.js b/src/data/things/content.js index 7f352795..7cf487f1 100644 --- a/src/data/things/content.js +++ b/src/data/things/content.js @@ -14,7 +14,7 @@ import { withResultOfAvailabilityCheck, } from '#composite/control-flow'; -import {withWebArchiveDate} from '#composite/things/commentary-entry'; +import {withWebArchiveDate} from '#composite/things/content'; export class ContentEntry extends Thing { static [Thing.getPropertyDescriptors] = ({Artist}) => ({ -- cgit 1.3.0-6-gf8a5