Extension:BugSquish

From MediaWiki.org

Jump to: navigation, search

Note - the most up to date version of this documentation is available at http://www.kennel17.co.uk/testwiki/BugSquish.


       

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

Release status: stable

Implementation  Parser extension
Description An extension to cross out links to closed bugs.
Author(s)  Mark Clements (HappyDogTalk)
Last Version  check http://www.kennel17.co.uk/testwiki/BugSquish for latest version.
License CC-by-sa 2.5 or later
Download Source is available at my test wiki

check usage (experimental)

This extension checks your bug tracker installation and adds a strikethrough to interwiki links for closed bugs. BugSquish currently supports the Bugzilla and RT * bug trackers, running on either MySQL or PostgreSQL* databases.

* Thanks to Dax Kelson for providing the RT and PostgreSQL code.

Contents

[edit] Installation

Simply copy and paste the code (below) into a new file in your 'extensions' directory and include() it from your LocalSettings.php file in the usual way.

[edit] Requirements

Firstly, links to your bug tracker need to be setup in your interwiki table. For example you might setup an interwiki link called bug with the URL http://www.example.com/bugzilla/show_bug.cgi?id=$1 (though see known issues, below, if you plan to use this prefix). This means you can enter the wiki code [[bug:2314]] to create a link to bug 2314 in your Bugzilla install (resulting in a link such as: bug:2314). For links to other bug-trackers, the URL format will change, but the principal is the same.

Note that setting up links to your bug-tracker in this manner is something that MediaWiki supports natively - it is not functionality added by this extension. BugSquish simply adds the ability to shown these links crossed out (or otherwise styled) based on their status.

For BugSquish to work are you need to have an interwiki prefix that accepts just a single number, and that the DB containing the bugs must be accessible locally (though the code is designed to allow for alternative access to the bug tracker data (e.g. via WebDAV)... once someone has written the necessary code!).

Multiple interwiki prefixes to different bug tracker installations can be defined on the same wiki.

[edit] Configuration

For each interwiki link that you want to use, you need to add an entry into $wgBugSquishSources. Each entry has the following required elements:

  • interwiki => The interwiki prefix this definition applies to.
  • type => The type of connection. Currently only BUGSQUISH_DBConnect is valid for this field.
  • tracker => The type of bug tracker you are linking to. Currently the following values are recognised: "bugzilla" and "rt".

The following elements are only required if necessary:

  • prefix => DB prefix (as setup in your Bugzilla installation - can be omitted if no prefix used).


The following optional elements can be used to define the database connection. If any of the elements are omitted, then the values used for your MediaWiki installation are used. Therefore if Bugzilla shares a database with MediaWiki (and the MediaWiki user has appropriate access privileges) then you can omit all of the settings. If not, then fill in anything that differs from your MediaWiki install.

  • dbtype => The database type. Currently only "mysql" and "postgresql" are supported.
  • host => The database host.
  • database => The database name.
  • user => Username for DB connection.
  • password => Password for DB connection.

[edit] Styling

You may wish to add the following styles to your common.css file (available on your wiki at MediaWiki:Common.css). Note that this has not been tested with all browsers - if you spot and fix any problems, please feel free to update the CSS below.

.bsBugLink a {
  font-size: 0.9em;
  border: 1px solid #E0E0FF;
  background-color: #F0F0FF !important;
 
  margin: 0 0.2em;
  padding: 0 0.5em !important;
 
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
}
 
.bsBugLink a:hover {
  border-color: #9999FF;
  background-color: #D0E0FF !important;
  color: #0000FF !important;
  text-decoration: none;
}
 
s.bsFixedBug {
  text-decoration: none !important;
}
 
.bsFixedBug a, .bsFixedBug a:hover {
  text-decoration: line-through;
}

[edit] Examples

[edit] Example 1 - shared DB

If MediaWiki and Bugzilla are installed in a single DB, then you only need to specify a minimal set of components:

include("extensions/BugSquish.php");
 
$wgBugSquishSources[] = array(
	'interwiki'	=> "bug",
	'type'		=> BUGSQUISH_DBConnect,
        'tracker'       => "bugzilla",
	'prefix'	=> "bugzilla_",
);

[edit] Example 2 - separate DB

If Bugzilla is stored in a separate DB, then you need to supply details. In most cases 'host' will be the same as for MediaWiki, in which case it can be omitted (as it has been here). Also if no table prefix is used in your Bugzilla install, then that field can be omitted.

include("extensions/BugSquish.php");
 
$wgBugSquishSources[] = array(
	'interwiki' 	=> "bug",
	'type'		=> BUGSQUISH_DBConnect,
        'tracker'       => "bugzilla",
	'database'	=> "dbname",
	'user'		=> "dbuser",
	'password'	=> "dbpass",
);

[edit] Known issues

  • Doesn't handle interwiki links created dynamically via templates, (e.g. [[bug:{{{1}}}]]. It should handle links that don't contain variables though - let me know if you spot any other problems with transclusion, however!
  • In MediaWiki v1.6 the 'Buginese' language was added, which has the ISO code 'bug'. This means that in the default configuration for version 1.6 upwards, you can't use 'bug' for the links (or rather, you can, but they appear in the left side-bar rather than in the text as expected). There are two work-arounds to this.
    1. Use a different interwiki prefix.
    2. If you don't use inter-language links (and if you're unsure, you probably don't) then you can disable them by setting $wgInterwikiMagic to false in your LocalSettings.php file.

[edit] Source Code

Available from http://www.kennel17.co.uk/testwiki/BugSquish.