MediaWiki SVN Patch: Difference between revisions

From BlueM
Jump to navigation Jump to search
(MediaWiki SVN Patch)
 
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Patch für die registrierung der magischen Wörter '''Bug''' (→ Bugzilla) und '''Rev''' oder '''Rev.''' (→ ViewVC) in der MediaWiki-Installation (Idee von [http://oss.segetech.com/bugzilla-svn-wiki.html#MediaWiki hier]).
''This no longer works with the current Wikimedia installation''


<diff>
Patch für die registrierung der magischen Wörter '''Bug''' (&rarr; Bugzilla) und '''Rev''' oder '''Rev.''' (&rarr; WebSVN) in der MediaWiki-Installation (Idee von [http://oss.segetech.com/bugzilla-svn-wiki.html#MediaWiki hier]).
Index: includes/Parser.php
 
<source lang="diff">
Index: Parser.php
===================================================================
===================================================================
--- includes/Parser.php (revision 20837)
--- Parser.php (revision 49595)
+++ includes/Parser.php (working copy)
+++ Parser.php (working copy)
@@ -1050,7 +1050,9 @@
@@ -1038,7 +1038,11 @@
                                      (?: 97[89] [\ \-]? )?  # optional 13-digit ISBN prefix
    (?: 97[89] [\ \-]? )?  # optional 13-digit ISBN prefix
                                      (?: [0-9]  [\ \-]? ){9} # 9 digits with opt. delimiters
    (?: [0-9]  [\ \-]? ){9} # 9 digits with opt. delimiters
                                      [0-9Xx]                # check digit
    [0-9Xx]                # check digit
-                                   \b)
-     \b)
+                                   \b) |
+     \b) |
+ Bug\s+(\d+) | # Bug numbers as m[3]
+ Bug\s+(\d+) | # m[6]: Bug numbers
+ Rev\.?\s+(\d+) # Rev numbers as m[4]
+ Rev\.?\s+(\d+) | # m[7]: Rev numbers
+ (?:doi|DOI):\s?
+     ([a-zA-Z0-9\.,/\-\[\]\(\):;]+[a-zA-Z0-9]) # m[8]: DOI
  )!x', array( &$this, 'magicLinkCallback' ), $text );
  )!x', array( &$this, 'magicLinkCallback' ), $text );
  wfProfileOut( __METHOD__ );
  wfProfileOut( __METHOD__ );
  return $text;
  return $text;
