« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/data/composite/wiki-data/withParsedCommentaryEntries.js27
-rw-r--r--src/util/wiki-data.js2
2 files changed, 27 insertions, 2 deletions
diff --git a/src/data/composite/wiki-data/withParsedCommentaryEntries.js b/src/data/composite/wiki-data/withParsedCommentaryEntries.js
index 5c28d20e..144781a8 100644
--- a/src/data/composite/wiki-data/withParsedCommentaryEntries.js
+++ b/src/data/composite/wiki-data/withParsedCommentaryEntries.js
@@ -95,6 +95,8 @@ export default templateCompositeFrom({
         'artistDisplayText',
         'annotation',
         'date',
+        'secondDate',
+        'dateKind',
         'accessDate',
         'accessKind',
       ]),
@@ -165,11 +167,28 @@ export default templateCompositeFrom({
         ['#entries.date']: date,
       }) => continuation({
         ['#entries.date']:
-          date.map(date => date ? new Date(date) : null),
+          date
+            .map(date => date ? new Date(date) : null),
       }),
     },
 
     {
+      dependencies: ['#entries.secondDate'],
+      compute: (continuation, {
+        ['#entries.secondDate']: secondDate,
+      }) => continuation({
+        ['#entries.secondDate']:
+          secondDate
+            .map(date => date ? new Date(date) : null),
+      }),
+    },
+
+    fillMissingListItems({
+      list: '#entries.dateKind',
+      fill: input.value(null),
+    }),
+
+    {
       dependencies: ['#entries.accessDate', '#entries.webArchiveDate'],
       compute: (continuation, {
         ['#entries.accessDate']: accessDate,
@@ -206,6 +225,8 @@ export default templateCompositeFrom({
         '#entries.artistDisplayText',
         '#entries.annotation',
         '#entries.date',
+        '#entries.secondDate',
+        '#entries.dateKind',
         '#entries.accessDate',
         '#entries.accessKind',
         '#entries.body',
@@ -216,6 +237,8 @@ export default templateCompositeFrom({
         ['#entries.artistDisplayText']: artistDisplayText,
         ['#entries.annotation']: annotation,
         ['#entries.date']: date,
+        ['#entries.secondDate']: secondDate,
+        ['#entries.dateKind']: dateKind,
         ['#entries.accessDate']: accessDate,
         ['#entries.accessKind']: accessKind,
         ['#entries.body']: body,
@@ -226,6 +249,8 @@ export default templateCompositeFrom({
             artistDisplayText,
             annotation,
             date,
+            secondDate,
+            dateKind,
             accessDate,
             accessKind,
             body,
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index f64902b7..33db526b 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -94,7 +94,7 @@ const dateRegex = groupName =>
   String.raw`(?<${groupName}>[a-zA-Z]+ [0-9]{1,2}, [0-9]{4,4}|[0-9]{1,2} [^,]*[0-9]{4,4}|[0-9]{1,4}[-/][0-9]{1,4}[-/][0-9]{1,4})`;
 
 const commentaryRegexRaw =
-  String.raw`^<i>(?<artistReferences>.+?)(?:\|(?<artistDisplayText>.+))?:<\/i>(?: \((?<annotation>(?:.*?(?=,|\)[^)]*$))*?)(?:,? ?${dateRegex('date')}(?: (?<accessKind>captured|accessed) ${dateRegex('accessDate')})?)?\))?`;
+  String.raw`^<i>(?<artistReferences>.+?)(?:\|(?<artistDisplayText>.+))?:<\/i>(?: \((?<annotation>(?:.*?(?=,|\)[^)]*$))*?)(?:,? ?(?:(?<dateKind>sometime|throughout|around) )?${dateRegex('date')}(?: ?- ?${dateRegex('secondDate')})?(?: (?<accessKind>captured|accessed) ${dateRegex('accessDate')})?)?\))?`;
 export const commentaryRegexCaseInsensitive =
   new RegExp(commentaryRegexRaw, 'gmi');
 export const commentaryRegexCaseSensitive =