Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review points! #483

Draft
wants to merge 9 commits into
base: preview
Choose a base branch
from
17 changes: 17 additions & 0 deletions src/content/dependencies/generateAlbumInfoPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default {
'generateCommentarySection',
'generateContentHeading',
'generatePageLayout',
'generateReviewPointsSection',
'linkAlbum',
'linkAlbumCommentary',
'linkAlbumGallery',
Expand Down Expand Up @@ -130,6 +131,13 @@ export default {
relation('generateCommentarySection', album.commentary);
}

// Section: Review points

if (!empty(album.reviewPoints)) {
sections.reviewPoints =
relation('generateReviewPointsSection', album.reviewPoints);
}

return relations;
},

Expand Down Expand Up @@ -204,6 +212,13 @@ export default {
sec.extra.commentaryLink
.slot('content', language.$('releaseInfo.viewCommentary.link')),
}),

sec.reviewPoints &&
language.$('releaseInfo.readReviewPoints', {
link: html.tag('a',
{href: '#review-points'},
language.$('releaseInfo.readReviewPoints.link')),
}),
]),

relations.trackList,
Expand Down Expand Up @@ -234,6 +249,8 @@ export default {
],

sec.artistCommentary,

sec.reviewPoints,
],

navLinkStyle: 'hierarchical',
Expand Down
9 changes: 2 additions & 7 deletions src/content/dependencies/generateCommentarySection.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
export default {
contentDependencies: [
'transformContent',
'generateCommentaryEntry',
'generateContentHeading',
],

contentDependencies: ['generateCommentaryEntry', 'generateContentHeading'],
extraDependencies: ['html', 'language'],

relations: (relation, entries) => ({
Expand All @@ -21,7 +16,7 @@ export default {
relations.heading
.slots({
id: 'artist-commentary',
title: language.$('misc.artistCommentary')
title: language.$('misc.artistCommentary'),
}),

relations.entries,
Expand Down
73 changes: 73 additions & 0 deletions src/content/dependencies/generateReferenceDiscussionItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import {empty} from '#sugar';

export default {
contentDependencies: ['linkArtist', 'linkExternal'],
extraDependencies: ['html', 'language'],

relations(relation, discussion) {
const relations = {};

relations.externalLink =
relation('linkExternal', discussion.url);

if (!empty(discussion.participatingArtists)) {
relations.participatingArtistLinks =
discussion.participatingArtists
.map(artist => relation('linkArtist', artist));
}

return relations;
},

data: (discussion) => ({
url: discussion.url,
date: discussion.date,
annotation: discussion.annotation,
}),

generate: (data, relations, {html, language}) => {
const prefix = 'misc.reviewPoints.entry.referenceDiscussions';

const parts = [prefix, 'item'];
const options = {};

options.dateAccent =
language.$(prefix, 'dateAccent', {
date:
language.formatDate(data.date),
});

const linkParts = [prefix, 'link'];
const linkOptions = {};

linkOptions.platform =
language.formatExternalLink(data.url);

if (data.annotation) {
linkParts.push('withAnnotation');
linkOptions.annotation =
language.sanitize(data.annotation);
}

options.link =
relations.externalLink.slots({
tab: 'separate',
indicateExternal: true,

content:
language.$(...linkParts, linkOptions),
});

if (relations.participatingArtistLinks) {
parts.push('withParticipants');
options.participantsAccent =
html.tag('span', {class: 'review-point-discussion-participants'},
language.$(prefix, 'participantsAccent', {
participants:
language.formatUnitList(relations.participatingArtistLinks),
}));
}

return html.tag('li', language.$(...parts, options));
}
};
76 changes: 76 additions & 0 deletions src/content/dependencies/generateReviewPointsEntry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import {empty} from '#sugar';

export default {
contentDependencies: [
'generateReferenceDiscussionItem',
'linkArtist',
'transformContent',
],

extraDependencies: ['html', 'language'],

relations(relation, point) {
const relations = {};

if (point.notes) {
relations.bodyContent =
relation('transformContent', point.notes);
}

if (!empty(point.referralArtists)) {
relations.referralArtistLinks =
point.referralArtists
.map(artist => relation('linkArtist', artist));
}

if (!empty(point.referenceDiscussions)) {
relations.referenceDiscussionItems =
point.referenceDiscussions
.map(discussion => relation('generateReferenceDiscussionItem', discussion));
}

return relations;
},

data: (point) => ({
date: point.dateRecorded,
field: point.field,
}),

generate(data, relations, {html, language}) {
const prefix = 'misc.reviewPoints.entry';

return html.tags([
html.tag('p', {class: 'review-point-heading'},
language.$(prefix, 'title', {
field:
html.tag('var', {class: 'review-point-field'},
language.sanitize(data.field)),

date:
language.formatDate(data.date),
})),

html.tag('p', {class: 'review-point-info'},
{[html.joinChildren]: html.tag('br')},

[
relations.referralArtistLinks &&
language.$(prefix, 'referralArtists', {
artists:
language.formatUnitList(relations.referralArtistLinks),
}),
]),

html.tag('ul', {class: 'review-point-reference-discussions'},
{[html.onlyIfContent]: true},
relations.referenceDiscussionItems),

html.tag('blockquote', {class: 'review-point-body'},
!relations.bodyContent && {class: 'no-notes'},
(relations.bodyContent
? relations.bodyContent.slot('mode', 'multiline')
: language.$(prefix, 'noNotes'))),
]);
},
};
24 changes: 24 additions & 0 deletions src/content/dependencies/generateReviewPointsSection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export default {
contentDependencies: ['generateReviewPointsEntry', 'generateContentHeading'],
extraDependencies: ['html', 'language'],

relations: (relation, entries) => ({
heading:
relation('generateContentHeading'),

entries:
entries.map(entry =>
relation('generateReviewPointsEntry', entry)),
}),

generate: (relations, {html, language}) =>
html.tags([
relations.heading
.slots({
id: 'review-points',
title: language.$('misc.reviewPoints'),
}),

relations.entries,
]),
};
17 changes: 17 additions & 0 deletions src/content/dependencies/generateTrackInfoPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default {
'generateContributionList',
'generatePageLayout',
'generateRelativeDatetimestamp',
'generateReviewPointsSection',
'generateTrackAdditionalNamesBox',
'generateTrackCoverArtwork',
'generateTrackList',
Expand Down Expand Up @@ -307,6 +308,13 @@ export default {
relation('generateCommentarySection', track.commentary);
}

// Section: Review points

if (!empty(track.reviewPoints)) {
sections.reviewPoints =
relation('generateReviewPointsSection', track.reviewPoints);
}

return relations;
},

Expand Down Expand Up @@ -377,6 +385,13 @@ export default {
{href: '#artist-commentary'},
language.$('releaseInfo.readCommentary.link')),
}),

sec.reviewPoints &&
language.$('releaseInfo.readReviewPoints', {
link: html.tag('a',
{href: '#review-points'},
language.$('releaseInfo.readReviewPoints.link')),
}),
]),

