« get me outta code hell

content: linkContribution: show "Other" as fallback platform - 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-03-29 16:28:50 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-03-29 20:01:45 -0300
commitcbfea6a0e017c4a8a4c47df688072d95180313a2 (patch)
tree876ae87b8e896382edee4775dc34ee60195cea48
parent4e11adf60b74db6a69fcebbf07dcd7c8e8b00a20 (diff)
content: linkContribution: show "Other" as fallback platform
-rw-r--r--src/content/dependencies/linkContribution.js27
-rw-r--r--src/strings-default.yaml4
2 files changed, 25 insertions, 6 deletions
diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js
index c69a5b4..41ce114 100644
--- a/src/content/dependencies/linkContribution.js
+++ b/src/content/dependencies/linkContribution.js
@@ -78,18 +78,33 @@ export default {
                   stitchArrays({
                     icon: relations.artistIcons,
                     url: data.urls,
-                  }).map(({icon, url}) => [
-                      icon.slots({
+                  }).map(({icon, url}) => {
+                      icon.setSlots({
                         context: 'artist',
                         withText: true,
-                      }),
+                      });
 
-                      html.tag('span', {class: 'icon-platform'},
+                      let platformText =
                         language.formatExternalLink(url, {
                           context: 'artist',
                           style: 'platform',
-                        })),
-                    ]),
+                        });
+
+                      // This is a pretty ridiculous hack, but we currently
+                      // don't have a way of telling formatExternalLink to *not*
+                      // use the fallback string, which just formats the URL as
+                      // its host/domain... so is technically detectable.
+                      if (platformText.toString() === (new URL(url)).host) {
+                        platformText =
+                          language.$('misc.artistLink.noExternalLinkPlatformName');
+                      }
+
+                      const platformSpan =
+                        html.tag('span', {class: 'icon-platform'},
+                          platformText);
+
+                      return [icon, platformSpan];
+                    }),
               }),
           })
         : relations.artistLink);
diff --git a/src/strings-default.yaml b/src/strings-default.yaml
index cd05ce5..de0cc96 100644
--- a/src/strings-default.yaml
+++ b/src/strings-default.yaml
@@ -453,6 +453,10 @@ misc:
     # Combination of above.
     withContribution.withExternalLinks: "{ARTIST} ({CONTRIB}) ({LINKS})"
 
+    # Displayed in an artist's tooltip, if one of their URLs
+    # isn't a specially detected web platform.
+    noExternalLinkPlatformName: "Other"
+
   # chronology:
   #
   #   "Chronology links" are a section that appear in the nav bar for