$30 off During Our Annual Pro Sale. View Details »

Hacking MediaWiki (for users)

Hacking MediaWiki (for users)

Presented at Linux Users of Victoria usergroup, 2008.

Brianna Laugher

November 05, 2008
Tweet

More Decks by Brianna Laugher

Other Decks in Technology

Transcript

  1. Brianna Laugher
    Linux Users of Victoria
    November 2008 meeting
    Hacking MediaWiki
    (For Users)
    http://www.mediawiki.org/

    View Slide


  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?

    View Slide


  3. MediaWiki/Wikimedia

    Wiki structure

    Magic words, access levels

    User JS/CSS – Gadgets

    “Uselang” hack
    Outline

    View Slide

  4. Open­source (GPL) wiki engine
    software (uses LAMP)
    MediaWiki
    Wikimedia
    MediaWiki
    Name of a social movement;
    also US charity
    (Wikimedia
    Foundation)

    View Slide


  5. Subpages
    Wiki structure

    View Slide

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

    View Slide


  7. Subpages

    Links
    Wiki structure

    View Slide

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

    View Slide


  9. Subpages

    Links

    Categories
    Wiki structure

    View Slide

  10. Categories
    Help:Categories
    Nine special pages for categories

    View Slide

  11. View Slide


  12. Subpages

    Links

    Categories

    Templates
    Wiki structure

    View Slide

  13. Page transclusion: {{foo}}
    ,
    ,
    {{subst:foo}}
    Parameters
    Templates
    Help:Templates

    View Slide

  14. View Slide

  15. View Slide

  16. Special:ExpandTemplates

    View Slide

  17. Special:ExpandTemplates

    View Slide


  18. Subpages

    Links

    Categories

    Templates

    Namespaces
    Wiki structure

    View Slide

  19. “Front” page + talk page

    Main, Project, Help

    Template

    Category

    Special*

    Image, Media*

    MediaWiki
    (* = psuedo namespace)
    Namespaces
    Help:Namespaces

    View Slide

  20. Special:RecentChanges
    Special:SpecialPages
    Special pages
    Help:Special pages

    View Slide

  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)

    View Slide

  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

    View Slide

  23. View Slide

  24. MediaWiki:sidebar
    MediaWiki:welcomecreation
    MediaWiki:copyrightwarning, 2
    MediaWiki:searchresulttext
    MediaWiki:uploadtext
    Interesting pages

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  28. About the sidebar...
    MediaWiki:Mainpage
    Main Page
    Move search box
    to top for
    usability
    Delete defaults,
    Add your
    own links

    View Slide

  29. MediaWiki:Common.css
    MediaWiki:Common.js
    Monobook skin: (same for others)
    MediaWiki:Monobook.css
    MediaWiki:Monobook.js
    Look & feel

    View Slide

  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

    View Slide

  31. “Behaviour switches”:
    __NOTOC__,__TOC__
    #REDIRECT [[Foo]]
    __HIDDENCAT__ (on category pages)
    Magic words
    Help:Magic words

    View Slide

  32. __HIDDENCAT__
    Help:Magic words

    View Slide

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

    Time, revision related

    Stats!
    {{NUMBEROFARTICLES}}
    {{NUMBEROFEDITS}}
    {{NUMBEROFUSERS}}
    {{PAGESINCATEGORY:Foo}}
    Variables
    Help:Magic words

    View Slide

  34. Special:ListGroupRights

    “Anonymous”/IP editor

    (registered) User

    ­> Autoconfirmed!

    Sysop (==”admin”)

    Bureaucrat

    Bot
    User access levels
    Manual:User rights

    View Slide

  35. Time ­ $wgAutoConfirmAge
    Edit count ­ $wgAutoConfirmCount
    After passing both, User automatically
    graduates to Autoconfirmed
    (On Wikipedia thought to
    be ~ 4 days)
    Autoconfirmed?

    View Slide

  36. Semi/protection
    Manual:Administrators

    View Slide

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

    View Slide

  38. Massively simplify user JS/CSS sharing:
    no more copying user subpages
    MediaWiki:Gadgets­definition
    ­> New Preferences tab
    JS/CSS Gadgets
    Extension:Gadgets

    View Slide

  39. MediaWiki:Gadgets­definition
    MediaWiki:Gadget-section-browsing-gadgets
    MediaWiki:Gadget-Navigation popups
    List of file names
    MediaWiki:Gadget-foo.js/css

    View Slide

  40. Special:Preferences ­> Gadgets

    View Slide

  41. Gadget rec: HotCat
    Instead of this:
    [[Category:Melbourne Cricket Ground]]
    Try this:
    http://commons.wikimedia.org/wiki/
    MediaWiki:Gadget­HotCat.js

    View Slide

  42. Make your edit box less scary:
    Gadget rec: wikEd
    http://enwp.org/WP:WIKED

    View Slide

  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

    View Slide

  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

    View Slide


  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

    View Slide

  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/

    View Slide