View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0006289 | mantisbt | feature | public | 2005-09-22 02:02 | 2007-03-26 03:49 |
| Reporter | pardini | Assigned To | |||
| Priority | normal | Severity | tweak | Reproducibility | N/A |
| Status | acknowledged | Resolution | open | ||
| Product Version | git trunk | ||||
| Summary | 0006289: 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. | ||||
| Tags | No tags attached. | ||||
| Attached Files | 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.
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>". " [<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. | ||||
|
see also bug 0003045 for generalized interwiki linking. |
|
|
pardini, please re-submit your patch. Also it may be worth checking out the Wiki integration feature in Mantis 1.1.0a1 and above. |
|
|
stumbled across the attached patch here: http://www.mantisbt.org/manual/manual.customizing.mantis.custom.functions.php |
|