A live bird collage card for your Home Assistant dashboard.
adding new list_pages tool
mcguirepr89087c3f6fb195
diff --git a/scripts/edit_pages.php b/scripts/edit_pages.phpnew file mode 100644index 00000000..4597b03c--- /dev/null+++ b/scripts/edit_pages.php@@ -0,0 +1,46 @@+<?php++// configuration+$url = 'list_scripts.php';+$file = $_POST["page"];++// check if form has been submitted+if (isset($_POST['text']))+{+ // save the text contents+ file_put_contents($file, $_POST['text']);++ // redirect to form again+ header(sprintf('Location: %s', $url));+ printf('<a href="%s">Moved</a>.', htmlspecialchars($url));+ exit();+}++// read the textfile+$text = file_get_contents($file);++?>+<!-- HTML form -->+<head>+<style>+* {+ font-family: 'monospace';+}++a {+ text-decoration: none;+ color: black;+}++form {+ text-align: center;+}+</style>+<body style="background-color:rgb(119, 196, 135);">+<form style="height:95%" action="" method="post">+<input style="margin-left:-150px;" type="submit" value="Update" />+<input type="reset" value="Discard Changes" />+<button type="text"><a href="advanced.php">Back</a></button><br>+<textarea name="text" style="font-size:large;width:100%;height:95%;"><?php echo htmlspecialchars($text) ?></textarea>+</form>+</body>diff --git a/scripts/list_pages.php b/scripts/list_pages.phpindex 92058689..0d2b8bbb 100644--- a/scripts/list_pages.php+++ b/scripts/list_pages.php@@ -5,6 +5,10 @@' Calibri', 'Trebuchet MS', 'sans-serif';box-sizing: border-box;}+button {+ font-size: large;+ padding: 5px;+}/* Create two unequal columns that floats next to each other */.column {float: left;@@ -80,7 +84,7 @@ width: 100%;</style><div class="row"><div class="column first">-<form action="edit_scripts.php" method="POST">+<form action="edit_pages.php" method="POST" id="form1"><?phpfunction printFoldersRecursive($dir) {$allfiles = array();@@ -89,7 +93,7 @@ function printFoldersRecursive($dir) {if (is_dir($dir)){if ($dh = opendir($dir)){while (($file = readdir($dh)) !== false){- if($file != '.' && $file != '..' && $file != 'By_Date' && $file != 'By_Common_Name' && $file != 'By_Scientific_Name' && $file != 'Charts' && $file != 'Processed' && $file != '.git' && $file != '.github' && $file != 'phpsysinfo' && $file != '.DS_Store'){+ if($file != '.' && $file != '..' && $file != 'By_Date' && $file != 'By_Common_Name' && $file != 'By_Scientific_Name' && $file != 'Charts' && $file != 'Processed' && $file != '.git' && $file != '.github' && $file != 'phpsysinfo' && $file != '.DS_Store' && $file != 'birdnet' && $file != 'scripts'){$allfiles[] = $file;}}@@ -100,14 +104,14 @@ function printFoldersRecursive($dir) {sort($allfiles);foreach($allfiles as $file) {- echo "<input name=\"script\" type=\"submit\" value=\"$file\">";+ echo "<button name=\"page\" type=\"submit\" form=\"form1\" value=\"$dir/$file\">$file</button><br>";if(is_dir($dir.'/'.$file)){- printFoldersRecursive($dir.'/'.$file);+ printFoldersRecursive($dir.'/'.$file);}}}-printFoldersRecursive('../../BirdSongs/Extracted');+printFoldersRecursive('/home/pi/BirdNET-Pi');?></form></div>diff --git a/scripts/list_scripts.php b/scripts/list_scripts.phpindex 4f5128eb..2ed06002 100644--- a/scripts/list_scripts.php+++ b/scripts/list_scripts.php@@ -89,7 +89,7 @@ function printFoldersRecursive($dir) {if (is_dir($dir)){if ($dh = opendir($dir)){while (($file = readdir($dh)) !== false){- if($file != '.' && $file != '..') {+ if($file != '.' && $file != '..' && $file != 'birdnet' && $file != '.git') {$allfiles[] = $file;}}