User:Chlod/Scripts/Deputy.js: Difference between revisions

Content deleted Content added
v0.3.1; https://github.com/ChlodAlejandro/deputy/releases/tag/v0.3.1
[480d81f] ia: add fields for presumptive deletion
Line 3,470:
 
var version = "0.3.1";
var gitAbbrevHash = "c0c34c8480d81f";
var gitBranch = "HEADmain";
var gitDate = "SatThu, 1729 Dec 2022 1510:2040:4117 +0800";
var gitVersion = "0.3.1+gc0c34c8g480d81f";
 
/**
Line 12,226:
"deputy.setting.wiki.ia.preload.name": "Preload",
"deputy.setting.wiki.ia.preload.description": "Defines the page content to preload the page with if a given subpage does not exist yet. This should be an existing page on-wiki. Leave blank to avoid using a preload entirely.",
"deputy.setting.wiki.ia.allowPresumptive.name": "Allow presumptive deletions",
"deputy.setting.wiki.ia.allowPresumptive.description": "Allows users to file listings for presumptive deletions. Note that the CCI setting \"Root page\" must be set for this to work, even if the \"CCI\" module is disabled entirely.",
"deputy.setting.wiki.ia.listingWikitext.name": "Listing wikitext",
"deputy.setting.wiki.ia.listingWikitext.description": "Defines the wikitext that will be used when adding listings to a noticeboard page. You may use \"$1\" to denote the page being reported, and \"$2\" for user comments (which shouldn't contain the signature).",
Line 12,672 ⟶ 12,674:
defaultValue: null,
displayOptions: { type: 'page' }
}),
allowPresumptive: new Setting({
defaultValue: true,
displayOptions: { type: 'checkbox' }
}),
listingWikitext: new Setting({
Line 13,327 ⟶ 13,333:
"deputy.ia.content.close": "-1) (Responding to [[$1#$2|$2]]",
"deputy.ia.content.listing": "Adding listing for [[$1#$2|$2]]",
"deputy.ia.content.listingComment": "from $1. $2",
"deputy.ia.content.batchListing": "Adding batch listing: \"[[$1#$2|$2]]\"",
"deputy.ia.content.listingComment": "from $1. $2",
"deputy.ia.content.hideAll": "Hiding page content due to a suspected or complicated copyright issue",
"deputy.ia.content.hide": "Hiding sections [[$1#$2|$3]] to [[$1#$4|$5]] for suspected or complicated copyright issues",
"deputy.ia.content.listing.pd": "Adding listing for [[$1#$2|$2]] (presumptive deletion)",
"deputy.ia.content.batchListing.pd": "Adding batch listing: \"[[$1#$2|$2]]\" (presumptive deletion)",
"deputy.ia.content.listingComment.pd": "presumptive deletion from [[$1/$2|$2]]. $3",
"deputy.ia.content.batchListingComment.pd": "Presumptive deletion from [[$1/$2|$2]]. $3",
"deputy.ia.content.hideAll.pd": "Hiding page content for presumptive deletion; see [[$1/$2]]",
"deputy.ia.content.hide.pd": "Hiding sections [[$1#$2|$3]] to [[$1#$4|$5]] for presumptive deletion; see [[$6/$7]]",
"deputy.ia.content.copyvio": "⛔ Content on this page has been temporarily hidden due to a suspected copyright violation",
"deputy.ia.content.copyvio.help": "Please see this wiki's noticeboard for copyright problems for more information.",
Line 13,345 ⟶ 13,357:
"deputy.ia.listing.new.title.label": "Batch title",
"deputy.ia.listing.new.title.placeholder": "Articles from ...",
"deputy.ia.listing.new.presumptive.label": "This is for presumptive deletion",
"deputy.ia.listing.new.presumptive.help": "Presumptive deletions are content removals where the actual source of copied content cannot be determined, but due to the history of the user, it is most likely a copyright violation. Enabling this will change related edit summaries and listing text.",
"deputy.ia.listing.new.presumptiveCase.label": "Case title",
"deputy.ia.listing.new.presumptiveCase.help": "The title of the case on a list of contributor copyright investigations. This is used to link to the case from the listing.",
"deputy.ia.listing.new.comments.label": "Batch listing comments",
"deputy.ia.listing.new.comments.placeholder": "Comments for each article",
Line 13,395 ⟶ 13,411:
"deputy.ia.report.endSection.label": "Ending section",
"deputy.ia.report.endSection.help": "This setting is inclusive, meaning it will also hide the section indicated.",
"deputy.ia.report.presumptive.label": "This is for presumptive deletion",
"deputy.ia.report.presumptive.help": "Presumptive deletions are content removals where the actual source of copied content cannot be determined, but due to the history of the user, it is most likely a copyright violation. Enabling this will change related edit summaries and listing text.",
"deputy.ia.report.presumptiveCase.label": "Case title",
"deputy.ia.report.presumptiveCase.help": "The title of the case on a list of contributor copyright investigations. This is used to link to the case from the listing.",
"deputy.ia.report.fromUrls.label": "Content copied from online sources",
"deputy.ia.report.fromUrls.help": "URLs will automatically be wrapped with brackets to shorten the external link. Disabling this option will present the text as is.",
Line 13,584 ⟶ 13,604:
* @param page
* @param comments
* @param presumptive
*/
postListing(page, comments, presumptive) {
return __awaiter(this, void 0, void 0, function* () {
const listingPage = this.main ? CopyrightProblemsPage.getCurrentListingPage() : this.title;
yield this.tryListingAppend(this.getListingWikitext(page, comments), decorateEditSummary(mw.msg(presumptive ?
'deputy.ia.content.listing.pd' :
'deputy.ia.content.listing', listingPage.getPrefixedText(), page.getPrefixedText())));
});
}
Line 13,615 ⟶ 13,638:
* @param title
* @param comments
* @param presumptive
*/
postListings(page, title, comments, presumptive) {
return __awaiter(this, void 0, void 0, function* () {
const listingPage = this.main ? CopyrightProblemsPage.getCurrentListingPage() : this.title;
yield this.tryListingAppend(this.getBatchListingWikitext(page, title, comments), decorateEditSummary(mw.msg(presumptive ?
'deputy.ia.content.batchListing.pd' :
'deputy.ia.content.batchListing', listingPage.getPrefixedText(), title)));
});
}
Line 14,276 ⟶ 14,302:
h_1("span", { class: "ia-listing-action--bracket" }, mw.msg('deputy.ia.listing.respondPost')));
return element;
}
 
