View Issue Details

IDProjectCategoryView StatusLast Update
0003045mantisbtfeaturepublic2007-12-07 16:51
Reporterlele Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status acknowledgedResolutionopen 
Summary0003045: Generalizing "cvs:" replacement
Description

It would be nice having a general mechanism to handle the replacement of "arbitrary" prefixes, not just "cvs:", to make it more friendly linking to other common services around, or other trackers.

Additional Information

I use Mantis combined with an intranet wiki, where I usually have a page, say "BugN325" that carries the details behind that particular bug. I'd like to have a simple prefix, say "wiki:BugN325" that expands to http:whatever/BugN325.

TagsNo tags attached.

Relationships

related to 0006289 acknowledged Patch for handling [[Wiki-style]] links (just like CVSWeb, but for wikis) 
child of 0004181 closed Features in Mantis 1.1 release 

Activities

anarcat

anarcat

2004-12-03 23:18

reporter   ~0008507

actually, this wouldn't be so hard to do. Mantis would need an "interwiki map", the same way wiki work now.

cf. http://www.usemod.com/cgi-bin/mb.pl?InterWiki

So string_process_cvs_link() could be generalized to do some interwiki parsing. There is already a lot of code floating around to do this, best place to start is probably http://phpwiki.sf.net.

http://cvs.sourceforge.net/viewcvs.py/phpwiki/phpwiki/lib/InlineParser.php?rev=1.61&view=auto

function getMatchRegexp () {
    global $request;
    $map = getInterwikiMap();
    return "(?<! [[:alnum:]])" . $map->getRegexp(). ": \S+ (?<![ ,.?;! \] \) \" \' ])";
}

The regexp are generated using:

function _getRegexp () {
    if (!$this->_map)
        return '(?:(?!a)a)'; //  Never matches.

    foreach (array_keys($this->_map) as $moniker)
        $qkeys[] = preg_quote($moniker, '/');
    return "(?:" . join("|", $qkeys) . ")";
}

in http://cvs.sourceforge.net/viewcvs.py/phpwiki/phpwiki/lib/PageType.php?rev=1.36&view=auto

2005-02-05 00:00

 

string_api.patch (1,070 bytes)   
--- core/string_api.php.orig	Fri Feb  4 23:28:17 2005
+++ core/string_api.php	Fri Feb  4 23:53:07 2005
@@ -94,6 +94,7 @@
 		$p_string = string_insert_hrefs( $p_string );
 		$p_string = string_process_bug_link( $p_string );
 		$p_string = string_process_cvs_link( $p_string );
+		$p_string = string_process_interwiki_link( $p_string );
 
 		return $p_string;
 	}
@@ -158,6 +159,18 @@
 		return preg_replace( '/cvs:([^\.\s:,\?!]+(\.[^\.\s:,\?!]+)*)(:)?(\d\.[\d\.]+)?([\W\s])?/i',
 							 $t_replace_with,
 							 $p_string );
+	}
+
+	function string_process_interwiki_link( $p_string, $p_include_anchor=true ) {
+		$t_interwiki_map = config_get( 'interwiki_map' );
+		
+		foreach (array_keys($t_interwiki_map) as $moniker) {
+			$mkeys[] = preg_quote($moniker, '/');
+		}
+		$regexp = "/(?<![[:alnum:]])" .  "(" . join("|", $mkeys) . ")". ":([[:alnum:]]+)(?<![ ,.?;!\]\)\"\'])/e";
+		$t_replace_with = '\'<a href="\'.$t_interwiki_map[\'\\1\'].\'\\2" target="_new">\\2</a>\'';
+
+		return preg_replace($regexp, $t_replace_with, $p_string);
 	}
 
 	# --------------------
string_api.patch (1,070 bytes)   
anarcat

anarcat

2005-02-05 00:04

reporter   ~0009217

I've successfully patched Mantis to implement InterWiki. This is pretty neat: with this patch, we basically have Wiki-like capabilities within mantis.

This does need extra modifications, not covered by the patch, to the config_inc.php file. What I've done is to plainly add something like this:

    $g_interwiki_map = array(&quot;AbbeNormal&quot; => &quot;http://www.ourpla.net/cgi-bin/pikie.cgi?&quot;,

"AcadWiki" => "http://xarch.tu-graz.ac.at/autocad/wiki/&quot;,
"Acronym" => "http://www.acronymfinder.com/af-query.asp?String=exact&amp;Acronym=&quot;,
"Advogato" => "http://www.advogato.org/&quot;,
"AIWiki" => "http://www.ifi.unizh.ch/ailab/aiwiki/aiw.cgi?&quot;,
...
);

And it works. I've created this array using the interwiki.map file from PhpWiki:

