MediaWiki Extending

From virtualMV2015wiki
Jump to: navigation, search

Overview

Media wiki can be extended in several ways

  1. Client-Side JavaScript
  2. Templates
  3. Extensions
  4. Widgets
  5. Miscellaneous Tools

The MediaWiki codebase contains various "hooks" using callback functions to add additional code in an extensible way. This allows developers to write extensions without modifying the core or having to submit their code for review. Installing an extension typically consists of adding a line to the configuration file, though in some cases additional changes such as database updates are required. Wikipedia:MediaWiki(2009)[1]

JavaScript

Media wiki allows a special page MediaWiki:Common.js that is loaded every time a page is displayed. It is not editible by users and is created by the system admin.

JavaScript inpage

In here I'd love to include a basic javascript that demonstrates how it can be included on a web page, something like..

<script type="text/javascript">
  function fnHello() {
    alert("HELLO");
  }
</script>
<form>
    <input type="button" onclick="fnHello()" value="Call function" />
</form>

Reference: wikibooks:MediaWiki Developer's Handbook/Add JavaScript (2009)[2] - really cryptic and really no help at all yet :)

However Media wiki describes an extension (Extension:Javascript, 2009, June 27)[3] which I must try (I want to add a text size JavaScript element).

Templates

==References==
<references />
<p>&nbsp;</p>
<div style="font-family: menu,Arial; border: 1px solid #0000FF;font-size: x-small; background-color: #E6F2FF;">
{{{1}}} ({{CURRENTYEAR}}). ''{{PAGENAME}}''. Retrieved {{CURRENTMONTHNAME}} {{CURRENTDAY}}, {{CURRENTYEAR}},
 from {{fullurl:{{PAGENAME}}}}</div>

and call it at the bottom of a wiki page using

{{Template:APAFooter}}

Examples

My templates Specify an APA reference at the footer of each page:

Extensions

Extensions usually are implemented in two parts

  1. First, some additional php files need to be uploaded to the server (that use wikiMedia hooks) to intercept the code and do the special things you want to do (e.g. GeSHI formats programming code using a code tag, cite allows for the ref tag to be used on a wiki page)
  2. Next a line of code is added to LocalSettings.php (on the Server)
    require_once('extensions/Cite/Cite.php');
  3. Finally the tags are added to the wiki page to call the new feature.

References

Examples

  • Cite extension (Arnfjörð Bjarmason,2009)[4] - adds two parser hooks <ref> and <reference /> to add citations to wiki pages.
  • GeSHI extension (Vibber, Starling, & Church (2009).[5]

Widgets

Widgets extension allows adding widgets to wiki by just creating pages in Widget namespace. (MediaWiki:Extension:Widgets, 2009)[6]. For the widgets to work, the widget extension (some additional php code) must be installed on your server first. As there is potential for unauthorised access to your data, permission to create a widget (in the widget namespace) is set in the LocalSettings file)

The cool thing about a widget is that you can extend Media Wiki inside the wiki rather than creating additional PHP code to upload separately to the server.

Example

  • YouTube widget (Koren, 2008)[7] - allows you to add YouTube video player to your wiki page

Miscellaneous tools

References

  1. Wikipedia:MediaWiki(2009) Media Wiki: Customisation. Retrieved June 6, 2009 from http://en.wikipedia.org/wiki/MediaWiki#Customization
  2. wikibooks:MediaWiki Developer's Handbook/Add JavaScript (2009) MediaWiki Developer's Handbook/Add JavaScript. Retrieved June 6, 2009 from http://en.wikibooks.org/wiki/MediaWiki_Developer's_Handbook/Add_JavaScript
  3. Extension:Javascript. (2009, June 27). MediaWiki, The Free Wiki Engine. Retrieved 11:24, October 7, 2009 from http://www.mediawiki.org/w/index.php?title=Extension:Javascript&oldid=262504
  4. Arnfjörð Bjarmason, Æ. (2009) Extension:Cite/Cite.php, MediaWiki Retrieved June 6, 2009 from http://www.mediawiki.org/wiki/Extension:Cite/Cite.php
  5. Vibber, B., Starling, T., & Church, R. (2009). Extension:SyntaxHighlight GeSHi, MediaWiki. Retrieved June 6, 2009 from http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi
  6. MediaWiki:Extension:Widgets (2009) Extension:Widgets. Retrieved June 6, 2009 from http://www.mediawiki.org/wiki/Extension:Widgets
  7. Koren, Y. (2008) Widget:YouTube. Retrieved June 6, 2009 from http://www.mediawikiwidgets.org/

 

Verhaart, M. (2017). MediaWiki Extending. Retrieved December 18, 2017, from http://www.virtualmv.com/wiki/index.php?title=MediaWiki_Extending