Extension:GetHub

From MediaWiki.org

Jump to: navigation, search


           

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
getHub

Release status: beta

Implementation  Tag
Description add gethub gists into your articles easily
Author(s)  Adam Meyer (noverflowTalk)
Last Version  .01
MediaWiki  1.14 (tested)
License MIT
Download no link

check usage (experimental)

Contents

[edit] What can this extension do?

add gethub gists into your articles easily using <gethub gist="123456"/>

[edit] Usage

<gethub gist="123456"/>

[edit] 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.

[edit] Installation

To install this extension, add the following to LocalSettings.php:

require_once("$IP/extensions/gethub/gethub.php");

[edit] User rights

Nothing promised. Took me 2min to make. Do with it as you would like.

[edit] 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 &lt;gethub gist=&quot;123456&quot;/&gt;',
    '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>';
}