Skip to content

Commit

Permalink
Merge branch 'master' into fix-linter-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae authored Apr 16, 2024
2 parents d278fab + a76f51c commit e0d013d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/modules/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,17 +604,18 @@

/**
* Modifies a page's content
* TODO the property name "contents" is quite silly, because people used to the MediaWiki API are gonna write "text"
*
* @todo the property name "contents" is quite silly, because people used to the MediaWiki API are gonna write "text"
* @param {string} pagename The page to be modified, namespace included
* @param {Object} options Object with properties:
* @param {Object} options Object with properties ('contents' is required, others are optional):
* contents: {string} the text to add to/replace the page,
* summary: {string} edit summary, will have the edit summary ad at the end,
* createonly: {bool} set to true to only edit the page if it doesn't exist,
* mode: {string} 'appendtext' or 'prependtext'; default: (replace everything)
* hide: {bool} Set to true to supress logging in statusWindow
* statusText: {string} message to show in status; default: "Editing"
* followRedirects: {boolean} true to follow redirects, false to ignore redirects
* watchlist: {string} 'nochange', 'preferences', 'unwatch', or 'watch'
* @return {jQuery.Deferred} Resolves if saved with all data
*/
editPage: function ( pagename, options ) {
Expand Down Expand Up @@ -652,6 +653,12 @@
request.minor = 'true';
}

if ( [ 'nochange', 'preferences', 'unwatch', 'watch' ].includes( options.watchlist ) ) {
request.watchlist = options.watchlist;
} else if ( AFCH.prefs.noWatch ) {
request.watchlist = 'nochange';
}

// Depending on mode, set appendtext=text or prependtext=text,
// which overrides the default text option
if ( options.mode ) {
Expand Down Expand Up @@ -737,6 +744,10 @@
reason: reason + AFCH.consts.summaryAd
}, additionalParameters );

if ( AFCH.prefs.noWatch ) {
request.watchlist = 'nochange';
}

if ( AFCH.consts.mockItUp ) {
AFCH.log( request );
deferred.resolve( { to: newTitle } );
Expand Down Expand Up @@ -1215,7 +1226,8 @@
autoOpen: false,
logCsd: true,
launchLinkPosition: 'p-cactions',
logAfc: false
logAfc: false,
noWatch: false
};

/**
Expand Down
5 changes: 3 additions & 2 deletions src/modules/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@
page_id: mw.config.get( 'wgArticleId' )
} ).then( function ( json ) {
var triageInfo = json.pagetriagelist.pages[ 0 ];
if ( triageInfo && triageInfo.copyvio === mw.config.get( 'wgCurRevisionId' ) ) {
if ( triageInfo && Number( triageInfo.copyvio ) === mw.config.get( 'wgCurRevisionId' ) ) {
addWarning( 'This submission may contain copyright violations', 'CopyPatrol', function () {
window.open( 'https://copypatrol.wmcloud.org/en?filter=all&searchCriteria=page_exact&searchText=' +
encodeURIComponent( afchPage.rawTitle ) + '&drafts=1&revision=' +
Expand Down Expand Up @@ -2378,7 +2378,8 @@

recentPage.edit( {
contents: newRecentText,
summary: 'Adding [[' + newPage + ']] to list of recent AfC creations'
summary: 'Adding [[' + newPage + ']] to list of recent AfC creations',
watchlist: 'nochange'
} );
} );

Expand Down
4 changes: 4 additions & 0 deletions src/templates/tpl-preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<label for="logAfc" class="afch-label">Log acceptances, declines, and rejects</label>
<input type="checkbox" id="logAfc" class="afch-input" {{#logAfc}}checked{{/logAfc}} />
</div>
<div id="noWatchWrapper">
<label for="noWatch" class="afch-label">Do not add pages to watchlist</label>
<input type="checkbox" id="noWatch" class="afch-input" {{#noWatch}}checked{{/noWatch}} />
</div>
</div>
<!-- /preferences -->

Expand Down

0 comments on commit e0d013d

Please sign in to comment.