リビジョン間の差分やコードの色分け表示に対応したsvnリポジトリのブラウザWebSVN。
こんな便利な物があるとは知らず、今までブラウジング目的だけでtrac使っていました。
早速乗り換えるべく設置してみましたが、バージョン2.2.1をUTF-8で使っていると、他の文字コードで化けてファイルの中身が一切表示されなかったりします。
そこでWebSVNの文字化け対策 - okonomiの日記を参考に2.1.1版のパッチを書きました。/usr/bin/nkfを利用しています。
diff -ur websvn-2.2.1/include/svnlook.php websvn/include/svnlook.php
--- websvn-2.2.1/include/svnlook.php 2009-05-10 20:19:20.000000000 +0900
+++ websvn/include/svnlook.php 2009-06-28 09:44:13.000000000 +0900
@@ -558,7 +558,7 @@
// If there's no filename, we'll just deliver the contents as it is to the user
if ($filename == "") {
$path = encodepath($this->getSvnpath($path));
- passthruCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' '.$pipe);
+ passthruCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' '.'|/usr/bin/nkf -w'.$pipe);
return $highlighted;
}
@@ -570,7 +570,7 @@
if ($l == "php") {
// Output the file to the filename
$path = encodepath($this->getSvnpath($path));
- $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' > '.quote($filename);
+ $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).'|/usr/bin/nkf -w'.' > '.quote($filename);
$retcode = 0;
execCommand($cmd, $retcode);
if ($retcode != 0) {
@@ -632,6 +632,7 @@
$path = encodepath($this->getSvnpath($path));
$cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' | '.
+ "/usr/bin/nkf -w |".
$config->enscript." --language=html ".
($l ? "--color --pretty-print=$l" : "")." -o - | ".
$config->sed." -n ".$config->quote."1,/^<PRE.$/!{/^<\\/PRE.$/,/^<PRE.$/!p;}".$config->quote." > $tempname";
@@ -648,7 +649,7 @@
} else {
$highlighted = false;
$path = encodepath(str_replace(DIRECTORY_SEPARATOR, "/", $this->getSvnpath($path)));
- $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' > '.quote($filename);
+ $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' |/usr/bin/nkf -w> '.quote($filename);
$retcode = 0;
execCommand($cmd, $retcode);
if ($retcode != 0) {
@@ -727,7 +728,7 @@
// Output the file to the filename
$path = encodepath($this->getSvnpath($path));
- $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' > '.quote($filename);
+ $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).'|/usr/bin/nkf -w'.' > '.quote($filename);
$retcode = 0;
execCommand($cmd, $retcode);
if ($retcode != 0) {
@@ -777,7 +778,7 @@
// Output the file to a temporary file
$path = encodepath($this->getSvnpath($path));
- $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' > '.$tmp;
+ $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' | /usr/bin/nkf -w > '.$tmp;
$retcode = 0;
execCommand($cmd, $retcode);
if ($retcode != 0) {
@@ -797,12 +798,13 @@
if ($config->useEnscript) {
$path = encodepath($this->getSvnpath($path));
$cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).' | '.
+ "/usr/bin/nkf -w|".
$config->enscript." --language=html ".
($l ? "--color --pretty-print=$l" : "")." -o - | ".
$config->sed." -n ".$config->quote."/^<PRE.$/,/^<\\/PRE.$/p".$config->quote;
} else {
$path = encodepath($this->getSvnpath($path));
- $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev);
+ $cmd = $config->svn." cat ".$this->repConfig->svnParams().quote($path.'@'.$rev).'|/usr/bin/nkf -w';
$pre = true;
}

No Comments yet »
コメント RSS TrackBack URI
コメントをどうぞ