Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/azatoth/twinkle.git
Browse files Browse the repository at this point in the history
  • Loading branch information
atlight committed Oct 1, 2013
2 parents 9bf38bc + 34fa873 commit b508540
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 82 deletions.
5 changes: 4 additions & 1 deletion jshint.json
@@ -1,3 +1,6 @@
{
"maxerr": 1000
"maxerr": 1000,
"undef": true,
"unused": true,
"smarttabs": true
}
5 changes: 5 additions & 0 deletions modules/friendlytag.js
Expand Up @@ -421,6 +421,7 @@ Twinkle.tag.article.tags = {
"metricate": "article exclusively uses non-SI units of measurement",
"more footnotes": "article has some references, but insufficient in-text citations",
"new unreviewed article": "mark article for later review",
"news release": "article reads like a news release",
"no footnotes": "article has references, but no in-text citations",
"non-free": "article may contain excessive or improper use of copyrighted materials",
"notability": "article's subject may not meet the notability guideline",
Expand Down Expand Up @@ -498,6 +499,7 @@ Twinkle.tag.article.tagCategories = {
"advert",
"essay-like",
"fansite",
"news release",
"prose",
"technical",
"tense",
Expand Down Expand Up @@ -866,6 +868,9 @@ Twinkle.tag.callbacks = {
currentTag += '|1=' + params.tagParameters.expertSubject;
}
break;
case 'news release':
currentTag += '|1=article';
break;
case 'not English':
case 'rough translation':
if (params.translationLanguage) {
Expand Down
136 changes: 60 additions & 76 deletions modules/twinklespeedy.js
Expand Up @@ -988,10 +988,6 @@ Twinkle.speedy.callbacks = {
}
},





user: {
main: function(pageobj) {
var statelem = pageobj.getStatusElement();
Expand Down Expand Up @@ -1019,13 +1015,12 @@ Twinkle.speedy.callbacks = {
}

var code, parameters, i;
if (params.normalizeds.length > 1)
{
if (params.normalizeds.length > 1) {
code = "{{db-multiple";
var breakFlag = false;
$.each(params.normalizeds, function(index, norm) {
code += "|" + norm.toUpperCase();
parameters = Twinkle.speedy.getParameters(params.values[index], norm, statelem);
parameters = Twinkle.speedy.getParameters(pageobj, params.values[index], norm, statelem);
if (!parameters) {
breakFlag = true;
return false; // the user aborted
Expand All @@ -1041,10 +1036,8 @@ Twinkle.speedy.callbacks = {
}
code += "}}";
params.utparams = [];
}
else
{
parameters = Twinkle.speedy.getParameters(params.values[0], params.normalizeds[0], statelem);
} else {
parameters = Twinkle.speedy.getParameters(pageobj, params.values[0], params.normalizeds[0], statelem);
if (!parameters) {
return; // the user aborted
}
Expand Down Expand Up @@ -1238,25 +1231,21 @@ Twinkle.speedy.callbacks = {
};

// prompts user for parameters to be passed into the speedy deletion tag
Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normalized, statelem)
{
Twinkle.speedy.getParameters = function twinklespeedyGetParameters(pageobj, value, normalized, statelem) {
var parameters = [];
switch( normalized ) {
case 'db':
var dbrationale = prompt('Please enter a mandatory rationale. \n\"This page qualifies for speedy deletion because:\"', "");
if (!dbrationale || !dbrationale.replace(/^\s*/, "").replace(/\s*$/, ""))
{
if (!dbrationale || !dbrationale.replace(/^\s*/, "").replace(/\s*$/, "")) {
statelem.error( 'You must specify a rationale. Aborted by user.' );
return null;
}
parameters["1"] = dbrationale;
break;
case 'u1':
if (mw.config.get('wgNamespaceNumber') === 3 && !((/\//).test(mw.config.get('wgTitle'))))
{
if (mw.config.get('wgNamespaceNumber') === 3 && !((/\//).test(mw.config.get('wgTitle')))) {
var u1rationale = prompt('[CSD U1] Please provide a mandatory rationale to explain why this user talk page should be deleted:', "");
if (!u1rationale || !u1rationale.replace(/^\s*/, "").replace(/\s*$/, ""))
{
if (!u1rationale || !u1rationale.replace(/^\s*/, "").replace(/\s*$/, "")) {
statelem.error( 'You must specify a rationale. Aborted by user.' );
return null;
}
Expand All @@ -1265,19 +1254,14 @@ Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normal
break;
case 'f8':
var filename = prompt( '[CSD F8] Please enter the name of the file on Commons:', Morebits.pageNameNorm );
if (filename === null)
{
if (filename === null) {
statelem.error( 'Aborted by user.' );
return null;
}
if (filename !== '' && filename !== Morebits.pageNameNorm)
{
if (filename.indexOf("Image:") === 0 || filename.indexOf("File:") === 0)
{
if (filename !== '' && filename !== Morebits.pageNameNorm) {
if (filename.indexOf("Image:") === 0 || filename.indexOf("File:") === 0) {
parameters["1"] = filename;
}
else
{
} else {
statelem.error("The File: prefix was missing from the image filename. Aborted.");
return null;
}
Expand All @@ -1286,22 +1270,19 @@ Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normal
break;
case 'g4':
var deldisc = prompt( '[CSD G4] Please enter the name of the page where the deletion discussion took place. \nNOTE: For regular AfD and MfD discussions, just click OK - a link will be automatically provided.', "" );
if (deldisc === null)
{
if (deldisc === null) {
statelem.error( 'Aborted by user.' );
return null;
}
if (deldisc !== "" && deldisc.substring(0, 9) !== "Wikipedia" && deldisc.substring(0, 3) !== "WP:")
{
if (deldisc !== "" && deldisc.substring(0, 9) !== "Wikipedia" && deldisc.substring(0, 3) !== "WP:") {
statelem.error( 'The deletion discussion page name, if provided, must start with "Wikipedia:". Cannot proceed.' );
return null;
}
parameters["1"] = deldisc;
break;
case 'g5':
var banneduser = prompt( '[CSD G5] Please enter the username of the banned user if available:', "" );
if (banneduser === null)
{
if (banneduser === null) {
statelem.error( 'Aborted by user.' );
return null;
}
Expand All @@ -1311,23 +1292,20 @@ Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normal
switch( value ) {
case 'histmerge':
var mergetitle = prompt( '[CSD G6: history merge] Please enter the title to be merged into this one:', "" );
if (mergetitle === null)
{
if (mergetitle === null) {
statelem.error( 'Aborted by user.' );
return null;
}
parameters["1"] = mergetitle;
break;
case 'move':
var title = prompt( '[CSD G6: move] Please enter the title of the page to be moved here:', "" );
if (title === null)
{
if (title === null) {
statelem.error( 'Aborted by user.' );
return null;
}
var reason = prompt( '[CSD G6: move] Please enter the reason for the page move:', "" );
if (reason === null)
{
if (reason === null) {
statelem.error( 'Aborted by user.' );
return null;
}
Expand All @@ -1336,31 +1314,27 @@ Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normal
break;
case 'xfd':
var votepage = prompt( '[CSD G6: xfd] Please provide a full link, without [[ ]], to the page where the deletion was discussed:', "" );
if (votepage === null)
{
if (votepage === null) {
statelem.error( 'Aborted by user.' );
return null;
}
parameters.fullvotepage = votepage;
break;
case 'copypaste':
var copytitle = prompt( '[CSD G6: copypaste] Please enter the title of the original page that was copy-pasted here:', "" );
if (copytitle === null)
{
if (copytitle === null) {
statelem.error( 'Aborted by user.' );
return null;
}
parameters["1"] = copytitle;
break;
case 'g6':
var g6rationale = prompt( '[CSD G6] Please provide an optional rationale (leave empty to skip):', "" );
if (g6rationale === null)
{
if (g6rationale === null) {
statelem.error( 'Aborted by user.' );
return null;
}
if (g6rationale !== '')
{
if (g6rationale !== '') {
parameters.rationale = g6rationale;
}
break;
Expand All @@ -1369,60 +1343,76 @@ Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normal
}
break;
case 'g7':
if (Twinkle.getPref('speedyPromptOnG7'))
{
if (Twinkle.getPref('speedyPromptOnG7')) {
var g7rationale = prompt('[CSD G7] Please provide an optional rationale (perhaps linking to where the author requested this deletion - leave empty to skip):', "");
if (g7rationale === null)
{
if (g7rationale === null) {
statelem.error( 'Aborted by user.' );
return null;
}
if (g7rationale !== '')
{
if (g7rationale !== '') {
parameters.rationale = g7rationale;
}
}
break;
case 'g12':
var url = prompt( '[CSD G12] Please enter the URL if available, including the "http://":', "" );
if (url === null)
{
if (url === null) {
statelem.error( 'Aborted by user.' );
return null;
}
parameters.url = url;
break;
case 'g13':
var pageName = pageobj.getPageName(),
currentRevisionID = pageobj.getCurrentID(),
query = {
action: "query",
titles: pageName,
prop: "revisions",
rvprop: "timestamp",
rvstartid: currentRevisionID,
rvlimit: 1
},
api = new Morebits.wiki.api( 'Grabbing the last revision timestamp...', query, function( self ) {
var xmlDoc = self.responseXML,
isoDateString = $(xmlDoc).find("rev").attr("timestamp");

parameters.ts = isoDateString;
});

// Wait for API call to finish
api.post({
async: false
});

break;
case 'f9':
var f9url = prompt( '[CSD F9] Please enter the URL of the copyvio, including the "http://". \nIf you cannot provide a URL, please do not use CSD F9. (Exception: for copyvios of non-Internet sources, leave the box blank.)', "" );
if (f9url === null)
{
if (f9url === null) {
statelem.error( 'Aborted by user.' );
return null;
}
parameters.url = f9url;
break;
case 'a2':
var source = prompt('[CSD A2] Enter an interwiki link to the article on the foreign-language wiki (for example, "fr:Bonjour"):', "");
if (source === null)
{
if (source === null) {
statelem.error('Aborted by user.');
return null;
}
parameters.source = source;
break;
case 'a10':
var duptitle = prompt( '[CSD A10] Enter the article name that is duplicated:', "" );
if (duptitle === null)
{
if (duptitle === null) {
statelem.error( 'Aborted by user.' );
return null;
}
parameters.article = duptitle;
break;
case 'f1':
var img = prompt( '[CSD F1] Enter the file this is redundant to, excluding the "Image:" or "File:" prefix:', "" );
if (img === null)
{
if (img === null) {
statelem.error( 'Aborted by user.' );
return null;
}
Expand All @@ -1432,8 +1422,7 @@ Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normal
switch( value ) {
case 'duplicatetemplate':
var template = prompt( '[CSD T3] Enter the template this is redundant to, excluding the "Template:" prefix:', "" );
if (template === null)
{
if (template === null) {
statelem.error( 'Aborted by user.' );
return null;
}
Expand All @@ -1442,8 +1431,7 @@ Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normal
break;
default:
var t3rationale = prompt( '[CSD T3] Please enter a mandatory rationale:', "" );
if (!t3rationale || !t3rationale.replace(/^\s*/, "").replace(/\s*$/, ""))
{
if (!t3rationale || !t3rationale.replace(/^\s*/, "").replace(/\s*$/, "")) {
statelem.error( 'Aborted by user.' );
return null;
}
Expand All @@ -1458,8 +1446,7 @@ Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normal
break;
case 'p1':
var criterion = prompt( '[CSD P1] Enter the code of the article CSD criterion which this portal falls under: \n\n(A1 = no context, A3 = no content, A7 = non-notable, A10 = duplicate)', "" );
if (!criterion || !criterion.replace(/^\s*/, "").replace(/\s*$/, ""))
{
if (!criterion || !criterion.replace(/^\s*/, "").replace(/\s*$/, "")) {
statelem.error( 'You must enter a criterion. Aborted by user.' );
return null;
}
Expand All @@ -1472,11 +1459,9 @@ Twinkle.speedy.getParameters = function twinklespeedyGetParameters(value, normal
};

// function for processing talk page notification template parameters
Twinkle.speedy.getUserTalkParameters = function twinklespeedyGetUserTalkParameters(normalized, parameters)
{
Twinkle.speedy.getUserTalkParameters = function twinklespeedyGetUserTalkParameters(normalized, parameters) {
var utparams = [];
switch (normalized)
{
switch (normalized) {
case 'db':
utparams["2"] = parameters["1"];
break;
Expand Down Expand Up @@ -1504,8 +1489,7 @@ Twinkle.speedy.resolveCsdValues = function twinklespeedyResolveCsdValues(e) {
return values;
};

Twinkle.speedy.callback.evaluateSysop = function twinklespeedyCallbackEvaluateSysop(e)
{
Twinkle.speedy.callback.evaluateSysop = function twinklespeedyCallbackEvaluateSysop(e) {
var form = (e.target.form ? e.target.form : e.target);

var tag_only = form.tag_only;
Expand Down

0 comments on commit b508540

Please sign in to comment.