Difference between revisions of "Writing mediawiki extensions"
From ThorstensHome
(→Ideas) |
|||
Line 54: | Line 54: | ||
= Ideas = | = Ideas = | ||
− | * scale an image relative to the browser window's size | + | What can we do with mediawiki extensions? |
− | * define a mindmap | + | * scale an image relative to the browser window's size -> [[adaptivethumb]] |
+ | * define a mindmap in mediawiki syntax | ||
+ | * define a mindmap in bubbl.us, export it, and display it in mediawiki | ||
+ | * work with imagemaps so they are in the wiki and scaleable | ||
+ | * get dokuwiki syntax for tables to work in mediawiki | ||
= See also = | = See also = | ||
* http://www.mediawiki.org/wiki/Extension:SimpleTable/1.2a - deliver mediawiki syntax, parsed | * http://www.mediawiki.org/wiki/Extension:SimpleTable/1.2a - deliver mediawiki syntax, parsed | ||
* http://stackoverflow.com/questions/2676388/how-can-i-add-per-page-permissions-to-a-user-in-mediawiki/2698312#2698312 - mediawiki on ACLs | * http://stackoverflow.com/questions/2676388/how-can-i-add-per-page-permissions-to-a-user-in-mediawiki/2698312#2698312 - mediawiki on ACLs |
Revision as of 11:02, 25 January 2015
Here is the simplest mediawiki extension you can write:
- in LocalSettings.php, add
include("extensions/circlextension.php");
- create a file extensions/circlextension.php:
<?php $wgExtensionFunctions[] = "wfcirclextension"; function wfcirclextension() { global $wgParser; $wgParser->setHook("circle", "circlehtml"); } function circlehtml($code, $argv) { $result="<svg><circle r=50 /></svg>"; return $result; }
- Now you can create a mediawiki page with the content
This is mediawiki-syntax <circle this goes into argv > this goes into code </circle>
- And you will see a circle on the resulting wiki page. Note the circle may not be complete.
Version 2
Version 2 could look like this:
<?php $wgExtensionFunctions[] = "wfcirclextension"; function wfcirclextension() { global $wgParser; $wgParser->setHook("circle", "circlehtml"); } function circlehtml($code, $argv) { $param=reset($argv); # get first value of array if (!is_numeric($param)) {$param=20;}; $result=" <svg width=".round($param*2)." height=".round($param*2)."> <circle r=$param cx=$param cy=$param /> </svg>"; $result=preg_replace("/\n/","",$result); return $result; }
Ideas
What can we do with mediawiki extensions?
- scale an image relative to the browser window's size -> adaptivethumb
- define a mindmap in mediawiki syntax
- define a mindmap in bubbl.us, export it, and display it in mediawiki
- work with imagemaps so they are in the wiki and scaleable
- get dokuwiki syntax for tables to work in mediawiki
See also
- http://www.mediawiki.org/wiki/Extension:SimpleTable/1.2a - deliver mediawiki syntax, parsed
- http://stackoverflow.com/questions/2676388/how-can-i-add-per-page-permissions-to-a-user-in-mediawiki/2698312#2698312 - mediawiki on ACLs