4 İşlemeler 913f418ead ... 60f007a20d

Yazar SHA1 Mesaj Tarih
  (quasar) nebula 60f007a20d data: Album.suffixTrackDirectories 3 hafta önce
  (quasar) nebula 163c541f4b data: Track.suffixDirectory, Album.directorySuffix 3 hafta önce
  (quasar) nebula 6ac3a98cb6 data: withDirectoryFromName: move to helpers 3 hafta önce
  (quasar) nebula 317138b543 data: directory: pass name option through 3 hafta önce

+ 2 - 0
src/data/composite/things/track/index.js

@@ -6,9 +6,11 @@ export {default as withAlbum} from './withAlbum.js';
 export {default as withAlwaysReferenceByDirectory} from './withAlwaysReferenceByDirectory.js';
 export {default as withContainingTrackSection} from './withContainingTrackSection.js';
 export {default as withDate} from './withDate.js';
+export {default as withDirectorySuffix} from './withDirectorySuffix.js';
 export {default as withHasUniqueCoverArt} from './withHasUniqueCoverArt.js';
 export {default as withOriginalRelease} from './withOriginalRelease.js';
 export {default as withOtherReleases} from './withOtherReleases.js';
 export {default as withPropertyFromAlbum} from './withPropertyFromAlbum.js';
 export {default as withPropertyFromOriginalRelease} from './withPropertyFromOriginalRelease.js';
+export {default as withSuffixDirectoryFromAlbum} from './withSuffixDirectoryFromAlbum.js';
 export {default as withTrackArtDate} from './withTrackArtDate.js';

+ 36 - 0
src/data/composite/things/track/withDirectorySuffix.js

@@ -0,0 +1,36 @@
+import {input, templateCompositeFrom} from '#composite';
+
+import {raiseOutputWithoutDependency} from '#composite/control-flow';
+
+import withPropertyFromAlbum from './withPropertyFromAlbum.js';
+import withSuffixDirectoryFromAlbum from './withSuffixDirectoryFromAlbum.js';
+
+export default templateCompositeFrom({
+  annotation: `withDirectorySuffix`,
+
+  outputs: ['#directorySuffix'],
+
+  steps: () => [
+    withSuffixDirectoryFromAlbum(),
+
+    raiseOutputWithoutDependency({
+      dependency: '#suffixDirectoryFromAlbum',
+      mode: input.value('falsy'),
+      output: input.value({['#directorySuffix']: null}),
+    }),
+
+    withPropertyFromAlbum({
+      property: input.value('directorySuffix'),
+    }),
+
+    {
+      dependencies: ['#album.directorySuffix'],
+      compute: (continuation, {
+        ['#album.directorySuffix']: directorySuffix,
+      }) => continuation({
+        ['#directorySuffix']:
+          directorySuffix,
+      }),
+    },
+  ],
+});

+ 53 - 0
src/data/composite/things/track/withSuffixDirectoryFromAlbum.js

@@ -0,0 +1,53 @@
+import {input, templateCompositeFrom} from '#composite';
+
+import {withResultOfAvailabilityCheck} from '#composite/control-flow';
+
+import withPropertyFromAlbum from './withPropertyFromAlbum.js';
+
+export default templateCompositeFrom({
+  annotation: `withSuffixDirectoryFromAlbum`,
+
+  inputs: {
+    flagValue: input({
+      defaultDependency: 'suffixDirectoryFromAlbum',
+      acceptsNull: true,
+    }),
+  },
+
+  outputs: ['#suffixDirectoryFromAlbum'],
+
+  steps: () => [
+    withResultOfAvailabilityCheck({
+      from: 'suffixDirectoryFromAlbum',
+    }),
+
+    {
+      dependencies: [
+        '#availability',
+        'suffixDirectoryFromAlbum'
+      ],
+
+      compute: (continuation, {
+        ['#availability']: availability,
+        ['suffixDirectoryFromAlbum']: flagValue,
+      }) =>
+        (availability
+          ? continuation.raiseOutput({['#suffixDirectoryFromAlbum']: flagValue})
+          : continuation()),
+    },
+
+    withPropertyFromAlbum({
+      property: input.value('suffixTrackDirectories'),
+    }),
+
+    {
+      dependencies: ['#album.suffixTrackDirectories'],
+      compute: (continuation, {
+        ['#album.suffixTrackDirectories']: suffixTrackDirectories,
+      }) => continuation({
+        ['#suffixDirectoryFromAlbum']:
+          suffixTrackDirectories,
+      }),
+    },
+  ],
+});

+ 1 - 2
src/data/composite/wiki-data/withDirectoryFromName.js

@@ -1,4 +1,4 @@
-// Compute a directory from a name - by default the current thing's own name.
+// Compute a directory from a name.
 
 import {input, templateCompositeFrom} from '#composite';
 
