14,091
edits
m (1 revision) |
(Add) |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 10: | Line 10: | ||
**************************************** | **************************************** | ||
* Mode of invocation: Tab ("PROD") | * Mode of invocation: Tab ("PROD") | ||
* Active on: Existing articles which are not redirects | * Active on: Existing articles and files which are not redirects | ||
* Config directives in: TwinkleConfig | * Config directives in: TwinkleConfig | ||
*/ | */ | ||
Twinkle.prod = function twinkleprod() { | Twinkle.prod = function twinkleprod() { | ||
if( mw.config.get('wgNamespaceNumber') | if( [0, 6].indexOf(mw.config.get('wgNamespaceNumber')) === -1 || !mw.config.get('wgCurRevisionId') || Morebits.wiki.isPageRedirect() ) { | ||
return; | return; | ||
} | } | ||
Twinkle.addPortletLink( Twinkle.prod.callback, "PROD", "tw-prod", "Propose deletion via | Twinkle.addPortletLink( Twinkle.prod.callback, "PROD", "tw-prod", "Propose deletion via SV:PROD" ); | ||
}; | }; | ||
// Used in edit summaries, for comparisons, etc. | |||
var namespace; | |||
Twinkle.prod.callback = function twinkleprodCallback() { | Twinkle.prod.callback = function twinkleprodCallback() { | ||
Twinkle.prod.defaultReason = Twinkle.getPref('prodReasonDefault'); | Twinkle.prod.defaultReason = Twinkle.getPref('prodReasonDefault'); | ||
// TODO: add 'book' as well, namespace number 108 | |||
switch (mw.config.get('wgNamespaceNumber')) { | |||
case 0: | |||
namespace = 'article'; | |||
break; | |||
case 6: | |||
namespace = 'file'; | |||
break; | |||
} | |||
var Window = new Morebits.simpleWindow( 800, 410 ); | var Window = new Morebits.simpleWindow( 800, 410 ); | ||
Window.setTitle( "Proposed deletion (PROD)" ); | Window.setTitle( "Proposed deletion (PROD)" ); | ||
Window.setScriptName( "Twinkle" ); | Window.setScriptName( "Twinkle" ); | ||
Window.addFooterLink( "Proposed deletion policy", " | Window.addFooterLink( "Proposed deletion policy", "SV:PROD" ); | ||
Window.addFooterLink( "BLP PROD policy", " | |||
Window.addFooterLink( "Twinkle help", " | if (namespace === 'article') { | ||
Window.addFooterLink( "BLP PROD policy", "SV:BLPPROD" ); | |||
} | |||
Window.addFooterLink( "Twinkle help", "SV:TW/DOC#prod" ); | |||
var form = new Morebits.quickForm( Twinkle.prod.callback.evaluate ); | var form = new Morebits.quickForm( Twinkle.prod.callback.evaluate ); | ||
var field = form.append( { | var field = form.append( { | ||
type: 'field', | type: 'field', | ||
label: 'PROD type' | label: 'PROD type', | ||
id: 'prodtype_fieldset' | |||
} ); | } ); | ||
field.append( { | field.append( { | ||
type: 'radio', | type: 'radio', | ||
Line 47: | Line 66: | ||
value: 'prod', | value: 'prod', | ||
checked: true, | checked: true, | ||
tooltip: 'Normal proposed deletion, per [[ | tooltip: 'Normal proposed deletion, per [[SV:PROD]]' | ||
}, | }, | ||
{ | { | ||
label: 'BLP PROD (proposed deletion of unsourced BLPs)', | label: 'BLP PROD (proposed deletion of unsourced BLPs)', | ||
value: 'prodblp', | value: 'prodblp', | ||
tooltip: 'Proposed deletion of new, completely unsourced biographies of living persons, per [[ | tooltip: 'Proposed deletion of new, completely unsourced biographies of living persons, per [[SV:BLPPROD]]' | ||
} | } | ||
] | ] | ||
Line 68: | Line 87: | ||
Window.setContent( result ); | Window.setContent( result ); | ||
Window.display(); | Window.display(); | ||
// | // Fake a change event on the first prod type radio, to initialize the type-dependent controls | ||
var evt = document.createEvent( "Event" ); | var evt = document.createEvent( "Event" ); | ||
evt.initEvent( 'change', true, true ); | evt.initEvent( 'change', true, true ); | ||
result.prodtype[0].dispatchEvent( evt ); | result.prodtype[0].dispatchEvent( evt ); | ||
// Hide fieldset for PROD type if File namespace since only normal PROD is allowed | |||
if (namespace === 'file') { | |||
$('#prodtype_fieldset').hide(); | |||
} | |||
}; | }; | ||
Line 119: | Line 143: | ||
value: 'notify', | value: 'notify', | ||
name: 'notify', | name: 'notify', | ||
tooltip: 'Creator of | tooltip: 'Creator of ' + namespace + ' has to be notified.', | ||
checked: true, | checked: true, | ||
disabled: true | disabled: true | ||
Line 133: | Line 157: | ||
label: boldtext | label: boldtext | ||
}); | }); | ||
break; | break; | ||
Line 153: | Line 171: | ||
if( !pageobj.exists() ) { | if( !pageobj.exists() ) { | ||
statelem.error( "It seems that the page doesn't exist. | statelem.error( "It seems that the page doesn't exist. Perhaps it has already been deleted." ); | ||
return; | return; | ||
} | } | ||
Line 160: | Line 178: | ||
var params = pageobj.getCallbackParameters(); | var params = pageobj.getCallbackParameters(); | ||
var tag_re = /( | var tag_re = /({{(?:db-?|delete|[aitcmrs]fd|md1)[^{}]*?\|?[^{}]*?}})/i; | ||
if( tag_re.test( text ) ) { | if( tag_re.test( text ) ) { | ||
statelem.warn( 'Page already tagged with a deletion template, aborting procedure' ); | statelem.warn( 'Page already tagged with a deletion template, aborting procedure' ); | ||
Line 167: | Line 185: | ||
// Remove tags that become superfluous with this action | // Remove tags that become superfluous with this action | ||
text = text.replace(/ | text = text.replace(/{{\s*(userspace draft|mtc|(copy|move) to wikimedia commons|(copy |move )?to ?commons)\s*(\|(?:{{[^{}]*}}|[^{}])*)?}}\s*/gi, ""); | ||
var prod_re = /{{\s*(?:dated prod|dated files|dated prod blp|Prod blp\/dated|Proposed deletion\/dated)\s*\|(?:{{[^{}]*}}|[^{}])*}}/i; | |||
var prod_re = / | |||
var summaryText; | var summaryText; | ||
if( !prod_re.test( text ) ) { | if( !prod_re.test( text ) ) { | ||
Line 183: | Line 200: | ||
} | } | ||
summaryText = "Proposing | summaryText = "Proposing " + namespace + " for deletion per [[SV:" + (params.blp ? "BLP" : "") + "PROD]]."; | ||
text = "{{subst:prod" + (params.blp ? " blp" : ("|1=" + Morebits.string.formatReasonText(params.reason))) + "}}\n" + text; | text = "{{subst:prod" + (params.blp ? " blp" : ("|1=" + Morebits.string.formatReasonText(params.reason))) + "}}\n" + text; | ||
} | } | ||
else { // already tagged for PROD, so try endorsing it | else { // already tagged for PROD, so try endorsing it | ||
var prod2_re = / | var prod2_re = /{{(?:Proposed deletion endorsed|prod-?2).*?}}/; | ||
if( prod2_re.test( text ) ) { | if( prod2_re.test( text ) ) { | ||
statelem.warn( 'Page already tagged with {{ | statelem.warn( 'Page already tagged with {{proposed deletion}} and {{proposed deletion endorsed}} templates, aborting procedure' ); | ||
return; | return; | ||
} | } | ||
var confirmtext = "A {{ | var confirmtext = "A {{proposed deletion}} tag was already found on this " + namespace + ". \nWould you like to add a {{proposed deletion endorsed}} tag with your explanation?"; | ||
if (params.blp) { | if (params.blp) { | ||
confirmtext = "A non-BLP {{ | confirmtext = "A non-BLP {{proposed deletion}} tag was found on this article.\nWould you like to add a {{proposed deletion endorsed}} tag with explanation \"article is a biography of a living person with no sources\"?"; | ||
} | } | ||
if( !confirm( confirmtext ) ) { | if( !confirm( confirmtext ) ) { | ||
Line 201: | Line 218: | ||
} | } | ||
summaryText = "Endorsing proposed deletion per [[ | summaryText = "Endorsing proposed deletion per [[SV:" + (params.blp ? "BLP" : "") + "PROD]]."; | ||
text = text.replace( prod_re, text.match( prod_re ) + "\n{{ | text = text.replace( prod_re, text.match( prod_re ) + "\n{{proposed deletion endorsed|1=" + (params.blp ? | ||
"article is a [[ | "article is a [[SV:BLPPROD|biography of a living person with no sources]]" : | ||
Morebits.string.formatReasonText(params.reason)) + "}}\n" ); | Morebits.string.formatReasonText(params.reason)) + "}}\n" ); | ||
Line 225: | Line 242: | ||
// Disallow warning yourself | // Disallow warning yourself | ||
if (initialContrib === mw.config.get("wgUserName")) { | if (initialContrib === mw.config.get("wgUserName")) { | ||
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification"); | |||
if (Twinkle.getPref("logProdPages")) { | if (Twinkle.getPref("logProdPages")) { | ||
Twinkle.prod.callbacks.addToLog(params); | Twinkle.prod.callbacks.addToLog(params); | ||
Line 230: | Line 248: | ||
return; | return; | ||
} | } | ||
// [[Template:Proposed deletion notify]] supports File namespace | |||
var notifyTemplate = params.blp ? 'prodwarningBLP' : 'proposed deletion notify'; | |||
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")"); | var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")"); | ||
var notifytext = "\n{{subst: | var notifytext = "\n{{subst:" + notifyTemplate + "|1=" + Morebits.pageNameNorm + "|concern=" + params.reason + "}} ~~~~"; | ||
usertalkpage.setAppendText(notifytext); | usertalkpage.setAppendText(notifytext); | ||
usertalkpage.setEditSummary("Notification: proposed deletion of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd')); | usertalkpage.setEditSummary("Notification: proposed deletion of [[:" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd')); | ||
usertalkpage.setCreateOption('recreate'); | usertalkpage.setCreateOption('recreate'); | ||
usertalkpage.setFollowRedirect(true); | usertalkpage.setFollowRedirect(true); | ||
Line 257: | Line 278: | ||
if (!pageobj.exists()) { | if (!pageobj.exists()) { | ||
text = | text = | ||
"This is a log of all [[ | "This is a log of all [[SV:PROD|proposed deletion]] tags applied or endorsed by this user using [[SV:TW|Twinkle]]'s PROD module.\n\n" + | ||
"If you no longer wish to keep this log, you can turn it off using the [[ | "If you no longer wish to keep this log, you can turn it off using the [[Sarkarverse:Twinkle/Preferences|preferences panel]], and " + | ||
"nominate this page for speedy deletion under [[ | "nominate this page for speedy deletion under [[SV:CSD#U1|CSD U1]].\n"; | ||
} | } | ||
Line 271: | Line 292: | ||
var summarytext; | var summarytext; | ||
if (params.logEndorsing) { | if (params.logEndorsing) { | ||
text += "\n# [[" + Morebits.pageNameNorm + "]]: endorsed " + (params.blp ? "BLP " : "") + "PROD. ~~~~~"; | text += "\n# [[:" + Morebits.pageNameNorm + "]]: endorsed " + (params.blp ? "BLP " : "") + "PROD. ~~~~~"; | ||
if (params.reason) { | if (params.reason) { | ||
text += "\n#* '''Reason''': " + params.reason + "\n"; | text += "\n#* '''Reason''': " + params.reason + "\n"; | ||
} | } | ||
summarytext = "Logging endorsement of PROD nomination of [[" + Morebits.pageNameNorm + "]]."; | summarytext = "Logging endorsement of PROD nomination of [[:" + Morebits.pageNameNorm + "]]."; | ||
} else { | } else { | ||
text += "\n# [[" + Morebits.pageNameNorm + "]]: " + (params.blp ? "BLP " : "") + "PROD"; | text += "\n# [[:" + Morebits.pageNameNorm + "]]: " + (params.blp ? "BLP " : "") + "PROD"; | ||
if (params.logInitialContrib) { | if (params.logInitialContrib) { | ||
text += "; notified {{user|" + params.logInitialContrib + "}}"; | text += "; notified {{user|" + params.logInitialContrib + "}}"; | ||
Line 285: | Line 306: | ||
text += "#* '''Reason''': " + params.reason + "\n"; | text += "#* '''Reason''': " + params.reason + "\n"; | ||
} | } | ||
summarytext = "Logging PROD nomination of [[" + Morebits.pageNameNorm + "]]."; | summarytext = "Logging PROD nomination of [[:" + Morebits.pageNameNorm + "]]."; | ||
} | } | ||
Line 316: | Line 337: | ||
Morebits.simpleWindow.setButtonsEnabled( false ); | Morebits.simpleWindow.setButtonsEnabled( false ); | ||
Morebits.status.init( form ); | Morebits.status.init( form ); | ||
Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName'); | Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName'); |