Mediawiki notes
Deleting unwanted revisions[1]Edit
Page old revisions can be deleted using a script. Without the page id argument, it will process all pages - be careful!
php maintenance/deleteOldRevisions.php [ <page_id>| --delete ]
Import pdf procedureEdit
- Open document in Word and let it deal with the conversion to .docx
- Copy the entire document to clipboard (ctrl-A, ctrl-C)
- Paste into a blank mediawiki page that is open with Visual Editor
- Deal with images
- Generally tidy the layout
Possibly will get better result from saving the Word documet to html format in step 1b.
Commonly-used shortcuts in Visual Editor[2]Edit
Template editor dialog shortcuts and keyboard interactionsEdit
PC shortcut | Action | Icon | Mac shortcut |
---|---|---|---|
Spacebar | Toggle a checkbox, adding or removing a parameter | Spacebar | |
↵ Enter | Add a parameter and immediately switch the focus to the input to start adding a value | ↵ Enter | |
Ctrl+⇧ Shift+D | Add an undocumented parameter | ⌘ Cmd+⇧ Shift+D | |
Ctrl+D | Add a template* (linked, not nested) | https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/OOjs_UI_icon_puzzle-ltr.svg/20px-OOjs_UI_icon_puzzle-ltr.svg.png | ⌘ Cmd+D |
Ctrl+⇧ Shift+Y | Add a wikitext part* | https://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/OOjs_UI_icon_wikiText.svg/20px-OOjs_UI_icon_wikiText.svg.png | ⌘ Cmd+⇧ Shift+Y |
Ctrl+Del | Delete a part (template or wikitext) when selected in the sidebar* | https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/OOjs_UI_icon_trash.svg/20px-OOjs_UI_icon_trash.svg.png | ⌘ Cmd+Del |
Ctrl+⇧ Shift+↑ | Move a part up when selected in the sidebar* | https://upload.wikimedia.org/wikipedia/commons/thumb/c/ca/OOjs_UI_icon_upTriangle.svg/20px-OOjs_UI_icon_upTriangle.svg.png | ⌘ Cmd+⇧ Shift+↑ |
Ctrl+⇧ Shift+↓ | Move a part down when selected in the sidebar* | https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/OOjs_UI_icon_downTriangle.svg/20px-OOjs_UI_icon_downTriangle.svg.png | ⌘ Cmd+⇧ Shift+↓ |
Full list of mouse and keyboard interactions[edit]Edit
Feature | Action | |
---|---|---|
Move cursor with mouse | Clicking | |
Move cursor with keyboard | Direction keys | |
Select content with mouse | Dragging | |
Select content with mouse | Double and triple clicking | |
Select content with keyboard | Shift + (Direction keys) | |
Select word with mouse | Double click word | |
Select block with mouse | Triple click block | |
Adjust selection with mouse | Shift + Click | |
Load insertion formatting from content | Move cursor | |
Insert text with keyboard | Character and number keys | |
Insert special characters with keyboard | Multiple character or number keys using an input method editor | |
Delete with keyboard | ← Backspace and Delete | |
Delete word with keyboard | Alt+← Backspace and Alt+Delete | ⌥ Option+← Backspace and ⌥ Option+Delete |
Delete line with keyboard | Ctrl+← Backspace and Ctrl+Delete | ⌘ Command+← Backspace and ⌘ Command+Delete |
Undo with keyboard | Ctrl+Z | ⌘ Command+Z |
Redo with keyboard | Ctrl+⇧ Shift+Z | ⌘ Command+⇧ Shift+Z |
Copy selection with keyboard | Ctrl+C | ⌘ Command+C |
Cut selection with keyboard | Ctrl+X | ⌘ Command+X |
Paste selection with keyboard | Ctrl+V | ⌘ Command+V |
Copy selection from menu | "Copy" in context or browser menu | |
Cut selection from menu | "Cut" in context or browser menu | |
Paste selection from menu | "Paste" in context or browser menu | |
Highlight object with mouse | Clicking | |
Toggle bold on selected content and in insertion formatting with mouse | Click bold tool in toolbar | |
Toggle italic on selected content and in insertion formatting with mouse | Click italic tool in toolbar | |
Toggle bold on selected content and in insertion formatting with keyboard | Ctrl+B | ⌘ Command+B |
Toggle italic on selected content and in insertion formatting with keyboard | Ctrl+I | ⌘ Command+I |
Split block with keyboard | ↵ Enter | |
Merge blocks with keyboard | Backspace at beginning or delete at end of block boundary | |
Switch the direction you write in between right-to-left and left-to-right | Ctrl+⇧ Shift+X | ⌘ Command+⇧ Shift+X |
File uploadsEdit
Add the following to the end of LocalSettings.php to allow uploads of different types[3]
## File Upload types ## $wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx', 'pptx', 'ps', 'odt', 'ods', 'odp', 'odg' );
File upload size will need to be adjusted. Open this file or its equivalent on your server:
nano /etc/php/7.4/apache2/php.ini
Then adjust the values for
post_max_size = 100M upload_max_filesize = 100M
Additionally, if behind an NGINX server block based reverse proxy, the limit will also need to be set otherwise there will be a 443 error [4]. Example:
server { client_max_body_size 100M; ... }
PDFEmbedEdit
This solves the problem of not being able to embed inline pdf viewing for ordinary users.
$wgGroupPermissions['user']['embed_pdf'] = true;
The width is not 100% which is irritating. To solve this edit file: /var/www/html/extensions/PDFEmbed/PDFEmbed.hooks.php
and then change the last function so that width
element in the first return array is equal to 100%
and not $width
static private function embed($url, $width, $height, $page, $iframe) { # secure and concatenate the url $pdfSafeUrl = htmlentities($url) . '#page=' . $page; # check the embed mode and return a proper HTML element if ($iframe) { return Html::rawElement('iframe', [ 'class' => 'pdf-embed', 'width' => '100%', 'height' => $height, 'src' => $pdfSafeUrl, 'style' => 'max-width: 100%;' ]); } else { # object mode (default) return Html::rawElement('object', [ 'class' => 'pdf-embed', 'width' => $width, 'height' => $height, 'data' => $pdfSafeUrl, 'style' => 'max-width: 100%;', 'type' => 'application/pdf' ], Html::rawElement( 'a', [ 'href' => $pdfSafeUrl ], 'load PDF' // i18n? )); } }
Highlightjs extension to syntaxhighlighterEdit
## highlightjs integration ## wfLoadExtension( 'Highlightjs_Integration' );
Create / update file cacheEdit
sudo -u www-data php /var/www/html/maintenance/rebuildFileCache.php
Add this as a cron job for daily cache regens (for example)
IframePage[5]Edit
Add this extension to embed 'external' (i.e. non-wiki pages to the wiki). To make the content iframe 100% tall, edit the extensions/IframePage/SpecialIframePage.php and set the array to:
$html .= Html::element( 'iframe', [ 'id' => "iframe-$srcName", 'src' => $src, 'frameborder' => '0', 'width' => '100%', 'height' => '100%', 'onload' => 'document.getElementById(\'iframeframe\').style.height = (this.contentWindow.document.body.offsetHeight + 50)> ] );
Configuration for the allowed iframe pages is done through LocalSettings.php as detailed on the reference.
URL arguments for pagesEdit
https://code.dcldesign.co.uk/index.php?title=Main_Page&action=purge
ReferencesEdit
- ↑ https://www.mediawiki.org/wiki/Manual:DeleteOldRevisions.php
- ↑ https://www.mediawiki.org/wiki/VisualEditor/Portal/Keyboard_shortcuts
- ↑ https://www.mediawiki.org/wiki/Manual_talk:Configuring_file_uploads
- ↑ https://docs.rackspace.com/support/how-to/limit-file-upload-size-in-nginx/
- ↑ https://www.mediawiki.org/wiki/Extension_talk:IframePage