Extension:GetHub
Appearance
Release status: beta |
|
|---|---|
| Implementation | Tag |
| Description | add gethub gists into your articles easily |
| Author(s) | Adam Meyer (noverflowtalk) |
| Latest version | .01 |
| MediaWiki | 1.14 (tested) |
| Licence | MIT License |
| Download | No link |
What can this extension do?
add gethub gists into your articles easily using <gethub gist="123456"/>
Usage
<gethub gist="123456"/>
Download instructions
Please cut and paste the code found below and place it in $IP/extensions/gethub/gethub.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
Installation
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/gethub/gethub.php");
User rights
Nothing promised. Took me 2min to make. Do with it as you would like.
Code
<?php
if( !defined( 'MEDIAWIKI' ) ) {
echo( "This file is part of an extension to the MediaWiki software and cannot be used standalone.\n" );
die( 1 );
}
$wgExtensionCredits['other'][] = array(
'name'=>'getList tag',
'author'=>'Adam Meyer',
'description'=>'add gethub gists into your articles easily using <gethub gist="123456"/>',
'version'=>'0.1'
);
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
$wgHooks['ParserFirstCallInit'][] = 'efGetHub';
} else {
$wgExtensionFunctions[] = 'efGetHub';
}
function efGetHub() {
global $wgParser;
$wgParser->setHook( 'gethub', 'efGetHubRender' );
return true;
}
function efGetHubRender( $input, $args, $parser ) {
$attr = array();
// This time, make a list of attributes and their values,
// and dump them, along with the user input
foreach( $args as $name => $value ){
if($name == 'gist'){
$num = $value;
}
}
return '<script src="http://gist.github.com/'.$num.'.js"></script>';
}
