It's better when it's simple

User Tools

Site Tools



Compatible with DokuWiki


plugin A convenience plugin for linking (and iframe-inlining) files in a WebSVN repository.

Last updated on

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with include, links, repository


This plugin offers a convenient way to reference files in a Subversion repository. It assumes that the repository is made web-accessible with WebSVN. Instead of using absolute links to files in WebSVN this plugin allows you to reference them with a short path relative to a root path. This not only makes the referencing links much shorter but also makes the links less prone to breaking later. -stefan


Link to a particular file in your WebSVN-served subversion repository.

<websvn repository/path/to/file>

Alternatively the file listing can be iframe-inlined by adding a trailing space to the path:

<websvn repository/path/to/file >


Point your Plugin Manager to this url: This automatically downloads, unzips and installs the plugin. Once installed it has to be configured.

To configure:

  • edit lib/plugins/websvn/syntax.php
  • set the $websvn_root_url to the root of your WebSVN installation
  • enjoy!

Source Code


 * Plugin websvn: Deep-links to files in a WebSVN repository
 * @license    GPL 2 (
 * @author     Stefan Hechenberger <>
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
//-----------------------------------CONFIGURE WEBSVN ROOT HERE---------
global $websvn_root_url;
$websvn_root_url = "http://your.websvn.root/";
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
class syntax_plugin_websvn extends DokuWiki_Syntax_Plugin {
     * return some info
    function getInfo(){
        return array(
            'author' => 'Stefan Hechenberger',
            'email'  => '',
            'date'   => '2007-02-06',
            'name'   => 'websvn Plugin',
            'desc'   => 'Generates deep links to files in a WebSVN repository.',
            'url'    => '',
     * What kind of syntax are we?
    function getType(){
        return 'substition';
     * Where to sort in?
    function getSort(){
        return 921;
     * Connect pattern to lexer
    function connectTo($mode) {
      $this->Lexer->addSpecialPattern('<websvn .*?>',$mode, substr(get_class($this), 7));
     * Handle the match
    function handle($match, $state, $pos, &$handler){
        $match = html_entity_decode(substr($match, 8, -1));
        if(substr($match, -1, 1) == ' ') {
            $iframe = 1;
            $match = substr($match, 0, -1);
        }else {
            $iframe = 0;
        list($repository, $reppath) = explode('/', $match, 2);
        $reppath = '/'.$reppath;
        $sourcefilename = substr(strrchr($reppath, "/"), 1);
        $reppath = urlencode($reppath);
        return array($repository, $reppath, $sourcefilename, $iframe);
     * Create output
    function render($mode, &$renderer, $data) {
        global $websvn_root_url;
        list($repository, $reppath, $sourcefilename, $iframe) = $data;
        $url = $websvn_root_url."filedetails.php?repname=$repository&path=$reppath";
        if($mode == 'xhtml'){
            if($iframe) {
                $w = "100%";
                $h = "400px";
                $renderer->doc .= '<iframe title="'.$sourcefilename.'" src="'.$url.'" style="width:'.$w.'; height: '.$h.';">'.$sourcefilename.'</iframe>';                
            } else {
                $renderer->doc .= "<a href=\"".$url."\">$sourcefilename</a>";
            return true;
        return false;


Works Great, just make sure the first argument in the path is the repository name → <websvn ReposName/trunk/path/filename>
???? (??-??-???? ??:??)

Works indeed very great. Only the fact that the link doesn't have an image to recognize the “WebSVN-link” is a little inconvenient. Therefore I have changed some code of the plugin, and created an small (16×16) image from the WebSVN-logo which is now rendered before the link. The other thing that I found inconvenient is that the link opens in the same window. I changed the target to _blank to let it open in a new window.

I have added a new “configure-section” to configure the image-url right below the CONFIGURE WEBSVN ROOT HERE-section:

//-----------------------------------CONFIGURE WEBSVN-LINK IMAGE HERE---------
global $websvn_image_url;
$websvn_image_url = "http://www.your.domain/path/to/button.png";

After that I have defined the new global variable $websvn_image_url in the render function by adding this:

        global $websvn_image_url;

straight below the line:

        global $websvn_root_url;

in the render function.

Finally I changed the following line from:

                $renderer->doc .= "<a href=\"".$url."\">$sourcefilename</a>";


                $renderer->doc .= "<img src=".$websvn_image_url."><a href=\"".$url."\" target=_blank>$sourcefilename</a>";

After those changes images are displayed before the link-name (just like InterWiki-links), and the links opens in a new window. Here's an example image of how my links look rightnow:

Mischa The Evil (27-06-2007 02:45)


I have been thinking about the way to link dokuwiki/subversion/…

  • Do you plan/Is it possible to allow a syntax like websvn>400 to allow either the display of all files changed (svn log -v) or all differences (svn diff) due to that version? This is usually what I would like to link to from the wiki towards svn.
  • What benefits does this plugin has compared to adding an interwiki.conf with the shortcut to the SVN repository displayed via websvn as well? The main one I see is that the code can be displayed in the page itself… for an external display, the interwiki option seems more straightforward, doesn't it?
  • Regarding websvn, how popular/active is the community? I have installed and am using it… but I am wondering if using apache/mod_svn module would not be a better way to publish my repository (since at the same time it allows modifications as far as I understand)?
  • For SVN fans out there, anyone with the idea to replace the DokuWiki version control (gzipping around) by straightforward svn add/update/commit? It would look natural (and more efficient)… at least as an alternate storage/versioning option…
plugin/websvn.txt · Last modified: 2010-10-03 15:19 by HåkanS