Jump to content

Extension:GetHub

From mediawiki.org
Revision as of 07:08, 27 June 2009 by 88.171.40.158 (talk) (Created page with '<!--- ************************************************************** Usage instructions: 1. REMOVE THE TAG line above this box IT WILL PREVENT PROPER DISPLAY OF THE INFOB...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


MediaWiki extensions manual
getHub
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 &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>';
}