LoginSignup
0
0

More than 1 year has passed since last update.

WebSVN 設定の小ネタ

Last updated at Posted at 2022-06-08

業務上、WebSVNをインストール&そこそこカスタマイズする機会に恵まれたので、その時のメモです。

1. WebSVNとは

指定したSubversionリポジトリの履歴や差分をWebベースで表示してくれる、PHPベースのオープンソースソフトウエア(OSS)です。
動作は軽く、特に複雑な設定も必要なく利用できます。
https://websvnphp.github.io/


2. WebSVNのインストール&初期設定

ネットで検索すればいくつも出てきますが、とりあえずおさらい。

  1. ダウンロードサイトからZIPファイルをダウンロードし、Webサーバーのドキュメントルート配下の適当なディレクトリに展開します。
      https://github.com/websvnphp/websvn/releases

  2. 展開したディレクトリのinclude/distconfig.phpをコピーして、include/config.phpファイルを作成します

  3. include/config.phpファイルのリポジトリ設定を行います。

include/config.php (91行目付近)
// Local repositories (without and with optional group):
// Note that the local URL to the repository depends on your platform:
//   Unix-like: file:///path/to/rep
//   Windows: file:///c:/svn/proj
//
$config->addRepository('WebApps', 'file:///var/www/html/subversion/webapps/');
// $config->addRepository('NameToDisplay', 'local URL', 'group');

4.(必要があれば)SVNのパスの所在なども設定します

include/config.php (38行目付近)
// Configure these lines if your commands aren't on your path.
//
// $config->setSvnCommandPath('/path/to/svn/command/'); //  e.g. c:\\program files\\subversion\\bin
$config->setSvnCommandPath('/usr/sbin'); //  e.g. c:\\program files\\subversion\\bin
// $config->setSvnAuthzCommandPath('/path/to/svnauthz/command/'); //  e.g. c:\\program files\\subversion\\bin\tools
// $config->setDiffPath('/path/to/diff/command/');

画面の初期表示はこんな感じです。
image.png


3. その他設定

残念ながら、WebSVNの設定に関する(特に日本語の)情報が少ないので:worried:、仕方なくいろいろ設定を調整する中で分かったことを。

1) 画面テンプレートの設定

初期状態では calm/BlueGray/Elegantという3種類のテンプレートが用意されていて、初期値では画面右上のリストから自由に選択できるようになっています。
特定のテンプレートのみで固定したい場合は、同じくinclude/config.phpファイルの他のテンプレートの設定をコメントにします。

include/config.php (137行目付近)
// {{{ LOOK AND FEEL ---
//
// Add custom template paths or comment out templates to modify the list of user selectable templates.
// The first added template serves as a default.

$config->addTemplatePath($locwebsvnreal.'/templates/calm/');
//$config->addTemplatePath($locwebsvnreal.'/templates/BlueGrey/');
//$config->addTemplatePath($locwebsvnreal.'/templates/Elegant/');

(修正後)
image.png

2) 日付の表示

初期状態では、画面のすべての日付表示が「○日前」などとなっており、これでは非常に分かりにくい!
次の設定をコメントアウトして、通常の日付表示にします。

include/config.php(194行目付近)
// By default, WebSVN displays the age of the last modification.
// Alternativly the date of the last modification can be shown.
// To show dates instead of ages uncomment this line.

$config->setShowAgeInsteadOfDate(false);

(修正後)
image.png

3) ファイルダウンロードの設定

初期状態では分からないのですが、実はWebSVNには各リビジョンのファイルを一括ダウンロードしたり、各履歴の内容を個別にダウンロードする機能が備わっています。

これを有効にするには、まずinclude/configclass.phpファイルの以下の箇所を変更します。
これで、各画面にダウンロードボタンが出現します。

include/configclass.php(661行目付近)
	var $useParsedown = false;
	var $inlineMimeTypes = array();
//	var $allowDownload = false;
	var $allowDownload = true;

image.png
次にinclude/config.phpファイルで、リビジョン単位で一括してファイルをダウンロードする場合のファイル形式を指定します。

include/config.php(326行目付近)
// Set download modes
// $config->setDefaultFileDlMode('plain');
// $config->setDefaultDirectoryDlMode('gzip');
$config->setDefaultDirectoryDlMode('zip');		// ディレクトリ単位はzipでダウンロード

あとリポジトリの構成にもよりますが、ディレクトリ構成のどのレベルからダウンロード対象とするかを指定します。
以下は、全レベルを対象とする設定です。

include/config.php(340行目付近)
// If your project is arranged with trunk, tags and branches at the root level, then a value of 2
// would allow the downloading of directories within branches/tags while disallowing the download
// of the entire branches or tags directories. This would also stop downloading of the trunk, but
// see after for path exceptions.
//
// Change the line below to set the download level across all your repositories.
//$config->setMinDownloadLevel(2);
$config->setMinDownloadLevel(0);

4.ちょっとしたカスタマイズ

1) ダウンロードファイル名の変更

現場のニーズから発生したカスタマイズ例(ダウンロードファイルにタイムスタンプを付与する)です。
WebSVNディレクトリ配下にあるdl.phpを次のように修正します。

dl.php(123行目付近)
//$plainfilename = $archiveName;
$plainfilename = str_replace(".conf", "_" . date("Ymd") . "_" . date("Hi") . ".conf", $archiveName);
$archiveName .= '.r'.$rev;
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0