wikimedia-gadgets / twinkle

The English Wikipedia twinkle javascript helper
http://en.wikipedia.org/wiki/Wikipedia:Twinkle
Other
135 stars 147 forks source link

Auto-fill "unlink" summary #370

Open owcz opened 7 years ago

owcz commented 7 years ago

I imagine the most common use for the "unlink" tab is unlinking articles deleted at AfD. When a page is deleted, it would be helpful to auto-populate the unlink summary with the text of the most recent deletion rationale (usually a variant of "[[Wikipedia:Articles for deletion/Example]] closed as delete").

Amorymeltzer commented 5 years ago

Maybe, but given that most XfD deletions (and thus subsequent unlinks) are now done via XfDCloser, I think any need for this is fairly diminished; moreover, it is autofilled if a sysop navigates to it after speedy deleting the page. We could autofill if we're on a a non-log AfD subpage, I suppose, but is it frequent where someone goes to the AfD to cleanup after a sysop has chosen not to do so? Not sure we should encourage that.

owcz commented 5 years ago

I wasn't thinking about the AfD subpage itself but when I visit the deleted page, and want to clear out any remaining unlinks (e.g., if the close was done manually or failed for whatever reason), I have to manually copy the AfD link into the unlinker's edit summary each time rather than it autopopulating.

Also before Evad's tool added automatic unlinking, many admins did not bother cleaning up links after AfDs so there is ostensibly a lot of unlinking left to do :)

Amorymeltzer commented 4 years ago

Something like this in Twinkle.unlink would be roughly what's needed:

var presetReason;
if (mw.config.get('wgArticleId') === 0 &&
    $('.mw-warning-with-logexcerpt li')[0].className === 'mw-logline-delete' &&
    mw.config.get('wgNamespaceNumber') === 0) {
    var reg = new RegExp(RegExp.escape('Wikipedia:Articles for deletion/' + Morebits.pageNameNorm, true), 'i');
    if (reg.test($('.mw-logline-delete span.comment').first().html())) {
        presetReason = '[[' + Morebits.pageNameNorm + ']] deleted at AfD';
    }
}

Twinkle.addPortletLink(Twinkle.unlink.callback(presetReason), 'Unlink', 'tw-unlink', 'Unlink backlinks');

It only detects cases where an AfD is physically linked in the description, and doesn't attempt to actually use that link.

It's not the end of the world, but it's far from perfect. Maybe net positive?