From 306b671439ad6b307cc15c46b0f1c05409de3ba1 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 5 Nov 2019 10:11:12 -0600 Subject: [PATCH 01/23] Improve parse errors #3, and avoid cache if it fails #31 --- src/ini.php | 32 +++++++++++++++++++++++--------- src/msq.php | 17 ++++++++--------- src/msqur.php | 30 +++++++++++++++++------------- 3 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/ini.php b/src/ini.php index 87774e1..3313ec0 100644 --- a/src/ini.php +++ b/src/ini.php @@ -1,4 +1,22 @@ htmlMessage = $html; + } + + public function getHTMLMessage() { + return $this->htmlMessage; + } +} + +class MSQ_ConfigException extends MSQ_ParseException { } + /* * @brief INI parsing * @@ -6,7 +24,7 @@ class INI { /** - * @brief Given a signature string, finds and parses the respective INI file. + * @brief Given a signature string, calculates the respective INI file. * * Returns an array of the config file contents. * @param $signature The signature string which will be modified into a firmware/version array. @@ -60,7 +78,7 @@ public static function getConfig(&$signature) break; default: - $msDir = "unknown"; + throw new MSQ_ConfigException("Unknown/Invalid MSQ signature: $msVersion/$fwVersion"); } //Setup firmware version for matching. @@ -76,9 +94,7 @@ public static function getConfig(&$signature) debug("INI File: $iniFile"); - $msqMap = INI::parse($iniFile, TRUE); - - return $msqMap; + return $iniFile; } /** @@ -87,10 +103,9 @@ public static function getConfig(&$signature) * Based on code from: goulven.ch@gmail.com (php.net comments) http://php.net/manual/en/function.parse-ini-file.php#78815 * * @param $file The path to the INI file that will be loaded and parsed. - * @param $something Unused * @returns A huge array of arrays, starting with sections. */ - public static function parse($file, $something) + public static function parse($file) { try { @@ -107,9 +122,8 @@ public static function parse($file, $something) if ($ini == FALSE || count($ini) == 0) { - echo "
Error opening file: $file
"; error("Error or empty file: $file"); - return null; + throw new MSQ_ConfigException("Could not open MSQ config file: $file"); } else if (DEBUG) debug("Opened: $file"); diff --git a/src/msq.php b/src/msq.php index 961e970..3b2b97d 100644 --- a/src/msq.php +++ b/src/msq.php @@ -69,21 +69,20 @@ public function parseMSQ($xml, &$engine, &$metadata) $msqHeader .= "
Tuning SW: " . $msq->bibliography['author'] . "
"; $msqHeader .= "
Date: " . $msq->bibliography['writeDate'] . "
"; $msqHeader .= ''; + $html['msqHeader'] = $msqHeader; $sig = $msq->versionInfo['signature']; $sigString = $sig; - $msqMap = INI::getConfig($sig); - - if ($msqMap == null) - { + try { + $iniFile = INI::getConfig($sig); + $msqMap = INI::parse($iniFile); + } catch (MSQ_ConfigException $e) { + error('Error parsing config file: ' . $e->getMessage()); $issueTitle = urlencode("INI Request: $sigString"); - $msqHeader .= '
Unable to load the corresponding configuration file for that MSQ. Please file a bug!
'; - $html['msqHeader'] = $msqHeader; - return $html; //TODO Signal caller to skip engine/metadata updates + $htmlMessage = $msqHeader . '
Unable to load the corresponding configuration file for that MSQ. Please file a bug!
'; + throw new MSQ_ParseException("Could not load configuration file for MSQ: " . $e->getMessage(), $htmlMessage, 100, $e); } - $html['msqHeader'] = $msqHeader; - //Calling function will update $metadata['fileFormat'] = $msq->versionInfo['fileFormat']; $metadata['signature'] = $sig[1]; diff --git a/src/msqur.php b/src/msqur.php index edb8ad7..818c721 100644 --- a/src/msqur.php +++ b/src/msqur.php @@ -155,20 +155,24 @@ public function view($id) $metadata = array(); $xml = $this->db->getXML($id); if ($xml !== null) { - $groupedHtml = $msq->parseMSQ($xml, $engine, $metadata); - $this->db->updateMetadata($id, $metadata); - $this->db->updateEngine($id, $engine); - - $html = ""; - foreach($groupedHtml as $group => $v) - { - //TODO Group name as fieldset legend or sth - $html .= "
"; - $html .= $v; - $html .= '
'; + try { + $groupedHtml = $msq->parseMSQ($xml, $engine, $metadata); + $this->db->updateMetadata($id, $metadata); + $this->db->updateEngine($id, $engine); + + $html = ""; + foreach($groupedHtml as $group => $v) + { + //TODO Group name as fieldset legend or sth + $html .= "
"; + $html .= $v; + $html .= '
'; + } + + $this->db->updateCache($id, $html); + } catch (MSQ_ParseException $e) { + $html = $e->getHTMLMessage(); } - - $this->db->updateCache($id, $html); } } } From 3137181b1ea609cede9fbc2168823d8e7319bbff Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 5 Nov 2019 10:21:09 -0600 Subject: [PATCH 02/23] add version string to deploy script --- deploy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 430f4e0..0309241 100755 --- a/deploy.sh +++ b/deploy.sh @@ -9,7 +9,8 @@ ssh-add .travis/id_rsa #TODO Run backup script on remote +git rev-parse HEAD | cut -b -7 > src/VERSION + rsync -av --delete --exclude-from 'deploy_excludes.txt' -e "ssh -o StrictHostKeyChecking=no" src/ $DEPLOY_HOST/ rm .travis/id_rsa -#cp -v VERSION $DEPLOY_DIR/ > /dev/null 2>&1 From 0c0bbaf307b7d8e91e78fde0190e6c789478038b Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 5 Nov 2019 10:45:31 -0600 Subject: [PATCH 03/23] Fix confusing getMSQ function name --- src/db.php | 2 +- src/msqur.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/db.php b/src/db.php index b5bcade..33fa264 100644 --- a/src/db.php +++ b/src/db.php @@ -244,7 +244,7 @@ public function resetReingest($id) * @param $id The metadata id * @returns FALSE if not cached, null if not found, otherwise the HTML. */ - public function getMSQ($id) + public function getCachedMSQ($id) { if (DISABLE_MSQ_CACHE) { diff --git a/src/msqur.php b/src/msqur.php index 818c721..f6fca60 100644 --- a/src/msqur.php +++ b/src/msqur.php @@ -37,10 +37,10 @@ function __construct() $this->db = new DB(); //TODO check reuse } - public function getMSQ($id) + public function getCachedMSQ($id) { //TODO hrm - return $this->db->getMSQ($id); + return $this->db->getCachedMSQ($id); } public function getMSQForDownload($id) @@ -143,7 +143,7 @@ public function view($id) $this->header(); if (DEBUG) debug('Load MSQ: ' . $id); //Get cached HTML and display it, or reparse and display (in order) - $html = $this->getMSQ($id); + $html = $this->getCachedMSQ($id); if ($html !== null) { $this->db->updateViews($id); From 9a0f9e2ee87dbdc6576d939881d92ae62c8c3807 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 5 Nov 2019 11:19:54 -0600 Subject: [PATCH 04/23] Update splash --- src/about.php | 2 +- src/view/msqur.css | 26 ++++++++++++++++++++++++++ src/view/splash.php | 19 ++++++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/about.php b/src/about.php index cac16e1..7ff30e2 100644 --- a/src/about.php +++ b/src/about.php @@ -35,7 +35,7 @@
  • Can you add X feature?
  • File a request for it here.
  • What tech stack does this site run on?
  • -
  • The frontend is Javascript (jQuery and a little Angular.js).
    The backend that does most of the work was made with PHP and data is stored in a SQL database.
  • +
  • The frontend is Javascript (jQuery and a little Angular.js).
    The backend that does most of the work was made with PHP and data is stored in an SQL database.
  • diff --git a/src/view/msqur.css b/src/view/msqur.css index c5c82d7..5ead4cc 100644 --- a/src/view/msqur.css +++ b/src/view/msqur.css @@ -183,6 +183,32 @@ span#literMargin input { /* display: none; */ } +ul.supportList { + list-style: none; + padding: 0; + margin: 0; +} + +aside { + width: 40%; + float: right; + border: 2px solid black; + padding: 10px; + box-shadow: 5px 5px 5px rgb(100, 100, 100); +} + +.supportList li { + text-indent: 1rem; +} + +.supportList li::before { + content: "❌ "; +} + +.supportList li.supported::before { + content: "✅ "; +} + #faq .q { font-weight: bold; } diff --git a/src/view/splash.php b/src/view/splash.php index 2848ca1..ae0f345 100644 --- a/src/view/splash.php +++ b/src/view/splash.php @@ -1,8 +1,25 @@

    Overview

    View MSQ files online. Upload your Tuner Studio .msq files to view and share them.

    -

    How to use this site:

    +
    +

    How to use this site:

    To add your MSQ file to share and view online:

    Click on the upload button:

    From 4a9081bde0535599aead6b487c3ff341f55c589b Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 6 Nov 2019 20:33:16 -0600 Subject: [PATCH 05/23] Fix invalid html #37 --- src/view.php | 10 ---------- src/view/header.php | 26 ++++++++++++++++++++------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/view.php b/src/view.php index c6cd911..58561a9 100644 --- a/src/view.php +++ b/src/view.php @@ -18,16 +18,6 @@ require "msqur.php"; if (isset($_GET['msq'])) { -?> -
    - - -
    -view($_GET['msq']); } else include "index.php"; diff --git a/src/view/header.php b/src/view/header.php index 4a3a4ac..4361d8c 100644 --- a/src/view/header.php +++ b/src/view/header.php @@ -13,14 +13,14 @@ - + - - + + - - - + + + @@ -62,3 +62,17 @@
    + +
    + + +
    + \ No newline at end of file From 11b70e6dd2e5b77ec012051775ed2d8feb147681 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 6 Nov 2019 20:36:55 -0600 Subject: [PATCH 06/23] Fix linter warnings --- src/view/msqur.css | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/view/msqur.css b/src/view/msqur.css index 5ead4cc..e211cd6 100644 --- a/src/view/msqur.css +++ b/src/view/msqur.css @@ -132,7 +132,6 @@ table th[scope=row] { } div.curve { - float: left; display: inline; } @@ -142,14 +141,6 @@ div.chart { display: inline; } -div.chart > canvas.curve { - -} - -div.chart > canvas.table { - -} - #engineForm { display: table; } @@ -179,10 +170,6 @@ input:focus:invalid { color: red; } -span#literMargin input { - /* display: none; */ -} - ul.supportList { list-style: none; padding: 0; From da3eec76778e4e4c6cbd6b0b36c1ab3528f12273 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 6 Nov 2019 20:37:05 -0600 Subject: [PATCH 07/23] Fix invalid HTML --- src/view/header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/header.php b/src/view/header.php index 4361d8c..7121d91 100644 --- a/src/view/header.php +++ b/src/view/header.php @@ -40,7 +40,7 @@
    - +
    From adc2d7d0ad4e6a5cc461ccfa95b1227fdd82d6ea Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 6 Nov 2019 20:41:51 -0600 Subject: [PATCH 08/23] Fix html validation select element --- src/view/header.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/view/header.php b/src/view/header.php index 7121d91..cf8fbdf 100644 --- a/src/view/header.php +++ b/src/view/header.php @@ -52,8 +52,8 @@
    - +
    From df4dee05818793e4f760660166bb32b1d5fe0c93 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 6 Nov 2019 20:45:12 -0600 Subject: [PATCH 09/23] Add img alt text --- src/view/header.php | 2 +- src/view/splash.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/view/header.php b/src/view/header.php index cf8fbdf..d9c8801 100644 --- a/src/view/header.php +++ b/src/view/header.php @@ -66,7 +66,7 @@ if (isset($_GET['msq'])) { ?>
    - + Settings