« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/linkContribution.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js
index c17cc45a..aee93d60 100644
--- a/src/content/dependencies/linkContribution.js
+++ b/src/content/dependencies/linkContribution.js
@@ -5,6 +5,7 @@ export default {
     'generateTextWithTooltip',
     'generateTooltip',
     'linkArtist',
+    'linkAnythingMan',
     'linkExternalAsIcon',
   ],
 
@@ -22,6 +23,26 @@ export default {
     relations.tooltip =
       relation('generateTooltip');
 
+    let previous = contribution;
+    while (previous && previous.thing === contribution.thing) {
+      previous = previous.previousBySameArtist;
+    }
+
+    let next = contribution;
+    while (next && next.thing === contribution.thing) {
+      next = next.nextBySameArtist;
+    }
+
+    if (previous) {
+      relations.previousLink =
+        relation('linkAnythingMan', previous.thing);
+    }
+
+    if (next) {
+      relations.nextLink =
+        relation('linkAnythingMan', next.thing);
+    }
+
     if (!empty(contribution.artist.urls)) {
       relations.artistIcons =
         contribution.artist.urls
@@ -41,6 +62,7 @@ export default {
   slots: {
     showContribution: {type: 'boolean', default: false},
     showIcons: {type: 'boolean', default: false},
+    showChronology: {type: 'boolean', default: false},
     preventWrapping: {type: 'boolean', default: true},
 
     iconMode: {
@@ -94,6 +116,29 @@ export default {
           }));
     }
 
+    if (slots.showChronology) {
+      tooltipContent.push(
+        language.encapsulate(capsule, 'chronology', capsule => [
+          html.tag('span', {class: 'chronology-link'},
+            {[html.onlyIfContent]: true},
+
+            language.$(capsule, 'previous', {
+              [language.onlyIfOptions]: ['thing'],
+
+              thing: relations.previousLink,
+            })),
+
+          html.tag('span', {class: 'chronology-link'},
+            {[html.onlyIfContent]: true},
+
+            language.$(capsule, 'next', {
+              [language.onlyIfOptions]: ['thing'],
+
+              thing: relations.nextLink,
+            })),
+        ]));
+    }
+
     // TODO: It probably shouldn't be necessary to do an isBlank call here.
     options.artist =
       (html.isBlank(tooltipContent)