« get me outta code hell

content: generateCommentaryEntry: date ranges, date kinds - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-06-21 20:50:07 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-23 22:15:00 -0300
commit818f37ed334b2ab215a840c5b1cf5ee233a9d423 (patch)
treee96bae3463be4134786ec992a30d479ba21c9611
parent4abfc0347a03e28eb954817bd84bf832840b6305 (diff)
content: generateCommentaryEntry: date ranges, date kinds
-rw-r--r--src/content/dependencies/generateCommentaryEntry.js36
-rw-r--r--src/strings-default.yaml8
2 files changed, 40 insertions, 4 deletions
diff --git a/src/content/dependencies/generateCommentaryEntry.js b/src/content/dependencies/generateCommentaryEntry.js
index f7f04f16..c148d244 100644
--- a/src/content/dependencies/generateCommentaryEntry.js
+++ b/src/content/dependencies/generateCommentaryEntry.js
@@ -45,6 +45,9 @@ export default {
 
   data: (entry) => ({
     date: entry.date,
+    secondDate: entry.secondDate,
+    dateKind: entry.dateKind,
+
     accessDate: entry.accessDate,
     accessKind: entry.accessKind,
   }),
@@ -113,11 +116,36 @@ export default {
                   {class: 'text-with-tooltip-interaction-cue'},
                   {[html.onlyIfContent]: true},
 
-                  language.$(titleCapsule, 'date', {
-                    [language.onlyIfOptions]: ['date'],
+                  language.encapsulate(titleCapsule, 'date', workingCapsule => {
+                    const workingOptions = {};
+
+                    if (!data.date) {
+                      return html.blank();
+                    }
+
+                    const rangeNeeded =
+                      data.dateKind === 'sometime' ||
+                      data.dateKind === 'throughout';
+
+                    if (rangeNeeded && !data.secondDate) {
+                      workingOptions.date = language.formatDate(data.date);
+                      return language.$(workingCapsule, workingOptions);
+                    }
+
+                    if (data.dateKind) {
+                      workingCapsule += '.' + data.dateKind;
+                    }
+
+                    if (data.secondDate) {
+                      workingCapsule += '.range';
+                      workingOptions.dateRange =
+                        language.formatDateRange(data.date, data.secondDate);
+                    } else {
+                      workingOptions.date =
+                        language.formatDate(data.date);
+                    }
 
-                    date:
-                      language.formatDate(data.date),
+                    return language.$(workingCapsule, workingOptions);
                   })),
 
               tooltip:
diff --git a/src/strings-default.yaml b/src/strings-default.yaml
index c685f1d7..eab080af 100644
--- a/src/strings-default.yaml
+++ b/src/strings-default.yaml
@@ -463,9 +463,17 @@ misc:
           withAnnotation: "({ANNOTATION})"
 
         date: "{DATE}"
+        date.range: "{DATE_RANGE}"
+
         date.accessed: "accessed {DATE}"
         date.captured: "captured {DATE}"
 
+        date.around: "around {DATE}"
+        date.around.range: "around {DATE_RANGE}"
+
+        date.sometime.range: "sometime {DATE_RANGE}"
+        date.throughout.range: "throughout {DATE_RANGE}"
+
       seeOriginalRelease: "See {ORIGINAL}!"
 
   # artistLink: