View Issue Details

IDProjectCategoryView StatusLast Update
0006289mantisbtfeaturepublic2007-03-26 03:49
Reporterpardini Assigned To 
PrioritynormalSeveritytweakReproducibilityN/A
Status acknowledgedResolutionopen 
Product Versiongit trunk 
Summary0006289: Patch for handling [[Wiki-style]] links (just like CVSWeb, but for wikis)
Description

Attached patch against CVS HEAD makes Mantis produce HTML links to an external Wiki for annotations and descriptions which conform to the wiki standard, for example: [[This should be a wiki link]]. Multiple links are supported.

It is, I think, an interesting way of linking a bugtracker with a knowledge base.

Patch is for string_api.php and config_defaults_inc.php.

Additional Information

The base URL for the Wiki is set in $g_wiki_link_url. Patch to config_defaults.inc.php explaining the config setting included.

TagsNo tags attached.

Relationships

related to 0003045 acknowledged Generalizing "cvs:" replacement 
child of 0004181 closed Features in Mantis 1.1 release 

Activities

2005-09-22 02:02

 

mantis.wiki.links.patch (2,928 bytes)   
Index: config_defaults_inc.php
===================================================================
RCS file: /var/lib/cvs/mantis/config_defaults_inc.php,v
retrieving revision 1.4
diff -u -r1.4 config_defaults_inc.php
--- config_defaults_inc.php	22 Sep 2005 01:58:38 -0000	1.4
+++ config_defaults_inc.php	22 Sep 2005 05:52:14 -0000
@@ -1053,6 +1053,11 @@
 	# insert the URL to your CVSweb or ViewCVS
 	# eg: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mantisbt/mantisbt/
 	$g_cvs_web				= '';
+	
+	# --- Wiki linking ---------------
+	# insert the base URL to a (your?) Wiki here
+	# eg: http://en.wikipedia.org/wiki/
+	$g_wiki_link_url		= '';
 
 	# --- Source Control Integration ------
 
Index: core/string_api.php
===================================================================
RCS file: /var/lib/cvs/mantis/core/string_api.php,v
retrieving revision 1.5
diff -u -r1.5 string_api.php
--- core/string_api.php	22 Sep 2005 05:31:23 -0000	1.5
+++ core/string_api.php	22 Sep 2005 05:45:46 -0000
@@ -101,6 +101,7 @@
 		$p_string = string_process_bug_link( $p_string );
 		$p_string = string_process_bugnote_link( $p_string );
 		$p_string = string_process_cvs_link( $p_string );
+		$p_string = string_process_wiki_link($p_string);
 
 		return $p_string;
 	}
@@ -143,7 +144,7 @@
 		$p_string = string_process_bug_link( $p_string, false );
 		$p_string = string_process_bugnote_link( $p_string, false );
 		$p_string = string_process_cvs_link( $p_string, false );
-
+		$p_string = string_process_wiki_link($p_string, false);
 		return $p_string;
 	}
 
@@ -192,6 +193,29 @@
 							 $p_string );
 	}
 
+	# Process the string, returning full HTML links to a wiki, if configured.
+	function string_process_wiki_link($string, $fullHTML = true) {
+		if (!config_get('wiki_link_url')) return $string;
+		if ($fullHTML) return preg_replace_callback('/\[\[(([^\]]*?))\]\]/', 'string_process_wiki_link_callback_fullhtml', $string);
+		return preg_replace_callback('/\[\[(([^\]]*?))\]\]/', 'string_process_wiki_link_callback_nohtml', $string);
+	}
+
+	# --------------------
+	# Subsitution callback for the regexp in string_process_wiki_link(); HTML version.
+	function string_process_wiki_link_callback_fullhtml($words) {
+		$p_url_text = $words[2];
+        $p_link = config_get('wiki_link_url').$p_url_text;
+	    return '<span class="bracket-link">[['. "<a href=\"$p_link\" target=\"_blank\">$p_url_text</a>". ']]</span> ';
+	}
+
+	# --------------------
+	# Subsitution callback for the regexp in string_process_wiki_link(); plaintext version.
+	function string_process_wiki_link_callback_nohtml($words) {
+		$p_url_text = $words[2];
+        $p_link = config_get('wiki_link_url').$p_url_text;
+	    return "$p_url_text ($p_link)";
+	}
+
 	# --------------------
 	# Process $p_string, looking for bug ID references and creating bug view
 	#  links for them.
mantis.wiki.links.patch (2,928 bytes)   
anarcat

anarcat

2005-12-08 09:09

reporter   ~0011744

see also bug 0003045 for generalized interwiki linking.

vboctor

vboctor

2006-09-29 03:28

manager   ~0013551

pardini, please re-submit your patch. Also it may be worth checking out the Wiki integration feature in Mantis 1.1.0a1 and above.

2007-03-26 03:45

 

