MediaWiki SVN Patch: Difference between revisions
Jump to navigation
Jump to search
(MediaWiki SVN Patch) |
mNo edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
''This no longer works with the current Wikimedia installation'' | |||
<diff> | Patch für die registrierung der magischen Wörter '''Bug''' (→ Bugzilla) und '''Rev''' oder '''Rev.''' (→ WebSVN) in der MediaWiki-Installation (Idee von [http://oss.segetech.com/bugzilla-svn-wiki.html#MediaWiki hier]). | ||
Index: | |||
<source lang="diff"> | |||
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+) | # | + Bug\s+(\d+) | # m[6]: Bug numbers | ||
+ Rev\.?\s+(\d+) | + 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; | ||
@@ - | @@ -1054,16 +1058,28 @@ | ||
} elseif ( isset( $m[3] ) && strval( $m[3] ) !== '' ) { | |||
# | # Free external link | ||
return $m[0]; | return $this->makeFreeExternalLink( $m[0] ); | ||
- } elseif ( | - } 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 '; | |||
if ( substr( $m[0], 0, 3 ) == 'RFC' ) { | |||
$urlmsg = 'rfcurl'; | $urlmsg = 'rfcurl'; | ||
$id = $m[4]; | |||
} elseif ( substr( $m[0], 0, 4 ) === 'PMID' ) { | |||
- $keyword = 'PMID'; | |||
+ $keyword = 'PMID '; | |||
$urlmsg = 'pubmedurl'; | $urlmsg = 'pubmedurl'; | ||
$id = $m[ | $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[ | + $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[ | + $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' => '/ | +'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', | ||
</ | </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',