sec.otherReleases && [
Expand Down Expand Up @@ -552,6 +567,8 @@ export default {
],

sec.artistCommentary,

sec.reviewPoints,
],

navLinkStyle: 'hierarchical',
Expand Down
2 changes: 2 additions & 0 deletions src/data/composite/wiki-data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export {default as inputWikiData} from './inputWikiData.js';
export {default as withParsedCommentaryEntries} from './withParsedCommentaryEntries.js';
export {default as withResolvedContribs} from './withResolvedContribs.js';
export {default as withResolvedReference} from './withResolvedReference.js';
export {default as withResolvedReferenceDiscussions} from './withResolvedReferenceDiscussions.js';
export {default as withResolvedReferenceList} from './withResolvedReferenceList.js';
export {default as withResolvedReviewPoints} from './withResolvedReviewPoints.js';
export {default as withReverseContributionList} from './withReverseContributionList.js';
export {default as withReverseReferenceList} from './withReverseReferenceList.js';
export {default as withThingsSortedAlphabetically} from './withThingsSortedAlphabetically.js';
Expand Down
89 changes: 89 additions & 0 deletions src/data/composite/wiki-data/withResolvedReferenceDiscussions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import {input, templateCompositeFrom} from '#composite';
import find from '#find';
import {stitchArrays} from '#sugar';
import {isReferenceDiscussion, strictArrayOf} from '#validators';

import {withResolvedReferenceList} from '#composite/wiki-data';

import {
fillMissingListItems,
withFlattenedList,
withPropertiesFromList,
withUnflattenedList,
} from '#composite/data';

export default templateCompositeFrom({
annotation: `withResolvedReferenceDiscussions`,

inputs: {
from: input({
validate: strictArrayOf(isReferenceDiscussion),
}),
},

outputs: ['#resolvedReferenceDiscussions'],

steps: () => [
withPropertiesFromList({
list: input('from'),
properties: input.value([
'url',
'date',
'annotation',
'participatingArtists',
]),
}),

fillMissingListItems({
list: '#list.participatingArtists',
fill: input.value([]),
}),

fillMissingListItems({
list: '#list.annotation',
fill: input.value(null),
}),

withFlattenedList({
list: '#list.participatingArtists',
}),

withResolvedReferenceList({
list: '#flattenedList',
data: 'artistData',
find: input.value(find.artist),
notFoundMode: input.value('null'),
}),

withUnflattenedList({
list: '#resolvedReferenceList',
}).outputs({
['#unflattenedList']:
'#list.participatingArtists',
}),

{
dependencies: [
'#list.url',
'#list.date',
'#list.annotation',
'#list.participatingArtists',
],

compute: (continuation, {
['#list.url']: url,
['#list.date']: date,
['#list.annotation']: annotation,
['#list.participatingArtists']: participatingArtists,
}) => continuation({
['#resolvedReferenceDiscussions']:
stitchArrays({
url,
date,
annotation,
participatingArtists,
}),
}),
},
],
});
Loading