wiki_links.patch (3,675 bytes)   
--- mantis-pre2/config_defaults_inc.php 2005-09-11 21:24:08.000000000 +1000
+++ mantis-old2/config_defaults_inc.php 2005-11-01 17:44:17.765625000 +1100
@@ -1053,6 +1053,9 @@
  # eg: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mantisbt/mantisbt/
  $g_cvs_web = '';
 
+ # --- Wiki linking ---
+ $g_wiki_link_url = '';
+ 
  # --- Source Control Integration ------
 
  # For open source projects it is expected that the notes be public, however,
diff -uNr mantis-pre2/core/string_api.php mantis-old2/core/string_api.php
--- mantis-pre2/core/string_api.php 2005-08-08 01:29:06.000000000 +1000
+++ mantis-old2/core/string_api.php 2005-12-20 10:24:53.187500000 +1100
@@ -101,6 +101,8 @@
  $p_string = string_process_bug_link( $p_string );
  $p_string = string_process_bugnote_link( $p_string );
  $p_string = string_process_cvs_link( $p_string );
+ $p_string = string_process_wiki_link($p_string);
+ $p_string = string_process_changeset_link($p_string);
 
  return $p_string;
  }
@@ -143,6 +145,7 @@
  $p_string = string_process_bug_link( $p_string, false );
  $p_string = string_process_bugnote_link( $p_string, false );
  $p_string = string_process_cvs_link( $p_string, false );
+ $p_string = string_process_wiki_link($p_string, false);
 
  return $p_string;
  }
@@ -192,6 +195,54 @@
  $p_string );
  }
 
+ # Process the string, returning full HTML links to a wiki, if configured.
+
+ function string_process_wiki_link($string, $fullHTML = true) {
+ if (!config_get('wiki_link_url')) return $string;
+ if ($fullHTML) return preg_replace_callback('/\[\[(([^\]]*?))\]\]/', 'string_process_wiki_link_callback_fullhtml', $string);
+ return preg_replace_callback('/\[\[(([^\]]*?))\]\]/', 'string_process_wiki_link_callback_nohtml', $string);
+
+ }
+
+ # --------------------
+ # Subsitution callback for the regexp in string_process_wiki_link(); HTML version.
+ function string_process_wiki_link_callback_fullhtml($words) {
+ $p_url_text = $words[2];
+ $p_link = config_get('wiki_link_url').$p_url_text;
+ return '<span class="bracket-link">'. "<a href=\"$p_link\" target=\"_blank\">$p_url_text</a>". '</span> ';
+ }
+
+ # --------------------
+ # Subsitution callback for the regexp in string_process_wiki_link(); plaintext version.
+ function string_process_wiki_link_callback_nohtml($words) {
+ $p_url_text = $words[2];
+ $p_link = config_get('wiki_link_url').$p_url_text;
+ return "$p_url_text ($p_link)";
+ }
+ 
+ # ---------------------
+ # Process 'changeset' links to ViewCVS pages
+ function string_process_changeset_link($string, $fullHTML = true) {
+ if(!config_get('changeset_link_url'))return $string;
+ $re = '/\b(version|revision|rev|changeset)\s+([0-9]+(\.[0-9]+)*)\b/';
+ if($fullHTML)return preg_replace_callback($re,'string_process_changeset_link_callback_fullhtml', $string);
+ return preg_replace_callback($re,'string_process_changeset_link_callback_nohtml', $string);
+ }
+
+ function string_process_changeset_link_callback_fullhtml($words) {
+ $p_link_text = $words[0];
+ $p_changeset = $words[2];
+ $p_url = config_get('changeset_link_url').$p_changeset;
+ return '<span class="viewcvs-link">'. "<a href=\"$p_url\">$p_link_text</a>". "&nbsp;[<a title=\"open in a new window\" href=\"$p_url\" target=_blank>^</a>]".'</span> ';
+ }
+
+ function string_process_changeset_link_callback_nohtml($words) {
+ $p_link_text = $words[0];
+ $p_changeset = $words[2];
+ $p_url = config_get('changeset_link_url').$p_url_text;
+ return "$p_link_text ($p_url)";
+ }
+ 
  # --------------------
  # Process $p_string, looking for bug ID references and creating bug view
  # links for them.
wiki_links.patch (3,675 bytes)   
exk72

exk72

2007-03-26 03:46

reporter   ~0014247

Last edited: 2007-03-26 03:49

stumbled across the attached patch here:

http://www.mantisbt.org/manual/manual.customizing.mantis.custom.functions.php

Issue History

Date Modified Username Field Change
2005-09-22 02:02 pardini New Issue
2005-09-22 02:02 pardini File Added: mantis.wiki.links.patch
2005-12-08 09:09 anarcat Note Added: 0011744
2005-12-08 17:44 jlatour Relationship added related to 0003045
2005-12-08 17:45 jlatour Status new => acknowledged
2005-12-08 17:45 jlatour Relationship added child of 0004181
2006-09-29 03:28 vboctor Note Added: 0013551
2007-03-26 03:45 exk72 File Added: wiki_links.patch
2007-03-26 03:46 exk72 Note Added: 0014247
2007-03-26 03:49 exk72 Note Edited: 0014247