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

addTalkPageBanners: |living= and |listas= go in banner shell #378

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading