Skip to content

Commit

Permalink
Add comments to talk page (#223)
Browse files Browse the repository at this point in the history
* add comments to talk page

* add comments to talk page

* fix accept + 0 afc comments + yes talk page bug

---------

Co-authored-by: NovemLinguae <[email protected]>
  • Loading branch information
gullyn and NovemLinguae authored Apr 9, 2024
1 parent e5f0e56 commit 8914696
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/modules/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@
this.text = this.text.replace( /^\s*/, '' );
};

AFCH.Text.prototype.getAfcComments = function () {
return this.text.match( /\{\{\s*afc comment[\s\S]+?\(UTC\)\}\}/gi );
};

AFCH.Text.prototype.removeAfcTemplates = function () {
// FIXME: Awful regex to remove the old submission templates
// This is bad. It works for most cases but has a hellish time
Expand Down Expand Up @@ -2210,6 +2214,12 @@
// ARTICLE
// -------

// get comments left by reviewers to put on talk page
var comments = [];
if ( data.copyComments ) {
comments = newText.getAfcComments();
}

newText.removeAfcTemplates();

newText.updateCategories( data.newCategories );
Expand Down Expand Up @@ -2324,6 +2334,10 @@
' WikiProject banner' + ( ( wikiProjectsToRemove.length === 1 ) ? '' : 's' );
}

if ( comments && comments.length > 0 ) {
talkText += '== Comments left by AfC reviewers ==\n' + comments.join( '\n\n' );
}

talkPage.edit( {
contents: talkText,
summary: summary
Expand Down
5 changes: 5 additions & 0 deletions src/templates/tpl-submissions.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@
<input type="checkbox" id="isBiography" class="afch-input"/>
</div>

<div id="copyCommentsWrapper">
<label for="copyComments" class="afch-label">Copy comments to talk page</label>
<input type="checkbox" id="copyComments" class="afch-input"/>
</div>

<div id="bioOptionsWrapper" class="hidden">

<div id="subjectNameWrapper">
Expand Down

0 comments on commit 8914696

Please sign in to comment.