********************
Noxon iRadio gateway
********************
-Push your own content onto Noxon iRadio devices.
+Push your own content onto Noxon iRadio devices:
+RSS feeds, text files and MediaTomb server structures.
This tool makes it possible to push own data into the menu
entries
- My Noxon
-================
-Adding a podcast
-================
-Create a file "Title.url" in ``var/podcasts/`` and write
-the URL of the podcast MP3 RSS feed into it.
+===================================
+Customizung the directory structure
+===================================
+The ``var/`` directory contains three directories you can fill with
+your own content.
+
+================ ==================
+Menu item ``var/`` Directory
+================ ==================
+Internet Radio ``internetradio``
+Podcasts ``podcasts``
+My Noxon ``mynoxon``
+================ ==================
+
+You can put folders and files into this directories.
+
+The ``internetradio`` directory is hard-coded to display the contents
+of a MediaTomb UPnP server.
+You can remove the check in ``index.php#handleRequest()`` if you do not
+want this.
+
+
+File types
+==========
+Directory
+ A directory is browsable by your Noxon radio
+``.sh`` file
+ Shell script which is shown as directory and which gets executed
+ when navigating into it.
+ Output is shown as it is for ``.txt`` files.
+
+ I use it to control my house's heating system from the radio.
+``.auto.sh``
+ Shell script which gets executed when browsing the folder.
+ The output is integrated into the directory listing with the same
+ rules as for ``.txt`` files.
+
+ You can use this to show the current time within the directory listing.
+``.txt`` file
+ Text files are rendered as un-actionable lists.
+
+ Empty lines get removed, consecutive spaces get collapsed.
+``.url`` file
+ Podcast feed URL file.
+
+ Simply contains the URL to the podcast's MP3 RSS feed.
+
+File extensions get removed for display purposes.
=====
gatekeeper.my-noxon.net
+MediaTomb
+=========
+To be able to browse a MediaTomb server, copy ``data/config.php.dist`` to
+``data/config.php`` and fill it with mediatomb web interface credentials.
+
+
=======
License
=======
return;
}
+ $ext = pathinfo($path, PATHINFO_EXTENSION);
if (is_dir($fullPath)) {
sendDir($path);
- } else if (substr($path, -4) == '.url') {
+ } else if ($ext == 'url') {
require_once 'podcasts.php';
sendPodcast($path);
- } else if (substr($path, -4) == '.txt') {
+ } else if ($ext == 'txt') {
sendTextFile($path);
+ } else if ($ext == 'sh') {
+ sendScript($path);
} else {
sendMessage('Unknown file type');
}
$count = 0;
foreach ($entries as $entry) {
$urlPath = pathEncode(substr($entry, strlen($varDir)));
+ $ext = pathinfo($entry, PATHINFO_EXTENSION);
if (is_dir($entry)) {
++$count;
$listItems[] = getDirItem(basename($entry), $urlPath . '/');
- } else if (substr($entry, -4) == '.url') {
+ } else if ($ext == 'url') {
//podcast
++$count;
$listItems[] = getPodcastItem(basename($entry, '.url'), $urlPath);
- } else if (substr($entry, -4) == '.txt') {
+ } else if (substr($entry, -8) == '.auto.sh') {
+ //automatically execute script while listing this directory
+ addScriptOutput($listItems, $entry);
+ } else if ($ext == 'txt' || $ext == 'sh') {
//plain text file
++$count;
- $listItems[] = getDirItem(basename($entry, '.txt'), $urlPath);
+ $listItems[] = getDirItem(basename($entry, '.' . $ext), $urlPath);
}
}
if (!$count) {
sendListItems($listItems);
}
+function sendScript($path)
+{
+ global $varDir;
+
+ $listItems = array();
+ addPreviousItem($listItems, $path);
+
+ $fullPath = $varDir . $path;
+ addScriptOutput($listItems, $fullPath);
+ sendListItems($listItems);
+}
+
+function addScriptOutput(&$listItems, $fullPath)
+{
+ exec($fullPath . ' 2>&1', $output, $retVal);
+
+ if ($retVal == 0) {
+ addTextLines($listItems, $output);
+ } else {
+ $listItems[] = getMessageItem('Error executing script');
+ addTextLines($listItems, $output);
+ }
+}
+
function sendTextFile($path)
{
global $varDir;
addPreviousItem($listItems, $path);
$lines = file($varDir . $path);
+ addTextLines($listItems, $lines);
+ sendListItems($listItems);
+}
+
+function addTextLines(&$listItems, $lines)
+{
foreach ($lines as $line) {
$line = trim($line);
if ($line != '') {
$listItems[] = getDisplayItem($line);
}
}
- sendListItems($listItems);
}
function getDisplayItem($line)