Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
console.info( 'Gadget loaded: https://samwilson.id.au/MediaWiki:Gadget-blog.js' );
// Purge the Welcome page if we've just saved a {{post}}.
mw.hook( 'postEdit' ).add( function () {
const post = document.querySelector( '.tpl-post' );
if ( post !== null ) {
const titles = ['Welcome', 'Blog'];
const time = post.querySelector( 'time' );
if ( time !== null ) {
const year = time.getAttribute( 'datetime' ).substring( 0, 4 );
titles.push( year, year + ' archive' );
}
( new mw.Api() ).post( { action: 'purge', titles: titles.join( '|' ) } );
}
} );
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
$textarea.wikiEditor( 'addToToolbar', {
section: 'main',
group: 'format',
tools: {
code: {
label: 'Code',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/3/30/Tt_icon.png',
action: {
type: 'encapsulate',
options: {
pre: "{{code|",
post: "}}"
}
}
},
quotation: {
label: 'Quotation',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/VisualEditor_-_Icon_-_Block-quote.svg/24px-VisualEditor_-_Icon_-_Block-quote.svg.png',
action: {
type: 'encapsulate',
options: {
pre: "{{quotation|",
post: "}}"
}
}
}
}
} );
} );