support nocache files to disable caching
authorChristian Weiske <cweiske@cweiske.de>
Tue, 5 Jan 2016 19:55:57 +0000 (20:55 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 5 Jan 2016 19:55:57 +0000 (20:55 +0100)
README.rst
www/html.xsl
www/index.php

index 1d3d3a307a586205982ff37470a006f56f067dc9..adb2c5c289b1851028d7d7985d3732dc7fd3e34a 100644 (file)
@@ -153,6 +153,8 @@ executable file
   rules as for ``.txt`` files.
 
   You can use this to show the current time within the directory listing.
   rules as for ``.txt`` files.
 
   You can use this to show the current time within the directory listing.
+``nocache``
+  Disables menu caching.
 
 File extensions get removed for display purposes.
 
 
 File extensions get removed for display purposes.
 
@@ -181,6 +183,18 @@ Would render as::
 (given that ``01_temp.auto.sh`` outputs the temperature string)
 
 
 (given that ``01_temp.auto.sh`` outputs the temperature string)
 
 
+Caching
+=======
+When going back in the menu strucutre with the left arrow button,
+Noxon iRadios display a cached version of the menu.
+
+If you do not want this - because a script modified values that are
+displayed in the parent menu, or because the script that displays
+the time should always be run - you may disable caching.
+
+Caching is disabled when a file named ``nocache`` is found in the directory.
+
+
 =====
 Setup
 =====
 =====
 Setup
 =====
index 4d15bd4be7c3d9ab0992a84cce5fc6cc3fe9e6da..da1d4b567f2faec0520af9dcea5194eef340901b 100644 (file)
         </pre>
        </xsl:for-each>
 
         </pre>
        </xsl:for-each>
 
+       <xsl:if test="NoCache">
+        <p>Caching disabled by <tt>NoCache</tt></p>
+       </xsl:if>
+
        <xsl:if test="Item[ItemType='Message']">
         <h2>Messages</h2>
         <xsl:for-each select="Item[ItemType='Message']">
        <xsl:if test="Item[ItemType='Message']">
         <h2>Messages</h2>
         <xsl:for-each select="Item[ItemType='Message']">
index b3b2a7b4b59d821ac1f80f39fc024b5ce5036c4c..31cab0723a44a9b0b8bac754aae8e7b876ba48e9 100644 (file)
@@ -81,6 +81,7 @@ function sendDir($path)
 
     $entries = glob(str_replace('//', '/', $varDir . rtrim($path, '/') . '/*'));
     $count = 0;
 
     $entries = glob(str_replace('//', '/', $varDir . rtrim($path, '/') . '/*'));
     $count = 0;
+    $noCache = false;
     foreach ($entries as $entry) {
         $urlPath = pathEncode(substr($entry, strlen($varDir)));
         $ext = pathinfo($entry, PATHINFO_EXTENSION);
     foreach ($entries as $entry) {
         $urlPath = pathEncode(substr($entry, strlen($varDir)));
         $ext = pathinfo($entry, PATHINFO_EXTENSION);
@@ -104,12 +105,17 @@ function sendDir($path)
             //plain text file
             ++$count;
             $listItems[] = getDirItem(basename($titleBase, '.' . $ext), $urlPath);
             //plain text file
             ++$count;
             $listItems[] = getDirItem(basename($titleBase, '.' . $ext), $urlPath);
+        } else  if (basename($entry) == 'nocache') {
+            $noCache = true;
         }
     }
     if (!$count) {
         $listItems[] = getMessageItem('No files or folders');
     }
         }
     }
     if (!$count) {
         $listItems[] = getMessageItem('No files or folders');
     }
-    sendListItems($listItems, buildPreviousItem($path), $enablePaging);
+    sendListItems(
+        $listItems, buildPreviousItem($path),
+        $enablePaging, $noCache
+    );
 }
 
 function sendScript($path)
 }
 
 function sendScript($path)
@@ -233,8 +239,9 @@ function sendMessage($msg)
     sendListItems(array(getMessageItem($msg)));
 }
 
     sendListItems(array(getMessageItem($msg)));
 }
 
-function sendListItems($listItems, $previous = null, $enablePaging = true)
-{
+function sendListItems(
+    $listItems, $previous = null, $enablePaging = true, $noCache = false
+) {
     $startitems = 1;
     $enditems   = 100000;
     if (isset($_GET['startitems'])) {
     $startitems = 1;
     $enditems   = 100000;
     if (isset($_GET['startitems'])) {
@@ -256,6 +263,9 @@ function sendListItems($listItems, $previous = null, $enablePaging = true)
     $xml = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
     $xml .= '<?xml-stylesheet type="text/xsl" href="/html.xsl"?>' . "\n";
     $xml .= '<ListOfItems>' . "\n";
     $xml = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
     $xml .= '<?xml-stylesheet type="text/xsl" href="/html.xsl"?>' . "\n";
     $xml .= '<ListOfItems>' . "\n";
+    if ($noCache) {
+        $xml .= "<NoCache>1</NoCache>\n";
+    }
     $xml .= '<ItemCount>' . $itemCount . '</ItemCount>' . "\n";
     $xml .= $previous;
 
     $xml .= '<ItemCount>' . $itemCount . '</ItemCount>' . "\n";
     $xml .= $previous;