@@ -13,7 +13,6 @@ export default templateCompositeFrom({
   inputs: {
     name: input({
       validate: isName,
-      defaultDependency: 'name',
       acceptsNull: true,
     }),
   },

+ 52 - 0
src/data/composite/wiki-data/helpers/withSimpleDirectory.js

@@ -0,0 +1,52 @@
+// A "simple" directory, based only on the already-provided directory, if
+// available, or the provided name.
+
+import {input, templateCompositeFrom} from '#composite';
+
+import {isDirectory, isName} from '#validators';
+
+import {withResultOfAvailabilityCheck} from '#composite/control-flow';
+
+import withDirectoryFromName from './withDirectoryFromName.js';
+
+export default templateCompositeFrom({
+  annotation: `withSimpleDirectory`,
+
+  inputs: {
+    directory: input({
+      validate: isDirectory,
+      defaultDependency: 'directory',
+      acceptsNull: true,
+    }),
+
+    name: input({
+      validate: isName,
+      acceptsNull: true,
+    }),
+  },
+
+  outputs: ['#directory'],
+
+  steps: () => [
+    withResultOfAvailabilityCheck({
+      from: input('directory'),
+    }),
+
+    {
+      dependencies: ['#availability', input('directory')],
+      compute: (continuation, {
+        ['#availability']: availability,
+        [input('directory')]: directory,
+      }) =>
+        (availability
+          ? continuation.raiseOutput({
+              ['#directory']: directory
+            })
+          : continuation()),
+    },
+
+    withDirectoryFromName({
+      name: input('name'),
+    }),
+  ],
+});

+ 0 - 1
src/data/composite/wiki-data/index.js

@@ -10,7 +10,6 @@ export {default as withClonedThings} from './withClonedThings.js';
 export {default as withContributionListSums} from './withContributionListSums.js';
 export {default as withCoverArtDate} from './withCoverArtDate.js';
 export {default as withDirectory} from './withDirectory.js';
-export {default as withDirectoryFromName} from './withDirectoryFromName.js';
 export {default as withParsedCommentaryEntries} from './withParsedCommentaryEntries.js';
 export {default as withRecontextualizedContributionList} from './withRecontextualizedContributionList.js';
 export {default as withRedatedContributionList} from './withRedatedContributionList.js';

+ 24 - 17
src/data/composite/wiki-data/withDirectory.js

@@ -7,9 +7,9 @@ import {input, templateCompositeFrom} from '#composite';
 
 import {isDirectory, isName} from '#validators';
 
-import {withResultOfAvailabilityCheck} from '#composite/control-flow';
+import {raiseOutputWithoutDependency} from '#composite/control-flow';
 
-import withDirectoryFromName from './withDirectoryFromName.js';
+import withSimpleDirectory from './helpers/withSimpleDirectory.js';
 
 export default templateCompositeFrom({
   annotation: `withDirectory`,
@@ -26,30 +26,37 @@ export default templateCompositeFrom({
       defaultDependency: 'name',
       acceptsNull: true,
     }),
+
+    suffix: input({
+      validate: isDirectory,
+      defaultValue: null,
+    }),
   },
 
   outputs: ['#directory'],
 
   steps: () => [
-    withResultOfAvailabilityCheck({
-      from: input('directory'),
+    withSimpleDirectory({
+      directory: input('directory'),
+      name: input('name'),
+    }),
+
+    raiseOutputWithoutDependency({
+      dependency: '#directory',
+      output: input.value({['#directory']: null}),
     }),
 
     {
-      dependencies: ['#availability', input('directory')],
+      dependencies: ['#directory', input('suffix')],
       compute: (continuation, {
-        ['#availability']: availability,
-        [input('directory')]: directory,
-      }) =>
-        (availability
-          ? continuation.raiseOutput({
-              ['#directory']: directory
-            })
-          : continuation()),
+        ['#directory']: directory,
+        [input('suffix')]: suffix,
+      }) => continuation({
+        ['#directory']:
+          (suffix
+            ? directory + '-' + suffix
+            : directory),
+      }),
     },
-
-    withDirectoryFromName({
-      name: input('name'),
-    }),
   ],
 });

+ 7 - 0
src/data/composite/wiki-properties/directory.js

@@ -19,11 +19,18 @@ export default templateCompositeFrom({
       validate: isName,
       defaultDependency: 'name',
     }),
+
+    suffix: input({
+      validate: isDirectory,
+      defaultValue: null,
+    }),
   },
 
   steps: () => [
     withDirectory({
       directory: input.updateValue({validate: isDirectory}),
+      name: input('name'),
+      suffix: input('suffix'),
     }),
 
     exposeDependency({

+ 20 - 3
src/data/things/album.js

@@ -11,7 +11,7 @@ import {traverse} from '#node-utils';
 import {sortAlbumsTracksChronologically, sortChronologically} from '#sort';
 import {accumulateSum, empty} from '#sugar';
 import Thing from '#thing';
-import {isColor, isDate, validateWikiData} from '#validators';
+import {isColor, isDate, isDirectory, validateWikiData} from '#validators';
 
 import {
   parseAdditionalFiles,
@@ -75,11 +75,25 @@ export class Album extends Thing {
     // Update & expose
 
     name: name('Unnamed Album'),
-    color: color(),
     directory: directory(),
-    urls: urls(),
+
+    directorySuffix: [
+      exposeUpdateValueOrContinue({
+        validate: input.value(isDirectory),
+      }),
+
+      withDirectory(),
+
+      exposeDependency({
+        dependency: '#directory',
+      }),
+    ],
 
     alwaysReferenceTracksByDirectory: flag(false),
+    suffixTrackDirectories: flag(false),
+
+    color: color(),
+    urls: urls(),
 
     additionalNames: additionalNameList(),
 
@@ -327,7 +341,10 @@ export class Album extends Thing {
   static [Thing.yamlDocumentSpec] = {
     fields: {
       'Album': {property: 'name'},
+
       'Directory': {property: 'directory'},
+      'Directory Suffix': {property: 'directorySuffix'},
+      'Suffix Track Directories': {property: 'suffixTrackDirectories'},
 
       'Always Reference Tracks By Directory': {
         property: 'alwaysReferenceTracksByDirectory',

+ 0 - 0
src/data/things/track.js


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor