« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkContribution.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/linkContribution.js')
-rw-r--r--src/content/dependencies/linkContribution.js29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js
index 26f0b2d7..c658d461 100644
--- a/src/content/dependencies/linkContribution.js
+++ b/src/content/dependencies/linkContribution.js
@@ -19,16 +19,20 @@ export default {
   }),
 
   data: (contribution) => ({
-    contribution: contribution.annotation,
+    annotation: contribution.annotation,
     urls: contribution.artist.urls,
   }),
 
   slots: {
-    showContribution: {type: 'boolean', default: false},
+    showAnnotation: {type: 'boolean', default: false},
     showExternalLinks: {type: 'boolean', default: false},
     showChronology: {type: 'boolean', default: false},
 
+    trimAnnotation: {type: 'boolean', default: false},
+
     preventWrapping: {type: 'boolean', default: true},
+    preventTooltip: {type: 'boolean', default: false},
+
     chronologyKind: {type: 'string'},
   },
 
@@ -42,6 +46,9 @@ export default {
       language.encapsulate('misc.artistLink', workingCapsule => {
         const workingOptions = {};
 
+        // Filling slots early is necessary to actually give the tooltip
+        // content. Otherwise, the coming-up html.isBlank() always reports
+        // the tooltip as blank!
         relations.tooltip.setSlots({
           showExternalLinks: slots.showExternalLinks,
           showChronology: slots.showChronology,
@@ -49,7 +56,7 @@ export default {
         });
 
         workingOptions.artist =
-          (html.isBlank(relations.tooltip)
+          (html.isBlank(relations.tooltip) || slots.preventTooltip
             ? relations.artistLink
             : relations.textWithTooltip.slots({
                 customInteractionCue: true,
@@ -60,17 +67,17 @@ export default {
                   }),
 
                 tooltip:
-                  relations.tooltip.slots({
-                    showExternalLinks: slots.showExternalLinks,
-                    showChronology: slots.showChronology,
-                    chronologyKind: slots.chronologyKind,
-                  }),
+                  relations.tooltip,
               }));
 
-        if (slots.showContribution && data.contribution) {
+        const annotation =
+          (slots.trimAnnotation
+            ? data.annotation?.replace(/^edits for wiki(: )?/, '')
+            : data.annotation);
+
+        if (slots.showAnnotation && annotation) {
           workingCapsule += '.withContribution';
-          workingOptions.contrib =
-            data.contribution;
+          workingOptions.contrib = annotation;
         }
 
         return language.formatString(workingCapsule, workingOptions);