Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* <nowiki> */
/* Bharat Mitra: maintenance tag module */
( function () {
'use strict';
var BM = window.BharatMitra;
/* Only templates that exist on Bharatpedia are listed. */
var TAGS = [
[ 'Cleanup', 'needs general cleanup' ],
[ 'Cleanup rewrite', 'needs a complete rewrite' ],
[ 'Cleanup reorganize', 'needs reorganisation' ],
[ 'Cleanup bare URLs', 'has bare URLs in its references' ],
[ 'Copy edit', 'needs copy editing for grammar and style' ],
[ 'Unreferenced', 'does not cite any sources at all' ],
[ 'More citations needed', 'needs additional references or sources' ],
[ 'No footnotes', 'has references but no inline citations' ],
[ 'One source', 'relies largely or entirely on a single source' ],
[ 'BLP sources', 'BLP that needs additional sources for verification' ],
[ 'BLP unsourced', 'BLP that has no sources at all' ],
[ 'Original research', 'contains original research' ],
[ 'Primary sources', 'relies too much on primary sources' ],
[ 'Self-published', 'uses self-published sources improperly' ],
[ 'Unreliable sources', 'some references may not be reliable' ],
[ 'Third-party', 'relies on sources too closely associated with the subject' ],
[ 'Sources exist', 'sources are available that could be added' ],
[ 'Citation style', 'has an inconsistent citation style' ],
[ 'POV', 'does not maintain a neutral point of view' ],
[ 'Peacock', 'contains wording that promotes the subject' ],
[ 'Weasel', 'neutrality is compromised by weasel words' ],
[ 'COI', 'an editor has a conflict of interest' ],
[ 'Fanpov', 'written from a fan point of view' ],
[ 'Undue weight', 'gives undue weight to minor viewpoints' ],
[ 'Too few opinions', 'may not include all significant viewpoints' ],
[ 'Recentism', 'slanted towards recent events' ],
[ 'Disputed', 'the accuracy is disputed' ],
[ 'Notability', 'the notability of the topic is not established' ],
[ 'Lead missing', 'has no lead section' ],
[ 'Lead rewrite', 'the lead needs to be rewritten' ],
[ 'Lead too short', 'the lead is too short' ],
[ 'Lead too long', 'the lead is too long' ],
[ 'Sections', 'needs section headings' ],
[ 'Too many sections', 'has too many sections' ],
[ 'Very long', 'the article is very long' ],
[ 'Underlinked', 'needs more internal links' ],
[ 'Overlinked', 'has too many internal links' ],
[ 'Dead end', 'has few or no links to other articles' ],
[ 'Orphan', 'few or no other articles link to it' ],
[ 'Uncategorized', 'is not in any category' ],
[ 'Improve categories', 'needs more or better categories' ],
[ 'External links', 'the external links section needs cleanup' ],
[ 'Update', 'information is out of date' ],
[ 'Current', 'documents a current event' ],
[ 'Expert needed', 'needs attention from an expert' ],
[ 'Expand language', 'should be expanded from a foreign-language article' ],
[ 'Rough translation', 'is a poor translation' ],
[ 'Globalize', 'does not reflect a worldwide view' ],
[ 'Overly detailed', 'is excessively detailed' ],
[ 'Context', 'needs more context' ],
[ 'Confusing', 'is confusing or unclear' ],
[ 'Technical', 'is too technical to understand' ],
[ 'Tone', 'the tone or style is not appropriate' ],
[ 'Essay-like', 'is written like an essay' ],
[ 'Prose', 'should be converted to prose' ],
[ 'Fiction', 'is written in an in-universe style' ],
[ 'Under construction', 'is under major construction' ],
[ 'In use', 'is being edited extensively' ]
];
var NO_DATE = { 'In use': true, 'Under construction': true, 'Current': true };
var MONTHS = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December' ];
function dateStr() {
var d = new Date();
return MONTHS[ d.getMonth() ] + ' ' + d.getFullYear();
}
function tagText( name ) {
return '{{' + name + ( NO_DATE[ name ] ? '' : '|date=' + dateStr() ) + '}}';
}
function selected( v ) {
var out = [];
TAGS.forEach( function ( t, i ) {
if ( v[ 't' + i ] ) { out.push( t[ 0 ] ); }
} );
return out;
}
BM.register( 'tag', {
open: function () {
var title = mw.config.get( 'wgPageName' ).replace( /_/g, ' ' );
var fields = TAGS.map( function ( t, i ) {
return { name: 't' + i, label: t[ 0 ] + ' - ' + t[ 1 ], type: 'checkbox' };
} );
BM.core.dialog( {
title: 'Add maintenance tags',
help: 'Tick the maintenance templates to place at the top of this article. Each tag is added with the current month and year. Tags already on the page are skipped.',
fields: fields,
preview: function ( v ) {
var sel = selected( v );
return sel.length ? sel.map( tagText ).join( '\n' ) : '(no tag selected)';
},
previewTitle: function () { return title; },
submitLabel: 'Add tags',
success: 'Tags added.',
onSubmit: function ( v ) {
var sel = selected( v );
if ( !sel.length ) { throw new Error( 'Select at least one tag.' ); }
return BM.core.getPage( title ).then( function ( p ) {
if ( !p.exists ) { throw new Error( 'The page could not be read.' ); }
var added = sel.filter( function ( name ) {
return p.content.indexOf( '{{' + name ) === -1 &&
p.content.indexOf( '{{' + name.toLowerCase() ) === -1;
} );
if ( !added.length ) { throw new Error( 'Those tags are already on the page.' ); }
var block = added.map( tagText ).join( '\n' ) + '\n';
var nl = p.content.indexOf( '\n' );
var firstLine = nl === -1 ? p.content : p.content.slice( 0, nl );
var out;
if ( /^\{\{(pp-|short description)/i.test( firstLine ) && nl !== -1 ) {
out = firstLine + '\n' + block + p.content.slice( nl + 1 );
} else {
out = block + p.content;
}
var summary = 'Added tags: ' + added.join( ', ' ) +
' (using [[Bharatpedia:Bharat Mitra|Bharat Mitra]])';
if ( summary.length > 480 ) {
summary = 'Added maintenance tags (using [[Bharatpedia:Bharat Mitra|Bharat Mitra]])';
}
return BM.core.savePage( title, out, summary, p.revid );
} );
}
} );
}
} );
}() );
/* </nowiki> */