« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateMusicVideo.js18
-rw-r--r--src/data/things/MusicVideo.js27
-rw-r--r--src/static/css/features.css7
-rw-r--r--src/strings-default.yaml4
4 files changed, 48 insertions, 8 deletions
diff --git a/src/content/dependencies/generateMusicVideo.js b/src/content/dependencies/generateMusicVideo.js
index 1eb33e0b..f02064c4 100644
--- a/src/content/dependencies/generateMusicVideo.js
+++ b/src/content/dependencies/generateMusicVideo.js
@@ -18,6 +18,10 @@ export default {
 
     contributorCredit:
       relation('generateArtistCredit', musicVideo.contributorContribs, []),
+
+    watchLinks:
+      musicVideo.urls
+        .map(url => relation('linkExternal', url)),
   }),
 
   data: (musicVideo, _thing) => ({
@@ -27,7 +31,7 @@ export default {
     label:
       musicVideo.label,
 
-    url:
+    primaryURL:
       musicVideo.url,
   }),
 
@@ -53,10 +57,20 @@ export default {
           })),
 
         relations.image.slots({
-          link: data.url,
+          link: data.primaryURL,
         }),
 
         html.tag('p',
+          {[html.onlyIfContent]: true},
+
+          html.tag('span', {class: 'watch-line'},
+            language.$(capsule, 'watchOn', {
+              links:
+                language.formatUnitList(relations.watchLinks),
+            }))),
+
+        html.tag('p',
+          {[html.onlyIfContent]: true},
           {[html.joinChildren]: html.tag('br')},
 
           [
diff --git a/src/data/things/MusicVideo.js b/src/data/things/MusicVideo.js
index 38387a30..c832072b 100644
--- a/src/data/things/MusicVideo.js
+++ b/src/data/things/MusicVideo.js
@@ -23,6 +23,7 @@ import {
   soupyFind,
   soupyReverse,
   thing,
+  urls,
 } from '#composite/wiki-properties';
 
 export class MusicVideo extends Thing {
@@ -65,10 +66,20 @@ export class MusicVideo extends Thing {
       constituteFrom('thing', V('date')),
     ],
 
-    url: {
-      flags: {update: true, expose: true},
-      update: {validate: isURL},
-    },
+    url: [
+      exposeUpdateValueOrContinue({
+        validate: input.value(isURL),
+      }),
+
+      exitWithoutDependency('urls', V(null), V('empty')),
+
+      {
+        dependencies: ['urls'],
+        compute: ({urls}) => urls[0],
+      },
+    ],
+
+    urls: urls(),
 
     coverArtFileExtension: fileExtension(V('jpg')),
     coverArtDimensions: dimensions(),
@@ -114,6 +125,7 @@ export class MusicVideo extends Thing {
       'Directory': {property: 'unqualifiedDirectory'},
       'Date': {property: 'date', transform: parseDate},
       'URL': {property: 'url'},
+      'URLs': {property: 'urls'},
 
       'Cover Art File Extension': {property: 'coverArtFileExtension'},
       'Cover Art Dimensions': {property: 'coverArtDimensions'},
@@ -122,6 +134,13 @@ export class MusicVideo extends Thing {
       'Contributor Style': {property: 'contributorStyle'},
       'Contributors': {property: 'contributorContribs', transform: parseContributors},
     },
+
+    invalidFieldCombinations: [
+      {message: `Specify all URLs on "URLs" field, if specifying multiple`, fields: [
+        'URL',
+        'URLs',
+      ]},
+    ],
   };
 
   static [Thing.reverseSpecs] = {
diff --git a/src/static/css/features.css b/src/static/css/features.css
index 410bf5b9..3a1a0cdd 100644
--- a/src/static/css/features.css
+++ b/src/static/css/features.css
@@ -780,13 +780,16 @@
     margin-bottom: 6px;
   }
 
-  .music-video .artists-line {
+  .music-video .artists-line,
+  .music-video .watch-line {
     display: block;
+    padding-right: 0.4ch;
     padding-left: 1.2ch;
     text-indent: -1.2ch;
   }
 
-  .music-video .artists-line > * {
+  .music-video .artists-line > *,
+  .music-video .watch-line > * {
     text-indent: 0;
   }
 
diff --git a/src/strings-default.yaml b/src/strings-default.yaml
index 9868745c..15bff2e8 100644
--- a/src/strings-default.yaml
+++ b/src/strings-default.yaml
@@ -377,6 +377,7 @@ releaseInfo:
 
   visitOn: "Visit on {LINKS}."
   playOn: "Play on {LINKS}."
+  watchOn: "Watch on {LINKS}."
 
   readCommentary:
     _: "Read {LINK}."
@@ -1037,6 +1038,9 @@ misc:
     label.customLabel: "{LABEL}!"
     label.customLabel.title: "{TITLE}"
 
+    watchOn: >-
+      Watch on: {LINKS}
+
     artistsLine: >-
       Music video {CREDIT}