Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Compatible with DokuWiki
2007-02-05+
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 Hechenberger
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: websvn-plugin-2007-02-07.zip. This automatically downloads, unzips and installs the plugin. Once installed it has to be configured.
To configure:
<?php /** * Plugin websvn: Deep-links to files in a WebSVN repository * http://websvn.tigris.org/ * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Stefan Hechenberger <foss@stefanix.net> */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); //-----------------------------------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' => 'foss@stefanix.net', 'date' => '2007-02-06', 'name' => 'websvn Plugin', 'desc' => 'Generates deep links to files in a WebSVN repository.', 'url' => 'http://www.dokuwiki.org/plugin:websvn', ); } /** * 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>";
to:
$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:
http://www.the-evil.pointclark.net/files/dw_plugins/websvn-hack/sample.png
— Mischa The Evil (27-06-2007 02:45)
I have been thinking about the way to link dokuwiki/subversion/…