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

Add comments to talk page #223

Merged
merged 4 commits into from Apr 9, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/modules/submissions.js
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
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