http://cvs.sourceforge.net/viewcvs.py/phpwiki/phpwiki/lib/interwiki.map?rev=1.26&amp;view=markup

This could also be done in Mantis, quite easily: just parse a text file to create an array with it. No biggy..

I just didn't want to make a policy out of it, so I hardcoded it for now. Maybe you guys will want to do it differently.

Another thing: maybe the regexp there is too wide and might badly interact with other already existing parsers. I haven't seen serious problems yet for myself.

anarcat

anarcat

2005-02-05 10:50

reporter   ~0009219

Last edited: 2005-02-05 10:55

BTW, the first patch (string_api.patch) also applies (fuzzily) on 0.19.2. Still, I made a new patch explicitely for 0.19.2, but that also includes an example of a InterWiki map for config_defaults.inc.php.

2005-02-05 10:54

 

interwiki-0.19.2.patch (7,829 bytes)   
--- core/string_api.php.orig	Fri Dec 10 22:57:02 2004
+++ core/string_api.php	Sat Feb  5 10:50:06 2005
@@ -96,6 +96,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_interwiki_link( $p_string );
 
 		return $p_string;
 	}
@@ -161,6 +162,18 @@
 		return preg_replace( '/cvs:([^\.\s:,\?!]+(\.[^\.\s:,\?!]+)*)(:)?(\d\.[\d\.]+)?([\W\s])?/i',
 							 $t_replace_with,
 							 $p_string );
+	}
+
+	function string_process_interwiki_link( $p_string, $p_include_anchor=true ) {
+		$t_interwiki_map = config_get( 'interwiki_map' );
+		
+		foreach (array_keys($t_interwiki_map) as $moniker) {
+			$mkeys[] = preg_quote($moniker, '/');
+		}
+		$regexp = "/(?<![[:alnum:]])" .  "(" . join("|", $mkeys) . ")". ":([[:alnum:]]+)(?<![ ,.?;!\]\)\"\'])/e";
+		$t_replace_with = '\'<a href="\'.$t_interwiki_map[\'\\1\'].\'\\2" target="_new">\\2</a>\'';
+
+		return preg_replace($regexp, $t_replace_with, $p_string);
 	}
 
 	# --------------------
--- config_defaults_inc.php.orig	Sat Feb  5 10:52:42 2005
+++ config_defaults_inc.php	Sat Feb  5 10:52:45 2005
@@ -1005,6 +1005,121 @@
 	# http://www.php.net/manual/en/function.preg-match-all.php
 	$g_source_control_regexp = "/\bissue [#]{0,1}(\d+)\b/i";
 
