From b98e4e050da99a62298a886f83bdf4508746819a Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Mon, 26 Aug 2024 04:35:17 -0700 Subject: [PATCH 1/4] capitalize article assessments such as Start, Stub, etc. Evad37/rater.js does this. Let's copy this practice, so that rater diffs are smaller. For example, the conversion of |class=start to |class=Start in this diff could have been avoided if AFCH had just written |class=Start in the first place: https://en.wikipedia.org/w/index.php?title=Talk:Phare_Circus&diff=next&oldid=1242207529 --- src/modules/core.js | 2 +- src/modules/submissions.js | 4 ++-- src/templates/tpl-submissions.html | 18 +++++++++--------- tests/test-core.js | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/modules/core.js b/src/modules/core.js index 6da57033..c00f0643 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -1687,7 +1687,7 @@ } // add disambiguation banner to array - if ( newAssessment === 'disambig' ) { + if ( newAssessment === 'Disambig' ) { banners.push( '{{WikiProject Disambiguation}}' ); } diff --git a/src/modules/submissions.js b/src/modules/submissions.js index 51b6a8a3..0e9d5b9a 100644 --- a/src/modules/submissions.js +++ b/src/modules/submissions.js @@ -1597,7 +1597,7 @@ // If draft is assessed as stub, show stub sorting // interface using User:SD0001/StubSorter.js $afch.find( '#newAssessment' ).on( 'change', function () { - const isClassStub = $( this ).val() === 'stub'; + const isClassStub = $( this ).val() === 'Stub'; $afch.find( '#stubSorterWrapper' ).toggleClass( 'hidden', !isClassStub ); if ( isClassStub ) { if ( mw.config.get( 'wgDBname' ) !== 'enwiki' ) { @@ -1622,7 +1622,7 @@ $( '#stub-sorter-select' ).addClass( 'afch-input' ); if ( /\{\{[^{ ]*[sS]tub(\|.*?)?\}\}\s*/.test( pageText ) ) { - $afch.find( '#newAssessment' ).val( 'stub' ).trigger( 'chosen:updated' ).trigger( 'change' ); + $afch.find( '#newAssessment' ).val( 'Stub' ).trigger( 'chosen:updated' ).trigger( 'change' ); } } ); } diff --git a/src/templates/tpl-submissions.html b/src/templates/tpl-submissions.html index 145d5051..3b483204 100644 --- a/src/templates/tpl-submissions.html +++ b/src/templates/tpl-submissions.html @@ -73,15 +73,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/tests/test-core.js b/tests/test-core.js index 40f2e735..0d5f154e 100644 --- a/tests/test-core.js +++ b/tests/test-core.js @@ -374,7 +374,7 @@ I have a question. Can you help answer it? –[[User:Novem Linguae| Date: Mon, 26 Aug 2024 04:41:02 -0700 Subject: [PATCH 2/4] allow StubSorter to load on testwiki --- src/modules/submissions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/submissions.js b/src/modules/submissions.js index 0e9d5b9a..73d152a0 100644 --- a/src/modules/submissions.js +++ b/src/modules/submissions.js @@ -1600,7 +1600,7 @@ const isClassStub = $( this ).val() === 'Stub'; $afch.find( '#stubSorterWrapper' ).toggleClass( 'hidden', !isClassStub ); if ( isClassStub ) { - if ( mw.config.get( 'wgDBname' ) !== 'enwiki' ) { + if ( mw.config.get( 'wgDBname' ) !== 'enwiki' && mw.config.get( 'wgDBname' ) !== 'testwiki' ) { console.warn( 'no stub sorting script available for this language wiki' ); return; } From 680be4649a9e20de84fbdbf16d2175a884d36b6c Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Mon, 26 Aug 2024 04:51:43 -0700 Subject: [PATCH 3/4] add space before pipe in template wikicode --- src/modules/core.js | 10 ++++---- tests/test-core.js | 62 ++++++++++++++++++++++----------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/modules/core.js b/src/modules/core.js index c00f0643..8a667e42 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -1669,7 +1669,7 @@ // Put at top for historical reasons. People are used to it being there. banners.unshift( '{{subst:WPAFC/article' + - ( revId ? '|oldid=' + revId : '' ) + + ( revId ? ' |oldid=' + revId : '' ) + '}}' ); @@ -1679,9 +1679,9 @@ // add biography banner to array if ( isBiography ) { banners.push( - '{{WikiProject Biography|living=' + + '{{WikiProject Biography |living=' + ( lifeStatus !== 'unknown' ? ( lifeStatus === 'living' ? 'yes' : 'no' ) : '' ) + - '|listas=' + subjectName + + ' |listas=' + subjectName + '}}' ); } @@ -1707,8 +1707,8 @@ // Add |class= to shell. // Add |1=. Improves readability when lots of other parameters present. wikicode = '{{WikiProject banner shell' + - ( newAssessment ? '|class=' + newAssessment : '' ) + - '|1=\n' + + ( newAssessment ? ' |class=' + newAssessment : '' ) + + ' |1=\n' + banners.join( '\n' ) + '\n}}\n' + wikicode; diff --git a/tests/test-core.js b/tests/test-core.js index 0d5f154e..14447323 100644 --- a/tests/test-core.js +++ b/tests/test-core.js @@ -132,8 +132,8 @@ describe( 'AFCH.addTalkPageBanners', () => { const subjectName = ''; const output = AFCH.addTalkPageBanners( wikicode, newAssessment, revId, isBiography, newWikiProjects, lifeStatus, subjectName ); expect( output ).toBe( -`{{WikiProject banner shell|1= -{{subst:WPAFC/article|oldid=592485}} +`{{WikiProject banner shell |1= +{{subst:WPAFC/article |oldid=592485}} }}` ); } ); @@ -150,8 +150,8 @@ I have a question. Can you help answer it? –[[User:Novem Linguae|