From 62b33fbd33c330f3b8b8f9864d850f28425b241f Mon Sep 17 00:00:00 2001 From: lbussy Date: Sun, 27 Dec 2020 06:40:21 -0600 Subject: [PATCH 01/18] Allow higher resolution in status --- js/beer-chart.js | 2 +- js/main.js | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/js/beer-chart.js b/js/beer-chart.js index be10e58..04b3047 100644 --- a/js/beer-chart.js +++ b/js/beer-chart.js @@ -65,7 +65,6 @@ function findTiltByColor(field) { // Determine Tilt color from json field name return null; } - var tiltColors = { // Array to pick Tilt color based on json field passed RedSG: "Red", GreenSG: "Green", @@ -531,6 +530,7 @@ function drawBeerChart(beerToDraw, div) { // Give name of the beer to display an // Tilt and iSpindel var gravityFormat = function (y) { + // TODO: Return 4? return parseFloat(y).toFixed(3); }; diff --git a/js/main.js b/js/main.js index e100dff..b1348c1 100644 --- a/js/main.js +++ b/js/main.js @@ -250,13 +250,10 @@ function refreshStatus() { for (var item in row) { var keys = Object.keys(row); dataName = keys[0]; - if (item.indexOf("SG") > -1) { - dataItem = parseFloat(row[item]).toFixed(3); - } else { - dataItem = row[item]; - } + dataItem = row[item]; $newStatusText.find('#new-status-item-' + curRow).html(dataName); $newValueText.find('#new-status-value-' + curRow).html(dataItem); + console.log("Status: " + dataName + " " + dataItem) // DEBUG } curRow++; } @@ -275,7 +272,7 @@ function refreshStatus() { $newValueText.find('#new-status-value-' + i).html(""); } }) - setTimeout(refreshStatus, 10000); + setTimeout(refreshStatus, 5000); } function updateScriptStatus(running) { // TODO: Make a "Starting" status From 0ac193c71791bc5ad08bb2b34211f747690fd6c8 Mon Sep 17 00:00:00 2001 From: lbussy Date: Sun, 27 Dec 2020 11:07:30 -0600 Subject: [PATCH 02/18] Fix BB temp resolution --- js/main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/main.js b/js/main.js index b1348c1..7e76241 100644 --- a/js/main.js +++ b/js/main.js @@ -253,7 +253,6 @@ function refreshStatus() { dataItem = row[item]; $newStatusText.find('#new-status-item-' + curRow).html(dataName); $newValueText.find('#new-status-value-' + curRow).html(dataItem); - console.log("Status: " + dataName + " " + dataItem) // DEBUG } curRow++; } From c34687683cb499f342aa9968e4a2270d4622ef41 Mon Sep 17 00:00:00 2001 From: lbussy Date: Mon, 28 Dec 2020 08:57:27 -0600 Subject: [PATCH 03/18] Make dygraph SG high res --- js/beer-chart.js | 39 +++++++++++++++++++++++++++++++---- tiltInfo.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 tiltInfo.php diff --git a/js/beer-chart.js b/js/beer-chart.js index 04b3047..a9227f0 100644 --- a/js/beer-chart.js +++ b/js/beer-chart.js @@ -35,6 +35,7 @@ var currBeerChart; var prevBeerChart; var colorTilt = ""; +var isHighResTilt = false; var colorIdle = "white"; var colorCool = "rgba(0, 0, 255, 0.4)"; @@ -415,7 +416,11 @@ function formatForChartLegendSG(v) { "use strict"; var val = parseFloat(v); if (!isNaN(val)) { - return val.toFixed(3); + if (isHighResTilt) { + return val.toFixed(4); + } else { + return val.toFixed(3); + } } return "--"; } @@ -489,7 +494,7 @@ function findLineByName(name) { return null; } -function drawBeerChart(beerToDraw, div) { // Give name of the beer to display and div in which to draw the graph +function drawBeerChart(beerToDraw, div) { // Give name of the beer to display and div in which to draw the graphs "use strict"; var $chartDiv = $("#" + div); $chartDiv.empty(); @@ -530,8 +535,12 @@ function drawBeerChart(beerToDraw, div) { // Give name of the beer to display an // Tilt and iSpindel var gravityFormat = function (y) { - // TODO: Return 4? - return parseFloat(y).toFixed(3); + var val = parseFloat(y); + if (isHighResTilt) { + return val.toFixed(4); + } else { + return val.toFixed(4); + } }; //Modification: Tilt & iSpindel colors @@ -766,6 +775,26 @@ function toggleAnnotations(el) { } } +function getTiltInfo() { + "use strict"; + $.post("tiltInfo.php", {}, function (answer) { + var tiltInfo = {}; + try { + tiltInfo = $.parseJSON(answer); + } catch (e) { + console.log("Error: Unable to parse Tilt data.") + return; + } + + isHighResTilt = tiltInfo.isHighRes; + + // Refresh Tilt info every 60 seconds + setTimeout(function () { + getTiltInfo(); + }, 60000); + }); +} + $(document).ready(function () { "use strict"; @@ -791,6 +820,8 @@ $(document).ready(function () { applyStateColors(); + getTiltInfo() + // Unhide after loading $("#beer-panel").show(); }); diff --git a/tiltInfo.php b/tiltInfo.php new file mode 100644 index 0000000..0ac6740 --- /dev/null +++ b/tiltInfo.php @@ -0,0 +1,53 @@ +. +*/ + +// load default settings from file +$defaultSettings = file_get_contents('defaultSettings.json'); +if ($defaultSettings == false) die("Cannot open: defaultSettings.json"); + +$settingsArray = json_decode(prepareJSON($defaultSettings), true); +if (is_null($settingsArray)) die("Cannot decode: defaultSettings.json"); + +if (file_exists('userSettings.json')){ + $userSettings = file_get_contents('userSettings.json'); + if ($userSettings == false) die("Cannot open: userSettings.json"); + + $userSettingsArray = json_decode(prepareJSON($userSettings), true); + if (is_null($settingsArray)) die("Cannot decode: userSettings.json"); + + foreach ($userSettingsArray as $key => $value) { + $settingsArray[$key] = $userSettingsArray[$key]; + } +} + +$tiltInfo = json_encode(['isHighRes' => $settingsArray["isHighResTilt"]]); + +function prepareJSON($input) { + // This will convert ASCII/ISO-8859-1 to UTF-8. + // Be careful with the third parameter (encoding detect list), because + // if set wrong, some input encodings will get garbled (including UTF-8!) + $input = mb_convert_encoding($input, 'UTF-8', 'ASCII,UTF-8,ISO-8859-1'); + // Remove UTF-8 BOM if present, json_decode() does not like it. + if(substr($input, 0, 3) == pack("CCC", 0xEF, 0xBB, 0xBF)) $input = substr($input, 3); + return $input; +} + +echo "$tiltInfo" + +?> From 7c8536e109db8e73d22e291d57e10b64397e77c5 Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 16:57:16 -0600 Subject: [PATCH 04/18] Rename file --- tiltInfo.php => get-tiltinfo.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tiltInfo.php => get-tiltinfo.php (100%) diff --git a/tiltInfo.php b/get-tiltinfo.php similarity index 100% rename from tiltInfo.php rename to get-tiltinfo.php From 05ca5fb1fd8beb94aa07dff3d74fc126dcd883db Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 17:09:43 -0600 Subject: [PATCH 05/18] Add css grid to header --- css/multi-index.css | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 css/multi-index.css diff --git a/css/multi-index.css b/css/multi-index.css new file mode 100644 index 0000000..148a23a --- /dev/null +++ b/css/multi-index.css @@ -0,0 +1,17 @@ +.grid-container { + display: grid; + grid-template-columns: 260px 698px; + grid-template-rows: 70px; + grid-gap: 0px; + padding: 5px; + grid-template-areas: + "m-logo m-title"; +} + +.m-logo { grid-area: m-logo; } +.m-title { + grid-area: m-title; + color: #FFFFFF; + padding: 12px; + font-size: x-large; +} From 534219029a592a2b409e9c6edd10ee3151759850 Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 17:10:41 -0600 Subject: [PATCH 06/18] Move to separate file --- get-bjprompt.php | 49 +++++++++++++++ get-gitinfo.php | 46 ++++++++++++++ get-logo.php | 158 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 253 insertions(+) create mode 100644 get-bjprompt.php create mode 100644 get-gitinfo.php create mode 100644 get-logo.php diff --git a/get-bjprompt.php b/get-bjprompt.php new file mode 100644 index 0000000..e9fb3ac --- /dev/null +++ b/get-bjprompt.php @@ -0,0 +1,49 @@ +. +*/ + +// See if we are using an IP to access page, and/or if user is on Windows +$ipurl = (filter_var($_SERVER['HTTP_HOST'], FILTER_VALIDATE_IP) ? true : false); +$windows = (preg_match('/windows|win32/i', $_SERVER['HTTP_USER_AGENT']) ? true : false); +// Form URL with host name +$named_url = 'http://' . gethostname() . '.local' . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); + +$bjlogo = "images/bonjour.png"; + +if (isset($chamberLoc)) { + // If we are running as multi-index.php, be sure to prepend a chamber path + // It will not read as a multi-chamber otherwise + $bjlogo = $chamberLoc . "/" . $bjlogo; +} + +// Bonjour prompt +$bjprompt = ''; +if ($ipurl && $windows) { + $bjprompt .= "
\r\n"; + $bjprompt .= "
\r\n"; + $bjprompt .= "\r\n"; + $bjprompt .= "\"Bonjour\r\n"; + $bjprompt .= "

 You are using an IP to access your BrewPi.\r\n"; + $bjprompt .= "You can use " . $named_url . " instead\r\n"; + $bjprompt .= "if you install Bonjour from Apple.\r\n"; + $bjprompt .= "

\r\n
"; +} + +echo $bjprompt; + +?> diff --git a/get-gitinfo.php b/get-gitinfo.php new file mode 100644 index 0000000..294d313 --- /dev/null +++ b/get-gitinfo.php @@ -0,0 +1,46 @@ +. +*/ + +// Git information for footer +$version = trim(shell_exec('git -C ' . __DIR__ . ' describe --tags $(git -C ' . __DIR__ . ' rev-list --tags --max-count=1)')); +$branch = trim(shell_exec('git -C ' . __DIR__ . ' branch | grep \* | cut -d " " -f2')); +$commit = trim(shell_exec('git -C ' . __DIR__ . ' log --oneline -n1')); +$cmtarr = explode(' ', trim($commit)); + +$commit = "[ "; +foreach ($cmtarr as $key => $word) { + if ($key == 0) { // Make commit hash yellow + $loop = "" . $word . " - "; + } else { + $loop .= $word . " "; + } +} +$commit .= trim($loop) . " ]"; + +$division = ""; +$division = "
\r\n"; +$division .= "
\r\n"; +$division .= "
\r\n"; +$division .= "BrewPi Remix version: " . trim($version) . " (" . trim($branch) . ")\r\n"; +$division .= trim($commit) . "\r\n"; +$division .= "
\r\n
\r\n
"; + +echo $division; + +?> diff --git a/get-logo.php b/get-logo.php new file mode 100644 index 0000000..b279dc5 --- /dev/null +++ b/get-logo.php @@ -0,0 +1,158 @@ +. + */ + +$mimetypes = array( + "image/bmp", + "image/cmu-raster", + "image/fif", + "image/florian", + "image/g3fax", + "image/gif", + "image/ief", + "image/jpeg", + "image/jutvision", + "image/naplps", + "image/pict", + "image/pjpeg", + "image/png", + "image/tiff", + "image/vasa", + "image/vnd.dwg", + "image/vnd.fpx", + "image/vnd.net-fpx", + "image/vnd.rn-realflash", + "image/vnd.rn-realpix", + "image/vnd.wap.wbmp", + "image/vnd.xiff", + "image/xbm", + "image/x-cmu-raster", + "image/x-dwg", + "image/x-icon", + "image/x-jg", + "image/x-jps", + "image/x-niff", + "image/x-pcx", + "image/x-pict", + "image/xpm", + "image/x-portable-anymap", + "image/x-portable-bitmap", + "image/x-portable-graymap", + "image/x-portable-greymap", + "image/x-portable-pixmap", + "image/x-quicktime", + "image/x-rgb", + "image/x-tiff", + "image/x-windows-bmp", + "image/x-xbitmap", + "image/x-xbm", + "image/x-xpixmap", + "image/x-xwd", + "image/x-xwindowdump" +); + +$mimeexts = array( + ".art", + ".bm", + ".bmp", + ".dwg", + ".dxf", + ".fif", + ".flo", + ".fpx", + ".g3", + ".gif", + ".ico", + ".ief", + ".iefs", + ".jfif", + ".jfif-tbnl", + ".jpe", + ".jpeg", + ".jpg", + ".jps", + ".jut", + ".mcf", + ".nap", + ".naplps", + ".nif", + ".niff", + ".pbm", + ".pct", + ".pcx", + ".pgm", + ".pic", + ".pict", + ".pm", + ".png", + ".pnm", + ".ppm", + ".qif", + ".qti", + ".qtif", + ".ras", + ".rast", + ".rf", + ".rgb", + ".rp", + ".svf", + ".tif", + ".tiff", + ".turbot", + ".wbmp", + ".xbm", + ".xif", + ".xpm", + ".x-png", + ".xwd" +); + +// Grab the custom logo if it exists, otherwise use the stock one +$custom_logo = glob('images/custom_logo.*'); +$logo = (count($custom_logo) ? $custom_logo[0] : 'images/brewpi_logo.png'); + +if (isset($chamberLoc)) { + // If we are running as multi-index.php, be sure to prepend a chamber path + // It will not read as a multi-chamber otherwise + $logo = $chamberLoc . "/" . $logo; +} + +if (file_exists($logo)) { + // Get some additional information about the logo file + $filemime = mime_content_type($logo); + $fileext = pathinfo($logo, PATHINFO_EXTENSION); + // Check to make sure the logo is a valid image + if (in_array ($filemime, $mimetypes) && in_array ("." . $fileext, $mimeexts)) { + // Use chamber path as link on logo if we are multi-chamber + $root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'; + $logo_code = (isset($chamber) ? '' : ''); + // Logo will be resized by CSS + $displayLogo = $logo_code; + } else { + $displayLogo = $logo . " is invalid"; + error_log("BrewPi: " . $logo . " is an invalid image."); + } +} else { + $displayLogo = "BrewPi: Missing " . $logo . "."; + error_log("BrewPi: " . $logo . " not found."); +} + +echo $displayLogo; +echo "\n"; + +?> From c5e2d59f8647baec4eb003ced7807c8850bbc260 Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 17:12:28 -0600 Subject: [PATCH 07/18] Fix alignments --- css/style.css | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/css/style.css b/css/style.css index 7be3660..cc7ab95 100644 --- a/css/style.css +++ b/css/style.css @@ -65,8 +65,8 @@ body { #version-panel{ width: 980px; height: 28px; - margin-top: 10px; - margin-bottom: 10px; + margin-top: 0px; + margin-bottom: 0px; float:left; } @@ -94,9 +94,8 @@ body { #bonjour-panel{ width: 980px; - height: 50; margin-bottom: 10px; - float:left; + float:left; } #lcd-panel{ @@ -107,7 +106,7 @@ body { .lcd-title{ color: #FFFFFF; padding: 12px; - font-size: large; + font-size: x-large; } #lcd-top-bar{ @@ -117,7 +116,6 @@ body { #lcd-portal{ width: 294px; - height: 125px; text-align: center; } @@ -130,6 +128,11 @@ iframe { margin: 5px; } +#bonjour-bar{ + width: 968px; + margin: 5px; +} + button.script-status{ width: 200px; margin: 5px; @@ -157,7 +160,8 @@ button#maintenance{ #control-panel{ width: 976px; - min-height: 340px; + min-height: 340px; + margin-bottom: 10px; float: left; } @@ -209,7 +213,6 @@ button#maintenance{ .header-grid-container { display: grid; grid-template-columns: 260px 240px 150px 90px 210px; - grid-template-rows: 70px; grid-template-areas: "logo lcd0 scrollname0 scrollvalue0 button" From 7f4d6941e694bf8c711bd4121a462ed2c27e1397 Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 17:13:02 -0600 Subject: [PATCH 08/18] Change post address --- js/beer-chart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/beer-chart.js b/js/beer-chart.js index a9227f0..c3381b3 100644 --- a/js/beer-chart.js +++ b/js/beer-chart.js @@ -777,7 +777,7 @@ function toggleAnnotations(el) { function getTiltInfo() { "use strict"; - $.post("tiltInfo.php", {}, function (answer) { + $.post("get-tiltinfo.php", {}, function (answer) { var tiltInfo = {}; try { tiltInfo = $.parseJSON(answer); From bdc0da8cb79c004bac3324ce61037ec1114ebb38 Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 17:13:46 -0600 Subject: [PATCH 09/18] Move some areas to separate files --- top-bar.php | 136 +--------------------------------------------------- 1 file changed, 2 insertions(+), 134 deletions(-) diff --git a/top-bar.php b/top-bar.php index b348fd6..3ad076a 100644 --- a/top-bar.php +++ b/top-bar.php @@ -16,151 +16,19 @@ * You should have received a copy of the GNU General Public License * along with BrewPi WWW RMX. If not, see . */ - -$mimetypes = array( - "image/bmp", - "image/cmu-raster", - "image/fif", - "image/florian", - "image/g3fax", - "image/gif", - "image/ief", - "image/jpeg", - "image/jutvision", - "image/naplps", - "image/pict", - "image/pjpeg", - "image/png", - "image/tiff", - "image/vasa", - "image/vnd.dwg", - "image/vnd.fpx", - "image/vnd.net-fpx", - "image/vnd.rn-realflash", - "image/vnd.rn-realpix", - "image/vnd.wap.wbmp", - "image/vnd.xiff", - "image/xbm", - "image/x-cmu-raster", - "image/x-dwg", - "image/x-icon", - "image/x-jg", - "image/x-jps", - "image/x-niff", - "image/x-pcx", - "image/x-pict", - "image/xpm", - "image/x-portable-anymap", - "image/x-portable-bitmap", - "image/x-portable-graymap", - "image/x-portable-greymap", - "image/x-portable-pixmap", - "image/x-quicktime", - "image/x-rgb", - "image/x-tiff", - "image/x-windows-bmp", - "image/x-xbitmap", - "image/x-xbm", - "image/x-xpixmap", - "image/x-xwd", - "image/x-xwindowdump" -); - -$mimeexts = array( - ".art", - ".bm", - ".bmp", - ".dwg", - ".dxf", - ".fif", - ".flo", - ".fpx", - ".g3", - ".gif", - ".ico", - ".ief", - ".iefs", - ".jfif", - ".jfif-tbnl", - ".jpe", - ".jpeg", - ".jpg", - ".jps", - ".jut", - ".mcf", - ".nap", - ".naplps", - ".nif", - ".niff", - ".pbm", - ".pct", - ".pcx", - ".pgm", - ".pic", - ".pict", - ".pm", - ".png", - ".pnm", - ".ppm", - ".qif", - ".qti", - ".qtif", - ".ras", - ".rast", - ".rf", - ".rgb", - ".rp", - ".svf", - ".tif", - ".tiff", - ".turbot", - ".wbmp", - ".xbm", - ".xif", - ".xpm", - ".x-png", - ".xwd" -); - -// Grab the custom logo if it exists, otherwise use the stock one -$custom_logo = glob('images/custom_logo.*'); -$logo = (count($custom_logo) ? $custom_logo[0] : 'images/brewpi_logo.png'); -// Get site root url -$root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'; - ?>
Logging: From bd20c9d5e6b798769513ffe011a056dafd19bf1e Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 17:14:20 -0600 Subject: [PATCH 10/18] Fix paths and alignment --- lcd.php | 87 +++++++++++++++++++++++---------------------------------- 1 file changed, 35 insertions(+), 52 deletions(-) diff --git a/lcd.php b/lcd.php index 42fa5d3..7b0100c 100644 --- a/lcd.php +++ b/lcd.php @@ -15,28 +15,16 @@ * * You should have received a copy of the GNU General Public License * along with BrewPi WWW RMX. If not, see . - * - * These scripts were originally a part of brewpi-www, a part of - * the BrewPi project. Legacy support (for the very popular Arduino - * controller) seems to have been discontinued in favor of new hardware. - * - * All credit for the original brewpi-www goes to @elcojacobs, - * @lukepower, @m-mcgowan, @vanosg, @GregAtkinson and I'm sure - * many more contributors around the world. My apologies if I have - * missed anyone; those were the names listed as contributors on the - * Legacy branch. - * - * See: 'original-license.md' for notes about the original project's - * license and credits. */ +*/ -// load default settings from file +// Load default settings from file $defaultSettings = file_get_contents('defaultSettings.json'); if ($defaultSettings == false) die("Cannot open: defaultSettings.json"); $settingsArray = json_decode(prepareJSON($defaultSettings), true); if (is_null($settingsArray)) die("Cannot decode: defaultSettings.json"); -// overwrite default settings with user settings +// Overwrite default settings with user settings if(file_exists('userSettings.json')){ $userSettings = file_get_contents('userSettings.json'); if($userSettings == false) die("Cannot open: userSettings.json"); @@ -49,35 +37,36 @@ } } +// Read configuration name for multi-chamber +if (file_exists('config.php')) { + require_once('config.php'); + if(file_exists($scriptPath . "/settings/config.cfg")) { + $ini_array = parse_ini_file($scriptPath . "/settings/config.cfg"); + } +} else { + die('ERROR: Unable to open required file (config.php).'); +} + $beerName = $settingsArray["beerName"]; $tempFormat = $settingsArray["tempFormat"]; $profileName = $settingsArray["profileName"]; $dateTimeFormat = $settingsArray["dateTimeFormat"]; $dateTimeFormatDisplay = $settingsArray["dateTimeFormatDisplay"]; +$chamberName = $ini_array['chamber']; function prepareJSON($input) { - //This will convert ASCII/ISO-8859-1 to UTF-8. - //Be careful with the third parameter (encoding detect list), because - //if set wrong, some input encodings will get garbled (including UTF-8!) + // This will convert ASCII/ISO-8859-1 to UTF-8. + // Be careful with the third parameter (encoding detect list), because + // if set wrong, some input encodings will get garbled (including UTF-8!) $input = mb_convert_encoding($input, 'UTF-8', 'ASCII,UTF-8,ISO-8859-1'); //Remove UTF-8 BOM if present, json_decode() does not like it. if(substr($input, 0, 3) == pack("CCC", 0xEF, 0xBB, 0xBF)) $input = substr($input, 3); return $input; } -// Read configuration name for multi-chamber -if (file_exists('config.php')) { - require_once('config.php'); - if(file_exists($scriptPath . "/settings/config.cfg")) { - $ini_array = parse_ini_file($scriptPath . "/settings/config.cfg"); - $chamber=$ini_array['chamber']; - } -} else { - die('ERROR: Unable to open required file (config.php).'); -} - +// Get link to root of chamber $rooturl = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT'])); -$title = ($chamber=='' ? 'BrewPi Remix' : 'LCD: ' . $chamber) +$title = ($chamberName == '' ? 'BrewPi Remix' : 'LCD: ' . $chamberName) ?> @@ -97,35 +86,29 @@ function prepareJSON($input) { -
-
- - Live LCD waiting - for update from - script. - -
+
+
+
+
Waiting for
+
update from
+
script.
+
+
+
+
-Open 's Main Page -
- - - - - + + + + - - - - - - + From 94095af38bccc50f348e85302b9fcb632c2f0387 Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 17:15:11 -0600 Subject: [PATCH 11/18] Use external files --- index.php | 56 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 54 deletions(-) diff --git a/index.php b/index.php index b9b5508..76273b9 100644 --- a/index.php +++ b/index.php @@ -78,54 +78,6 @@ function prepareJSON($input) die('ERROR: Unable to open required file (config.php).'); } -// Git information for footer -$docloc = str_replace($_SERVER['DOCUMENT_ROOT'], '', dirname($scriptPath)); -$tbwd = getcwd(); -if (is_dir($_SERVER['DOCUMENT_ROOT'] . $GLOBALS['docloc'])) { - chdir($_SERVER['DOCUMENT_ROOT'] . $GLOBALS['docloc']); -} -$version = trim(shell_exec('git describe --tags $(git rev-list --tags --max-count=1)')); -$branch = trim(shell_exec('git branch | grep \* | cut -d " " -f2')); -$commit = trim(shell_exec('git -C . log --oneline -n1')); -chdir($tbwd); -$arr = explode(' ', trim($commit)); -$commit = "[ "; -$loop = ''; -foreach ($arr as $key => $word) { - if ($key == 0) { // Make commit hash yellow - $loop = "" . $word . " - "; - } else { - $loop .= $word . " "; - } -} -$commit .= trim($loop) . " ]"; -$division = "
\r\n"; -$division .= "
\r\n"; -$division .= "
\r\n"; -$division .= "BrewPi Remix version: " . trim($version) . " (" . trim($branch) . ")\r\n"; -$division .= trim($commit) . "\r\n"; -$division .= "
\r\n
\r\n
"; -$gitinfo = $division; - -// See if we are using an IP to access page, and/or if user is on Windows -$ipurl = (filter_var($_SERVER['HTTP_HOST'], FILTER_VALIDATE_IP) ? true : false); -$windows = (preg_match('/windows|win32/i', $_SERVER['HTTP_USER_AGENT']) ? true : false); -// Form URL with host name -$named_url = 'http://' . gethostname() . '.local' . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); - -// Bonjour prompt -$bjprompt = ''; -if ($ipurl && $windows) { - $bjprompt .= "
\r\n"; - $bjprompt .= "
\r\n"; - $bjprompt .= "\r\n"; - $bjprompt .= "\"Bonjour\r\n"; - $bjprompt .= "

 You are using an IP to access your BrewPi.\r\n"; - $bjprompt .= "You can use " . $named_url . " instead\r\n"; - $bjprompt .= "if you install Bonjour from Apple.\r\n"; - $bjprompt .= "

