<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -46,7 +46,18 @@ class syntax_plugin_repo extends DokuWiki_Syntax_Plugin {
  
       $match = substr($match, 7, -2);
       list($base, $title) = explode('|', $match, 2);
-      return array(trim($base), trim($title), $pos); 
+      list($base, $refresh) = explode(' ', $base, 2);
+      
+      if (preg_match('/(\d+)([dhm])/', $refresh, $match)){
+        $period = array('d' =&gt; 86400, 'h' =&gt; 3600, 'm' =&gt; 60);
+        // n * period in seconds, minimum 10 minutes
+        $refresh = max(600, $match[1] * $period[$match[2]]);
+      } else {
+        // default to 4 hours
+        $refresh = 14400;
+      }
+      
+      return array(trim($base), trim($title), $pos, $refresh);
   }     
  
   /** 
@@ -61,26 +72,32 @@ class syntax_plugin_repo extends DokuWiki_Syntax_Plugin {
     $url   = $base.$path;
 
     if ($mode == 'xhtml'){
-          
-      // prevent caching to ensure the included page is always fresh 
-      $renderer-&gt;info['cache'] = false;
-                  
+                        
       // output
       $renderer-&gt;header($title.$path, 5, $data[2]);
       $renderer-&gt;section_open(5);
       if ($url{strlen($url) - 1} == '/'){                 // directory
-        $this-&gt;_directory($base, $renderer, $path);
+        $this-&gt;_directory($base, $renderer, $path, $data[3]);
       } elseif (preg_match('/(jpe?g|gif|png)$/i', $url)){ // image
         $this-&gt;_image($url, $renderer);
       } else {                                            // source code file
-        $this-&gt;_codefile($url, $renderer);
+        $this-&gt;_codefile($url, $renderer, $data[3]);
       }
       if ($path) $this-&gt;_location($path, $title, $renderer);
       $renderer-&gt;section_close();
       
     // for metadata renderer
     } elseif ($mode == 'metadata'){
+    
+      // list the URL as an included part of the page
       $renderer-&gt;meta['relation']['haspart'][$url] = 1;
+      
+      // set the time for cache expiration
+      if (isset($renderer-&gt;meta['date']['valid']['age']))
+        $renderer-&gt;meta['date']['valid']['age'] =
+        min($renderer-&gt;meta['date']['valid']['age'], $data[3]);
+      else
+        $renderer-&gt;meta['date']['valid']['age'] = $data[3];
     }
  
     return $ok;  
@@ -89,13 +106,13 @@ class syntax_plugin_repo extends DokuWiki_Syntax_Plugin {
   /**
    * Handle remote directories
    */
-  function _directory($url, &amp;$renderer, $path){
+  function _directory($url, &amp;$renderer, $path, $refresh){
     global $conf;
     
     $cache = getCacheName($url.$path, '.repo');
     $mtime = @filemtime($cache); // 0 if it doesn't exist
     
-    if (($mtime != 0) &amp;&amp; !$_REQUEST['purge'] &amp;&amp; ($mtime &gt; time() - $conf['cachetime'])){
+    if (($mtime != 0) &amp;&amp; !$_REQUEST['purge'] &amp;&amp; ($mtime &gt; time() - $refresh)){
       $idx = io_readFile($cache, false);
       if ($conf['allowdebug']) $idx .= &quot;\n&lt;!-- cachefile $cache used --&gt;\n&quot;;
     } else {
@@ -151,10 +168,10 @@ class syntax_plugin_repo extends DokuWiki_Syntax_Plugin {
   /**
    * Handle remote source code files: display as code box with link to file at the end
    */
-  function _codefile($url, &amp;$renderer){
+  function _codefile($url, &amp;$renderer, $refresh){
           
     // output the code box with syntax highlighting
-    $renderer-&gt;doc .= $this-&gt;_cached_geshi($url);
+    $renderer-&gt;doc .= $this-&gt;_cached_geshi($url, $refresh);
     
     // and show a link to the original file
     $renderer-&gt;p_open();
@@ -169,14 +186,14 @@ class syntax_plugin_repo extends DokuWiki_Syntax_Plugin {
    * @author Christopher Smith &lt;chris@jalakai.co.uk&gt;
    * @author Esther Brunner &lt;wikidesign@gmail.com&gt;
    */
-  function _cached_geshi($url){
+  function _cached_geshi($url, $refresh){
     global $conf;
     
     $cache = getCacheName($url, '.code');
     $mtime = @filemtime($cache); // 0 if it doesn't exist
   
     if (($mtime != 0) &amp;&amp; !$_REQUEST['purge'] &amp;&amp;
-      ($mtime &gt; time() - $conf['cachetime']) &amp;&amp;
+      ($mtime &gt; time() - $refresh) &amp;&amp;
       ($mtime &gt; filemtime(DOKU_INC.'inc/geshi.php'))){
   
       $hi_code = io_readFile($cache, false);</diff>
      <filename>syntax.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>750567097422edd9f8abce40f35a515c18a6a7ed</id>
    </parent>
  </parents>
  <author>
    <name>wikidesign</name>
    <login>chimeric</login>
    <email>chi@chimeric.de</email>
  </author>
  <url>http://github.com/dokufreaks/plugin-repo/commit/e97424bdc21a9af411cb77533a22a92bf78b9d53</url>
  <id>e97424bdc21a9af411cb77533a22a92bf78b9d53</id>
  <committed-date>2007-03-14T06:47:49-07:00</committed-date>
  <authored-date>2007-03-14T06:47:49-07:00</authored-date>
  <message>3 Optional cache refresh time -- thanks to Doug Daniels!

darcs-hash:20070314134749-89468-ce0a92bc40afa23dfac2cf05ed08768152af8006.gz</message>
  <tree>a2caf9622002201b626d2bb464d35e57e2e9b8a1</tree>
  <committer>
    <name>wikidesign</name>
    <login>chimeric</login>
    <email>chi@chimeric.de</email>
  </committer>
</commit>
