JargonExtension
Contents |
[edit] About
This is a Mediawiki extension that inserts JargonFile definitions on wiki pages.
[edit] Usage
The simplest way to do so is to insert <jargon /> in a page, that will use the current page title as lookup term.
Alternatively you can use <jargon>something</jargon>.
Pages using it are also automatically included in Category:Jargon.
[edit] ToDo
If you find a missing page, simply insert <jargon /> (and nothing else) into the new page and save it.
[edit] Source
[edit] Install
To install copy into ./extensions/JargonExtension.php and then include("extensions/JargonExtension.php"); in LocalSettings.php as usual with Mediawiki extensions.
The extension uses the Debian package jargon. apt-get install jargon. (Also see vh).
<HighlightSyntax> <?php
- JargonFile terms on Mediawiki pages
- On inserting <jargon>something</jargon> in a wiki page,
- execute "jargon something" on the shell and return the formatted output
- mutante/s23 - 10/2007
$wgExtensionCredits['other'][] = array(
'name' => 'JargonFile extension',
'author' => 'mutante',
'version' => '10/2007',
'url' => 'http://s23.org/wiki/JargonExtension',
'description' => 'displays the JargonFile entry for a term on a wiki page.'
);
$wgExtensionFunctions[] = "wfJargonExtension";
function wfJargonExtension() { global $wgParser; $wgParser->setHook( "jargon", "getJargon" ); }
function getJargon( $input, $args, &$parser ) { global $wgParser; global $wgTitle;
- Get the definition of a term from the JargonFile
- if no input term is set get the current page title and use that
if ($input=="") { $mytitle=$wgTitle->mTextform; $term=$mytitle; } else {
- if there is input use that
$term = $input; }
- avoid evil stuff from user and at the same time make terms with whitespace work
$term = escapeshellarg($term);
- execute, we dont want the info messages from errout
$jargon=`jargon 2>/dev/null $term`;
- Get next link
$next=explode("Next: ",$jargon); $next=explode(",",$next[1]); $next=$next[0];
- Get previous link
$prev=explode("Prev: ",$jargon); $prev=explode(",",$prev[1]); $prev=$prev[0];
- remove header line
$jargon=explode("=",$jargon); $jargon=$jargon[2];
- add wiki links
$jargon=str_replace("{","[[",$jargon); $jargon=str_replace("}","]]",$jargon);
- remove ` and stuff
$jargon=str_replace("'","",$jargon); $jargon=str_replace("`","",$jargon);
- build output
| "; $output.="This is the Jargon File entry for $term - Next: ".$next.", Prev: ".$prev." | |
".$jargon." | |
| * (text is auto-included via JargonExtension by mutante using jargon with VERSION 4.0.0, 24 JUL 1996 - JargonFile by Eric S. Raymond is in the public domain) |
- trim,parse and return it
$output=trim($output); $parsed_output = $parser->recursiveTagParse( $output ); return $parsed_output;
}
?> </HighlightSyntax>