From: Christian Weiske Date: Tue, 5 Jan 2016 19:55:57 +0000 (+0100) Subject: support nocache files to disable caching X-Git-Url: https://git.cweiske.de/noxon-gateway.git/commitdiff_plain/16d2ad3c6150c6d50c265ad1d8ee37b33b300deb support nocache files to disable caching --- diff --git a/README.rst b/README.rst index 1d3d3a3..adb2c5c 100644 --- a/README.rst +++ b/README.rst @@ -153,6 +153,8 @@ executable file 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. @@ -181,6 +183,18 @@ Would render as:: (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 ===== diff --git a/www/html.xsl b/www/html.xsl index 4d15bd4..da1d4b5 100644 --- a/www/html.xsl +++ b/www/html.xsl @@ -16,6 +16,10 @@ + +

Caching disabled by NoCache

+
+

Messages

diff --git a/www/index.php b/www/index.php index b3b2a7b..31cab07 100644 --- a/www/index.php +++ b/www/index.php @@ -81,6 +81,7 @@ function sendDir($path) $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); @@ -104,12 +105,17 @@ function sendDir($path) //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'); } - sendListItems($listItems, buildPreviousItem($path), $enablePaging); + sendListItems( + $listItems, buildPreviousItem($path), + $enablePaging, $noCache + ); } function sendScript($path) @@ -233,8 +239,9 @@ function sendMessage($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'])) { @@ -256,6 +263,9 @@ function sendListItems($listItems, $previous = null, $enablePaging = true) $xml = '' . "\n"; $xml .= '' . "\n"; $xml .= '' . "\n"; + if ($noCache) { + $xml .= "1\n"; + } $xml .= '' . $itemCount . '' . "\n"; $xml .= $previous;