\r\n
"; -} - $title = ($chamber == '' ? 'BrewPi Remix' : 'BLR: ' . $chamber) ?> @@ -148,9 +100,7 @@ function prepareJSON($input) - - - + - - - + From b383fe85ca3231a44071b882f313f8967b1e2f18 Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 17:15:35 -0600 Subject: [PATCH 12/18] Complete re-write --- multi-index.php | 191 ++++++++++++++++-------------------------------- 1 file changed, 65 insertions(+), 126 deletions(-) diff --git a/multi-index.php b/multi-index.php index 90f2629..c531a3e 100644 --- a/multi-index.php +++ b/multi-index.php @@ -15,74 +15,53 @@ * * You should have received a copy of the GNU General Public License * along with BrewPi WWW RMX. If not, see . - * - * These scripts were originally a part of brewpi-www, a part of - * the BrewPi project. Legacy support (for the very popular Arduino - * controller) seems to have been discontinued in favor of new hardware. - * - * All credit for the original brewpi-www goes to @elcojacobs, - * @lukepower, @m-mcgowan, @vanosg, @GregAtkinson and I'm sure - * many more contributors around the world. My apologies if I have - * missed anyone; those were the names listed as contributors on the - * Legacy branch. - * - * See: 'original-license.md' for notes about the original project's - * license and credits. */ +*/ + +// TODO: Remove +clearstatcache(); $columns = 3; // Number of columns in display table +$chamberLoc = ""; function getFileList($dir, $recurse = FALSE, $depth = FALSE) { - $retval = []; - - // Add trailing slash if missing - if(substr($dir, -1) != "/") { - $dir .= "/"; - } - - // Open pointer to directory and read list of files - $d = @dir($dir) or die("getFileList: Failed opening directory {$dir} for reading"); - while(FALSE !== ($entry = $d->read())) { - // Skip hidden files - if($entry{0} == ".") continue; - if(is_dir("{$dir}{$entry}")) { - // Skip directory; - if($recurse && is_readable("{$dir}{$entry}/")) { - if($depth === FALSE) { - $retval = array_merge($retval, getFileList("{$dir}{$entry}/", TRUE)); - } elseif($depth > 0) { - $retval = array_merge($retval, getFileList("{$dir}{$entry}/", TRUE, $depth-1)); + $retval = []; + + // Add trailing slash if missing + if (substr($dir, -1) != "/") { + $dir .= "/"; + } + + // Open pointer to directory and read list of files + $d = @dir($dir) or die("getFileList: Failed opening directory {$dir} for reading"); + while (FALSE !== ($entry = $d->read())) { + // Skip hidden files + if ($entry{0} == ".") continue; + if (is_dir("{$dir}{$entry}")) { + // Skip directory; + if ($recurse && is_readable("{$dir}{$entry}/")) { + if ($depth === FALSE) { + $retval = array_merge($retval, getFileList("{$dir}{$entry}/", TRUE)); + } elseif($depth > 0) { + $retval = array_merge($retval, getFileList("{$dir}{$entry}/", TRUE, $depth-1)); + } + } + } elseif(is_readable("{$dir}{$entry}")) { + if ($entry == 'lcd.php') { + $retval[] = [ + 'name' => "{$dir}{$entry}", + ]; + } } - } - } elseif(is_readable("{$dir}{$entry}")) { - if ($entry == 'lcd.php') { - $retval[] = [ - 'name' => "{$dir}{$entry}", - ]; - } } - } - $d->close(); - return $retval; + $d->close(); + return $retval; } - // See if we are using an IP to access page, and/or if user is on Windows - $ipurl = (filter_var($_SERVER['HTTP_HOST'], FILTER_VALIDATE_IP) ? true : false); - $windows = (preg_match('/windows|win32/i', $_SERVER['HTTP_USER_AGENT']) ? true : false); - // Form URL with host name - $named_url = 'http://' . gethostname() . '.local' . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); - -// Bonjour prompt -$bjprompt = ''; -if ($ipurl && $windows) { - $bjprompt .= "
\r\n"; - $bjprompt .= "
\r\n"; - $bjprompt .= "\r\n"; - $bjprompt .= "\"Bonjour\r\n"; - $bjprompt .= "

 You are using an IP to access your BrewPi.\r\n"; - $bjprompt .= "You can use " . $named_url . " instead\r\n"; - $bjprompt .= "if you install Bonjour from Apple.\r\n"; - $bjprompt .= "

