Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copyvio: Add copyvio-templates on non-wikitext pages [feature] #207

Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions modules/twinklecopyvio.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ Twinkle.copyvio.callbacks = {
tag = oldcsd[0] + '\n' + tag;
}

if (mw.config.get('wgPageContentModel') === 'json') {
tag = JSON.stringify([{
_addText: tag
}]);
} else if (mw.config.get('wgPageContentModel') === 'Scribunto') {
Twinkle.copyvio.callbacks.tagginglua(pageobj, tag);
return;
Xi-Plus marked this conversation as resolved.
Show resolved Hide resolved
} else if (['javascript', 'css', 'sanitized-css'].indexOf(mw.config.get('wgPageContentModel')) > -1) {
if (tag.indexOf('*/')) {
tag = tag.replace(/\*\//g, '*/');
}
tag = '/* _addText: ' + tag + ' */';
}

pageobj.setPageText(tag);
pageobj.setEditSummary(wgULS('本页面疑似侵犯著作权', '本頁面疑似侵犯版權'));
pageobj.setChangeTags(Twinkle.changeTags);
Expand All @@ -132,6 +146,27 @@ Twinkle.copyvio.callbacks = {
pageobj.patrol();
}
},
tagginglua: function(pageobj, tag) {
new mw.Api().parse(tag, {
onlypst: 1
}).then(function (tag) {
var equals = '';
while (tag.indexOf(']' + equals + ']') !== -1) {
equals += '=';
}
tag = "require('Module:Module wikitext')._addText([" + equals + '[' + tag + ']' + equals + ']);';

pageobj.setPageText(tag);
pageobj.setEditSummary(wgULS('本页面疑似侵犯著作权', '本頁面疑似侵犯版權'));
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('copyvioWatchPage'));
// pageobj.setCreateOption('recreate');
pageobj.save();
}, function (err) {
mw.log.error(err);
Morebits.status.error(wgULS('错误', '錯誤'), wgULS('无法展开wikitext', '無法展開wikitext'));
});
},
copyvioList: function(pageobj) {
var text = pageobj.getPageText();
var output = '';
Expand Down