GitSnax MediaWiki Extension

From trapsink.com
Jump to: navigation, search


Overview

GitSnax adds a {{#gitsnack: }} parser function to MediaWiki which allows embedding raw files and gists from github.com into the wiki page.


Installation

Download the code to your server:

cd /path/to/mediawiki/extensions
git clone https://github.com/troyengel/GitSnax.git

Add the following code to your LocalSettings.php:

require_once "$IP/extensions/GitSnax/GitSnax.php";


Usage

Find the 'Raw' link on the github.com file or gist you want to embed then extract the URL part after the hostname to use in this hook like so:

Gist: (https://gist.githubusercontent.com/)

{{#gitsnack: gist | troyengel/c09459d43431ec98799b/raw/4bbab685fa4ab1391de3fcc8732718750a274340/arch-default-kernel}}

Code: (https://raw.githubusercontent.com/)

{{#gitsnack: code | troyengel/scripts/master/archmate.sh}}


Example

The arch-default-kernel Gist snippet referenced above:

ROOT_PART=$(grub-probe --target=device /)
ROOT_UUID=$(grub-probe --device ${ROOT_PART} --target=fs_uuid)
grub-set-default "gnulinux-linux-advanced-${ROOT_UUID}"


License

This code is licensed under the GNU GPL v2.0 or above, see COPYING for details.


References