Content deleted Content added
pull request #152: Update link ___location, notification method, and namespace check (publish.php) |
code cleanup (publish.php) |
||
Line 18:
- clean external links out of the main article area (turn them into references)
- add ==References== section
-
- Other uses:
Line 45:
- if article has headings but no lead, remove first heading
- replace unicode bullets with asterisks
Add one of the following to your User:yourName/common.js (at the top) to change the position where DraftCleaner puts its link:
window.draftCleanerPutInToolsMenu = true;
window.draftCleanerPutInMoreMenu = true;
This page was assembled from 3 files using my publish.php script. I have an offline test suite with around 100 unit tests for the DraftCleaner and StringFilter classes.
Line 50 ⟶ 54:
async function getWikicode(title) {
if ( pageIsDeleted ) {
return '';
}▼
var wikicode = '';
title = encodeURIComponent(title);
Line 61 ⟶ 69:
});
return wikicode;
▲}
},▼
}
Line 94 ⟶ 84:
.append($('<input type="hidden" name="wpUltimateParam">').val('1'))
.appendTo($(document.body)) //it has to be added somewhere into the <body>
.
}
Line 100 ⟶ 90:
function getArticleName() {
return mw.config.get('wgPageName');
}▼
}
// don't run when not viewing articles
let action = mw.config.get('wgAction');
if ( isNotViewing ) {
return;
▲}
// don't run when viewing diffs
let isDiff = mw.config.get('wgDiffNewId');
if ( isDiff ) {
return; }
// Don't run in virtual namespaces
if ( isVirtualNamespace ) {
return;
}
let menuID = 'p-navigation';
Line 138 ⟶ 130:
$('#DraftCleanerLink').on('click', async function() {
// prevent running the script while script is already in progress
if ( running ) {
return; running = true;
mw.notify('Parsing page content...');
Line 152 ⟶ 145:
wikicode = dc.cleanDraft(wikicode, namespaceNumber, titleWithNamespaceAndSpaces);
let needsChanges = wikicode != originalWikicode;
if (
let summary = 'clean up ([[User:Novem Linguae/Scripts/DraftCleaner.js|DraftCleaner]])';
await goToShowChangesScreen(titleWithNamespaceAndUnderscores, wikicode, summary);
} else {
mw.notify('No changes needed!');
|