Saturday, January 29, 2011

Use WebSVN as default HTML view

Hello *,

when opening an subversion URL like https://server.local/svn/reproname using a normal webbrowser I get a (not very nice but useful) webpage showing me the files of the highest revision of the repository.

Is it possible to change this HTML-view to use WebSVN instead? So I want to use the same URL for TortoiseSVN which then browses the repository using WebDAV and for browsing it with a webbrowser getting the nice interface of WebSVN.

I am using Apache 2.2 on an Win 2003 Server with mod_dav_svn.

Thanks in advance for any help.

sc911

  • I too tried to get it to work like this, but I don't think it's possible. According to this site, mod_dav_svn generates the html page you see, and it only supports simple skinning using xslt.

    What I did was use a new virtual host for my WebSVN content (eg https://websvn.server.local/svn/reponame).

  • What about using mod_rewrite? You could do something like this:-

    RewriteCond %{HTTP_USER_AGENT}          !^SVN.*
    RewriteRule ^/svn/(.*?)(/.*)$           http://websvn.host/websvn/listing.php?repname=$1&path=$2      [R]
    

    This should redirect any client that doesn't have a User-Agent string starting with 'SVN/' to a WebSVN installation at http://websvn.host/websvn/, and leave queries from SVN clients alone.

    Alexandre Jasmin : Interesting but it could break some third party svn clients
    Andrew Strong : Great idea! Didn't know this was possible.
    Andy Smith : Hi Alexandre, Yeah - I'm aware it could cause issues with some, but it's a start :-). If it's that much of a problem, you could flip the User-Agent stuff and only redirect to WebSVN if it positively matches for Mozilla or such.
    From Andy Smith
  • Solved it with mod_rewrite as Andy suggested. I am using this set of rules now

    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^SVN.*
    RewriteRule (.*) - [S=3] 
    RewriteRule ^svn$ /svn/ [R,N]
    RewriteRule ^svn/$ /websvn/ [R,L]
    RewriteRule ^svn/(.*?)(/.*)$ /websvn/listing.php?repname=$1&path=$2 [R,L]
    

    This checks for the User-Agent to start with SVN (this is how Tortoise identifies) and then skips the next three rules.

    Those three rules are doing the following:

    • add the trailing slash to the svn-URL (not done automatically because svn is no directory)
    • redirect the direct access to the repository list
    • redirect direct repository view

    All this is done in the <Directory>-directive of the RootDir.

    Thanks Andy for this hint!

    sc911

    Andy Smith : No worries - glad it was useful :-)
    From sc911

0 comments:

Post a Comment