+	$g_interwiki_map = array("AbbeNormal" => "http://www.ourpla.net/cgi-bin/pikie.cgi?",
+"AcadWiki" => "http://xarch.tu-graz.ac.at/autocad/wiki/",
+"Acronym" => "http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=",
+"Advogato" => "http://www.advogato.org/",
+"AIWiki" => "http://www.ifi.unizh.ch/ailab/aiwiki/aiw.cgi?",
+"ALife" => "http://news.alife.org/wiki/index.php?",
+"AndStuff" => "http://andstuff.org/wiki.php?",
+"Annotation" => "http://bayle.stanford.edu/crit/nph-med.cgi/",
+"AnnotationWiki" => "http://www.seedwiki.com/page.cfm?wikiid=368&doc=",
+"AwarenessWiki" => "http://taoriver.net/aware/",
+"BcWireless" => "http://www.bcwireless.net/wiki-moinmoin/moin.cgi/",
+"BenefitsWiki" => "http://www.benefitslink.com/cgi-bin/wiki.cgi?",
+"BridgesWiki" => "http://c2.com/w2/bridges/",
+"bsdWiki" => "http://profile.sh/syswiki/index.php?",
+"C2find" => "http://c2.com/cgi/wiki?FindPage&value=",
+"Cache" => "http://www.google.com/search?q=cache:",
+"Category" => "Category",
+"CLiki" => "http://ww.telent.net/cliki/",
+"CmWiki" => "http://www.ourpla.net/cgi-bin/wiki.pl?",
+"CreationMatters" => "http://www.ourpla.net/cgi-bin/wiki.pl?",
+"DejaNews" => "http://www.deja.com/=dnc/getdoc.xp?AN=",
+"DeWikiPedia" => "http://de.wikipedia.org/wiki/",
+"Dict" => "http://www.dict.org/bin/Dict?Database=*&Form=Dict1&Strategy=*&Query=",
+"Dictionary" => "http://www.dict.org/bin/Dict?Database=*&Form=Dict1&Strategy=*&Query=",
+"DiveIntoOsx" => "http://diveintoosx.org/",
+"DocBook" => "http://docbook.org/wiki/moin.cgi/",
+"DolphinWiki" => "http://www.object-arts.com/wiki/html/Dolphin/",
+"DseWiki" => "http://www.wikiservice.at/dse/wiki.cgi?",
+"EfnetCeeWiki" => "http://purl.net/wiki/c/",
+"EfnetCppWiki" => "http://purl.net/wiki/cpp/",
+"EfnetPythonWiki" => "http://purl.net/wiki/python/",
+"EfnetXmlWiki" => "http://purl.net/wiki/xml/",
+"EljWiki" => "http://elj.sourceforge.net/phpwiki/index.php/",
+"EmacsWiki" => "http://www.emacswiki.org/cgi-bin/wiki.pl?",
+"EoWikiPedia" => "http://eo.wikipedia.org/",
+"FinalEmpire" => "http://final-empire.sourceforge.net/cgi-bin/wiki.pl?",
+"Foldoc" => "http://www.foldoc.org/foldoc/foldoc.cgi?",
+"FoxWiki" => "http://fox.wikis.com/wc.dll?Wiki~",
+"FreeBSDman" => "http://www.FreeBSD.org/cgi/man.cgi?apropos=1&query=",
+"FreeNetworks" => "http://www.freenetworks.org/index.cgi/",
+"FreshMeat" => "http://freshmeat.net/",
+"FrWikiPedia" => "http://fr.wikipedia.org/",
+"Google" => "http://www.google.com/search?q=",
+"GoogleGroups" => "http://groups.google.com/groups?q=",
+"GreenCheese" => "http://www.greencheese.org/",
+"HammondWiki" => "http://www.dairiki.org/HammondWiki/index.php3?",
+"Haribeau" => "http://wiki.haribeau.de/cgi-bin/wiki.pl?",
+"IAWiki" => "http://www.IAwiki.net/",
+"IMDB" => "http://us.imdb.com/Title?",
+"ISBN" => "http://www.amazon.com/exec/obidos/ISBN=",
+"JargonFile" => "http://sunir.org/apps/meta.pl?wiki=JargonFile&redirect=",
+"JiniWiki" => "http://www.cdegroot.com/cgi-bin/jini?",
+"JspWiki" => "http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=",
+"KmWiki" => "http://www.voght.com/cgi-bin/pywiki?",
+"KnowHow" => "http://www2.iro.umontreal.ca/~paquetse/cgi-bin/wiki.cgi?",
+"LanifexWiki" => "http://opt.lanifex.com/cgi-bin/wiki.pl?",
+"LegoWiki" => "http://www.object-arts.com/wiki/html/Lego-Robotics/",
+"LinuxWiki" => "http://www.linuxwiki.de/",
+"LugKR" => "http://lug-kr.sourceforge.net/cgi-bin/lugwiki.pl?",
+"MathSongsWiki" => "http://SeedWiki.com/page.cfm?wikiid=237&doc=",
+"MbTest" => "http://www.usemod.com/cgi-bin/mbtest.pl?",
+"MeatBall" => "http://www.usemod.com/cgi-bin/mb.pl?",
+"MetaWiki" => "http://sunir.org/apps/meta.pl?",
+"MetaWikiPedia" => "http://meta.wikipedia.com/wiki/",
+"MoinMoin" => "http://purl.net/wiki/moin/",
+"MuWeb" => "http://www.dunstable.com/scripts/MuWebWeb?",
+"NetVillage" => "http://www.netbros.com/?",
+"OpenWiki" => "http://openwiki.com/?",
+"OrgPatterns" => "http://www.bell-labs.com/cgi-user/OrgPatterns/OrgPatterns?",
+"PangalacticOrg" => "http://www.pangalactic.org/Wiki/",
+"PersonalTelco" => "http://www.personaltelco.net/index.cgi/",
+"php-function" => "http://www.php.net/%s",
+"php-lookup" => "http://www.php.net/manual-lookup.php?pattern=",
+"PhpWiki" => "http://phpwiki.sourceforge.net/phpwiki/index.php?",
+"PhpWikiCvs" => "http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/phpwiki/phpwiki/",
+"PhpWikiDemo" => "http://phpwiki.sourceforge.net/demo/",
+"Pikie" => "http://pikie.darktech.org/cgi/pikie?",
+"PolitizenWiki" => "http://www.politizen.com/wiki.asp?",
+"PlWikiPedia" => "http://pl.wikipedia.org/",
+"PPR" => "http://c2.com/cgi/wiki?",
+"PurlNet" => "http://purl.oclc.org/NET/",
+"PythonInfo" => "http://www.python.org/cgi-bin/moinmoin/",
+"PythonWiki" => "http://www.pythonwiki.de/",
+"PyWiki" => "http://www.voght.com/cgi-bin/pywiki?",
+"RFC" => "http://www.faqs.org/rfcs/rfc%s.html",
+"SeaPig" => "http://www.seapig.org/ ",
+"SeattleWireless" => "http://seattlewireless.net/?",
+"SenseisLibrary" => "http://senseis.xmp.net/?",
+"Shakti" => "http://cgi.algonet.se/htbin/cgiwrap/pgd/ShaktiWiki/",
+"SourceForge" => "http://sourceforge.net/",
+"Squeak" => "http://minnow.cc.gatech.edu/squeak/",
+"StrikiWiki" => "http://ch.twi.tudelft.nl/~mostert/striki/teststriki.pl?",
+"SVGWiki" => "http://www.protocol7.com/svg-wiki/default.asp?",
+"Tavi" => "http://tavi.sourceforge.net/index.php?",
+"Thesaurus" => "http://www.thesaurus.com/cgi-bin/search?config=roget&words=",
+"Thinki" => "http://www.thinkware.se/cgi-bin/thinki.cgi/",
+"TmNet" => "http://www.technomanifestos.net/?",
+"TMwiki" => "http://www.EasyTopicMaps.com/?page=",
+"TWiki" => "http://twiki.org/cgi-bin/view/",
+"TwistedWiki" => "http://purl.net/wiki/twisted/",
+"Unreal" => "http://wiki.beyondunreal.com/wiki/",
+"UseMod" => "http://www.usemod.com/cgi-bin/wiki.pl?",
+"VisualWorks" => "http://wiki.cs.uiuc.edu/VisualWorks/",
+"WebDevWikiNL" => "http://www.promo-it.nl/WebDevWiki/index.php?page=",
+"WebSeitzWiki" => "http://webseitz.fluxent.com/wiki/",
+"Why" => "http://clublet.com/c/c/why?",
+"Wiki" => "http://c2.com/cgi/wiki?",
+"WikiPedia" => "http://www.wikipedia.com/wiki/",
+"WikiWorld" => "http://WikiWorld.com/wiki/index.php/",
+"YpsiEyeball" => "http://sknkwrks.dyndns.org:1957/writewiki/wiki.pl?",
+"ZWiki" => "http://www.zwiki.org/",
+"KoumbitWiki" => "http://koumbit.org/wiki/",
+"OrangeSeeds" => "http://orangeseeds.net/wiki/",
+);
+
 	# --- Bug Linking ---------------
 	# if a number follows this tag it will create a link to a bug.
 	# eg. for # a link would be #45