let InternalCCICaseInputWidget;
/**
* Initializes the process element.
*/
function initCCICaseInputWidget() {
InternalCCICaseInputWidget = class CCICaseInputWidget extends mw.widgets.TitleInputWidget {
/**
*
* @param config
*/
constructor(config) {
super(Object.assign(Object.assign({}, config), { inputFilter: (value) => {
const prefix = window.InfringementAssistant.wikiConfig
.cci.rootPage.get().getPrefixedText() + '/';
// Simple replace, only 1 replacement made anyway.
const trimmed = value.replace(prefix, '').trim();
if (config.inputFilter) {
return config.inputFilter(trimmed);
}
else {
return trimmed;
}
} }));
this.getQueryValue = function () {
return `${window.InfringementAssistant.wikiConfig.cci.rootPage.get()
.getPrefixedText()}/${this.getValue()}`;
};
}
};
}
/**
* Creates a new CCICaseInputWidget.
*
* @param config Configuration to be passed to the element.
* @return A CCICaseInputWidget object
*/
function CCICaseInputWidget (config) {
if (!InternalCCICaseInputWidget) {
initCCICaseInputWidget();
}
return new InternalCCICaseInputWidget(config);
}
 
Line 14,374 ⟶ 14,443:
disabled: entirePageByDefault,
placeholder: mw.msg('deputy.ia.report.endSection.placeholder')
}),
presumptive: new OO.ui.CheckboxInputWidget({
selected: false
}),
presumptiveCase: CCICaseInputWidget({
allowArbitrary: false,
required: true,
showMissing: false,
validateTitle: true,
excludeDynamicNamespaces: true
}),
fromUrls: new OO.ui.CheckboxInputWidget({
Line 14,410 ⟶ 14,489:
label: mw.msg('deputy.ia.report.endSection.label'),
help: mw.msg('deputy.ia.report.endSection.help')
}),
presumptive: new OO.ui.FieldLayout(this.inputs.presumptive, {
align: 'inline',
label: mw.msg('deputy.ia.report.presumptive.label'),
help: mw.msg('deputy.ia.report.presumptive.help')
}),
presumptiveCase: new OO.ui.FieldLayout(this.inputs.presumptiveCase, {
align: 'top',
label: mw.msg('deputy.ia.report.presumptiveCase.label'),
help: mw.msg('deputy.ia.report.presumptiveCase.help')
}),
fromUrls: new OO.ui.FieldLayout(this.inputs.fromUrls, {
Line 14,492 ⟶ 14,581:
}
entirePageHiddenCheck();
});
const enablePresumptive = window.InfringementAssistant.wikiConfig.ia.allowPresumptive.get() &&
!!window.InfringementAssistant.wikiConfig.cci.rootPage.get();
fields.presumptive.toggle(enablePresumptive);
fields.presumptiveCase.toggle(false);
this.inputs.presumptive.on('change', (selected) => {
var _a;
this.data.presumptive = selected;
fields.presumptiveCase.toggle(selected);
fields.fromUrls.toggle(!selected);
if (!selected) {
if ((_a = this.data.fromUrls) !== null && _a !== void 0 ? _a : window.InfringementAssistant.config.ia.defaultFromUrls.get()) {
fields.sourceUrls.toggle(true);
// No need to toggle sourceText, assume it is already hidden.
}
else {
fields.sourceText.toggle(true);
// No need to toggle sourceText, assume it is already hidden.
}
}
else {
fields.sourceUrls.toggle(false);
fields.sourceText.toggle(false);
}
});
this.inputs.presumptiveCase.on('change', (text) => {
this.data.presumptiveCase = text.replace(window.InfringementAssistant.wikiConfig.cci.rootPage.get().getPrefixedText(), '');
});
this.inputs.fromUrls.on('change', (selected = this.data.fromUrls) => {
Line 14,508 ⟶ 14,624:
this.data.sourceText = text.replace(/\.\s*$/, '');
});
// Presumptive deletion is default false, so no need to check for its state here.
if (window.InfringementAssistant.config.ia.defaultFromUrls.get()) {
fields.sourceText.toggle(false);
Line 14,518 ⟶ 14,635:
});
return this.shadow ? getObjectValues(fields) : [
fields.presumptive, fields.presumptiveCase,
fields.fromUrls, fields.sourceUrls, fields.sourceText,
fields.additionalNotes
Line 14,603 ⟶ 14,721:
text: finalPageContent,
summary: decorateEditSummary(this.data.entirePage ?
mw.msg('deputythis.iadata.content.hideAll')presumptive :?
'deputy.ia.content.hideAll.pd' :
mw.msg('deputy.ia.content.hide', this.page.getPrefixedText(), (_c = this.data.startSection) === null || _c === void 0 ? void 0 : _c.anchor, (_d = this.data.startSection) === null || _d === void 0 ? void 0 : _d.line, (_e = this.data.endSection) === null || _e === void 0 ? void 0 : _e.anchor, (_f = this.data.endSection) === null || _f === void 0 ? void 0 : _f.line))
'deputy.ia.content.hideAll',
// Only ever used if presumptive is set.
...(this.data.presumptive ? [
window.InfringementAssistant.wikiConfig
.cci.rootPage.get().getPrefixedText(),
this.data.presumptiveCase
] : [])) :
mw.msg(this.data.presumptive ?
'deputy.ia.content.hideAll.pd' :
'deputy.ia.content.hide', this.page.getPrefixedText(), (_c = this.data.startSection) === null || _c === void 0 ? void 0 : _c.anchor, (_d = this.data.startSection) === null || _d === void 0 ? void 0 : _d.line, (_e = this.data.endSection) === null || _e === void 0 ? void 0 : _e.anchor, (_f = this.data.endSection) === null || _f === void 0 ? void 0 : _f.line, ...(this.data.presumptive ? [
window.InfringementAssistant.wikiConfig
.cci.rootPage.get().getPrefixedText(),
this.data.presumptiveCase
] : [])))
});
});
Line 14,622 ⟶ 14,754:
' ') :
this.data.sourceText;
const comments = (from || '').trim().length !== 0 || this.data.presumptive ?
mw.format(mw.msg('deputy.ia.content.listingComment', from, this.data.notes))presumptive :?
'deputy.ia.content.listingComment.pd' :
'deputy.ia.content.listingComment', ...(this.data.presumptive ? [
window.InfringementAssistant.wikiConfig
.cci.rootPage.get().getPrefixedText(),
this.data.presumptiveCase
] : [from]), this.data.notes)) :
(_b = this.data.notes) !== null && _b !== void 0 ? _b : '';
yield CopyrightProblemsPage.getCurrent()
.postListing(this.page, comments, this.data.presumptive);
});
}
Line 14,807 ⟶ 14,945:
titleMultiselect: new mw.widgets.TitlesMultiselectWidget({
inputPosition: 'outline',
allowArbitrary: false,
required: true,
showMissing: false,
validateTitle: true,
excludeDynamicNamespaces: true
}),
presumptive: new OO.ui.CheckboxInputWidget({
selected: false
}),
presumptiveCase: CCICaseInputWidget({
allowArbitrary: false,
required: true,
Line 14,829 ⟶ 14,977:
align: 'top',
label: mw.msg('deputy.ia.listing.new.comments.label')
}),
presumptive: new OO.ui.FieldLayout(inputs.presumptive, {
align: 'inline',
label: mw.msg('deputy.ia.listing.new.presumptive.label'),
help: mw.msg('deputy.ia.listing.new.presumptive.help')
}),
presumptiveCase: new OO.ui.FieldLayout(inputs.presumptiveCase, {
align: 'top',
label: mw.msg('deputy.ia.listing.new.presumptiveCase.label'),
help: mw.msg('deputy.ia.listing.new.presumptiveCase.help')
})
};
const getData = (listingPage) => {
return {
wikitext: listingPage.getBatchListingWikitext(inputs.titleMultiselect.items.map((v) => new mw.Title(v.data)), inputs.title.getValue(), inputs.commentspresumptive.getValue()), ?
summary: mw.msg('deputy.ia.content.batchListingbatchListingComment.pd', listingPagewindow.titleInfringementAssistant.getPrefixedText(), delink(inputs.title.getValue()))wikiConfig
.cci.rootPage.get().getPrefixedText(), inputs.presumptiveCase.getValue(), inputs.comments.getValue()) :
inputs.comments.getValue()),
summary: mw.msg(inputs.presumptive.getValue() ?
'deputy.ia.content.batchListing.pd' :
'deputy.ia.content.batchListing', listingPage.title.getPrefixedText(), delink(inputs.title.getValue()))
};
};
Line 15,282 ⟶ 15,445:
'mediawiki.util',
'mediawiki.api',
'mediawiki.Title',
'mediawiki.widgets'
];