|
|
Line 1,027: |
Line 1,027: |
| | | |
| // === Template usage rules === | | // === Template usage rules === |
|
| |
| ct.rules.push(function (s) {
| |
| // Initialise statics
| |
| var _static = arguments.callee;
| |
| if (_static.LANGUAGE_MAP == null) {
| |
| _static.LANGUAGE_MAP = { // : Hashtable<String, String>
| |
| // From http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
| |
| // Note, that not all of these have a lang-xx template, but finding a reference
| |
| // to such a language is a good reason to create the template.
| |
| aa: 'Afar', ab: 'Abkhazian', ae: 'Avestan', af: 'Afrikaans', ak: 'Akan', am: 'Amharic', an: 'Aragonese', ar: 'Arabic',
| |
| as: 'Assamese', av: 'Avaric', ay: 'Aymara', az: 'Azerbaijani', ba: 'Bashkir', be: 'Belarusian', bg: 'Bulgarian',
| |
| bh: 'Bihari', bi: 'Bislama', bm: 'Bambara', bn: 'Bengali', bo: 'Tibetan', br: 'Breton', bs: 'Bosnian', ca: 'Catalan',
| |
| ce: 'Chechen', ch: 'Chamorro', co: 'Corsican', cr: 'Cree', cs: 'Czech', cu: 'Church Slavic', cv: 'Chuvash', cy: 'Welsh',
| |
| da: 'Danish', de: 'German', dv: 'Divehi', dz: 'Dzongkha', ee: 'Ewe', el: 'Greek', en: 'English', eo: 'Esperanto',
| |
| es: 'Spanish', et: 'Estonian', eu: 'Basque', fa: 'Persian', ff: 'Fulah', fi: 'Finnish', fj: 'Fijian', fo: 'Faroese',
| |
| fr: 'French', fy: 'Western Frisian', ga: 'Irish', gd: 'Gaelic', gl: 'Galician', gn: 'Guaran\u00ed', gu: 'Gujarati',
| |
| gv: 'Manx', ha: 'Hausa', he: 'Hebrew', hi: 'Hindi', ho: 'Hiri Motu', hr: 'Croatian', ht: 'Haitian', hu: 'Hungarian',
| |
| hy: 'Armenian', hz: 'Herero', ia: 'Interlingua (International Auxiliary Language Association)', id: 'Indonesian',
| |
| ie: 'Interlingue', ig: 'Igbo', ii: 'Sichuan Yi', ik: 'Inupiaq', io: 'Ido', is: 'Icelandic', it: 'Italian', iu: 'Inuktitut',
| |
| ja: 'Japanese', jv: 'Javanese', ka: 'Georgian', kg: 'Kongo', ki: 'Kikuyu', kj: 'Kuanyama', kk: 'Kazakh', kl: 'Kalaallisut',
| |
| km: 'Khmer', kn: 'Kannada', ko: 'Korean', kr: 'Kanuri', ks: 'Kashmiri', ku: 'Kurdish', kv: 'Komi', kw: 'Cornish',
| |
| ky: 'Kirghiz', la: 'Latin', lb: 'Luxembourgish', lg: 'Ganda', li: 'Limburgish', ln: 'Lingala', lo: 'Lao', lt: 'Lithuanian',
| |
| lu: 'Luba-Katanga', lv: 'Latvian', mg: 'Malagasy', mh: 'Marshallese', mi: 'M\u0101ori', mk: 'Macedonian', ml: 'Malayalam',
| |
| mn: 'Mongolian', mo: 'Moldavian', mr: 'Marathi', ms: 'Malay', mt: 'Maltese', my: 'Burmese', na: 'Nauru',
| |
| nb: 'Norwegian Bokm\u00e5l', nd: 'North Ndebele', ne: 'Nepali', ng: 'Ndonga', nl: 'Dutch', nn: 'Norwegian Nynorsk',
| |
| no: 'Norwegian', nr: 'South Ndebele', nv: 'Navajo', ny: 'Chichewa', oc: 'Occitan', oj: 'Ojibwa', om: 'Oromo', or: 'Oriya',
| |
| os: 'Ossetian', pa: 'Panjabi', pi: 'P\u0101li', pl: 'Polish', ps: 'Pashto', pt: 'Portuguese', qu: 'Quechua',
| |
| rm: 'Raeto-Romance', rn: 'Kirundi', ro: 'Romanian', ru: 'Russian', rw: 'Kinyarwanda', sa: 'Sanskrit', sc: 'Sardinian',
| |
| sd: 'Sindhi', se: 'Northern Sami', sg: 'Sango', sh: 'Serbo-Croatian', si: 'Sinhala', sk: 'Slovak', sl: 'Slovenian',
| |
| sm: 'Samoan', sn: 'Shona', so: 'Somali', sq: 'Albanian', sr: 'Serbian', ss: 'Swati', st: 'Southern Sotho', su: 'Sundanese',
| |
| sv: 'Swedish', sw: 'Swahili', ta: 'Tamil', te: 'Telugu', tg: 'Tajik', th: 'Thai', ti: 'Tigrinya', tk: 'Turkmen',
| |
| tl: 'Tagalog', tn: 'Tswana', to: 'Tonga', tr: 'Turkish', ts: 'Tsonga', tt: 'Tatar', tw: 'Twi', ty: 'Tahitian',
| |
| ug: 'Uighur', uk: 'Ukrainian', ur: 'Urdu', uz: 'Uzbek', ve: 'Venda', vi: 'Vietnamese', vo: 'Volap\u00fck', wa: 'Walloon',
| |
| wo: 'Wolof', xh: 'Xhosa', yi: 'Yiddish', yo: 'Yoruba', za: 'Zhuang', zh: 'Chinese', zu: 'Zulu'
| |
| };
| |
| _static.REVERSE_LANGUAGE_MAP = {}; // : Hashtable<String, String>
| |
| for (var i in _static.LANGUAGE_MAP) {
| |
| _static.REVERSE_LANGUAGE_MAP[_static.LANGUAGE_MAP[i]] = i;
| |
| }
| |
| }
| |
|
| |
| // U+201e and U+201c are opening and closing double quotes
| |
| // U+2013 and U+2014 are an ndash and an mdash
| |
| var re = /\[\[(\w+) language\|\1\]\] *: (\'+)*([{letter} \"\'\u201e\u201c\/\u2014\u2013\-]+)(?:\2)/g;
| |
| re = ct.fixRegExp(re);
| |
| var a = ct.getAllMatches(re, s);
| |
| var b = [];
| |
| for (var i = 0; i < a.length; i++) {
| |
| var m = a[i];
| |
| if (_static.REVERSE_LANGUAGE_MAP[m[1]] == null) {
| |
| continue;
| |
| }
| |
| var code = _static.REVERSE_LANGUAGE_MAP[m[1]];
| |
| // Markers for italics and bold are stripped off
| |
| b.push({
| |
| start: m.start,
| |
| end: m.end,
| |
| replacement: '{{lang-' + code + '|' + m[3] + '}}',
| |
| name: 'lang-' + code,
| |
| description: 'Apply the {{lang-' + code + '}} template',
| |
| help: 'The <tt>' + ct.hlink('Template:lang-' + code, '{{lang-' + code + '}}')
| |
| + '</tt> template can be applied for this text.'
| |
| + '<br/>Similar templates are available in the '
| |
| + ct.hlink('Category:Multilingual_support_templates', 'multilingual support templates category')
| |
| + '.'
| |
| });
| |
| }
| |
| return b;
| |
| });
| |
| | | |
| ct.rules.push(function (s) { | | ct.rules.push(function (s) { |
Line 1,116: |
Line 1,047: |
| } | | } |
| return b; | | return b; |
| });
| |
|
| |
| ct.rules.push(function (s) {
| |
| var re = /^[ ':]*(?:(?:Further|More) +info(?:rmation)?)[ ']*:[ ']*\[\[([^\]]+)\]\][ ']*$/mig;
| |
| var a = ct.getAllMatches(re, s);
| |
| var b = [];
| |
| for (var i = 0; i < a.length; i++) {
| |
| var m = a[i];
| |
| if ((m[1] != null) && (m[1] != '')) {
| |
| b.push({
| |
| start: m.start,
| |
| end: m.end,
| |
| replacement: '{{futher|' + m[1] + '}}',
| |
| name: 'template-further',
| |
| description: 'Use the {{futher|...}} template',
| |
| help: 'Template <tt>' + ct.hlink('Template:Further', '{{further|...}}')
| |
| + '</tt> can be used in this place.'
| |
| });
| |
| }
| |
| }
| |
| return b;
| |
| });
| |
|
| |
| ct.rules.push(function (s) {
| |
| var exceptions = {};
| |
| var wgTitle = window.wgTitle || '';
| |
| if (exceptions[wgTitle]) {
| |
| return [];
| |
| }
| |
| var re0 = /^([{letter}\-]+(?: [{letter}\-]+\.?)?) ([{letter}\-]+(?:ov|ev|ski))$/;
| |
| re0 = ct.fixRegExp(re0);
| |
| var m0 = re0.exec(wgTitle);
| |
| if (m0 == null) {
| |
| return [];
| |
| }
| |
| if (s.indexOf('DEFAULTSORT:') != -1) {
| |
| return [];
| |
| }
| |
| var firstNames = m0[1];
| |
| var lastName = m0[2];
| |
| var re1 = new RegExp(
| |
| '\\[\\[(Category:[\\w _\\(\\),\\-]+)\\| *'
| |
| + ct.escapeRegExp(lastName) + ', *'
| |
| + ct.escapeRegExp(firstNames)
| |
| + ' *\\]\\]', 'gi'
| |
| );
| |
| var a = ct.getAllMatches(re1, s);
| |
| if (a.length == 0) {
| |
| return [];
| |
| }
| |
| var aStart = a[0].start;
| |
| var aEnd = a[a.length - 1].end;
| |
| var original = s.substring(aStart, aEnd);
| |
| var replacement = '{{' + 'DEFAULTSORT:' + lastName + ', ' + firstNames + '}}\n'
| |
| + original.replace(re1, '[[$1]]');
| |
| return [{
| |
| start: aStart,
| |
| end: aEnd,
| |
| replacement: replacement,
| |
| name: 'default-sort',
| |
| description: 'Use DEFAULTSORT to specify the common sort key',
| |
| help: 'The <tt>' + ct.hlink('Help:Categories#Default_sort_key', 'DEFAULTSORT')
| |
| + '</tt> magic word can be used to specify sort keys for categories. It was '
| |
| + ct.hlink('Wikipedia:Wikipedia_Signpost/2007-01-02/Technology_report',
| |
| 'announced in January 2007')
| |
| + '.'
| |
| }];
| |
| });
| |
|
| |
| ct.rules.push(function (s) {
| |
| var wgTitle = window.wgTitle || '';
| |
| var reTitle = /^(a|the) (.*)$/i;
| |
| if (!reTitle.test(wgTitle) || (s.indexOf('DEFAULTSORT') !== -1)) {
| |
| return [];
| |
| }
| |
| var a = ct.getAllMatches(/(\[\[)[Cc]ategory:[^\]]+\]\]/g, s);
| |
| if (a.length === 0) {
| |
| return [];
| |
| }
| |
| var mTitle = ct.getAllMatches(reTitle, wgTitle)[0]; // the match object for the title
| |
| var article = mTitle[1];
| |
| var nounPhrase = mTitle[2];
| |
| var highlightStart = a[0].start;
| |
| var highlightEnd = a[a.length - 1].end;
| |
| return [{
| |
| start: highlightStart,
| |
| end: highlightEnd,
| |
| replacement: '{{' + 'DEFAULTSORT:' + nounPhrase + ', ' + article + '}}\n'
| |
| + s.substring(highlightStart, highlightEnd),
| |
| name: 'defaultsort-' + article.toLowerCase(),
| |
| description: 'Add DEFAULTSORT',
| |
| help: "Articles starting with ``a'' or ``the'' should participate in categories without the first word."
| |
| }];
| |
| }); | | }); |
| | | |
Line 1,230: |
Line 1,068: |
| }); | | }); |
| | | |
| ct.rules.push(function (s) {
| |
| var _static = arguments.callee;
| |
| if (_static.DEPRECATED_TEMPLATES_ARRAY == null) {
| |
| _static.DEPRECATED_TEMPLATES_ARRAY = [
| |
| 'ArB', 'ArTranslit', 'ArabDIN', 'BridgeType', 'CFB Coaching Record End', 'CFB Coaching Record Entry',
| |
| 'CFB Coaching Record Start', 'CFB Coaching Record Team', 'CFB Coaching Record Team End', 'CURRENTWEEKDAY', 'Canada CP 2001',
| |
| 'CelsiusToKelvin', 'Chembox', 'Chembox simple inorganic', 'Chembox simple organic', 'Chinesename', 'ConvertVolume',
| |
| 'ConvertWeight', 'Country', 'Cultivar hybrid', 'Dated episode notability', 'Doctl', 'Dynamic navigation box',
| |
| 'Dynamic navigation box with image', 'Dynamic navigation small', 'Episode-unreferenced', 'Extra album cover', 'Extra chronology',
| |
| 'Fa', 'Factor', 'Fn', 'Fnb', 'Football stadium', 'Footnote', 'GUE', 'Geolinks-US-loc', 'Getamap', 'Harvard reference',
| |
| 'Hiddenkey', 'IAST-hi', 'IAST1', 'ISOtranslit', 'Iftrue', 'Illinois Area Codes', 'Infobox Minor Planet', 'Infobox Ship',
| |
| 'Infobox music venue', 'Ivrit', 'JER', 'Lang-yi2', 'Lang2iso', 'LangWithNameNoItals', 'Latinx',
| |
| 'Military-Insignia', 'Mmuk mapdet', 'Mmuk mapho25', 'Mmuk maphot', 'Mmuknr map', 'Mmuknr photo', 'Mmukpc prim', 'Navbox generic',
| |
| 'Navigation', 'Navigation box with image', 'Navigation no hide', 'Navigation with columns', 'Navigation with image', 'NavigationBox',
| |
| 'Novelinfoboxincomp', 'Novelinfoboxneeded', 'OldVGpeerreview', 'Ordinal date', 'PD-LOC', 'PIqaD',
| |
| 'Pekinensis tail familia Amaranthaceae', 'Pekinensis tail genus Chenopodium', 'Pekinensis tail regnum Plantae', 'PerB',
| |
| 'PerTranslit', 'Pound avoirdupois', 'Prettyinfobox', 'Prettytable', 'Qif', 'Rating-10', 'Rating-3', 'Rating-4', 'Rating-5',
| |
| 'Rating-6', 'Ref num', 'Reqimage', 'Rewrite-section', 'Ruby', 'Sectionrewrite', 'Semxlit', 'Skyscraper', 'Sortdate', 'Source',
| |
| 'Storm pics', 'Supertribus', 'Switch', 'Tablabonita', 'Taxobox superregnum entry', 'Taxobox supertribus entry', 'IPA fonts',
| |
| 'Unicode fonts', 'User R-proglang', 'User asm', 'User cobol', 'User css', 'User haskell', 'User html', 'User java', 'User mobile',
| |
| 'User programming', 'User unicode', 'User xhtml', 'User xml', 'Tfd-kept', 'Timeline infobox finish', 'Timeline infobox start',
| |
| 'Translit-yi2', 'WAFerry', 'Weight'
| |
| ];
| |
| _static.DEPRECATED_TEMPLATES_SET = {};
| |
| for (var i = _static.DEPRECATED_TEMPLATES_ARRAY.length - 1; i >= 0; i--) {
| |
| _static.DEPRECATED_TEMPLATES_SET[_static.DEPRECATED_TEMPLATES_ARRAY[i]] = true;
| |
| }
| |
| }
| |
| var a = ct.getAllMatches(ct.fixRegExp(/(\{\{\s*)([{letter}0-9\s\-]+)(\s*(\||\}\}))/g), s);
| |
| var b = [];
| |
| for (var i = 0; i < a.length; i++) {
| |
| var m = a[i];
| |
| var name = m[2].replace(/ /g, '_');
| |
| name = name.charAt(0).toUpperCase() + name.substring(1);
| |
| if (_static.DEPRECATED_TEMPLATES_SET[name]) {
| |
| b.push({
| |
| start: m.start,
| |
| end: m.end,
| |
| name: 'deprecated-template',
| |
| description: 'Template {{' + name + '}} has been deprecated',
| |
| help: 'Template <tt>' + ct.hlink('Template:' + name, '{{' + name + '}}')
| |
| + ' is ' + ct.hlink('Category:Deprecated templates', 'deprecated')
| |
| + '. Consider using another one as recommended on the template page.'
| |
| });
| |
| }
| |
| }
| |
| return b;
| |
| });
| |
| | | |
| // === Other rules === | | // === Other rules === |