@@ -1060,7 +1062,8 @@
@@ -1054,16 +1058,28 @@
  if ( substr( $m[0], 0, 1 ) == '<' ) {
  } elseif ( isset( $m[3] ) && strval( $m[3] ) !== '' ) {
  # Skip HTML element
  # Free external link
  return $m[0];
  return $this->makeFreeExternalLink( $m[0] );
- } elseif ( substr( $m[0], 0, 4 ) == 'ISBN' ) {
- } elseif ( isset( $m[4] ) && strval( $m[4] ) !== '' ) {
+ }  
+ } elseif ( (isset( $m[4] ) && strval( $m[4] ) !== '') || in_array(substr($m[0], 0, 3), array('Bug', 'Rev', 'doi')) ) {
+ elseif ( substr( $m[0], 0, 4 ) == 'ISBN' ) {
# RFC or PMID
$isbn = $m[2];
  if ( substr( $m[0], 0, 3 ) === 'RFC' ) {
$num = strtr( $isbn, array(
- $keyword = 'RFC';
'-' => '',
+ $keyword = 'RFC ';
@@ -1071,7 +1074,8 @@
$text = '<a href="' .
$titleObj->escapeLocalUrl( "isbn=$num" ) .
"\" class=\"internal\">ISBN $isbn</a>";
- } else {
+ }
+ else {
  if ( substr( $m[0], 0, 3 ) == 'RFC' ) {
$keyword = 'RFC';
  $urlmsg = 'rfcurl';
  $urlmsg = 'rfcurl';
@@ -1080,6 +1084,14 @@
$id = $m[4];
$keyword = 'PMID';
} elseif ( substr( $m[0], 0, 4 ) === 'PMID' ) {
- $keyword = 'PMID';
+ $keyword = 'PMID ';
  $urlmsg = 'pubmedurl';
  $urlmsg = 'pubmedurl';
  $id = $m[1];
  $id = $m[4];
+ } else if ( substr( $m[0], 0, 3 ) == 'Bug' ) {
+ } else if ( substr( $m[0], 0, 3 ) == 'Bug' ) {
+ $keyword = 'Bug';
+ $keyword = 'Bug ';
+ $urlmsg = 'bugurl';
+ $urlmsg = 'bugurl';
+ $id = $m[3];
+ $id = $m[6];
+ } else if ( substr( $m[0], 0, 3 ) == 'Rev' ) {
+ } else if ( substr( $m[0], 0, 3 ) == 'Rev' ) {
+ $keyword = 'Rev';
+ $keyword = 'Rev ';
+ $urlmsg = 'revurl';
+ $urlmsg = 'revurl';
+ $id = $m[4];
+ $id = $m[7];
+ } elseif ( strtolower(substr( $m[0], 0, 3 )) == 'doi' ) {
+ $keyword = 'doi:';
+ $urlmsg = 'doiurl';
+ $id = $m[8];
  } else {
  } else {
  throw new MWException( __METHOD__.': unrecognised match type "' .
  throw new MWException( __METHOD__.': unrecognised match type "' .
  substr($m[0], 0, 20 ) . '"' );
  substr($m[0], 0, 20 ) . '"' );
@@ -1071,7 +1087,7 @@
$url = wfMsg( $urlmsg, $id);
$sk = $this->mOptions->getSkin();
$la = $sk->getExternalLinkAttributes( $url, $keyword.$id );
- return "<a href=\"{$url}\"{$la}>{$keyword} {$id}</a>";
+ return "<a href=\"{$url}\"{$la}>{$keyword}{$id}</a>";
} elseif ( isset( $m[5] ) && strval( $m[5] ) !== '' ) {
# ISBN
$isbn = $m[5];
</diff>
<diff>
Index: languages/messages/MessagesEn.php
Index: languages/messages/MessagesEn.php
===================================================================
===================================================================
Line 61: Line 74:
  'rfcurl' =>  'http://www.ietf.org/rfc/rfc$1.txt',
  'rfcurl' =>  'http://www.ietf.org/rfc/rfc$1.txt',
+'bugurl' => '/bugzilla/show_bug.cgi?id=$1',
+'bugurl' => '/bugzilla/show_bug.cgi?id=$1',
+'revurl' => '/viewvc/viewvc.cgi/BlauesModell/BlauesModell/trunk/?pathrev=$1',
+'revurl' => '/websvn/listing.php?repname=BlueM&path=%2F&rev=$1&sc=1',
  'pubmedurl' =>  'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$1',
  'pubmedurl' =>  'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$1',
  'alphaindexline' => "$1 to $2",
  'alphaindexline' => "$1 to $2",
  'version' => 'Version',
  'version' => 'Version',
</diff>
</source>

Latest revision as of 17:14, 7 December 2013

This no longer works with the current Wikimedia installation

Patch für die registrierung der magischen Wörter Bug (→ Bugzilla) und Rev oder Rev. (→ WebSVN) in der MediaWiki-Installation (Idee von hier).

Index: Parser.php
===================================================================
--- Parser.php	(revision 49595)
+++ Parser.php	(working copy)
@@ -1038,7 +1038,11 @@
 				    (?: 97[89] [\ \-]? )?   # optional 13-digit ISBN prefix
 				    (?: [0-9]  [\ \-]? ){9} # 9 digits with opt. delimiters
 				    [0-9Xx]                 # check digit
-				    \b)
+				    \b) |
+				Bug\s+(\d+) |				# m[6]: Bug numbers
+				Rev\.?\s+(\d+) |			# m[7]: Rev numbers
+				(?:doi|DOI):\s?
+				    ([a-zA-Z0-9\.,/\-\[\]\(\):;]+[a-zA-Z0-9]) 	# m[8]: DOI
 			)!x', array( &$this, 'magicLinkCallback' ), $text );
 		wfProfileOut( __METHOD__ );
 		return $text;
@@ -1054,16 +1058,28 @@
 		} elseif ( isset( $m[3] ) && strval( $m[3] ) !== '' ) {
 			# Free external link
 			return $this->makeFreeExternalLink( $m[0] );
-		} elseif ( isset( $m[4] ) && strval( $m[4] ) !== '' ) {
+		} elseif ( (isset( $m[4] ) && strval( $m[4] ) !== '') || in_array(substr($m[0], 0, 3), array('Bug', 'Rev', 'doi')) ) {
 			# RFC or PMID
 			if ( substr( $m[0], 0, 3 ) === 'RFC' ) {
-				$keyword = 'RFC';
+				$keyword = 'RFC ';
 				$urlmsg = 'rfcurl';
 				$id = $m[4];
 			} elseif ( substr( $m[0], 0, 4 ) === 'PMID' ) {
-				$keyword = 'PMID';
+				$keyword = 'PMID ';
 				$urlmsg = 'pubmedurl';
 				$id = $m[4];
+			} else if ( substr( $m[0], 0, 3 ) == 'Bug' ) {
+				$keyword = 'Bug ';
+				$urlmsg = 'bugurl';
+				$id = $m[6];
+			} else if ( substr( $m[0], 0, 3 ) == 'Rev' ) {
+				$keyword = 'Rev ';
+				$urlmsg = 'revurl';
+				$id = $m[7];
+			} elseif ( strtolower(substr( $m[0], 0, 3 )) == 'doi' ) {
+				$keyword = 'doi:';
+				$urlmsg = 'doiurl';
+				$id = $m[8];
 			} else {
 				throw new MWException( __METHOD__.': unrecognised match type "' .
 					substr($m[0], 0, 20 ) . '"' );
@@ -1071,7 +1087,7 @@
 			$url = wfMsg( $urlmsg, $id);
 			$sk = $this->mOptions->getSkin();
 			$la = $sk->getExternalLinkAttributes( $url, $keyword.$id );
-			return "<a href=\"{$url}\"{$la}>{$keyword} {$id}</a>";
+			return "<a href=\"{$url}\"{$la}>{$keyword}{$id}</a>";
 		} elseif ( isset( $m[5] ) && strval( $m[5] ) !== '' ) {
 			# ISBN
 			$isbn = $m[5];
</diff>

<diff>
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php	(revision 20837)
+++ languages/messages/MessagesEn.php	(working copy)
@@ -1544,6 +1544,8 @@
 
 'isbn'	=> 'ISBN',
 'rfcurl' =>  'http://www.ietf.org/rfc/rfc$1.txt',
+'bugurl' => '/bugzilla/show_bug.cgi?id=$1',
+'revurl' => '/websvn/listing.php?repname=BlueM&path=%2F&rev=$1&sc=1',
 'pubmedurl' =>  'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$1',
 'alphaindexline' => "$1 to $2",
 'version'		=> 'Version',