From 2572618a340410379cebfbde270d8428fe002b97 Mon Sep 17 00:00:00 2001 From: LarsDW223 Date: Tue, 3 May 2016 19:34:16 +0200 Subject: [PATCH] Added option 'randlinks' to create random links with a timestamp attached to it as a URL parameter. This prevents the referenced resource from being cached. The user will see the latest version of a file if he clicks on it, at least after refreshing the page. See #9. --- syntax.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/syntax.php b/syntax.php index 23768d7..b4ef234 100644 --- a/syntax.php +++ b/syntax.php @@ -96,6 +96,7 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin { 'recursive' => 0, 'titlefile' => '_title.txt', 'cache' => 0, + 'randlinks' => 0, ); foreach($flags as $flag) { list($name, $value) = explode('=', $flag); @@ -216,10 +217,14 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin { $link['suf'] = ''; $link['more'] = ''; $link['class'] = 'media'; + $urlparams = ''; + if ($params['randlinks']) { + $urlparams = '?'.time(); + } if (!$params['direct']) { - $link['url'] = ml(':'.$this->_convert_mediapath($filepath)); + $link['url'] = ml(':'.$this->_convert_mediapath($filepath)).$urlparams; } else { - $link['url'] = $webdir.substr($filepath, strlen($basedir)); + $link['url'] = $webdir.substr($filepath, strlen($basedir)).$urlparams; } $link['name'] = $filename; $link['title'] = $renderer->_xmlEntities($link['url']);