I recently set up my public Subversion repository – I decided that setting up a sourceforge or google code account for my stuff would just be lame, given that I have my own website that I’ve recently started putting effort into making presentable. By default, however, svn displays a very basic browser that doesn’t really give any info and is just ugly:

My 5 year old step-nephew (moptop from here on out) can do better than that. Here’s my how-to for setting up a baller ass looking Subversion tree like this one. Also, I just like ripping on Crowley.
Things we’ll be using:
- Dreamhost panel’s svn manager
- Subversion
- WebSVN – a kick ass php web-based SVN browser
- Enscript – a GNU app for highlighting source code.
We’ll start with the hardest, yet optional part:
Optional: Installing Enscript
If you want WebSVN to have broad highlighting support, follow this how-to to install it before we begin.
Setting up Subversion
- create a subdomain using this page. Mine is svn.mihasya.com.
- go to the dh svn manager and set up you repository. The two examples I’ll use are ked_core and mihasya.com. Make sure you make the repository a “public project”. Set up a username or however many you need. Your respositories can now be found at http://your.svn.subdomain.com/repository_name and locally at /home/username/svn/repository_name
- Do the usual commit/import routine so your repository isn’t empty.
Installing WebSVN
This part is easy. From your DH home folder run: (you should obviously replace the URL with teh latest WebSVN tarball and the svn.mihasya.com with the appropriate subdomain’s folder.
$ wget http://websvn.tigris.org/files/documents/1380/39378/websvn-2.0.tar.gz $ tar -zxvf websvn-2.0.tar.gz $ mv websvn-2.0/* svn.mihasya.com $ rm -Rf websvn-2.0WebSVN is ready to go. Going to your.svn.subdomain.com should now load WebSVN with no repositories.
Configuring WebSVN
Also easy. Now that your WebSVN files are in your subdomain’s folder (/home/mihasya/svn.mihasya.com for me) find the includes/distconfig.php and rename it to includes/config.php.
In that file, find the lines that look like this:
// $config->addRepository('NameToDisplay', 'URL to repository (e.g. file:///c:/svn/proj)');
Copy that, without the comments naturally, and change it to point to your repository. My example:
$config->addRepository('ked_core', 'file:///home/mihasya/svn/ked_core');
Save and refresh the WebSVN page – your repository should now appear. You could be done here, but if you’re not lazy, you could really be a rockstar. Like me.
Optional: Setting up Highlighting Using Enscript
By default, my understanding is that WebSVN only highlights PHP – probably just uses PHP’s highlight functions
Remember how we (might have) set up Enscript earlier? Well, now find this line:
// $config->setEnscriptPath('Path/to/enscript/command/');
Uncomment it and replace it with your path from step 1. Mine:
$config->setEnscriptPath('/home/mihasya/packages/bin');
Then find this and uncomment it:
// $config->useEnscript();Enable Additional Extensions
If you’re like me and use Smarty with somethign like .tpl for files that are really mostly html, do this in the same section to tell Enscript what known filetype to associate that extension with:
$extEnscript['.tpl'] = 'html';
Optional (but awesome): Block Ugly UI Using Rewrite
There is still one problem to be solved. Going to http://svn.mihasya.com/ked_core still goes to the stupid old SVN interface (the one Crowley is using above). You can’t be doin that if you wanna be a rockstar. However, there is one thing it remember (which I initially didn’t): you use the exact same URL when running svn commands. Nothing a little RewriteCond magic can’t fix. Put something like this in the .htaccess file in your svn subdomain’s root folder (where we copied WebSVN earlier):
[ UPDATE: turns out you have to put the RewriteCond statement before every rule (if someone has a better way of doing this, holler); also added the [NC] flag to make the condition not case sensitive, just to be safe ]
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !^SVN [NC]
RewriteRule ^ked_core$ /listing.php?repname=ked_core [R,QSA]
RewriteCond %{HTTP_USER_AGENT} !^SVN [NC]
RewriteRule ^mihasya.com$ /listing.php?repname=mihasya.com [R,QSA]
That second line makes sure that the URL isn’t being called by a Subversion client. Browsers will be directed to the pretty new interface, while svn will operate as usual. Fucking WIN!
Conclusion
Now you can be cool like me and show off your code off your own domain with a sweet ass interface. Not like the chumps with that generic garbage… Explore includes/config.php some more if you want to tailor things more to your tastes.
look at all those fancy pictures you up and deleted… I guess I’ll never get to see them.
[...] publishing my first code, I wend ahead and set up websvn. With syntax highlighting! (Thanks to mihasya) So, if you’re ever curious about what I’ve been coding recently you can check out [...]
great tutorial – very helpful, thanks!
Thanks for this. Helped me get WebSVN up and running in half an hour!
very helpful, even till now, thanks a lot!