Skip to content

Commit

Permalink
addTalkPageBanners: |living= and |listas= go in banner shell (#378)
Browse files Browse the repository at this point in the history
instead of in {{WikiProject Biography}}
  • Loading branch information
NovemLinguae authored Sep 2, 2024
1 parent 88c6124 commit b6afc53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
19 changes: 14 additions & 5 deletions src/modules/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1676,14 +1676,22 @@
// delete existing biography banner. when accepting, reviewer is forced to choose if it's a biography or not, so we'll add (or not add) our own biography banner later
banners = banners.filter( ( value ) => !value.match( /^{{WikiProject Biography/i ) );

// add biography banner to array
// add biography banner to array. and add |living= and |listas= to banner shell
let bannerShellExtraParams = '';
if ( isBiography ) {
banners.push(
'{{WikiProject Biography |living=' +
( lifeStatus !== 'unknown' ? ( lifeStatus === 'living' ? 'yes' : 'no' ) : '' ) +
' |listas=' + subjectName +
'}}'
'{{WikiProject Biography}}'
);

if ( lifeStatus === 'living' ) {
bannerShellExtraParams += ' |living=yes';
} else if ( lifeStatus === 'dead' ) {
bannerShellExtraParams += ' |living=no';
}

if ( subjectName ) {
bannerShellExtraParams += ' |listas=' + subjectName;
}
}

// add disambiguation banner to array
Expand All @@ -1708,6 +1716,7 @@
// Add |1=. Improves readability when lots of other parameters present.
wikicode = '{{WikiProject banner shell' +
( newAssessment ? ' |class=' + newAssessment : '' ) +
bannerShellExtraParams +
' |1=\n' +
banners.join( '\n' ) +
'\n}}\n' +
Expand Down
12 changes: 6 additions & 6 deletions tests/test-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ I have a question. Can you help answer it? –[[User:Novem Linguae|<span style="
const subjectName = 'Lazarut, Raluca';
const output = AFCH.addTalkPageBanners( wikicode, newAssessment, revId, isBiography, newWikiProjects, lifeStatus, subjectName );
expect( output ).toBe(
`{{WikiProject banner shell |1=
`{{WikiProject banner shell |living=yes |listas=Lazarut, Raluca |1=
{{subst:WPAFC/article |oldid=592507}}
{{WikiProject Film}}
{{WikiProject Women}}
{{WikiProject Television}}
{{WikiProject Biography |living=yes |listas=Lazarut, Raluca}}
{{WikiProject Biography}}
{{WikiProject Romania}}
}}`
);
Expand Down Expand Up @@ -326,9 +326,9 @@ I have a question. Can you help answer it? –[[User:Novem Linguae|<span style="
const subjectName = 'Jones, Bob';
const output = AFCH.addTalkPageBanners( wikicode, newAssessment, revId, isBiography, newWikiProjects, lifeStatus, subjectName );
expect( output ).toBe(
`{{WikiProject banner shell |class=B |1=
`{{WikiProject banner shell |class=B |living=yes |listas=Jones, Bob |1=
{{subst:WPAFC/article |oldid=592496}}
{{WikiProject Biography |living=yes |listas=Jones, Bob}}
{{WikiProject Biography}}
{{WikiProject Africa}}
{{WikiProject Alabama}}
}}`
Expand All @@ -345,9 +345,9 @@ I have a question. Can you help answer it? –[[User:Novem Linguae|<span style="
const subjectName = '';
const output = AFCH.addTalkPageBanners( wikicode, newAssessment, revId, isBiography, newWikiProjects, lifeStatus, subjectName );
expect( output ).toBe(
`{{WikiProject banner shell |1=
`{{WikiProject banner shell |living=no |1=
{{subst:WPAFC/article |oldid=592496}}
{{WikiProject Biography |living=no |listas=}}
{{WikiProject Biography}}
}}`
);
} );
Expand Down

0 comments on commit b6afc53

Please sign in to comment.