\r\n
"; +function htmlpath($relative_path) { + $realpath=realpath($relative_path); + $htmlpath=str_replace($_SERVER['DOCUMENT_ROOT'],'',$realpath); + return $htmlpath; } // Create table of frames @@ -93,6 +72,10 @@ function getFileList($dir, $recurse = FALSE, $depth = FALSE) $dirlist = getFileList("./", TRUE, 1); // Sort the array sort($dirlist); +// Get a chamber location +$chamberLoc = htmlpath(pathinfo($dirlist[0]['name'])['dirname']); +$chamberLoc = ltrim($chamberLoc,'/'); + foreach($dirlist as $file) { $dyn_table .= ($i % $columns == 0 ? '' . "\n" : ''); // Make a table up to $columns columns wide $dyn_table .= '' . '' . "\n"; $dyn_table .= '' . "\n"; $i++; @@ -110,18 +110,32 @@ function htmlpath($relative_path) { - + -
-
- -
Multi-Chamber Dashboard
-
+ - + From 5a08e4dbf7680482713733581ae60561551312d1 Mon Sep 17 00:00:00 2001 From: lbussy Date: Wed, 30 Dec 2020 18:46:46 -0600 Subject: [PATCH 15/18] Cleanup notes --- lcd.php | 2 +- multi-index.php | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lcd.php b/lcd.php index 85ac3fd..657cfc2 100644 --- a/lcd.php +++ b/lcd.php @@ -89,7 +89,7 @@ function prepareJSON($input) { -