Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hacking MediaWiki (for users)

Hacking MediaWiki (for users)

Presented at Linux Users of Victoria usergroup, 2008.

Brianna Laugher

November 05, 2008

More Decks by Brianna Laugher

Other Decks in Technology


  1. Brianna Laugher Linux Users of Victoria November 2008 meeting Hacking

    MediaWiki (For Users) http://www.mediawiki.org/
  2. • Me: 2005—now Wikimedia editor, Wikimedia Commons administrator ~ 2

    years, frustrated wannabe hacker • You: Use MediaWiki outside of Wikimedia, comfortable with basic editing Who are we?
  3. • MediaWiki/Wikimedia • Wiki structure • Magic words, access levels

    • User JS/CSS – Gadgets • “Uselang” hack Outline
  4. Open­source (GPL) wiki engine software (uses LAMP) MediaWiki Wikimedia MediaWiki

    Name of a social movement; also US charity (Wikimedia Foundation)
  5. • Subpages Wiki structure

  6. By default only in talk, user pages Subpages Help:Subpages

  7. • Subpages • Links Wiki structure

  8. Special:MostLinked Special:WhatLinksHere Special:RecentChangesLinked Special:WantedPages Links Help:Links

  9. • Subpages • Links • Categories Wiki structure

  10. Categories Help:Categories Nine special pages for categories

  11. None
  12. • Subpages • Links • Categories • Templates Wiki structure

  13. Page transclusion: {{foo}} <noinclude>, <includeonly>, {{subst:foo}} Parameters Templates Help:Templates

  14. None
  15. None
  16. Special:ExpandTemplates

  17. Special:ExpandTemplates

  18. • Subpages • Links • Categories • Templates • Namespaces

    Wiki structure
  19. “Front” page + talk page • Main, Project, Help •

    Template • Category • Special* • Image, Media* • MediaWiki (* = psuedo namespace) Namespaces Help:Namespaces
  20. Special:RecentChanges Special:SpecialPages Special pages Help:Special pages

  21. Special:Upload Image namespace ­> File (soon!) [[Image:foo.jpg]] to embed [[:Image:foo.jpg]]

    to link to image page, not embed [[Media:foo.jpg]] to link to file directly Images (uploaded files)
  22. “System [interface] messages” Edit MediaWiki: pages to overrride defaults (sysops

    only) Search on Special:Allmessages to find the right message/page MediaWiki namespace Manual:System message
  23. None
  24. MediaWiki:sidebar MediaWiki:welcomecreation MediaWiki:copyrightwarning, 2 MediaWiki:searchresulttext MediaWiki:uploadtext Interesting pages

  25. About the sidebar... Manual:Interface/Sidebar

  26. About the sidebar... Move search box to top for usability

  27. About the sidebar... MediaWiki:Mainpage Main Page Move search box to

    top for usability
  28. About the sidebar... MediaWiki:Mainpage Main Page Move search box to

    top for usability Delete defaults, Add your own links
  29. MediaWiki:Common.css MediaWiki:Common.js Monobook skin: (same for others) MediaWiki:Monobook.css MediaWiki:Monobook.js Look

    & feel
  30. Modify an existing one: User:Foo/monobook.css,js Myskin – empty to start

    with Skins – roll your own Your user page Name of skin. Must start with lowercase
  31. “Behaviour switches”: __NOTOC__,__TOC__ #REDIRECT [[Foo]] __HIDDENCAT__ (on category pages) Magic

    words Help:Magic words
  32. __HIDDENCAT__ Help:Magic words

  33. Look like {{CAPS TEMPLATES}} Especially used in templates ­ context.

    • Time, revision related • Stats! {{NUMBEROFARTICLES}} {{NUMBEROFEDITS}} {{NUMBEROFUSERS}} {{PAGESINCATEGORY:Foo}} Variables Help:Magic words
  34. Special:ListGroupRights • “Anonymous”/IP editor • (registered) User • ­> Autoconfirmed!

    • Sysop (==”admin”) • Bureaucrat • Bot User access levels Manual:User rights
  35. Time ­ $wgAutoConfirmAge Edit count ­ $wgAutoConfirmCount After passing both,

    User automatically graduates to Autoconfirmed (On Wikipedia thought to be ~ 4 days) Autoconfirmed?
  36. Semi/protection Manual:Administrators

  37. Semi/protection Manual:Administrators AND non- autoconfirmed users!

  38. Massively simplify user JS/CSS sharing: no more copying user subpages

    MediaWiki:Gadgets­definition ­> New Preferences tab JS/CSS Gadgets Extension:Gadgets
  39. MediaWiki:Gadgets­definition MediaWiki:Gadget-section-browsing-gadgets MediaWiki:Gadget-Navigation popups List of file names MediaWiki:Gadget-foo.js/css

  40. Special:Preferences ­> Gadgets

  41. Gadget rec: HotCat Instead of this: [[Category:Melbourne Cricket Ground]] Try

    this: http://commons.wikimedia.org/wiki/ MediaWiki:Gadget­HotCat.js
  42. Make your edit box less scary: Gadget rec: wikEd http://enwp.org/WP:WIKED

  43. (This is not really recommended...) Use it to make different

    versions of special pages, eg upload form Uselang parameter overrides user language prefs Special:Upload?uselang=fr – I can see the French version of the form without changing my prefs “Uselang” hack http://commons.wikimedia.org/wiki/ Commons:Redesigning_the_upload_form
  44. What if I make a link to Special:Upload?uselang=blah ? For

    each message 'Foo', MW checks • MediaWiki:Foo/blah (localised message) • MediaWiki:Foo (localised default wiki lang message) • MessagesBlah.php file (MW defaults) “Uselang” hack http://commons.wikimedia.org/wiki/ Commons:Redesigning_the_upload_form
  45. • http://mediawiki.org is half­decent now • Still lots of info

    on http://meta.wikimedia.org/ • IRC is popular: irc://irc.freenode.net/mediawiki • MLs: mediawiki-l • Forum: http://mwusers.com/ (unofficial) Support
  46. Questions? Brianna Laugher [email protected] These slides are dual­licensed GFDL1.2+, CC­BY­SA­3.0.

    Screenshots are GFDL/GPL, WMF logo is all rights reserved, MediaWiki logo is public domain. Thankyou! http://brianna.modernthings.org/