MediaWiki:Gadget-twinklexfd.js
Görünüm
Not: Sayfayı kaydettikten sonra değişiklikleri görebilmek için tarayıcınızın önbelleğinizi temizlemeniz gerekir. Google Chrome, Firefox, Microsoft Edge ve Safari: ⇧ Shift tuşuna basılı tutun ve Yeniden Yükle araç çubuğu düğmesine tıklayın. Ayrıntılar ve diğer tarayıcılara yönelik yönergeler için Vikipedi:Önbelleğinizi atlayın sayfasını inceleyin.
// <nowiki>
(function() {
/*
****************************************
*** twinklexfd.js: SAS modülü
****************************************
* Çağırma modu: Sekme ("SAS")
* Etkin olduğu yerler: Commons'tan gelen dosyaların sayfaları ve özel sayfalar dışındaki var olan sayfalar
*/
Twinkle.xfd = function twinklexfd() {
// Disable on:
// * special pages
// * non-existent pages
// * files on Commons, whether there is a local page or not (unneeded local pages of files on Commons are eligible for CSD F2, or R4 if it's a redirect)
if (mw.config.get('wgNamespaceNumber') < 0 || !mw.config.get('wgArticleId') || (mw.config.get('wgNamespaceNumber') === 6 && document.getElementById('mw-sharedupload'))) {
return;
}
let tooltip;
if (mw.config.get('wgIsRedirect')) {
tooltip = 'Bu yönlendirmeyi silmek veya yönlendirilen maddeyi değiştirmek için bir tartışma başlatın';
} else {
switch (mw.config.get('wgNamespaceNumber')) {
case 0:
tooltip = 'Bu maddeyi silmek veya taşımak için bir tartışma başlatın';
break;
case 10:
tooltip = 'Bu şablonu silmek veya birleştirmek için bir tartışma başlatın';
break;
case 828:
tooltip = 'Bu modülü silmek veya birleştirmek için bir tartışma başlatın';
break;
case 6:
tooltip = 'Bu dosyayı silmek için bir tartışma başlatın';
break;
case 14:
tooltip = 'Bu kategoriyi silmek, birleştirmek veya yeniden adlandırmak için bir tartışma başlatın';
break;
default:
tooltip = 'Bu sayfayı silmek için bir tartışma başlatın';
break;
}
}
Twinkle.addPortletLink(Twinkle.xfd.callback, 'SAS', 'tw-xfd', tooltip);
};
const utils = {
/** Get ordinal number figure */
num2order: function(num) {
switch (num) {
case 1:
return '';
case 2:
return '2.';
case 3:
return '3.';
default:
return num + '.';
}
},
/**
* Remove namespace name from title if present
* Exception-safe wrapper around mw.Title
*
* @param {string} title
*/
stripNs: function(title) {
const title_obj = mw.Title.newFromUserInput(title);
if (!title_obj) {
return title; // user entered invalid input; do nothing
}
return title_obj.getNameText();
},
/**
* Add namespace name to page title if not already given
* CAUTION: namespace name won't be added if a namespace (*not* necessarily
* the same as the one given) already is there in the title
*
* @param {string} title
* @param {number} namespaceNumber
*/
addNs: function(title, namespaceNumber) {
const title_obj = mw.Title.newFromUserInput(title, namespaceNumber);
if (!title_obj) {
return title; // user entered invalid input; do nothing
}
return title_obj.toText();
},
/**
* Provide Wikipedian TLA style: AfD, RfD, CfDS, RM, SfD, etc.
*
* @param {string} venue
* @return {string}
*/
toTLACase: function(venue) {
return venue
.toString()
// Everybody up, inclduing rm and the terminal s in cfds
.toUpperCase()
// Lowercase the central f in a given TLA and normalize sfd-t and sfr-t
.replace(/(.)F(.)(?:-.)?/, '$1f$2');
}
};
Twinkle.xfd.currentRationale = null;
// error callback on Morebits.Status.object
Twinkle.xfd.printRationale = function twinklexfdPrintRationale() {
if (Twinkle.xfd.currentRationale) {
Morebits.Status.printUserText(Twinkle.xfd.currentRationale, 'Silme gerekçeniz aşağıda verilmiştir. Yeniden denemek isterseniz bu metni kopyalayıp yeni bir pencerede kullanabilirsiniz:');
// only need to print the rationale once
Twinkle.xfd.currentRationale = null;
}
};
Twinkle.xfd.callback = function twinklexfdCallback() {
const Window = new Morebits.SimpleWindow(700, 400);
Window.setTitle('Silinme tartışması başlatın (SAS)');
Window.setScriptName('Twinkle');
Window.addFooterLink('Silinme tartışmaları hakkında', 'VP:SAS');
Window.addFooterLink('SAS tercihleri', 'WP:TWTER#xfd');
Window.addFooterLink('Twinkle yardımı', 'VT:TW');
//Window.addFooterLink('Give feedback', 'WT:TW');
const form = new Morebits.QuickForm(Twinkle.xfd.callback.evaluate);
const categories = form.append({
type: 'select',
name: 'venue',
label: 'Silinme tartışması için tür:',
tooltip: 'Etkinleştirildiğinde, bulunduğunuz ad alanı için varsayılan bir seçim yapılır. Bu varsayılanın en uygun seçenek olması muhtemeldir.',
event: Twinkle.xfd.callback.change_category
});
const namespace = mw.config.get('wgNamespaceNumber');
categories.append({
type: 'option',
label: 'Bütün sayfalar',
selected: [0, 2, 4, 6, 12, 100, 102].indexOf(namespace) !== -1, // Kategori, Modül ve Şablon hariç tüm ana ad alanları
// Other namespaces, and userboxes in template namespace
value: 'sas'
});
// categories.append({
// type: 'option',
// label: 'AfD (Articles for deletion)',
// selected: namespace === 2300, // Ayak altından çekilsin diye Gadget ad alanına atalım
// value: 'afd'
// });
categories.append({
type: 'option',
label: 'Şablon',
selected: [10, 828].indexOf(namespace) !== -1, // Template and module namespaces
value: 'saş'
});
// categories.append({
// type: 'option',
// label: 'FfD (Files for discussion)',
// selected: namespace === 6, // File namespace
// value: 'ffd'
// });
categories.append({
type: 'option',
label: 'Kategori',
selected: namespace === 14 || (namespace === 10 && /-stub$/.test(Morebits.pageNameNorm)), // Category namespace and stub templates
value: 'kt'
});
// categories.append({
// type: 'option',
// label: 'CfD/S (Categories for speedy renaming)',
// value: 'cfds'
// });
// categories.append({
// type: 'option',
// label: 'RfD (Redirects for discussion)',
// selected: Morebits.wiki.isPageRedirect(),
// value: 'rfd'
// });
// categories.append({
// type: 'option',
// label: 'RM (Requested moves)',
// selected: false,
// value: 'rm'
// });
form.append({
type: 'div',
id: 'wrong-venue-warn',
style: 'color: red; font-style: italic'
});
form.append({
type: 'checkbox',
list: [{
label: 'Mümkünse sayfayı oluşturan kullanıcıyı bilgilendir',
value: 'notify',
name: 'notifycreator',
tooltip: "Seçilirse, sayfayı oluşturan kullanıcıya bir bildirim mesajı gönderilecektir.",
checked: true
}]
});
form.append({
type: 'field',
label: 'Work area',
name: 'work_area'
});
const previewlink = document.createElement('a');
$(previewlink).on('click', () => {
Twinkle.xfd.callbacks.preview(result); // |result| is defined below
});
previewlink.style.cursor = 'pointer';
previewlink.textContent = 'Önizleme';
form.append({ type: 'div', id: 'xfdpreview', label: [previewlink] });
form.append({ type: 'div', id: 'twinklexfd-previewbox', style: 'display: none' });
form.append({ type: 'submit' });
var result = form.render();
Window.setContent(result);
Window.display();
result.previewer = new Morebits.wiki.Preview($(result).find('div#twinklexfd-previewbox').last()[0]);
// We must init the controls
const evt = document.createEvent('Event');
evt.initEvent('change', true, true);
result.venue.dispatchEvent(evt);
};
Twinkle.xfd.callback.wrongVenueWarning = function twinklexfdWrongVenueWarning(venue) {
let text = '';
const namespace = mw.config.get('wgNamespaceNumber');
switch (venue) {
case 'saş': //eskiden VP:ŞT, artık VP:SAS - bunu seçince kendi özel şablonlarını kullanıyor
if (namespace !== 10 && namespace !== 828) {
text = 'Bu seçenek yalnızca şablon ve modüller içindir.';
}
break;
case 'kt': //eskiden VP:KT, artık VP:SAS - bunu seçince kendi özel şablonlarını kullanıyor
if (namespace !== 14) {
text = 'Bu seçenek yalnızca kategoriler içindir.';
}
break;
/* bunlar bizde yok
case 'cfds':
if (namespace !== 2301) {
text = 'CfDS is only for categories.';
}
break;
case 'ffd':
if (namespace !== 2302) {
text = 'DT yalnızca dosyalar içindir.';
}
break;
case 'rm':
if (namespace === 14) { // category
text = 'Please use CfD or CfDS for category renames.';
} else if ([118, 119, 2, 3].indexOf(namespace) > -1) { // draft, draft talk, user, user talk
text = 'RMs are not permitted in draft and userspace, unless they are uncontroversial technical requests.';
}
break;
case 'afd':
if (namespace !== 2300) {
text = 'AfD is generally appropriate only for articles.';
} else if (mw.config.get('wgIsRedirect')) {
text = 'Please use RfD for redirects.';
}
break;
*/
default: // Silinemeye aday sayfalar: maddeler
break;
}
$('#wrong-venue-warn').text(text);
};
Twinkle.xfd.callback.change_category = function twinklexfdCallbackChangeCategory(e) {
const value = e.target.value;
const form = e.target.form;
const old_area = Morebits.QuickForm.getElements(e.target.form, 'work_area')[0];
let work_area = null;
const oldreasontextbox = form.getElementsByTagName('textarea')[0];
const oldreason = oldreasontextbox ? oldreasontextbox.value : '';
var appendReasonBox = function twinklexfdAppendReasonBox() {
work_area.append({
type: 'textarea',
name: 'reason',
label: 'Gerekçe:',
value: oldreason,
tooltip: 'Gerekçenizde vikimetin kullanabilirsiniz. Twinkle otomatik olarak imzalayacak.'
});
};
Twinkle.xfd.callback.wrongVenueWarning(value);
form.previewer.closePreview();
switch (value) {
case 'afd':
work_area = new Morebits.QuickForm.Element({
type: 'field',
label: 'Silinmeye aday sayfalar',
name: 'work_area'
});
work_area.append({
type: 'div',
label: '', // Added later by Twinkle.makeFindSourcesDiv()
id: 'twinkle-xfd-findsources',
style: 'margin-bottom: 5px; margin-top: -5px;'
});
work_area.append({
type: 'checkbox',
list: [{
label: 'Wrap deletion tag with <noinclude>',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Will wrap the deletion tag in <noinclude> tags, so that it won\'t transclude. This option is not normally required.'
}]
});
work_area.append({
type: 'select',
name: 'xfdcat',
label: 'Choose what category this nomination belongs in:',
list: [
{ type: 'option', label: 'Unknown', value: '?', selected: true },
{ type: 'option', label: 'Media and music', value: 'M' },
{ type: 'option', label: 'Organisation, corporation, or product', value: 'O' },
{ type: 'option', label: 'Biographical', value: 'B' },
{ type: 'option', label: 'Society topics', value: 'S' },
{ type: 'option', label: 'Web or internet', value: 'W' },
{ type: 'option', label: 'Games or sports', value: 'G' },
{ type: 'option', label: 'Science and technology', value: 'T' },
{ type: 'option', label: 'Fiction and the arts', value: 'F' },
{ type: 'option', label: 'Places and transportation', value: 'P' },
{ type: 'option', label: 'Indiscernible or unclassifiable topic', value: 'I' },
{ type: 'option', label: 'Debate not yet sorted', value: 'U' }
]
});
work_area.append({
type: 'select',
multiple: true,
name: 'delsortCats',
label: 'Choose deletion sorting categories:',
tooltip: 'Select a few categories that are specifically relevant to the subject of the article. Be as precise as possible; categories like People and USA should only be used when no other categories apply.'
});
// grab deletion sort categories from en-wiki
Morebits.wiki.getCachedJson('Wikipedia:WikiProject_Deletion_sorting/Computer-readable.json').then((delsortCategories) => {
const $select = $('[name="delsortCats"]');
$.each(delsortCategories, (groupname, list) => {
const $optgroup = $('<optgroup>').attr('label', groupname);
const $delsortCat = $select.append($optgroup);
list.forEach((item) => {
const $option = $('<option>').val(item).text(item);
$delsortCat.append($option);
});
});
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
Twinkle.makeFindSourcesDiv('#twinkle-xfd-findsources');
$(work_area).find('[name=delsortCats]')
.attr('data-placeholder', 'Select delsort pages')
.select2({
theme: 'default select2-morebits',
width: '100%',
matcher: Morebits.select2.matcher,
templateResult: Morebits.select2.highlightSearchMatches,
language: {
searching: Morebits.select2.queryInterceptor
},
// Link text to the page itself
templateSelection: function(choice) {
return $('<a>').text(choice.text).attr({
href: mw.util.getUrl('Wikipedia:WikiProject_Deletion_sorting/' + choice.text),
target: '_blank'
});
}
});
mw.util.addCSS(
// Remove black border
'.select2-container--default.select2-container--focus .select2-selection--multiple { border: 1px solid #aaa; }' +
// Reduce padding
'.select2-results .select2-results__option { padding-top: 1px; padding-bottom: 1px; }' +
'.select2-results .select2-results__group { padding-top: 1px; padding-bottom: 1px; } ' +
// Adjust font size
'.select2-container .select2-dropdown .select2-results { font-size: 13px; }' +
'.select2-container .selection .select2-selection__rendered { font-size: 13px; }' +
// Make the tiny cross larger
'.select2-selection__choice__remove { font-size: 130%; }'
);
break;
case 'saş':
work_area = new Morebits.QuickForm.Element({
type: 'field',
label: 'Şablon tartışmaları',
name: 'work_area'
});
var templateOrModule = mw.config.get('wgPageContentModel') === 'Scribunto' ? 'modül' : 'şablon';
work_area.append({
type: 'select',
label: 'İstediğiniz işlem türünü seçin:',
name: 'xfdcat',
event: function(e) {
const target = e.target;
let tfdtarget = target.form.tfdtarget;
// add/remove extra input box
if (target.value === 'baş' && !tfdtarget) {
tfdtarget = new Morebits.QuickForm.Element({
name: 'tfdtarget',
type: 'input',
label: 'Birleştirilecek diğer ' + templateOrModule + ':',
tooltip: 'Zorunludur. ' + Morebits.string.toUpperCaseFirstChar(templateOrModule) + ': ad alanı önekini içermemelidir.',
required: true
});
target.parentNode.appendChild(tfdtarget.render());
} else {
$(Morebits.QuickForm.getElementContainer(tfdtarget)).remove();
tfdtarget = null;
}
},
list: [
{ type: 'option', label: 'Silme', value: 'saş', selected: true },
{ type: 'option', label: 'Birleştirme', value: 'baş' }
]
});
work_area.append({
type: 'select',
name: 'templatetype',
label: 'Silme etiketi görüntüleme biçemi:',
tooltip: 'ŞT etiket şablonuna eklenecek <code>tür=</code> parametresi.',
list: templateOrModule === 'modül' ? [
{ type: 'option', value: 'modül', label: 'Modül', selected: true }
] : [
{ type: 'option', value: 'standart', label: 'Standart', selected: true },
{ type: 'option', value: 'kutu', label: 'Kenar/bilgi kutusu', selected: $('.infobox').length },
{ type: 'option', value: 'satır', label: 'Satır şablonu', selected: $('.mw-parser-output > p .Inline-Template').length },
{ type: 'option', value: 'küçük', label: 'Küçük satır' }
/*,
{ type: 'option', value: 'disabled', label: 'Devre dışı' }*/
]
});
work_area.append({
type: 'checkbox',
list: [{
label: 'Silme etiketi <noinclude> içine alınsın (yalnızca yerine koyma ile eklenen şablonlar için)',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Silme etiketini <noinclude> etiketi içine alacaktır. Bu sayede etiket şablonla birlikte kopyalanmaz.',
disabled: templateOrModule === 'modül',
checked: !!$('.box-Subst_only').length // Default to checked if page carries {{subst only}}
}]
});
work_area.append({
type: 'checkbox',
list: [{
label: 'Etkilenen kullanıcıları bilgilendirin',
value: 'devpages',
name: 'devpages',
tooltip: 'Seçilirse ve eğer şablon Twinkle veya AWB tarafından kullanılıyorsa, araçların tartışma sayfasına bir bildirim şablonu gönderilecek.', //ve Ultraviolet
checked: true
}]
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'sas':
work_area = new Morebits.QuickForm.Element({
type: 'field',
label: 'Silinmeye aday sayfalar',
name: 'work_area'
});
work_area.append({
type: 'div',
label: '', // Added later by Twinkle.makeFindSourcesDiv()
id: 'twinkle-xfd-findsources',
style: 'margin-bottom: 5px; margin-top: -5px;'
});
work_area.append({
type: 'checkbox',
list: [{
label: 'SAS etiketini <noinclude> içine al',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Silme etiketini sayfanın şablon gibi görüntülenerek kullanıldığı durumlar için <noinclude> etiketi içine alır. Normalde gerekli olmayacaktır.'
}]
});
/*if ((mw.config.get('wgNamespaceNumber') === 2 || mw.config.get('wgNamespaceNumber') === 3) && mw.config.exists('wgRelevantUserName')) {
work_area.append({
type: 'checkbox',
list: [
{
label: 'Notify owner of userspace (if they are not the page creator)',
value: 'notifyuserspace',
name: 'notifyuserspace',
tooltip: 'If the user in whose userspace this page is located is not the page creator (for example, the page is a rescued article stored as a userspace draft), notify the userspace owner as well.',
checked: false
}
]
});
}*/
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
Twinkle.makeFindSourcesDiv('#twinkle-xfd-findsources');
break;
case 'ffd':
work_area = new Morebits.QuickForm.Element({
type: 'field',
label: 'Discussion venues for files',
name: 'work_area'
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'kt':
work_area = new Morebits.QuickForm.Element({
type: 'field',
label: 'Silinmeye aday sayfalar',
name: 'work_area'
});
var isCategory = mw.config.get('wgNamespaceNumber') === 14;
work_area.append({
type: 'select',
label: 'İstediğiniz işlem türünü seçin:',
name: 'xfdcat',
event: function(e) {
const value = e.target.value,
cfdtarget = e.target.form.cfdtarget;
let cfdtarget2 = e.target.form.cfdtarget2;
// update enabled status
cfdtarget.disabled = value === 'kt' || value === 'sfd-t';
if (isCategory) {
// update label
if (value === 'böak') {
Morebits.QuickForm.setElementLabel(cfdtarget, 'Hedef kategoriler: ');
} else if (value === 'maak') {
Morebits.QuickForm.setElementLabel(cfdtarget, 'Hedef madde: ');
} else {
Morebits.QuickForm.setElementLabel(cfdtarget, 'Hedef kategori: ');
}
// add/remove extra input box
if (value === 'böak') {
if (cfdtarget2) {
cfdtarget2.disabled = false;
$(cfdtarget2).show();
} else {
cfdtarget2 = document.createElement('input');
cfdtarget2.setAttribute('name', 'cfdtarget2');
cfdtarget2.setAttribute('type', 'text');
cfdtarget2.setAttribute('required', 'true');
cfdtarget.parentNode.appendChild(cfdtarget2);
}
} else {
$(cfdtarget2).prop('disabled', true);
$(cfdtarget2).hide();
}
} else { // Update stub template label
Morebits.QuickForm.setElementLabel(cfdtarget, 'Target stub template: ');
}
},
list: isCategory ? [
{ type: 'option', label: 'Silme', value: 'kt', selected: true },
{ type: 'option', label: 'Birleştirme', value: 'bak' },
{ type: 'option', label: 'Yeniden adlandırma', value: 'yaak' },
{ type: 'option', label: 'Bölme', value: 'böak' },
{ type: 'option', label: 'Maddeye dönüştürme', value: 'maak' }
] : [
//{ type: 'option', label: 'Stub Deletion', value: 'sfd-t', selected: true },
//{ type: 'option', label: 'Stub Renaming', value: 'sfr-t' }
]
});
work_area.append({
type: 'input',
name: 'cfdtarget',
label: 'Hedef kategori:', // default, changed above
disabled: true,
required: true, // only when enabled
value: ''
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'cfds':
work_area = new Morebits.QuickForm.Element({
type: 'field',
label: 'Categories for speedy renaming',
name: 'work_area'
});
work_area.append({
type: 'select',
label: 'C2 sub-criterion:',
name: 'xfdcat',
tooltip: 'See WP:CFDS for full explanations.',
list: [
{ type: 'option', label: 'C2A: Typographic and spelling fixes', value: 'C2A', selected: true },
{ type: 'option', label: 'C2B: Naming conventions and disambiguation', value: 'C2B' },
{ type: 'option', label: 'C2C: Consistency with names of similar categories', value: 'C2C' },
{ type: 'option', label: 'C2D: Rename to match article name', value: 'C2D' },
{ type: 'option', label: 'C2E: Author request', value: 'C2E' },
{ type: 'option', label: 'C2F: One eponymous article', value: 'C2F' }
]
});
work_area.append({
type: 'input',
name: 'cfdstarget',
label: 'New name:',
size: 70,
value: '',
required: true
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
/* Bize yaramaz
case 'rfd':
work_area = new Morebits.QuickForm.Element({
type: 'field',
label: 'Redirects for discussion',
name: 'work_area'
});
work_area.append({
type: 'checkbox',
list: [
{
label: 'Notify target page if possible',
value: 'relatedpage',
name: 'relatedpage',
tooltip: "A notification template will be placed on the talk page of this redirect's target if this is true.",
checked: true
}
]
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
case 'rm': {
work_area = new Morebits.QuickForm.Element({
type: 'field',
label: 'Requested moves',
name: 'work_area'
});
work_area.append({
type: 'checkbox',
list: [
{
label: 'Uncontroversial technical request',
value: 'rmtr',
name: 'rmtr',
tooltip: 'Use this option when you are unable to perform this uncontroversial move yourself because of a technical reason (e.g. a page already exists at the new title, or the page is protected)',
checked: false,
event: function() {
$('input[name="newname"]', form).prop('required', this.checked);
$('input[type="button"][value="more"]', form)[0].sublist.inputs[1].required = this.checked;
},
subgroup: {
type: 'checkbox',
list: [
{
label: 'Opt out of discussion if the request is contested',
value: 'rmtr-discuss',
name: 'rmtr-discuss',
tooltip: 'Use this option if you prefer to withdraw the request if contested, rather than discuss it. This suppresses the "discuss" link, which may be used to convert your request to a discussion on the talk page.',
checked: false
}
]
}
}
]
});
work_area.append({
type: 'dyninput',
inputs: [
{
label: 'From:',
name: 'currentname',
required: true
},
{
label: 'To:',
name: 'newname',
tooltip: 'Required for technical requests. Otherwise, if unsure of the appropriate title, you may leave it blank.'
}
],
min: 1
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
const currentNonTalkPage = mw.Title.newFromText(Morebits.pageNameNorm).getSubjectPage().toText();
form.currentname.value = currentNonTalkPage;
break;
}
*/
default:
work_area = new Morebits.QuickForm.Element({
type: 'field',
label: 'Nothing for anything',
name: 'work_area'
});
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
}
// Return to checked state when switching, but no creator notification for CFDS or RM
form.notifycreator.disabled = value === 'cfds' || value === 'rm';
form.notifycreator.checked = !form.notifycreator.disabled;
};
Twinkle.xfd.callbacks = {
// Requires having the tag text (params.tagText) set ahead of time
autoEditRequest: function(pageobj, params) {
const talkName = new mw.Title(pageobj.getPageName()).getTalkPage().toText();
if (talkName === pageobj.getPageName()) {
pageobj.getStatusElement().error('Sayfa koruma altında ve değişiklik isteği eklenecek bir yer yor, iptal ediliyor');
} else {
pageobj.getStatusElement().warn('Sayfa koruma altında, değişiklik talep ediliyor');
const editRequest = '{{Değişiklik isteği|' + pageobj.getPageName() +
'|cevaplandı=hayır}}' + '\n' + '\'\'\'' + pageobj.getPageName() + '\'\'\'' +
' silinmek üzere tartışmaya açıldı ancak koruma altında olduğu için etikelenemedi. Adaylığı tamamlamak için' +
' lütfen sayfanın üst kısmına şunu ekleyin:' + '\n\n' + '<code><nowiki>' + params.tagText + '\u003C/nowiki></code>' +
'\n\n' + 'Teşekkürler. ~~~~'; // U+003C: <
params.discussionpage
params.tagText
const talk_page = new Morebits.wiki.Page(talkName, 'Tartışma sayfasına olarak değişiklik isteği ekleniyor');
talk_page.setNewSectionTitle(utils.toTLACase(params.venue) + ' adaylığını tamamlamak için değişik isteği');
talk_page.setNewSectionText(editRequest);
talk_page.setCreateOption('recreate');
talk_page.setWatchlist(Twinkle.getPref('xfdWatchPage'));
talk_page.setFollowRedirect(true); // should never be needed, but if the article is moved, we would want to follow the redirect
talk_page.setChangeTags(Twinkle.changeTags);
talk_page.setCallbackParameters(params);
talk_page.newSection(null, () => {
talk_page.getStatusElement().warn('Değişiklik isteği eklenemiyor, tartışma sayfası da korumalı olabilir');
});
}
},
getDiscussionWikitext: function(venue, params) {
if (venue === 'cfds') { // CfD/S takes a completely different style
return '* [[:' + Morebits.pageNameNorm + ']] to [[:' + params.cfdstarget + ']]\u00A0\u2013 ' +
params.xfdcat + (params.reason ? ': ' + Morebits.string.formatReasonText(params.reason) : '.') + ' ~~~~';
// U+00A0 NO-BREAK SPACE; U+2013 EN RULE
}
if (venue === 'rm') {
if (params.rmtr) {
const rmtrDiscuss = params['rmtr-discuss'] ? '|discuss=no' : '';
return params.currentname
.map((currentname, i) => `{{subst:RMassist|1=${currentname}|2=${params.newname[i]}${rmtrDiscuss}|reason=${params.reason}}}`)
.join('\n');
}
return `{{subst:Requested move${
params.currentname
.map((currentname, i) => `|current${i + 1}=${currentname}|new${i + 1}=${params.newname[i]}`)
.join('')
}|reason=${params.reason}}}`;
}
let text;
//şt şablonları
if (params.xfdcat === 'baş') text = '{{yk:baş2';
else if (params.xfdcat === 'yaak') text = '{{yk:yaak2';
else if (params.xfdcat === 'böak') text = '{{yk:böak2';
else if (params.xfdcat === 'maak') text = '{{yk:maak2';
else if (venue === 'kt') {
text = '{{yk:sak2';
if (params.cfdtarget) text = '{{yk:bak2';
} else text = '{{yk:' + venue + '2';
const reasonKey = venue === 'ffd' ? 'Gerekçe' : 'metin';
// Add a reason unconditionally, so that at least a signature is added
text += '|' + reasonKey + '=' + Morebits.string.formatReasonText(params.reason, true);
if (venue === 'afd' || venue === 'sas') {
text += '|sa=' + Morebits.pageNameNorm;
if (venue === 'afd') {
text += '|cat=' + params.xfdcat;
}
} else if (venue === 'rfd') {
text += '|redirect=' + Morebits.pageNameNorm;
} else {
text += '|1=' + mw.config.get('wgTitle');
}
if (mw.config.get('wgPageContentModel') === 'Scribunto') {
text += '|modül=Modül:';
}
if (params.rfdtarget) {
text += '|target=' + params.rfdtarget + (params.section ? '#' + params.section : '');
} else if (params.tfdtarget) {
text += '|2=' + params.tfdtarget;
} else if (params.cfdtarget) {
text += '|2=' + params.cfdtarget;
if (params.cfdtarget2) {
text += '|3=' + params.cfdtarget2;
}
} else if (params.uploader) {
text += '|Uploader=' + params.uploader;
}
text += '}}';
// Don't delsort if delsortCats is undefined (TFD, FFD, etc.)
// Don't delsort if delsortCats is an empty array (AFD where user chose no categories)
if (Array.isArray(params.delsortCats) && params.delsortCats.length) {
text += '\n{{subst:Deletion sorting/multi|' + params.delsortCats.join('|') + '|sig=~~~~}}';
}
//baş2 şablonu, eğer parametrede şablon öneki varsa "Şablon:Şablon:Örnek" yapıyor. Düzeltelim
if (params.xfdcat === 'baş') {
text = text.replace('Şablon:', '');
text = text.replace('Modül:', '');
}
return text;
},
showPreview: function(form, venue, params) {
const templatetext = Twinkle.xfd.callbacks.getDiscussionWikitext(venue, params);
if (venue === 'rm') { // RM templates are sensitive to page title
form.previewer.beginRender(templatetext, params.rmtr ? 'Wikipedia:Requested moves/Technical requests' : new mw.Title(Morebits.pageNameNorm).getTalkPage().toText());
} else {
form.previewer.beginRender(templatetext, 'VP:TW'); // Force wikitext
}
},
preview: function(form) {
// venue, reason, xfdcat, tfdtarget, cfdtarget, cfdtarget2, cfdstarget, delsortCats, newname
const params = Morebits.QuickForm.getInputData(form);
const venue = params.venue;
// Remove CfD or TfD namespace prefixes if given
if (params.tfdtarget) {
params.tfdtarget = utils.stripNs(params.tfdtarget);
} else if (params.cfdtarget) {
params.cfdtarget = utils.stripNs(params.cfdtarget);
if (params.cfdtarget2) {
params.cfdtarget2 = utils.stripNs(params.cfdtarget2);
}
} else if (params.cfdstarget) { // Add namespace if not given (CFDS)
params.cfdstarget = utils.addNs(params.cfdstarget, 14);
}
if (venue === 'ffd') {
// Fetch the uploader
const page = new Morebits.wiki.Page(mw.config.get('wgPageName'));
page.lookupCreation(() => {
params.uploader = page.getCreator();
Twinkle.xfd.callbacks.showPreview(form, venue, params);
});
} else if (venue === 'rfd') { // Find the target
Twinkle.xfd.callbacks.rfd.findTarget(params, (params) => {
Twinkle.xfd.callbacks.showPreview(form, venue, params);
});
} else if (venue === 'kt') { // Swap in CfD subactions
Twinkle.xfd.callbacks.showPreview(form, params.xfdcat, params);
} else {
Twinkle.xfd.callbacks.showPreview(form, venue, params);
}
},
/**
* Unified handler for sending {{Xfd notice}} notifications
* Also handles userspace logging
*
* @param {Object} params
* @param {string} notifyTarget The user or page being notified
* @param {boolean} [noLog=false] Whether to skip logging to userspace
* XfD log, especially useful in cases in where multiple notifications
* may be sent out (MfD, TfM, RfD)
* @param {string} [actionName] Alternative description of the action
* being undertaken. Required if not notifying a user talk page.
*/
notifyUser: function(params, notifyTarget, noLog, actionName) {
// Ensure items with User talk or no namespace prefix both end
// up at user talkspace as expected, but retain the
// prefix-less username for addToLog
notifyTarget = mw.Title.newFromText(notifyTarget, 3);
const targetNS = notifyTarget.getNamespaceId();
const usernameOrTarget = notifyTarget.getRelativeText(3);
notifyTarget = notifyTarget.toText();
if (targetNS === 3) {
// Disallow warning yourself
if (usernameOrTarget === mw.config.get('wgUserName')) {
Morebits.Status.warn('Bu sayfayı siz (' + usernameOrTarget + ') oluşturdunuz, bilgilendirme atlanıyor');
// if we thought we would notify someone but didn't,
// then jump to logging.
Twinkle.xfd.callbacks.addToLog(params, null);
return;
}
// Default is notifying the initial contributor, but MfD also
// notifies userspace page owner
actionName = actionName || 'Sayfayı oluşturan kullanıcı (' + usernameOrTarget + ') bilgilendiriliyor.';
}
let notifytext = '\n{{subst:' + params.venue + ' bildirim';
if (params.venue === 'kt') notifytext = '\n{{subst:sak bildirim';
// Venue-specific parameters
switch (params.venue) {
case 'afd':
case 'mfd':
notifytext += params.numbering !== '' ? '|order= ' + params.numbering : '';
break;
case 'saş':
if (params.xfdcat === 'baş') {
notifytext = '\n{{subst:Baş bildirim|2=' + params.tfdtarget;
}
break;
case 'kt':
notifytext += '|eylem=' + params.action + (mw.config.get('wgNamespaceNumber') === 10 ? '|stub=yes' : '');
break;
default: // ffd, rfd
break;
}
notifytext += '|1=' + Morebits.pageNameNorm + '}}';
// Link to the venue; object used here rather than repetitive items in switch
const venueNames = {
afd: 'Silinmeye aday sayfalar',
saş: 'Silinmeye aday sayfalar|silinmeye aday gösterildi',
sas: 'Silinmeye aday sayfalar|silinmeye aday gösterildi',
kt: 'Silinmeye aday sayfalar|tartışmaya açıldı'
//ffd: 'Files for discussion',
//rfd: 'Redirects for discussion'
};
let sayfaadı = params.discussionpage;
sayfaadı.replace(":Şablon:", "Şablon:");
sayfaadı.replace(":Kategori:", "Kategori:");
const editSummary = 'Bildirim: [[' + Morebits.pageNameNorm + ']] adlı sayfa, [[' + sayfaadı + ']] sayfasında ' +
'[[VP:' + venueNames[params.venue] + ']].';
const usertalkpage = new Morebits.wiki.Page(notifyTarget, actionName);
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary(editSummary);
usertalkpage.setChangeTags(Twinkle.changeTags);
usertalkpage.setCreateOption('recreate');
// Different pref for RfD target notifications
if (params.venue === 'rfd' && targetNS !== 3) {
usertalkpage.setWatchlist(Twinkle.getPref('xfdWatchRelated'));
} else {
usertalkpage.setWatchlist(Twinkle.getPref('xfdWatchUser'));
}
usertalkpage.setFollowRedirect(true, false);
if (noLog) {
usertalkpage.append();
} else {
usertalkpage.append(() => {
// Don't treat RfD target or MfD userspace owner as initialContrib in log
if (!params.notifycreator) {
notifyTarget = null;
}
// add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, usernameOrTarget);
}, () => {
// if user could not be notified, log nomination without mentioning that notification was sent
Twinkle.xfd.callbacks.addToLog(params, null);
});
}
},
addToLog: function(params, initialContrib) {
if (!Twinkle.getPref('logXfdNominations') || Twinkle.getPref('noLogOnXfdNomination').indexOf(params.venue) !== -1) {
return;
}
const usl = new Morebits.UserspaceLogger(Twinkle.getPref('xfdLogPageName')); // , 'Adding entry to userspace log');
usl.initialText =
"Bu, [[VP:TW|Twinkle]]\'ın SAS modülünü kullanarak bu kullanıcı tarafından başlatılan tüm sayfa tartışmalarının bir günlüğüdür.\n\n" +
'Bu günlüğü artık saklamak istemiyorsanız, [[Vikipedi:Twinkle/Tercihler|tercihler panelini]] kullanarak kapatabilir ve ' +
'bu sayfayı [[Vikipedi:Hızlı_silme#G6|G6]] kapsamında hızlı silinmesi için işaretleyebilirsiniz. ' +
(Morebits.userIsSysop ? '\n\nBu günlük, Twinkle kullanılarak yapılan SAS ile ilgili silme işlemlerini izlemez.' : '');
let editsummary;
if (params.discussionpage) {
editsummary = '[[:' + Morebits.pageNameNorm + ']] için [[' + params.discussionpage + '|' + utils.toTLACase(params.venue) + ' adaylığı]] ekleniyor.';
} else {
editsummary = '[[:' + Morebits.pageNameNorm + ']] için ' + utils.toTLACase(params.venue) + ' adaylığı ekleniyor.';
}
// If a logged file is deleted but exists on commons, the wikilink will be blue, so provide a link to the log
const fileLogLink = mw.config.get('wgNamespaceNumber') === 6 ? ' ([{{fullurl:Special:Log|page=' + mw.util.wikiUrlencode(mw.config.get('wgPageName')) + '}} log])' : '';
// CFD/S and RM don't have canonical links
const nominatedLink = params.discussionpage ? '[[' + params.discussionpage + '|aday gösterildi]]' : 'aday gösterildi';
let appendText = '# [[:' + Morebits.pageNameNorm + ']]:' + fileLogLink + ' [[VP:' + params.venue.toUpperCase() + '|' + utils.toTLACase(params.venue) + ']] sayfasında ' + nominatedLink;
switch (params.venue) {
case 'saş':
if (params.xfdcat === 'baş') {
appendText += ' (birleştirmeye)';
if (params.tfdtarget) {
const contentModel = mw.config.get('wgPageContentModel') === 'Scribunto' ? 'Modül:' : 'Şablon:';
appendText += '; Diğer ' + contentModel.toLowerCase() + ' [[';
if (!new RegExp('^:?' + Morebits.namespaceRegex([10, 828]) + ':', 'i').test(params.tfdtarget)) {
appendText += contentModel;
}
appendText += params.tfdtarget + ']]';
}
}
break;
case 'sas':
if (params.notifyuserspace && params.userspaceOwner && params.userspaceOwner !== initialContrib) {
appendText += '; {{kullanıcı|1=' + params.userspaceOwner + '}} bilgilendirildi';
}
break;
case 'kt':
let parantez = utils.toTLACase(params.xfdcat);
if (utils.toTLACase(params.xfdcat) === 'KT') parantez = 'silinmeye';
else if (utils.toTLACase(params.xfdcat) === 'BAK') parantez = 'birleştirmeye';
else if (utils.toTLACase(params.xfdcat) === 'YAAK') parantez = 'yeniden adlandırmaya';
else if (utils.toTLACase(params.xfdcat) === 'MAAK') parantez = 'maddeye aktarılmaya';
else if (utils.toTLACase(params.xfdcat) === 'BÖAK') parantez = 'bölünmeye';
appendText += ' (' + parantez + ')';
if (params.cfdtarget) {
const categoryOrTemplate = params.xfdcat.charAt(0) === 's' ? 'Şablon:' : ':Kategori:';
if (utils.toTLACase(params.xfdcat) === 'MAAK') {
let madde = params.cfdtarget;
//madde = madde.replace('Kategori:', '');
appendText += '; [[' + madde + ']]';
} else {
appendText += '; [[' + categoryOrTemplate + params.cfdtarget + ']]';
}
if (params.xfdcat === 'böak' && params.cfdtarget2) {
appendText += ', [[' + categoryOrTemplate + params.cfdtarget2 + ']]';
}
}
break;
case 'cfds':
appendText += ' (' + utils.toTLACase(params.xfdcat) + ')';
// Ensure there's more than just 'Category:'
if (params.cfdstarget && params.cfdstarget.length > 9) {
appendText += '; New name: [[:' + params.cfdstarget + ']]';
}
break;
case 'rfd':
if (params.rfdtarget) {
appendText += '; Target: [[:' + params.rfdtarget + ']]';
if (params.relatedpage) {
appendText += ' (notified)';
}
}
break;
case 'rm':
appendText = params.currentname
.map((currentname, i) => `# [[:${currentname}]]: ${nominatedLink} at [[WP:RM${params.rmtr ? '/TR' : ''}|]]${params.newname[i] ? `; New name: [[:${params.newname[i]}]]` : ''}`)
.join('\n');
break;
default: // afd or ffd
break;
}
if (initialContrib && params.notifycreator) {
appendText += '; {{kullanıcı|1=' + initialContrib + '}} bilgilendirildi';
}
appendText += ' -- ~~~~~';
if (params.reason) {
appendText += "\n#* '''Gerekçe''': " + Morebits.string.formatReasonForLog(params.reason);
}
usl.changeTags = Twinkle.changeTags;
usl.log(appendText, editsummary);
},
afd: {
main: function(apiobj) {
const response = apiobj.getResponse();
const titles = response.query.allpages;
// There has been no earlier entries with this prefix, just go on.
if (titles.length <= 0) {
apiobj.params.numbering = apiobj.params.number = '';
} else {
let number = 0;
for (let i = 0; i < titles.length; ++i) {
const title = titles[i].title;
// First, simple test, is there an instance with this exact name?
if (title === 'Vikipedi:Silinmeye aday sayfalar/' + Morebits.pageNameNorm) {
number = Math.max(number, 1);
continue;
}
const order_re = new RegExp('^' +
Morebits.string.escapeRegExp('Vikipedi:Silinmeye aday sayfalar/' + Morebits.pageNameNorm) +
'\\s*\\(\\s*(\\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\\s*\\)\\s*$');
const match = order_re.exec(title);
// No match; A non-good value
// Or the match is an unrealistically high number. Avoid false positives such as Wikipedia:Articles for deletion/The Basement (2014), by ignoring matches greater than 100
if (!match || match[1] > 100) {
continue;
}
// A match, set number to the max of current
number = Math.max(number, Number(match[1]));
}
apiobj.params.number = utils.num2order(parseInt(number, 10) + 1);
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' adaylık)' : '';
}
apiobj.params.discussionpage = 'Vikipedi:Silinmeye aday sayfalar/' + Morebits.pageNameNorm + apiobj.params.numbering;
Morebits.Status.info('Next discussion page', '[[' + apiobj.params.discussionpage + ']]');
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = apiobj.params.discussionpage;
Morebits.wiki.actionCompleted.notice = 'Nomination completed, now redirecting to the discussion page';
// Tagging article
var wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName'), 'Adding deletion tag to article');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the article is moved, we would want to follow the redirect
wikipedia_page.setChangeTags(Twinkle.changeTags); // Here to apply to triage
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.afd.taggingArticle);
},
// Tagging needs to happen before everything else: this means we can check if there is an AfD tag already on the page
taggingArticle: function(pageobj) {
let text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
if (!pageobj.exists()) {
statelem.error("It seems that the page doesn't exist; perhaps it has already been deleted");
return;
}
// Check for existing AfD tag, for the benefit of new page patrollers
const textNoAfd = text.replace(/<!--.*AfD.*\n\{\{(?:Article for deletion\/dated|AfDM).*\}\}\n<!--.*(?:\n<!--.*)?AfD.*(?:\s*\n)?/g, '');
if (text !== textNoAfd) {
if (confirm('An AfD tag was found on this article. Maybe someone beat you to it. \nClick OK to replace the current AfD tag (not recommended), or Cancel to abandon your nomination.')) {
text = textNoAfd;
} else {
statelem.error('Article already tagged with AfD tag, and you chose to abort');
window.location.reload();
return;
}
}
// Now we know we want to go ahead with it, trigger the other AJAX requests
// Mark the page as curated/patrolled, if wanted
if (Twinkle.getPref('markXfdPagesAsPatrolled')) {
new Morebits.wiki.Page(Morebits.pageNameNorm).triage();
}
// Start discussion page, will also handle pagetriage and delsort listings
let wikipedia_page = new Morebits.wiki.Page(params.discussionpage, 'Creating article deletion discussion page');
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.afd.discussionPage);
// Today's list
const date = new Morebits.Date(pageobj.getLoadTime());
wikipedia_page = new Morebits.wiki.Page('Vikipedi:Silinmeye aday sayfalar/Kayıt/' +
date.format('YYYY MMMM D', 'utc'), "Adding discussion to today's list");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.afd.todaysList);
// Notification to first contributor
if (params.notifycreator) {
const thispage = new Morebits.wiki.Page(mw.config.get('wgPageName'));
thispage.setCallbackParameters(params);
thispage.setLookupNonRedirectCreator(true); // Look for author of first non-redirect revision
thispage.lookupCreation((pageobj) => {
Twinkle.xfd.callbacks.notifyUser(pageobj.getCallbackParameters(), pageobj.getCreator());
});
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
params.tagText = (params.noinclude ? '<noinclude>{{' : '{{') + (params.number === '' ? 'subst:afd|help=off' : 'subst:afdx|' +
params.number + '|help=off') + (params.noinclude ? '}}</noinclude>\n' : '}}\n');
if (pageobj.canEdit()) {
// Remove some tags that should always be removed on AfD.
text = text.replace(/\{\{\s*(dated prod|dated prod blp|Prod blp\/dated|Proposed deletion\/dated|prod2|Proposed deletion endorsed|Userspace draft)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/ig, '');
// Then, test if there are speedy deletion-related templates on the article.
const textNoSd = text.replace(/\{\{\s*(db(-\w*)?|delete|(?:hang|hold)[- ]?on)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/ig, '');
if (text !== textNoSd && confirm('A speedy deletion tag was found on this page. Should it be removed?')) {
text = textNoSd;
}
// Insert tag after short description or any hatnotes
const wikipage = new Morebits.wikitext.Page(text);
text = wikipage.insertAfterTemplates(params.tagText, Twinkle.hatnoteRegex).getText();
pageobj.setPageText(text);
pageobj.setEditSummary('Silinmeye aday gösterildi. Bkz: [[:' + params.discussionpage + ']].');
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('nocreate');
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
discussionPage: function(pageobj) {
const params = pageobj.getCallbackParameters();
pageobj.setPageText(Twinkle.xfd.callbacks.getDiscussionWikitext('afd', params));
pageobj.setEditSummary('Creating deletion discussion page for [[:' + Morebits.pageNameNorm + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('createonly');
pageobj.save(() => {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
// Actions that should wait on the discussion page actually being created
// and whose errors shouldn't output the user rationale
// List at deletion sorting pages
if (params.delsortCats) {
params.delsortCats.forEach((cat) => {
var delsortPage = new Morebits.wiki.Page('Wikipedia:WikiProject Deletion sorting/' + cat, 'Adding to list of ' + cat + '-related deletion discussions');
delsortPage.setFollowRedirect(true); // In case a category gets renamed
delsortPage.setCallbackParameters({ discussionPage: params.discussionpage });
delsortPage.load(Twinkle.xfd.callbacks.afd.delsortListing);
});
}
});
},
todaysList: function(pageobj) {
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
const added_data = '{{subst:afd3|pg=' + Morebits.pageNameNorm + params.numbering + '}}\n';
let text;
// add date header if the log is found to be empty (a bot should do this automatically)
if (!pageobj.exists()) {
text = '{{subst:AfD log}}\n' + added_data;
} else {
const old_text = pageobj.getPageText() + '\n'; // MW strips trailing blanks, but we like them, so we add a fake one
text = old_text.replace(/(<!-- Add new entries to the TOP of the following list -->\n+)/, '$1' + added_data);
if (text === old_text) {
const linknode = document.createElement('a');
linknode.setAttribute('href', mw.util.getUrl('Wikipedia:Twinkle/Fixing AFD') + '?action=purge');
linknode.appendChild(document.createTextNode('How to fix AFD'));
statelem.error(['Could not find the target spot for the discussion. To fix this problem, please see ', linknode, '.']);
return;
}
}
pageobj.setPageText(text);
pageobj.setEditSummary('Adding [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchList'));
pageobj.setCreateOption('recreate');
pageobj.save();
},
delsortListing: function(pageobj) {
const discussionPage = pageobj.getCallbackParameters().discussionPage;
const text = pageobj.getPageText().replace('directly below this line -->', 'directly below this line -->\n{{' + discussionPage + '}}');
pageobj.setPageText(text);
pageobj.setEditSummary('Listing [[:' + discussionPage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setCreateOption('nocreate');
pageobj.save();
}
},
tfd: { //Vikipedi:Şablon tartışmaları artık tarihsel, burası iptal
main: function(pageobj) {
const params = pageobj.getCallbackParameters();
//const date = new Morebits.Date(pageobj.getLoadTime());
params.logpage = 'Vikipedi:Şablon tartışmaları',
params.discussionpage = params.logpage + '/' + Morebits.pageNameNorm;
// Add log/discussion page params to the already-loaded page object
pageobj.setCallbackParameters(params);
// Defined here rather than below to reduce duplication
let watchModule, watch_query;
if (params.scribunto) {
const watchPref = Twinkle.getPref('xfdWatchPage');
// action=watch has no way to rely on user
// preferences (T262912), so we do it manually.
// The watchdefault pref appears to reliably return '1' (string),
// but that's not consistent among prefs so might as well be "correct"
watchModule = watchPref !== 'no' && (watchPref !== 'default' || !!parseInt(mw.user.options.get('watchdefault'), 10));
if (watchModule) {
watch_query = {
action: 'watch',
titles: [mw.config.get('wgPageName')],
token: mw.user.tokens.get('watchToken')
};
// Only add the expiry if page is unwatched or already temporarily watched
if (pageobj.getWatched() !== true && watchPref !== 'default' && watchPref !== 'yes') {
watch_query.expiry = watchPref;
}
}
}
// Tagging template(s)/module(s)
if (params.xfdcat === 'baş') { // Merge
let wikipedia_otherpage;
if (params.scribunto) {
wikipedia_otherpage = new Morebits.wiki.Page(params.otherTemplateName + '/belge', 'Diğer modül belgeleme sayfası birleştirme etiketiyle etiketleniyor');
// Watch tagged module pages as well
if (watchModule) {
watch_query.titles.push(params.otherTemplateName);
new Morebits.wiki.Api('Modüller izleme listesine ekleniyor', watch_query).post();
}
} else {
wikipedia_otherpage = new Morebits.wiki.Page(params.otherTemplateName, 'Diğer şablon birleştirme etiketiyle etiketleniyor');
}
// Tag this template/module
Twinkle.xfd.callbacks.tfd.taggingTemplateForMerge(pageobj);
// Tag other template/module
wikipedia_otherpage.setFollowRedirect(true);
const otherParams = $.extend({}, params);
otherParams.otherTemplateName = Morebits.pageNameNorm;
wikipedia_otherpage.setCallbackParameters(otherParams);
wikipedia_otherpage.load(Twinkle.xfd.callbacks.tfd.taggingTemplateForMerge);
} else { // delete
if (params.scribunto && Twinkle.getPref('xfdWatchPage') !== 'no') {
// Watch tagged module page as well
if (watchModule) {
new Morebits.wiki.Api('Modül izleme listesine ekleniyor', watch_query).post();
}
}
Twinkle.xfd.callbacks.tfd.taggingTemplate(pageobj);
}
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = "Adaylık tamamlandı. Tartışma sayfası açılıyor";
// Adding discussion
let wikipedia_page = new Morebits.wiki.Page(params.logpage, "Adaylık sayfası ekleniyor");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.todaysList);
// Discussion page
wikipedia_page = new Morebits.wiki.Page(params.discussionpage, 'Silinme tartışması sayfası oluşturuluyor');
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.discussionPage);
// Notification to first contributors
if (params.notifycreator) {
const involvedpages = [];
const seenusers = [];
involvedpages.push(new Morebits.wiki.Page(mw.config.get('wgPageName')));
if (params.xfdcat === 'baş') {
if (params.scribunto) {
involvedpages.push(new Morebits.wiki.Page('Modül:' + params.tfdtarget));
} else {
involvedpages.push(new Morebits.wiki.Page('Şablon:' + params.tfdtarget));
}
}
involvedpages.forEach(function(page) {
page.setCallbackParameters(params);
page.lookupCreation(function(innerpage) {
var username = innerpage.getCreator();
if (seenusers.indexOf(username) === -1) {
seenusers.push(username);
// Only log once on merge nominations, for the initial template
Twinkle.xfd.callbacks.notifyUser(innerpage.getCallbackParameters(), username,
params.xfdcat === 'baş' && innerpage.getPageName() !== Morebits.pageNameNorm);
}
});
});
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
// Notify developer(s) of script(s) that use(s) the nominated template
if (params.devpages) {
const inCategories = mw.config.get('wgCategories');
const categoryNotificationPageMap = {
'Twinkle ile kullanılan şablonlar': 'Vikipedi tartışma:Twinkle',
'AWB ile kullanılan şablonlar': 'Vikipedi tartışma:AutoWikiBrowser' //,
//'Ultraviolet ile kullanılan şablonlar': 'Wikipedia talk:Ultraviolet'
};
$.each(categoryNotificationPageMap, (category, page) => {
if (inCategories.indexOf(category) !== -1) {
Twinkle.xfd.callbacks.notifyUser(params, page, true, page + ' için şablon adaylığı bildirimi');
}
});
}
},
taggingTemplate: function(pageobj) {
const text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
params.tagText = '{{yk:saş|yardım=kapalı' + (params.templatetype !== 'standart' ? '|tür=' + params.templatetype : '') + '}}';
if (pageobj.getContentModel() === 'sanitized-css') {
params.tagText = '/* ' + params.tagText + ' */';
} else {
if (params.noinclude) {
params.tagText = '<noinclude>' + params.tagText + '</noinclude>';
}
params.tagText += params.templatetype === 'standart' || params.templatetype === 'kutu' || params.templatetype === 'disabled' ? '\n' : ''; // No newline for inline
}
if (pageobj.canEdit() && ['wikitext', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Silinmeye aday gösterildi. Bkz: [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
if (params.scribunto) {
pageobj.setCreateOption('recreate'); // Module /doc might not exist
}
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
taggingTemplateForMerge: function(pageobj) {
const text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
params.tagText = '{{subst:baş|yardım=kapalı|' + (params.templatetype !== 'standart' ? 'tür=' + params.templatetype + '|' : '') +
'1=' + params.otherTemplateName.replace(new RegExp('^' + Morebits.namespaceRegex([10, 828]) + ':'), '') + '}}';
if (pageobj.getContentModel() === 'sanitized-css') {
params.tagText = '/* ' + params.tagText + ' */';
} else {
if (params.noinclude) {
params.tagText = '<noinclude>' + params.tagText + '</noinclude>';
}
params.tagText += params.templatetype === 'standart' || params.templatetype === 'kenar' || params.templatetype === 'disabled' ? '\n' : ''; // No newline for inline
}
if (pageobj.canEdit() && ['wikitext', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('[[:' + params.otherTemplateName + ']] ile birleştirilmesi için aday gösterildi. Bkz: [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
if (params.scribunto) {
pageobj.setCreateOption('recreate'); // Module /doc might not exist
}
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
discussionPage: function(pageobj) {
const params = pageobj.getCallbackParameters();
pageobj.setPageText(Twinkle.xfd.callbacks.getDiscussionWikitext('saş', params));
pageobj.setEditSummary('[[:' + Morebits.pageNameNorm + ']] için adaylık sayfası oluşturuluyor.');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('createonly');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
todaysList: function(pageobj) {
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
let added_data = Twinkle.xfd.callbacks.getDiscussionWikitext(params.xfdcat, params);
let text;
const old_text = pageobj.getPageText() + '\n';
added_data = "{{kopyala:saş3|sa=" + Morebits.pageNameNorm + "}}"
text = old_text;
text += added_data;
pageobj.setPageText(text);
pageobj.setEditSummary('/* ' + Morebits.pageNameNorm + ' */ [[:' + Morebits.pageNameNorm + ']] için ' + (params.xfdcat === 'saş' ? 'silme adaylığı' : 'birleştirme adaylığı') + ' ekleniyor.');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(() => {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
}
},
mfd: { // Silinemeye aday sayfalar: maddeler
main: function(apiobj) {
const response = apiobj.getResponse();
const titles = response.query.allpages;
// Sayfa daha önce aday gösterilmiş mi? Kontrol edelim
if (titles.length <= 0) {
apiobj.params.numbering = apiobj.params.number = '';
} else {
let number = 0;
for (let i = 0; i < titles.length; ++i) {
const title = titles[i].title;
// First, simple test, is there an instance with this exact name?
if (title === 'Vikipedi:Silinmeye aday sayfalar/' + Morebits.pageNameNorm) {
number = Math.max(number, 1);
continue;
}
const order_re = new RegExp('^' +
Morebits.string.escapeRegExp('Vikipedi:Silinmeye aday sayfalar/' + Morebits.pageNameNorm) +
'\\s*\\(\\s*(\\d*)\\. adaylık\\s*\\)\\s*$');
const match = order_re.exec(title);
// No match; A non-good value
if (!match) {
continue;
}
// A match, set number to the max of current
number = Math.max(number, Number(match[1]));
}
apiobj.params.number = utils.num2order(parseInt(number, 10) + 1);
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' adaylık)' : '';
}
apiobj.params.discussionpage = 'Vikipedi:Silinmeye aday sayfalar/' + Morebits.pageNameNorm + apiobj.params.numbering;
apiobj.statelem.info('Sıradaki uygun sayfa "' + apiobj.params.discussionpage + '"');
let wikipedia_page;
// Tagging page
if (mw.config.get('wgNamespaceNumber') !== 710) { // cannot tag TimedText pages
wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName'), 'Sayfaya silme etiketi ekleniyor');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.taggingPage);
}
Morebits.wiki.actionCompleted.redirect = apiobj.params.discussionpage;
Morebits.wiki.actionCompleted.notice = 'Adaylık tamamlandı, tartışma sayfası açılıyor';
// Tartışma sayfası
wikipedia_page = new Morebits.wiki.Page(apiobj.params.discussionpage, 'Silinme tartışması sayfası oluşturuluyor');
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.discussionPage);
// Ana listeye ekleyelim
wikipedia_page = new Morebits.wiki.Page('Vikipedi:Silinmeye aday sayfalar', "Adaylık, listeye ekleniyor");
wikipedia_page.setPageSection(1);
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.todaysList);
// Alakalı ayın sayfasına ekleyelim
const tarih = new Date();
const tarihAy = ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"];
const tarihSene = tarih.getUTCFullYear();
const tarihAyAd = tarihAy[tarih.getUTCMonth()];
let kayitSayfasi = new Morebits.wiki.Page('Vikipedi:Silinmeye aday sayfalar/Kayıt/' + tarihSene + " " + tarihAyAd, "Adaylık, mevcut ayın kayıtlarına ekleniyor");
kayitSayfasi.setFollowRedirect(true);
kayitSayfasi.setCallbackParameters(apiobj.params);
kayitSayfasi.load(Twinkle.xfd.callbacks.mfd.todaysList2);
// Sayfayı oluşturan kullanıcıyı bilgilendirme
if (apiobj.params.notifycreator || apiobj.params.notifyuserspace) {
const thispage = new Morebits.wiki.Page(mw.config.get('wgPageName'));
thispage.setCallbackParameters(apiobj.params);
thispage.lookupCreation(Twinkle.xfd.callbacks.mfd.sendNotifications);
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(apiobj.params, null);
}
},
taggingPage: function(pageobj) {
let text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
const textNoSd = text.replace(/\{\{\s*(sil|delete)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}/ig, '');
if (text !== textNoSd && confirm('Sayfada bir silme etiketi bulundu. Kaldırılsın mı?')) {
text = textNoSd;
}
let sablonNo = params.number;
sablonNo = sablonnumara.replace('.', '');
params.tagText = '{{' + (params.number === '' ? 'sas|yardım=hayır' : 'sas|' + sablonNo + '|{{yk:FULLPAGENAME}}|yardım=hayır') + '}}';
if (['javascript', 'css', 'sanitized-css'].indexOf(mw.config.get('wgPageContentModel')) !== -1) {
params.tagText = '/* ' + params.tagText + ' */\n';
} else {
params.tagText += '\n';
if (params.noinclude) {
params.tagText = '<noinclude>' + params.tagText + '</noinclude>';
}
}
if (pageobj.canEdit() && ['wikitext', 'javascript', 'css', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Silinmeye aday gösterildi. Bkz: [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('nocreate');
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
discussionPage: function(pageobj) {
const params = pageobj.getCallbackParameters();
pageobj.setPageText(Twinkle.xfd.callbacks.getDiscussionWikitext('sas', params));
pageobj.setEditSummary('[[:' + Morebits.pageNameNorm + ']] için adaylık sayfası oluşturuluyor.');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('createonly');
pageobj.save(() => {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
//Ana liste VP:SAS
todaysList: function(pageobj) {
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
const old_text = pageobj.getPageText() + '\n';
const added_data = "{{kopyala:sas3|" + Morebits.pageNameNorm + params.numbering + "}}"
let text = old_text;
text += added_data;
pageobj.setPageText(text);
pageobj.setEditSummary('[[:' + params.discussionpage + ']] ekleniyor.');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchList'));
pageobj.setCreateOption('recreate');
pageobj.save();
},
//Mevcut ayın kayıt sayfası
todaysList2: function(pageobj) {
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
const old_text = pageobj.getPageText() + '\n';
const added_data = "{{kopyala:sas3|" + Morebits.pageNameNorm + params.numbering + "}}"
let text = old_text;
text += added_data;
pageobj.setPageText(text);
pageobj.setEditSummary('[[:' + params.discussionpage + ']] ekleniyor.');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchList'));
pageobj.setCreateOption('recreate');
pageobj.save();
},
sendNotifications: function(pageobj) {
const initialContrib = pageobj.getCreator();
const params = pageobj.getCallbackParameters();
// Notify the creator
if (params.notifycreator) {
Twinkle.xfd.callbacks.notifyUser(params, initialContrib);
}
// Notify the user who owns the subpage if they are not the creator
params.userspaceOwner = mw.config.get('wgRelevantUserName');
if (params.notifyuserspace) {
if (params.userspaceOwner !== initialContrib) {
// Don't log if notifying creator above, will log then
Twinkle.xfd.callbacks.notifyUser(params, params.userspaceOwner, params.notifycreator, 'Kullanıcı sayfasının sahibi (' + params.userspaceOwner + ') bilgilendiriliyor');
} else if (!params.notifycreator) {
// If we thought we would notify the owner but didn't,
// then we need to log if we didn't notify the creator
// Twinkle.xfd.callbacks.addToLog(params, null);
Twinkle.xfd.callbacks.addToLog(params, initialContrib);
}
}
}
},
ffd: {
taggingImage: function(pageobj) {
let text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
const date = new Morebits.Date(pageobj.getLoadTime()).format('YYYY MMMM D', 'utc');
params.logpage = 'Wikipedia:Files for discussion/' + date;
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
params.tagText = '{{ffd|log=' + date + '|help=off}}\n';
if (pageobj.canEdit()) {
text = text.replace(/\{\{(mtc|(copy |move )?to ?commons|move to wikimedia commons|copy to wikimedia commons)[^}]*\}\}/gi, '');
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Listed for discussion at [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('recreate'); // it might be possible for a file to exist without a description page
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = 'Nomination completed, now redirecting to the discussion page';
// Contributor specific edits
const wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.lookupCreation(Twinkle.xfd.callbacks.ffd.main);
},
main: function(pageobj) {
// this is coming in from lookupCreation...!
const params = pageobj.getCallbackParameters();
const initialContrib = pageobj.getCreator();
params.uploader = initialContrib;
// Adding discussion
const wikipedia_page = new Morebits.wiki.Page(params.logpage, "Adding discussion to today's list");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.ffd.todaysList);
// Notification to first contributor
if (params.notifycreator) {
Twinkle.xfd.callbacks.notifyUser(params, initialContrib);
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
},
todaysList: function(pageobj) {
let text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
// add date header if the log is found to be empty (a bot should do this automatically)
if (!pageobj.exists()) {
text = '{{subst:FfD log}}';
}
pageobj.setPageText(text + '\n\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('ffd', params));
pageobj.setEditSummary('Adding [[:' + Morebits.pageNameNorm + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(() => {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
}
},
cfd: { //kategoriler için SAS
main: function(pageobj) {
const params = pageobj.getCallbackParameters();
const date = new Morebits.Date(pageobj.getLoadTime());
params.logpage = 'Vikipedi:Silinmeye aday sayfalar',
params.discussionpage = params.logpage + '/' + Morebits.pageNameNorm;
// Add log/discussion page params to the already-loaded page object
pageobj.setCallbackParameters(params);
// Tagging category
Twinkle.xfd.callbacks.cfd.taggingCategory(pageobj);
// Tartışma sayfası
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = "Adaylık tamamlandı. Tartışma sayfası açılıyor";
// Ana listeye ekleyelim
let wikipedia_page = new Morebits.wiki.Page(params.logpage, "Adaylık, listeye ekleniyor");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfd.todaysList);
// Discussion page
wikipedia_page = new Morebits.wiki.Page(params.discussionpage, 'Kategori tartışması sayfası oluşturuluyor');
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfd.discussionPage);
// Notification to first contributor
if (params.notifycreator) {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.lookupCreation(function(pageobj) {
Twinkle.xfd.callbacks.notifyUser(pageobj.getCallbackParameters(), pageobj.getCreator());
});
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
// Alakalı ayın sayfasına ekleyelim
const tarih = new Date();
const tarihAy = ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"];
const tarihSene = tarih.getUTCFullYear();
const tarihAyAd = tarihAy[tarih.getUTCMonth()];
let kayitSayfasi = new Morebits.wiki.Page('Vikipedi:Silinmeye aday sayfalar/Kayıt/' + tarihSene + " " + tarihAyAd, "Adaylık, mevcut ayın kayıtlarına ekleniyor");
kayitSayfasi.setFollowRedirect(true);
kayitSayfasi.setCallbackParameters(params);
kayitSayfasi.load(Twinkle.xfd.callbacks.mfd.todaysList2);
},
taggingCategory: function(pageobj) {
let text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
let sablon;
if (params.xfdcat === "kt") sablon = "Silinmeye aday kategori|yardım=kapalı";
else sablon = params.xfdcat + "|yardım=kapalı";
params.tagText = '{{yk:' + sablon;
const summaryActions = {
'kt': 'silinmek',
'sfd-t': 'deletion',
'bak': 'birleştirilmek',
'yaak': 'yeniden adlandırılmak',
'sfr-t': 'renaming',
'böak': 'bölünmek',
'maak': 'maddeye dönüştürülmek'
};
params.action = summaryActions[params.xfdcat];
let editsummary = (mw.config.get('wgNamespaceNumber') === 14 ? 'Kategori' : 'Stub template') + ' ' + params.action +
' üzere aday gösteriliyor';
switch (params.xfdcat) {
case 'kt':
case 'sfd-t':
break;
case 'maak':
//editsummary += ' to an article';
// falls through
case 'bak':
case 'yaak':
case 'sfr-t':
params.tagText += '|hedef=' + params.cfdtarget;
break;
case 'böak':
params.tagText += '|hedef1=' + params.cfdtarget + '|hedef2=' + params.cfdtarget2;
break;
default:
alert('twinklexfd in taggingCategory(): unknown CFD action');
break;
}
params.tagText += '}}\n';
editsummary += '; bkz [[:' + params.discussionpage + ']].';
if (pageobj.canEdit()) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary(editsummary);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
discussionPage: function(pageobj) {
const params = pageobj.getCallbackParameters();
pageobj.setPageText(Twinkle.xfd.callbacks.getDiscussionWikitext('kt', params));
pageobj.setEditSummary('[[:' + Morebits.pageNameNorm + ']] için adaylık sayfası oluşturuluyor.');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('createonly');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
//Ana liste VP:SAS
todaysList: function(pageobj) {
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
let added_data = Twinkle.xfd.callbacks.getDiscussionWikitext(params.xfdcat, params);
let text;
const old_text = pageobj.getPageText() + '\n';
let parametre = Morebits.pageNameNorm;
parametre = parametre.replace('Kategori:', '');
added_data = "{{kopyala:Kt-3|kategori ismi=" + parametre + "}}";
text = old_text;
text += added_data;
pageobj.setPageText(text);
pageobj.setEditSummary('[[:' + Morebits.pageNameNorm + ']] için ' + (params.xfdcat === 'kt' ? 'silme adaylığı' : 'birleştirme adaylığı') + ' ekleniyor.');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
//Mevcut ayın kayıt sayfası
todaysList2: function(pageobj) {
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
const old_text = pageobj.getPageText() + '\n';
const added_data = "{{kopyala:sas3|" + Morebits.pageNameNorm + "}}"
let text = old_text;
text += added_data;
pageobj.setPageText(text);
pageobj.setEditSummary('[[:' + params.discussionpage + ']] ekleniyor.');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchList'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
}
},
cfds: {
taggingCategory: function(pageobj) {
const text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
if (params.xfdcat === 'C2F') {
params.tagText = '{{subst:cfm-speedy|1=' + params.cfdstarget.replace(/^:?Category:/, '') + '}}\n';
} else {
params.tagText = '{{subst:cfr-speedy|1=' + params.cfdstarget.replace(/^:?Category:/, '') + '}}\n';
}
params.discussionpage = ''; // CFDS is just a bullet in a bulleted list. There's no section to link to, so we set this to blank. Blank will be recognized by both the generate userspace log code and the generate userspace log edit summary code as "don't wikilink to a section".
if (pageobj.canEdit()) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Listed for speedy renaming; see [[WP:CFDS|Categories for discussion/Speedy]].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
pageobj.save(() => {
// No user notification for CfDS, so just add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
});
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
// No user notification for CfDS, so just add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
}
},
addToList: function(pageobj) {
const old_text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
const text = old_text.replace('BELOW THIS LINE -->', 'BELOW THIS LINE -->\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('cfds', params));
if (text === old_text) {
statelem.error('failed to find target spot for the discussion');
return;
}
pageobj.setPageText(text);
pageobj.setEditSummary('Adding [[:' + Morebits.pageNameNorm + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(() => {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
}
},
rfd: {
// This gets called both on submit and preview to determine the redirect target
findTarget: function(params, callback) {
// Used by regular redirects to find the target, but for all redirects,
// avoid relying on the client clock to build the log page
const query = {
action: 'query',
curtimestamp: true,
format: 'json'
};
if (document.getElementById('softredirect')) {
// For soft redirects, define the target early
// to skip target checks in findTargetCallback
params.rfdtarget = document.getElementById('softredirect').textContent.replace(/^:+/, '');
} else {
// Find current target of redirect
query.titles = mw.config.get('wgPageName');
query.redirects = true;
}
const wikipedia_api = new Morebits.wiki.Api('Finding target of redirect', query, Twinkle.xfd.callbacks.rfd.findTargetCallback(callback));
wikipedia_api.params = params;
wikipedia_api.post();
},
// This is a closure for the callback from the above API request, which gets the target of the redirect
findTargetCallback: function(callback) {
return function(apiobj) {
const response = apiobj.getResponse();
apiobj.params.curtimestamp = response.curtimestamp;
if (!apiobj.params.rfdtarget) { // Not a softredirect
const target = response.query.redirects && response.query.redirects[0].to;
if (!target) {
let message = 'No target found. this page does not appear to be a redirect, aborting';
if (mw.config.get('wgAction') === 'history') {
message += '. If this is a soft redirect, try again from the content page, not the page history.';
}
apiobj.statelem.error(message);
return;
}
apiobj.params.rfdtarget = target;
const section = response.query.redirects[0].tofragment;
apiobj.params.section = section;
}
callback(apiobj.params);
};
},
main: function(params) {
const date = new Morebits.Date(params.curtimestamp);
params.logpage = 'Wikipedia:Redirects for discussion/Log/' + date.format('YYYY MMMM D', 'utc');
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
// Tagging redirect
let wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName'), 'Adding deletion tag to redirect');
wikipedia_page.setFollowRedirect(false);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.rfd.taggingRedirect);
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to today's log";
// Adding discussion
wikipedia_page = new Morebits.wiki.Page(params.logpage, "Adding discussion to today's log");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.rfd.todaysList);
// Notifications
if (params.notifycreator || params.relatedpage) {
const thispage = new Morebits.wiki.Page(mw.config.get('wgPageName'));
thispage.setCallbackParameters(params);
thispage.lookupCreation(Twinkle.xfd.callbacks.rfd.sendNotifications);
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
},
taggingRedirect: function(pageobj) {
const text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
// Imperfect for edit request but so be it
params.tagText = '{{subst:rfd|' + (mw.config.get('wgNamespaceNumber') === 10 ? 'showontransclusion=1|' : '') + 'content=\n';
if (pageobj.canEdit()) {
pageobj.setPageText(params.tagText + text + '\n}}');
pageobj.setEditSummary('Listed for discussion at [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('nocreate');
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
},
todaysList: function(pageobj) {
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
const added_data = Twinkle.xfd.callbacks.getDiscussionWikitext('rfd', params);
let text;
// add date header if the log is found to be empty (a bot should do this automatically)
if (!pageobj.exists()) {
text = '{{subst:RfD log}}' + added_data;
} else {
const old_text = pageobj.getPageText();
text = old_text.replace(/(<!-- Add new entries directly below this line\.? -->)/, '$1\n' + added_data);
if (text === old_text) {
statelem.error('failed to find target spot for the discussion');
return;
}
}
pageobj.setPageText(text);
pageobj.setEditSummary('Adding [[:' + Morebits.pageNameNorm + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.setCreateOption('recreate');
pageobj.save(() => {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
sendNotifications: function(pageobj) {
const initialContrib = pageobj.getCreator();
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
// Notifying initial contributor
if (params.notifycreator) {
Twinkle.xfd.callbacks.notifyUser(params, initialContrib);
}
// Notifying target page's watchers, if not a soft redirect
if (params.relatedpage) {
const targetTalk = new mw.Title(params.rfdtarget).getTalkPage();
// On the offchance it's a circular redirect
if (params.rfdtarget === mw.config.get('wgPageName')) {
statelem.warn('Circular redirect; skipping target page notification');
} else if (document.getElementById('softredirect')) {
statelem.warn('Soft redirect; skipping target page notification');
// Don't issue if target talk is the initial contributor's talk or your own
} else if (targetTalk.getNamespaceId() === 3 && targetTalk.getNameText() === initialContrib) {
statelem.warn('Target is initial contributor; skipping target page notification');
} else if (targetTalk.getNamespaceId() === 3 && targetTalk.getNameText() === mw.config.get('wgUserName')) {
statelem.warn('You (' + mw.config.get('wgUserName') + ') are the target; skipping target page notification');
} else {
// Don't log if notifying creator above, will log then
Twinkle.xfd.callbacks.notifyUser(params, targetTalk.toText(), params.notifycreator, 'Notifying redirect target of the discussion');
return;
}
// If we thought we would notify the target but didn't,
// we need to log if we didn't notify the creator
if (!params.notifycreator) {
Twinkle.xfd.callbacks.addToLog(params, null);
}
}
}
},
rm: {
listAtTalk: function(pageobj) {
const params = pageobj.getCallbackParameters();
params.discussionpage = pageobj.getPageName();
pageobj.setAppendText('\n\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('rm', params));
pageobj.setEditSummary(`Proposing move of ${
params.currentname
.map((currentname, i) => `[[:${currentname}]]${params.newname[i] ? ` to [[:${params.newname[i]}]]` : ''}`)
.join(', ')
}.`);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setCreateOption('recreate'); // since the talk page need not exist
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.append(() => {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
// add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
});
},
listAtRMTR: function(pageobj) {
const text = pageobj.getPageText();
const params = pageobj.getCallbackParameters();
const statelem = pageobj.getStatusElement();
const discussionWikitext = Twinkle.xfd.callbacks.getDiscussionWikitext('rm', params);
const newtext = Twinkle.xfd.insertRMTR(text, discussionWikitext);
if (text === newtext) {
statelem.error('failed to find target spot for the entry');
return;
}
pageobj.setPageText(newtext);
pageobj.setEditSummary(`Adding [[:${params.currentname.join(']], [[:')}]].`);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.save(() => {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
// add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
});
}
}
};
/**
* Given the wikitext of the WP:RM/TR page and the wikitext to insert, insert it at the bottom of the ==== Uncontroversial technical requests ==== section.
*
* @param {string} pageWikitext
* @param {string} wikitextToInsert Will typically be `{{subst:RMassist|1=From|2=To|reason=Reason}}`, which expands out to `* {{RMassist/core | 1 = From | 2 = To | discuss = yes | reason = Reason | sig = Signature | requester = YourUserName}}`
* @return {string} pageWikitext
*/
Twinkle.xfd.insertRMTR = function(pageWikitext, wikitextToInsert) {
const placementRE = /\n{1,}(==== ?Requests to revert undiscussed moves ?====)/i;
return pageWikitext.replace(placementRE, '\n' + wikitextToInsert + '\n\n$1');
};
Twinkle.xfd.callback.evaluate = function(e) {
const form = e.target;
const params = Morebits.QuickForm.getInputData(form);
Morebits.SimpleWindow.setButtonsEnabled(false);
Morebits.Status.init(form);
Twinkle.xfd.currentRationale = params.reason;
Morebits.Status.onError(Twinkle.xfd.printRationale);
let query, wikipedia_page, wikipedia_api;
switch (params.venue) {
case 'afd': // AFD
query = {
action: 'query',
list: 'allpages',
apprefix: 'Silinmeye aday sayfalar/' + Morebits.pageNameNorm,
apnamespace: 4,
apfilterredir: 'nonredirects',
aplimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
format: 'json'
};
wikipedia_api = new Morebits.wiki.Api('Tagging article with deletion tag', query, Twinkle.xfd.callbacks.afd.main);
wikipedia_api.params = params;
wikipedia_api.post();
break;
case 'saş': // TFD
if (params.tfdtarget) { // remove namespace name
params.tfdtarget = utils.stripNs(params.tfdtarget);
}
// Modules can't be tagged, TfD instructions are to place on /doc subpage
params.scribunto = mw.config.get('wgPageContentModel') === 'Scribunto';
if (params.xfdcat === 'baş') { // Merge
// Tag this template/module
if (params.scribunto) {
wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName') + '/belge', 'Modül belgelendirmesi birleştirme etiketiyle etiketleniyor');
params.otherTemplateName = 'Modül:' + params.tfdtarget;
} else {
wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName'), 'Şablon birleştirme etiketiyle etiketleniyor');
params.otherTemplateName = 'Şablon:' + params.tfdtarget;
}
} else { // delete
if (params.scribunto) {
wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName') + '/belge', 'Modül belgeleme sayfası silinme adaylığı için etiketleniyor');
} else {
wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName'), 'Şablon silinme adaylığı için etiketleniyor');
}
}
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.main);
break;
case 'sas': // Silinemeye aday sayfalar: maddeler
query = {
action: 'query',
list: 'allpages',
apprefix: 'Silinmeye aday sayfalar/' + Morebits.pageNameNorm,
apnamespace: 4,
apfilterredir: 'nonredirects',
aplimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
format: 'json'
};
wikipedia_api = new Morebits.wiki.Api('Bu sayfanın önceki adaylıkları aranıyor', query, Twinkle.xfd.callbacks.mfd.main);
wikipedia_api.params = params;
wikipedia_api.post();
break;
case 'ffd': // FFD
// Tagging file
// A little out of order with this coming before 'main',
// but tagging doesn't need the uploader parameter,
// while everything else does, so tag then get the uploader
wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName'), 'Adding deletion tag to file page');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.ffd.taggingImage);
break;
case 'kt':
if (params.cfdtarget) {
params.cfdtarget = utils.stripNs(params.cfdtarget);
} else {
params.cfdtarget = ''; // delete
}
if (params.cfdtarget2) { // split
params.cfdtarget2 = utils.stripNs(params.cfdtarget2);
}
// Used for customized actions in edit summaries and the notification template
var summaryActions = {
'kt': 'silme',
'sfd-t': 'deletion',
'bak': 'birleştirme',
'yaak': 'yeniden adlandırma',
'sfr-t': 'renaming',
'böak': 'bölme',
'maak': 'maddeye dönüştürme'
};
params.action = summaryActions[params.xfdcat];
// Tagging category
wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName'), 'Kategori ' + params.action + ' etiketiyle etiketleniyor');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfd.main);
break;
case 'cfds':
// add namespace name if missing
params.cfdstarget = utils.addNs(params.cfdstarget, 14);
var logpage = 'Wikipedia:Categories for discussion/Speedy';
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = logpage;
Morebits.wiki.actionCompleted.notice = 'Nomination completed, now redirecting to the discussion page';
// Tagging category
wikipedia_page = new Morebits.wiki.Page(mw.config.get('wgPageName'), 'Tagging category with rename tag');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfds.taggingCategory);
// Adding discussion to list
wikipedia_page = new Morebits.wiki.Page(logpage, 'Adding discussion to the list');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfds.addToList);
break;
//case 'rfd':
// // find target and pass main as the callback
// Twinkle.xfd.callbacks.rfd.findTarget(params, Twinkle.xfd.callbacks.rfd.main);
// break;
case 'rm':
var nomPageName = params.rmtr ?
'Wikipedia:Requested moves/Technical requests' :
new mw.Title(Morebits.pageNameNorm).getTalkPage().toText();
Morebits.wiki.actionCompleted.redirect = nomPageName;
Morebits.wiki.actionCompleted.notice = 'Nomination completed, now redirecting to the discussion page';
wikipedia_page = new Morebits.wiki.Page(nomPageName, params.rmtr ? 'Adding entry at WP:RM/TR' : 'Adding entry on talk page');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
if (params.rmtr) {
wikipedia_page.load(Twinkle.xfd.callbacks.rm.listAtRMTR);
} else {
// listAtTalk uses .append(), so no need to load the page
Twinkle.xfd.callbacks.rm.listAtTalk(wikipedia_page);
}
break;
default:
alert('twinklexfd: unknown XFD discussion venue');
break;
}
};
Twinkle.addInitCallback(Twinkle.xfd, 'xfd');
}());
// </nowiki>