interwiki-0.19.2.patch (7,829 bytes)   
anarcat

anarcat

2005-11-01 22:42

reporter   ~0011579

small update: the patch still applies cleanly on 1.0.0rc3:

mantis# patch -p 0 < ../interwiki-0.19.2.patch
patching file core/string_api.php
Hunk 0000001 succeeded at 101 (offset 5 lines).
Hunk 0000002 succeeded at 191 with fuzz 1 (offset 29 lines).
patching file config_defaults_inc.php
Hunk 0000001 succeeded at 1083 with fuzz 2 (offset 78 lines).

anarcat

anarcat

2005-11-01 22:56

reporter   ~0011580

it also applies similarly to HEAD.

anarcat

anarcat

2005-12-08 09:10

reporter   ~0011745

this summary should be renamed "interwiki linking"

polzin

polzin

2006-01-24 10:04

reporter   ~0012012

An additional useful feature (which I am just planing to patch into Mantis) could be a link to a "BugXXXX"-wiki page on each bug page XXXX. But probably this is to specific for a general solution and patching the top_include_page should be easy enought.

tandler

tandler

2006-12-08 03:31

reporter   ~0013787

The attachments are missing ... could someone maybe upload them again? Thanks!

webwesen

webwesen

2007-12-07 16:51

reporter   ~0016402

the attachments are still missing...
anyone has a copy?

Issue History

Date Modified Username Field Change
2003-03-08 02:08 lele New Issue
2004-12-03 23:18 anarcat Note Added: 0008507
2005-02-05 00:00 anarcat File Added: string_api.patch
2005-02-05 00:04 anarcat Note Added: 0009217
2005-02-05 10:50 anarcat Note Added: 0009219
2005-02-05 10:54 anarcat File Added: interwiki-0.19.2.patch
2005-02-05 10:55 anarcat Note Edited: 0009219
2005-11-01 22:42 anarcat Note Added: 0011579
2005-11-01 22:56 anarcat Note Added: 0011580
2005-12-08 09:10 anarcat Note Added: 0011745
2005-12-08 09:28 jlatour Status new => acknowledged
2005-12-08 09:31 jlatour Relationship added child of 0004181
2005-12-08 17:44 jlatour Relationship added related to 0006289
2006-01-24 10:04 polzin Note Added: 0012012
2006-12-08 03:31 tandler Note Added: 0013787
2007-12-07 16:51 webwesen Note Added: 0016402