This is a very short tutorial – it should take you about 15 minutes from start to end – that explains how to run your own SVN server, install WebSVN, which is a web front-end to browse your SVN repository, and apply Drupal syntax highlighting to it.
An example can be seen used to be online at websvn.wimleers.com.
I run my own SVN repository, because it's much faster (svn:// FTW), I don't have size limitations, I can ensure it's backed up properly and because it's so easy.
I'm going to assume you've already installed svn on your (Linux) server.
First, decide where you're going to put all your SVN repositories. I put mine at /data/svn. Whenever I use the e command, use your favorite editor instead (for me e is an alias for TextMate). Then go through these simple steps:
cd /data/svn svnadmin create reponame
reponame. This creates a certain directory structure.
cd reponame/conf e svnserve.conf
svnserve daemon behavior for this repository. You probably want to set anon-access = read, or anon-access = none in case it's a private repository, and auth-access = write. You probably want to uncomment password-db = passwd — this indicates you want to use the file passwd as the database with user/password combinations.
e passwdsvnserve daemon:
svnserve -d -r /data/svn
/data/svn, they'll be picked up automatically!
This part is simply amazingly effortless. Assuming you're using Apache, create the proper virtual host, e.g. websvn.example.com. For me this means that Apache looks for files in /data/www/websvn.example.com.
Now, onto the actual installation (2.1.0 was the latest version of WebSVN at the time of writing, you should replace this by the current version):
cd /data/www/websvn.example.com svn co http://websvn.tigris.org/svn/websvn/tags/2.1.0 .
http://websvn.example.com/doc/install.html and there you go, further installation instructions! Most of it is probably even overkill for you. The bases are covered in this tutorial.
chmod 0777 cachecache directory writable.
cd include cp distconfig.php config.php e config.php
config.php file, starting from the default one, and edit it. You should add something like (near line 70):
$config->addRepository('Some repository', 'file:///data/svn/somerepository');
$config->expandTabsBy(2);
If you'd like to tweak the interface a little bit, that is, the left sidebar on the front page, you should edit templates/calm/index.tmpl to your liking. It's plain HTML.
And last but not least: Drupal syntax highlighting – including links to api.drupal.org – within WebSVN.
This is easier than it looks, thanks to the code included in the excellent GeSHi Filter module for Drupal. We'll just borrow their Drupal 6 GeSHi language definition file.
You can either apply the patch I've attached to this tutorial, or do it yourself, by following the steps below.
Download the drupal6.php file that ships with it and place it in the lib/geshi directory, that same directory contains GeSHi language definition files for all other supported languages.
Now we have to map certain file extensions to use this language definition. For that, we'll have to hack WebSVN in one file: include/setup.php. Add this to the $extEnscript array (around line 200):
// Drupal support. '.inc' => 'drupal6', '.install' => 'drupal6', '.module' => 'drupal6', '.profile' => 'drupal6', '.test' => 'drupal6',
Managing this server is very easy: SVN upgrades should come with your operating system's packet manager.
Your changes to WebSVN can be stored through a simple patch:
cd /data/www/websvn.example.com svn add include/config.php svn add lib/geshi/drupal6.php svn diff > mywebsvn.patch
Update: I stopped using WebSVN because it was generating caches of multiple gigabytes in size. Which obviously sucks — it's understandable, but they should offer the option to set a maximum cache size, or a cache TTL.
| Attachment | Size |
|---|---|
| websvn-drupal.patch | 70.1 KB |
Comments
It's not clear for me where
It's not clear for me where i have to put the drupal6.php file. Where is the
lib/geshidirectory exactly? Is it in the websvn root folder?Or do i have install geshi in websvn first?
That's right!
The
lib/geshidirectory is indeed in the websvn root folder!websvn version
Thanks for you quick reply. I had websvn 2.0 installed on ubuntu and that version doesn't support geshi out of the box. websvn 2.1.0 and greater provide supports for Geshi engine.
Now i have installed websvn 2.3.0 and php-geshi package for ubuntu.
The drupal6.php file i have to put into the folder /usr/share/php-geshi/geshi/ .
The new drupal extensions goes to the new $extGeshi array up to line 255.
The new syntax looks like this:
'drupal6' => array('module'),'drupal6' => array('info'),
Now it looks fine with Geshi!
It's better to put all
It's better to put all extensions into the array 'drupal6':
// Drupal support.'drupal6' => array('module', 'info', 'inc', 'install', 'profile', 'test'),
Probably for the new version
Thanks for the clarifications, which are probably only applicable to the new versions :)
Post new comment