Extension:MagnetLinks
From MediaWiki.org
|
MagnetLinks Release status: beta |
|
|---|---|
| Implementation | Tag |
| Description | Allows creation of links to magnet URI |
| Author(s) | Jmkim dot com |
| Last version | 0.1 (2012-02-05) |
| MediaWiki | 1.16 or above |
| License | GPL |
| Download | No link |
|
Check usage (experimental) |
|
Contents |
[edit] Description
This extension renders links to magnet URI.
[edit] Examples
The following examples should show how you can use this extension.
<magnet>magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C</magnet>
<magnet>magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C Magnet Link</magnet>
[edit] Source code
Add the following to your LocalSettings.php:
require_once("$IP/extensions/MagnetLinks/MagnetLinks.php");
Add the following source code to the extensions/MagnetLinks/MagnetLinks.php directory
<?php /** * This file contains the main include file for the MagnetLinks extension of * MediaWiki. This code is released under the GNU General Public License. * * @author Jmkim dot com <banking@nate.com> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @package MediaWikiExtensions * @version 0.1 */ $wgExtensionFunctions[] = 'MagnetLinksExtension'; function MagnetLinksExtension() { global $wgParser; $wgParser->setHook('magnet', 'render_MagnetLink'); } function render_MagnetLink($input, $argv) { $pos = strpos($input, ' '); if($pos === false) { $uri = htmlentities(trim($input)); $linktext = $uri; } else { $uri = htmlentities(trim(substr($input, 0, $pos))); $linktext = htmlentities(trim(substr($input, $pos)), ENT_COMPAT, 'UTF-8'); } $icon_img = 'http://upload.wikimedia.org/wikipedia/commons/c/c2/Magnet-icon.gif'; $link_color = '#0088a4'; return "<img src=\"$icon_img\"/> <a style=\"color:$link_color\" href=\"$uri\">$linktext</a>"; } $wgExtensionCredits['parserhook'][] = array( 'name' => 'MagnetLinks', 'author' => 'Jmkim dot com', 'description' => 'render links to magnet URI between <magnet> and </magnet>', 'url' => 'http://www.mediawiki.org/wiki/Extension:MagnetLinks', 'version' => '0.1.0'); ?>
[edit] See also
| Language: | English • Русский |
|---|
