Skip to content

Commit

Permalink
prevent placing of protection, XFD, or CSD tags on TimedText pages (#…
Browse files Browse the repository at this point in the history
…2027)

* Prevent prot, XFD, CSD tagging of TimedText pages

TimedText pages cannot have any tags applied to them, so Twinkle should
not allow the user to place any tags there.

* fix lint errors

* add comments

---------

Co-authored-by: NovemLinguae <[email protected]>
  • Loading branch information
TollensWP and NovemLinguae authored Nov 19, 2024
1 parent e0e1b75 commit cbf09f5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
10 changes: 5 additions & 5 deletions modules/twinkleprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Twinkle.protect.callback = function twinkleprotectCallback() {
label: 'Tag page with protection template',
value: 'tag',
tooltip: 'If the protecting admin forgot to apply a protection template, or you have just protected the page without tagging, you can use this to apply the appropriate protection tag.',
disabled: mw.config.get('wgArticleId') === 0 || mw.config.get('wgPageContentModel') === 'Scribunto'
disabled: mw.config.get('wgArticleId') === 0 || mw.config.get('wgPageContentModel') === 'Scribunto' || mw.config.get('wgNamespaceNumber') === 710 // TimedText
}
]
});
Expand Down Expand Up @@ -502,7 +502,7 @@ Twinkle.protect.callback.changeAction = function twinkleprotectCallbackChangeAct
value: '',
tooltip: 'Optional revision ID of the RfPP page where protection was requested.'
});
if (!mw.config.get('wgArticleId') || mw.config.get('wgPageContentModel') === 'Scribunto') { // tagging isn't relevant for non-existing or module pages
if (!mw.config.get('wgArticleId') || mw.config.get('wgPageContentModel') === 'Scribunto' || mw.config.get('wgNamespaceNumber') === 710) { // tagging isn't relevant for non-existing, module, or TimedText pages
break;
}
/* falls through */
Expand Down Expand Up @@ -1075,8 +1075,8 @@ Twinkle.protect.callback.changePreset = function twinkleprotectCallbackChangePre
// Add any annotations
Twinkle.protect.callback.annotateProtectReason(e);

// sort out tagging options, disabled if nonexistent or lua
if (mw.config.get('wgArticleId') && mw.config.get('wgPageContentModel') !== 'Scribunto') {
// sort out tagging options, disabled if nonexistent, lua, or TimedText
if (mw.config.get('wgArticleId') && mw.config.get('wgPageContentModel') !== 'Scribunto' && mw.config.get('wgNamespaceNumber') !== 710) {
if (form.category.value === 'unprotect') {
form.tagtype.value = 'none';
} else {
Expand Down Expand Up @@ -1112,7 +1112,7 @@ Twinkle.protect.callback.evaluate = function twinkleprotectCallbackEvaluate(e) {
var input = Morebits.quickForm.getInputData(form);

var tagparams;
if (input.actiontype === 'tag' || (input.actiontype === 'protect' && mw.config.get('wgArticleId') && mw.config.get('wgPageContentModel') !== 'Scribunto')) {
if (input.actiontype === 'tag' || (input.actiontype === 'protect' && mw.config.get('wgArticleId') && mw.config.get('wgPageContentModel') !== 'Scribunto' && mw.config.get('wgNamespaceNumber') !== 710 /* TimedText */)) {
tagparams = {
tag: input.tagtype,
reason: false,
Expand Down
4 changes: 2 additions & 2 deletions modules/twinklespeedy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ Twinkle.speedy.callbacks = {
}

// Tag if possible, post on talk if not
if (pageobj.canEdit() && ['wikitext', 'Scribunto', 'javascript', 'css', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
if (pageobj.canEdit() && ['wikitext', 'Scribunto', 'javascript', 'css', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1 && mw.config.get('wgNamespaceNumber') !== 710 /* TimedText */) {
var text = pageobj.getPageText();

statelem.status('Checking for tags on the page...');
Expand Down Expand Up @@ -1483,7 +1483,7 @@ Twinkle.speedy.callbacks = {
talk_page.setCallbackParameters(params);
talk_page.newSection(Twinkle.speedy.callbacks.user.tagComplete);
} else {
pageobj.getStatusElement().error('Page protected and nowhere to add an edit request, aborting');
pageobj.getStatusElement().error('Page cannot be edited and no other location to place a speedy deletion request, aborting');
}
}
},
Expand Down
36 changes: 21 additions & 15 deletions modules/twinklexfd.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,17 +500,19 @@ Twinkle.xfd.callback.change_category = function twinklexfdCallbackChangeCategory
label: 'Miscellany for deletion',
name: 'work_area'
});
work_area.append({
type: 'checkbox',
list: [
{
label: 'Wrap deletion tag with &lt;noinclude&gt;',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Will wrap the deletion tag in &lt;noinclude&gt; tags, so that it won\'t transclude. Select this option for userboxes.'
}
]
});
if (mw.config.get('wgNamespaceNumber') !== 710) { // TimedText cannot be tagged, so asking whether to noinclude the tag is pointless
work_area.append({
type: 'checkbox',
list: [
{
label: 'Wrap deletion tag with &lt;noinclude&gt;',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Will wrap the deletion tag in &lt;noinclude&gt; tags, so that it won\'t transclude. Select this option for userboxes.'
}
]
});
}
if ((mw.config.get('wgNamespaceNumber') === 2 /* User: */ || mw.config.get('wgNamespaceNumber') === 3 /* User talk: */) && mw.config.exists('wgRelevantUserName')) {
work_area.append({
type: 'checkbox',
Expand Down Expand Up @@ -1522,11 +1524,15 @@ Twinkle.xfd.callbacks = {

apiobj.statelem.info('next in order is [[' + apiobj.params.discussionpage + ']]');

var wikipedia_page;

// Tagging page
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Tagging page with deletion tag');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.taggingPage);
if (mw.config.get('wgNamespaceNumber') !== 710) { // cannot tag TimedText pages
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Tagging page with deletion tag');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.taggingPage);
}

// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = apiobj.params.discussionpage;
Expand Down

0 comments on commit cbf09f5

Please sign in to comment.