DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:jira

jira Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Create links to JIRA tracker from JIRA IDs

Last updated on
2009-09-02
Provides
Syntax

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with embed, links, management

Download and Installation

Download and install the plugin using the Plugin Manager using the following URL. Refer to Plugins on how to install plugins manually.

Update your host and project keys in the syntax.php.

Has been tested successfully with Release 2011-05-25a “Rincewind”

Usage

Adds a link into your JIRA tracker for (KEY1-123), where KEY1 is a JIRA project key.

Plugin

Create a new folder lib/plugins/jira/ and place the following file in it: syntax.php.

syntax.php
<?php
/**
 * Plugin jira: Creates links into JIRA from JIRA IDs.
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Robert Lopuszanski <rlop@gmx.de>
 */
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_jira extends DokuWiki_Syntax_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'Robert Lopuszanski',
            'email'  => 'rlop@gmx.de',
            'date'   => '2009-09-02',
            'name'   => 'JIRA plugin',
            'desc'   => 'Creates links into JIRA from JIRA ids',
            'url'    => 'http://www.dokuwiki.org/plugin:jira',
        );
    }
 
    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }
 
    function getSort(){ return 359; }
 
    function connectTo($mode) {
		$projectKeys = array('KEY1', 'KEY2');
		foreach($projectKeys as $key) {
			$this->Lexer->addSpecialPattern('(' . $key . '-\d+)',$mode,'plugin_jira');
		}
    }
 
 
    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        return array( substr( $match, 1, strlen($match) - 2 ));
    }
 
    /**
     * Create output
     */
    function render($format, &$renderer, $data) {
        if($format == 'xhtml'){
            $renderer->doc .= '(<a href="http://host/browse/' . $data[0] . '" >' . $data[0] . '</a>)';
 
        } else {
            $renderer->doc .= $data[0];
        }
        return true;
    }
}
?>

Discussion

Similar results can be achieved using a custom interwiki link without installing any plugin.

plugin/jira.txt · Last modified: 2016-01-26 17:16 by Aleksandr