MediaWiki Introduction 2023
Appearance
MediaWiki Introduction 2023 is a 3-part video series by Timo Tijhof, recorded in December 2023 for the MediaWiki Code Jam.
Part 1: MediaWiki core concepts
Watch on Wikimedia Commons. • Watch on YouTube
Timestamps:
00:00 Outline 00:50 Database schema 01:37 Users 02:55 Preferences 04:12 Localisation 05:02 Permissions 08:50 Bot passwords 10:10 Logging 11:58 Comments 12:35 Recent changes 15:39 Pages 16:00 Namespaces 18:14 Revisions 18:20 Example: Save an edit 19:59 Example: View a page 20:52 Link tables 21:02 Categories 24:20 Templates 25:05 Image links 25:59 GLAM 26:43 External links 27:40 Statistics 28:02 Search 29:14 JobQueue 31:58 Multimedia
High-level product and architecture perspective. Component walk-through.
- Database layout
- Who writes Wikipedia
- Why create an account
- CSSJanus docs
- CSSJanus demo
- Permissions
- Change user rights
- Bot passwords
- Logging
- No original research
- Recent changes
- RCFeed
- Listen to Wikipedia
- CodePen
- ClueBot
- Namespaces
- Special pages
- Page table
- Revision table
- Text table
- External storage
- Example category
- Everything is a wiki page
- GLAM
- Glamorous tool
- Example photo
- Statistics
- JobQueue
- MediaWiki Engineering - Performance practices
- Multimedia
Part 2: Wikipedia's extensions
Watch on Wikimedia Commons. • Watch on YouTube
Timestamps:
00:00 Outline 00:25 What is an extension? 01:52 How to install an extension? 02:01 Install WikiEditor 02:54 Install VisualEditor 03:58 Wikipedia's extensions 04:10 CentralAuth 04:38 Echo 04:56 OAuth for MediaWiki 05:40 Editor extensions 05:48 Parser extensions 06:37 Cite extension 07:37 EasyTimeline 07:56 InputBox extension 08:38 Scribunto 09:38 Faster editing performance 11:24 Media handlers 11:31 TimedMediaHandler 11:42 3D extension for MediaWiki 11:57 Spam prevention extensions 12:35 Gadgets 13:05 Gadget demo 13:41 Gadget examples
What is an extension?
How to install an extension in two easy steps.
Walk-through the installed extensions via Wikipedia's Special:Version page.
- What is an extension
- WikiEditor extension
- VisualEditor extension
- Wikipedia's extensions
- CentralAuth
- Echo
- Cite
- EasyTimeline
- EasyTimeline example: Version lifecycle
- InputBox
- InputBox example: Incident status
- Scribunto
- Lua example: SchemaDiagram
- What Lua scripting means for Wikimedia (2013)
- How we made editing Wikipedia twice as fast (2014)
- Save Timing in Grafana
- TimedMediaHandler
- 3D extension
- AbuseFilter
- Gadgets
- Gadget example: RTRC
- Gadget example: Stockphoto
- Half-timbered mansion, by Radomianin
Part 3: Write an example patch
- Homework preparation:
- Quickstart.
- Run PHPUnit, e.g.
composer phpunit -- tests/phpunit/includes/ResourceLoader/ - Run QUnit, e.g. view
http://localhost:4000/index.php/Special:JavaScriptTest - Clone the "examples" repo in your extensions/ directory, and enable it.
- How does an extension actually work?
- Manual:Extension registration (wfLoadExtension loads extension.json)
- Manual:Extension.json/Schema ("type", "SpecialPages" is a registry, "AutoloadNamespaces" is a registry).
- Best practices for extensions (keep it simple, reduce decisions/choices, fewer things to verify, "includes/").
- Manual:Coding conventions/PHP (quick open, file name = class name)
- How do special pages work?
- MediaWiki takes care of URL routing.
- File:MediaWiki_infrastructure_2022.png
- MediaWiki at WMF
- MediaWiki loves registries that do things for you automatically. MediaWiki constructs your SpecialPage class, and skins the output.
- Special:SpecialPages.
- Special:HelloWorld -> execute, now it's our turn.
- OutputPage
- RequestContext->msg
- Localisation
- uselang=qqx (debugging, contributions, Translatewiki.net)
- Help:System message
- i18n/en.json (git-grep, "MessageDirs")
- Excercise 1: Edit a localisation message. Change the "example-helloworld" message and notice the change on Special:HelloWorld.
- Excercise 2: Create a new localisation message, and output it on Special:HelloWorld.
- Hooks
- extension.json ("Hooks" is a registry, "HookHandlers" is a registry)
- MediaWiki will call Hooks.php#onSomething, now it's our turn.
- Manual:Hooks
- BeforePageDisplay
- $wgExampleEnableWelcome (extension.json, "config" is another registry)
- Namespaces (remember from Part 1)
- Excercise 3: Make a config change. Edit LocalSettings.php to disable $wgExampleEnableWelcome and notice the change on Main_Page. Comment your edit to re-enable it.
- Excercise 4: Edit a hook handler. Make it welcome you on special pages instead of articles. Notice the change on Special:HelloWorld and Main Page.
- ResourceLoader
- extension.json ("ResourceModules" is another registry, "dependencies", "packageFiles")
- ResourceLoader/Developing with ResourceLoader
- onBeforePageDisplay, OutputPage::addModule.
- welcome.js
- styles.css
- Special:JavaScriptTest?filter=welcome
- ext.Example.welcome.test.js
- Excercise 5: Fix a bug and test it with QUnit. The welcome message greets you with the wrong day.
- Save your change and upload it to Gerrit:
git add -pgit commit- git-review.
- Gerrit.
- WMF CI: Jenkins build output.