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 1 commit
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
27 changes: 6 additions & 21 deletions modules/twinklecopyvio.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Twinkle.copyvio.callbacks = {
},
taggingArticle: function(pageobj) {
var params = pageobj.getCallbackParameters();
var tag = '{{subst:Copyvio/auto|url=' + params.source.replace(/http/g, 'http').replace(/\n+/g, '\n').replace(/^\s*([^*])/gm, '* $1').replace(/^\* $/m, '') + '|OldRevision=' + mw.config.get('wgRevisionId') + '}}';
var tag = '{{safeubst:Copyvio/auto|url=' + params.source.replace(/http/g, 'http').replace(/\n+/g, '\n').replace(/^\s*([^*])/gm, '* $1').replace(/^\* $/m, '') + '|OldRevision=' + mw.config.get('wgRevisionId') + '}}';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safesubst

var text = pageobj.getPageText();
var oldcsd = text.match(/\{\{\s*(db(-\w*)?|d|delete)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}/i);
if (oldcsd && confirm(wgULS('在页面上找到快速删除模板,要保留吗?\n\n当页面同时侵犯著作权又符合快速删除标准时,应该优先走快速删除程序。\n单击“确认”以保留快速删除模板,若您认为快速删除理由不合,单击“取消”以移除快速删除模板。', '在頁面上找到快速刪除模板,要保留嗎?\n\n當頁面同時侵犯版權又符合快速刪除標準時,應該優先走快速刪除程序。\n點擊「確認」以保留快速刪除模板,若您認為快速刪除理由不合,點擊「取消」以移除快速刪除模板。'))) {
Expand All @@ -126,26 +126,11 @@ Twinkle.copyvio.callbacks = {
_addText: tag
}]);
} else if (mw.config.get('wgPageContentModel') === 'Scribunto') {
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'));
});
return;
var equals = '';
while (tag.indexOf(']' + equals + ']') !== -1) {
equals += '=';
}
tag = "require('Module:Module wikitext')._addText([" + equals + '[' + tag + ']' + equals + ']);';
} else if (['javascript', 'css', 'sanitized-css'].indexOf(mw.config.get('wgPageContentModel')) > -1) {
tag = '/* _addText: ' + tag.replace(/\*\//g, '*/') + ' */';
}
Expand Down