« get me outta code hell

data: Contribution.annotationFront, is{Featuring,EditsForWiki}Credit - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/contrib/Contribution.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-01-26 17:49:33 -0400
committer(quasar) nebula <qznebula@protonmail.com>2026-01-26 17:49:33 -0400
commitdf244f21af6078f9456d8281da3a19e7c1e1a2f3 (patch)
treee54b9000c85266d3bfbfaa69526285c8d5ac71b1 /src/data/things/contrib/Contribution.js
parent4f9adf7339e0c646ff732ee1b6d164f32e352103 (diff)
data: Contribution.annotationFront, is{Featuring,EditsForWiki}Credit
Diffstat (limited to 'src/data/things/contrib/Contribution.js')
-rw-r--r--src/data/things/contrib/Contribution.js53
1 files changed, 44 insertions, 9 deletions
diff --git a/src/data/things/contrib/Contribution.js b/src/data/things/contrib/Contribution.js
index 4048709b..57a5c301 100644
--- a/src/data/things/contrib/Contribution.js
+++ b/src/data/things/contrib/Contribution.js
@@ -121,16 +121,51 @@ export class Contribution extends Thing {
 
     isContribution: exposeConstant(V(true)),
 
-    annotationParts: {
-      flags: {expose: true},
-      expose: {
-        dependencies: ['annotation'],
-        compute: ({annotation}) =>
-          (annotation
-            ? annotation.split(',').map(part => part.trim())
-            : []),
+    recognizedAnnotationFronts: exposeConstant(V([])),
+
+    annotationFront: [
+      exitWithoutDependency('annotation'),
+
+      {
+        dependencies: ['recognizedAnnotationFronts', 'annotation'],
+        compute: ({recognizedAnnotationFronts, annotation}) =>
+          recognizedAnnotationFronts
+            .find(front =>
+              annotation.startsWith(front) && (
+                annotation === front ||
+                annotation.at(front.length) === ':' ||
+                annotation.at(front.length) === ','
+              )) ?? null,
       },
-    },
+    ],
+
+    annotationBack: [
+      exitWithoutDependency('annotation'),
+
+      exitWithoutDependency({
+        dependency: 'annotationFront',
+        value: 'annotation',
+      }),
+
+      {
+        dependencies: ['annotation', 'annotationFront'],
+        compute: ({annotation, annotationFront}) =>
+          annotation.slice(annotationFront.length + 1).trim()
+            || null,
+      },
+    ],
+
+    annotationParts: [
+      exitWithoutDependency('annotationBack', V([])),
+
+      {
+        dependencies: ['annotationBack'],
+        compute: ({annotationBack}) =>
+          annotationBack
+            .split(',')
+            .map(part => part.trim()),
+      },
+    ],
 
     context: [
       withContributionContext(),