diff options
-rw-r--r-- | src/common-util/wiki-data.js | 11 | ||||
-rw-r--r-- | src/content/dependencies/generateTrackInfoPage.js | 8 | ||||
-rw-r--r-- | src/content/dependencies/listTracksNeedingLyrics.js | 9 | ||||
-rw-r--r-- | src/data/composite/things/content/withAnnotationParts.js | 12 | ||||
-rw-r--r-- | src/data/things/content.js | 4 | ||||
-rw-r--r-- | src/data/things/track.js | 32 | ||||
-rw-r--r-- | src/external-links.js | 11 | ||||
-rw-r--r-- | src/listing-spec.js | 8 | ||||
-rw-r--r-- | src/strings-default.yaml | 25 |
9 files changed, 116 insertions, 4 deletions
diff --git a/src/common-util/wiki-data.js b/src/common-util/wiki-data.js index 546f1ad9..603069a5 100644 --- a/src/common-util/wiki-data.js +++ b/src/common-util/wiki-data.js @@ -113,10 +113,16 @@ export function matchContentEntries(sourceText) { let previousMatchEntry = null; let previousEndIndex = null; + const trimBody = body => + body + .replace(/^\n*/, '') + .replace(/\n*$/, ''); + for (const {0: matchText, index: startIndex, groups: matchEntry} of sourceText.matchAll(commentaryRegexCaseSensitive)) { if (previousMatchEntry) { - previousMatchEntry.body = sourceText.slice(previousEndIndex, startIndex); + previousMatchEntry.body = + trimBody(sourceText.slice(previousEndIndex, startIndex)); } matchEntries.push(matchEntry); @@ -126,7 +132,8 @@ export function matchContentEntries(sourceText) { } if (previousMatchEntry) { - previousMatchEntry.body = sourceText.slice(previousEndIndex); + previousMatchEntry.body = + trimBody(sourceText.slice(previousEndIndex)); } return matchEntries; diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index 2c082cc4..efd0ec9f 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -149,6 +149,9 @@ export default { dateAlbumAddedToWiki: track.album.dateAddedToWiki, + needsLyrics: + track.needsLyrics, + singleTrackSingle: query.singleTrackSingle, @@ -370,6 +373,11 @@ export default { !html.isBlank(relations.referencingSourceEntries)) && html.tag('hr', {class: 'main-separator'}), + data.needsLyrics && + html.isBlank(relations.lyricsSection) && + html.tag('p', + language.$(pageCapsule, 'needsLyrics')), + relations.lyricsSection, html.tags([ diff --git a/src/content/dependencies/listTracksNeedingLyrics.js b/src/content/dependencies/listTracksNeedingLyrics.js new file mode 100644 index 00000000..655bf2a0 --- /dev/null +++ b/src/content/dependencies/listTracksNeedingLyrics.js @@ -0,0 +1,9 @@ +export default { + contentDependencies: ['listTracksWithExtra'], + + relations: (relation, spec) => + ({page: relation('listTracksWithExtra', spec, 'needsLyrics', 'truthy')}), + + generate: (relations) => + relations.page, +}; diff --git a/src/data/composite/things/content/withAnnotationParts.js b/src/data/composite/things/content/withAnnotationParts.js index 6311b57a..0c5a0294 100644 --- a/src/data/composite/things/content/withAnnotationParts.js +++ b/src/data/composite/things/content/withAnnotationParts.js @@ -1,5 +1,5 @@ import {input, templateCompositeFrom} from '#composite'; -import {transposeArrays} from '#sugar'; +import {empty, transposeArrays} from '#sugar'; import {is} from '#validators'; import {raiseOutputWithoutDependency} from '#composite/control-flow'; @@ -33,6 +33,16 @@ export default templateCompositeFrom({ }), { + dependencies: ['#contentNodeLists'], + compute: (continuation, { + ['#contentNodeLists']: nodeLists, + }) => continuation({ + ['#contentNodeLists']: + nodeLists.filter(list => !empty(list)), + }), + }, + + { dependencies: ['#contentNodeLists', input('mode')], compute: (continuation, { ['#contentNodeLists']: nodeLists, diff --git a/src/data/things/content.js b/src/data/things/content.js index d2cf32dc..a3dfc183 100644 --- a/src/data/things/content.js +++ b/src/data/things/content.js @@ -187,6 +187,10 @@ export class LyricsEntry extends ContentEntry { part: input.value('wiki lyrics'), }), + helpNeeded: hasAnnotationPart({ + part: input.value('help needed'), + }), + hasSquareBracketAnnotations: [ withHasAnnotationPart({ part: input.value('wiki lyrics'), diff --git a/src/data/things/track.js b/src/data/things/track.js index 18faebc3..da6b3227 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -22,7 +22,7 @@ import { parseLyrics, } from '#yaml'; -import {withPropertyFromObject} from '#composite/data'; +import {withPropertyFromList, withPropertyFromObject} from '#composite/data'; import { exitWithoutDependency, @@ -245,6 +245,32 @@ export class Track extends Thing { exposeDependency({dependency: '#album.color'}), ], + needsLyrics: [ + exposeUpdateValueOrContinue({ + mode: input.value('falsy'), + validate: input.value(isBoolean), + }), + + exitWithoutDependency({ + dependency: 'lyrics', + mode: input.value('empty'), + value: input.value(false), + }), + + withPropertyFromList({ + list: 'lyrics', + property: input.value('helpNeeded'), + }), + + { + dependencies: ['#lyrics.helpNeeded'], + compute: ({ + ['#lyrics.helpNeeded']: helpNeeded, + }) => + helpNeeded.includes(true) + }, + ], + urls: urls(), // > Update & expose - Artworks @@ -574,6 +600,10 @@ export class Track extends Thing { 'Color': {property: 'color'}, + 'Needs Lyrics': { + property: 'needsLyrics', + }, + 'URLs': {property: 'urls'}, // Artworks diff --git a/src/external-links.js b/src/external-links.js index ab1555bd..a4e16325 100644 --- a/src/external-links.js +++ b/src/external-links.js @@ -582,6 +582,17 @@ export const externalLinkSpec = [ }, { + match: {domains: ['reddit.com', 'old.reddit.com']}, + platform: 'reddit', + icon: 'globe', + + detail: { + substring: 'subreddit', + subreddit: {pathname: /^r\/[^\/]+(?=\/)?/}, + }, + }, + + { match: {domain: 'soundcloud.com'}, platform: 'soundcloud', diff --git a/src/listing-spec.js b/src/listing-spec.js index 142c5976..a47bd38c 100644 --- a/src/listing-spec.js +++ b/src/listing-spec.js @@ -178,6 +178,7 @@ listingSpec.push({ directory: 'tracks/with-lyrics', stringsKey: 'listTracks.withLyrics', contentFunction: 'listTracksWithLyrics', + seeAlso: ['tracks/needing-lyrics'], }); listingSpec.push({ @@ -195,6 +196,13 @@ listingSpec.push({ }); listingSpec.push({ + directory: 'tracks/needing-lyrics', + stringsKey: 'listTracks.needingLyrics', + contentFunction: 'listTracksNeedingLyrics', + seeAlso: ['tracks/with-lyrics'], +}); + +listingSpec.push({ directory: 'tags/by-name', stringsKey: 'listArtTags.byName', contentFunction: 'listArtTagsByName', diff --git a/src/strings-default.yaml b/src/strings-default.yaml index 93881aa2..a8dbc28c 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -719,6 +719,11 @@ misc: nintendoMusic: "Nintendo Music" patreon: "Patreon" poetryFoundation: "Poetry Foundation" + + reddit: + _: "Reddit" + subreddit: "Reddit ({SUBREDDIT})" + soundcloud: "SoundCloud" spotify: "Spotify" steam: "Steam" @@ -2332,6 +2337,23 @@ listingPage: title.withDate: "{ALBUM} ({DATE})" item: "{TRACK}" + # listTracks.needingLyrics: + # List tracks, chunked by album (which are sorted by date, + # falling back alphabetically) and in their usual track order, + # displaying only tracks which are marked as needing lyrics. + # The chunk titles also display the date each album was released, + # and tracks' own custom "Date First Released" fields are totally + # ignored. + + needingLyrics: + title: "Tracks - which need Lyrics" + title.short: "...which need Lyrics" + + chunk: + title: "{ALBUM}" + title.withDate: "{ALBUM} ({DATE})" + item: "{TRACK}" + other: # other.allSheetMusic: @@ -2555,6 +2577,9 @@ trackPage: wiki: "across this wiki" album: "within this album" + needsLyrics: >- + This track has vocals, but there aren't lyrics available for it on this wiki, yet! + socialEmbed: heading: "{ALBUM}" title: "{TRACK}" |