From 434ee94548f7fc4902fee2796b65eda07754724c Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Mon, 8 Jan 2024 15:34:29 +0000 Subject: [PATCH 01/11] updated to prevent special handling of '??' in playlist editor entry See http://bugs.jquery.com/ticket/12326/ fixes #429 --- js/playlists.track.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/playlists.track.js b/js/playlists.track.js index 2af34f4f..f9b59b96 100644 --- a/js/playlists.track.js +++ b/js/playlists.track.js @@ -523,7 +523,8 @@ $().ready(function(){ type: "POST", // use API v1.1 or later for correct auto timestamp semantics url: "api/v1.1/playlist/" + playlistId + "/events", - dataType : 'json', + dataType: 'json', + contentType: "application/json; charset=utf-8", accept: "application/json; charset=utf-8", data: JSON.stringify(postData), success: function(respObj) { @@ -891,6 +892,7 @@ $().ready(function(){ $.ajax({ dataType : 'json', type: 'PATCH', + contentType: "application/json; charset=utf-8", accept: "application/json; charset=utf-8", url: "api/v1/playlist/" + playlistId + "/events", data: JSON.stringify(postData), From 8e5cfbb9f2348eab277cc71d7ca27c6f1000ebd1 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Tue, 9 Jan 2024 14:24:36 +0000 Subject: [PATCH 02/11] rewrote procedural array iteration (non-semantic change) --- ui/UICommon.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/UICommon.php b/ui/UICommon.php index 15fb941e..f47d502a 100644 --- a/ui/UICommon.php +++ b/ui/UICommon.php @@ -3,7 +3,7 @@ * Zookeeper Online * * @author Jim Mason - * @copyright Copyright (C) 1997-2023 Jim Mason + * @copyright Copyright (C) 1997-2024 Jim Mason * @link https://zookeeper.ibinx.com/ * @license GPL-3.0 * @@ -288,12 +288,12 @@ public static function deLatin1ify($string, * @return best available locale from the header */ public static function acceptFromHttp($header) { - $locales = []; - foreach(explode(',', $header) as $locale) { - $parts = explode(';', $locale); - $weight = count($parts) == 2 ? explode('=', $parts[1])[1] : 1; - $locales[] = [ $parts[0], $weight ]; - } + $locales = array_map(function($locale) { + // parse /(.+)(;.+=(.+))?/ + $lang = strtok($locale, ';'); + $weight = strtok('=') ? (strtok('') ?: 1) : 1; + return [ $lang, $weight ]; + }, explode(',', $header)); usort($locales, function($a, $b) { return $b[1] <=> $a[1]; From 2d996334f5ebc05a4d460d9e803f55f2114f4a42 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Mon, 15 Jan 2024 14:41:30 +0000 Subject: [PATCH 03/11] suppress 'Post Review to Slack' option if Slack is not configured --- ui/Reviews.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/Reviews.php b/ui/Reviews.php index c0ce23bd..fb492198 100644 --- a/ui/Reviews.php +++ b/ui/Reviews.php @@ -3,7 +3,7 @@ * Zookeeper Online * * @author Jim Mason - * @copyright Copyright (C) 1997-2023 Jim Mason + * @copyright Copyright (C) 1997-2024 Jim Mason * @link https://zookeeper.ibinx.com/ * @license GPL-3.0 * @@ -443,6 +443,9 @@ public function editReview() { $airnames[] = $row['airname']; $airnames[] = $self; + $slack = Engine::param('slack'); + $export = $slack && $slack['token'] && $slack['review_channel']; + $this->template = "review.edit.html"; $this->addVar("id", $id ?? 0); $this->addVar("album", $albums[0]); @@ -452,7 +455,7 @@ public function editReview() { $this->addVar("self", $self); $this->addVar("review", $review); $this->addVar("private", $_REQUEST["private"] ?? 0); - $this->addVar("exported", isset($exportid)); + $this->addVar("exported", !$export || isset($exportid)); $this->addVar("MAX_AIRNAME_LENGTH", IDJ::MAX_AIRNAME_LENGTH); $this->addVar("MAX_REVIEW_LENGTH", IReview::MAX_REVIEW_LENGTH); } From 8dddc909758517e08a370545b7496431cc5957e7 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Mon, 15 Jan 2024 15:05:09 +0000 Subject: [PATCH 04/11] added logo block to topnav --- ui/templates/default/topnav.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/templates/default/topnav.html b/ui/templates/default/topnav.html index bd5104c3..afa02c6a 100644 --- a/ui/templates/default/topnav.html +++ b/ui/templates/default/topnav.html @@ -24,7 +24,9 @@ {% for item in app.menu %} From d8dbd0ce5dbd80696a4b815031fc25affba2c575 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Tue, 16 Jan 2024 10:23:03 +0000 Subject: [PATCH 05/11] normalised setTemplate (non-semantic change) --- ui/Reviews.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/Reviews.php b/ui/Reviews.php index fb492198..cf440b9d 100644 --- a/ui/Reviews.php +++ b/ui/Reviews.php @@ -119,7 +119,7 @@ public function reviewsByDJ() { $this->addVar("airname", $airname); $this->addVar("key", $viewuser); $this->tertiary = $airname; - $this->template = "search.reviews.html"; + $this->setTemplate("search.reviews.html"); return; } } @@ -446,7 +446,7 @@ public function editReview() { $slack = Engine::param('slack'); $export = $slack && $slack['token'] && $slack['review_channel']; - $this->template = "review.edit.html"; + $this->setTemplate("review.edit.html"); $this->addVar("id", $id ?? 0); $this->addVar("album", $albums[0]); $this->addVar("errorMessage", $errorMessage); From cec3e3d932f949728535d2dc7ccd07ad8d0e0649 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Wed, 24 Jan 2024 18:30:43 +0000 Subject: [PATCH 06/11] added Experimental subcategory for General --- engine/ILibrary.php | 1 + 1 file changed, 1 insertion(+) diff --git a/engine/ILibrary.php b/engine/ILibrary.php index 4f4cf215..4f94efe6 100644 --- a/engine/ILibrary.php +++ b/engine/ILibrary.php @@ -33,6 +33,7 @@ interface ILibrary { "C"=>"Country", "G"=>"General", "1"=>"General - Electronic", + "3"=>"General - Experimental", "2"=>"General - Loud", "H"=>"Hip-hop", "J"=>"Jazz", From 3c35cf418ddee68ae464494195c21c9f6103280f Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Tue, 30 Jan 2024 10:07:14 +0000 Subject: [PATCH 07/11] added Powered By metadata --- api/index.php | 1 + controllers/TemplateFactoryXML.php | 1 + controllers/templates/default/rss/adds.xml | 1 + controllers/templates/default/rss/charts.xml | 1 + controllers/templates/default/rss/reviews.xml | 1 + ui/UIController.php | 1 + 6 files changed, 6 insertions(+) diff --git a/api/index.php b/api/index.php index 01e6c1e5..d9ad9721 100644 --- a/api/index.php +++ b/api/index.php @@ -89,6 +89,7 @@ function serveRequest() { } header("HTTP/1.1 ".$response->status()); + header("X-Powered-By: " . Engine::UA); foreach($response->headers()->all() as $header => $value) header("$header: $value"); diff --git a/controllers/TemplateFactoryXML.php b/controllers/TemplateFactoryXML.php index 7cc4c86d..467ce296 100644 --- a/controllers/TemplateFactoryXML.php +++ b/controllers/TemplateFactoryXML.php @@ -40,5 +40,6 @@ public function __construct() { $escaper->setDefaultStrategy('xml'); $this->app->baseUrl = Engine::getBaseUrl(); + $this->app->UA = Engine::UA; } } diff --git a/controllers/templates/default/rss/adds.xml b/controllers/templates/default/rss/adds.xml index ce89d1f4..0dd1b5fb 100644 --- a/controllers/templates/default/rss/adds.xml +++ b/controllers/templates/default/rss/adds.xml @@ -5,6 +5,7 @@ {{ app.station_title }} A-File Adds {{ app.email.md }} en-us + {{ app.UA }} {% for add in adds %} {%~ set title = app.station ~ " Adds for " ~ add.addDate | date(dateSpec) %} {%~ set link = app.baseUrl ~ "?action=addmgr&subaction=adds&date=" ~ add.addDate %} diff --git a/controllers/templates/default/rss/charts.xml b/controllers/templates/default/rss/charts.xml index 664705df..aa12c02d 100644 --- a/controllers/templates/default/rss/charts.xml +++ b/controllers/templates/default/rss/charts.xml @@ -5,6 +5,7 @@ {{ app.station_title }} Airplay Charts {{ app.email.md }} en-us + {{ app.UA }} {% for chart in charts %} {%~ set title = app.station ~ " TOP " ~ limit ~ " for the week ending " ~ chart.endDate | date(dateSpec) %} {%~ set link = app.baseUrl ~ "?action=viewChart&subaction=weekly&year=" ~ chart.endDate | slice(0, 4) ~ "&month=" ~ chart.endDate | slice(5, 2) ~ "&day=" ~ chart.endDate | slice(8, 2) %} diff --git a/controllers/templates/default/rss/reviews.xml b/controllers/templates/default/rss/reviews.xml index 906af7fd..a496b8a0 100644 --- a/controllers/templates/default/rss/reviews.xml +++ b/controllers/templates/default/rss/reviews.xml @@ -6,6 +6,7 @@ {{ app.email.md }} 20 en-us + {{ app.UA }} {% for review in reviews %} dispatch($action, $subaction); From 35fcc8f538fcb21ee0575b2684b0f39427525f9c Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Tue, 30 Jan 2024 16:01:50 +0000 Subject: [PATCH 08/11] finessed narrow layout --- css/topnav.css | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/css/topnav.css b/css/topnav.css index 2836244c..4c5975a4 100644 --- a/css/topnav.css +++ b/css/topnav.css @@ -27,7 +27,7 @@ div.box { nav { background: var(--theme-nav-background-colour); display: flex; - flex-wrap: wrap; + flex-wrap: nowrap; align-items: center; justify-content: space-between; height: 70px; @@ -171,7 +171,7 @@ ul#search-filter-menu li { nav .menu-icon, nav .cancel-icon, nav .search-icon { - width: 40px; + width: 18px; text-align: center; margin: 0 50px; font-size: 18px; @@ -255,6 +255,7 @@ nav .search-icon { nav .logo { flex: 2; text-align: center; + margin-right: inherit; } nav .nav-items { position: fixed; @@ -344,9 +345,7 @@ nav .search-icon { #search-submit { display: none; } - nav .menu-icon { - display: block; - } + nav .menu-icon, nav .search-icon, nav .menu-icon span { display: block; @@ -359,7 +358,9 @@ nav .search-icon { display: block; } nav .login-search .login a { - padding-right: 20px; + margin-left: 10px; + margin-right: 20px; + font-size: 16px; } nav .login-search .login .whois { position: absolute; @@ -379,17 +380,26 @@ nav .search-icon { nav .search-icon { margin: 0 20px; } + nav .menu-icon { + margin-left: 31px; + } nav form { right: 30px; } } -@media (max-width: 350px) { +@media (max-width: 400px) { nav .menu-icon, nav .cancel-icon, nav .search-icon { margin: 0 10px; font-size: 16px; } + nav .menu-icon { + margin-left: 21px; + } + nav .login-search .login a { + font-size: 14px; + } } .result-count { @@ -471,6 +481,11 @@ nav .search-icon { display: none; } } +@media (max-width: 400px) { + .breadcrumbs { + left: -20px; + } +} /* end breadcrumbs */ /* start topnav extra */ From 3a3666aa4e421255098c779e94411165ea0cb79c Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Fri, 9 Feb 2024 16:03:17 +0000 Subject: [PATCH 09/11] suppress on-now album name if none --- js/home.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/home.js b/js/home.js index 0f2e550f..caf52ffc 100644 --- a/js/home.js +++ b/js/home.js @@ -173,7 +173,10 @@ $().ready(function(){ if(onnow.id == 0) { $(".home-currenttrack").html(" "); } else { - $(".home-currenttrack").html(onnow.track_artist + " – " + onnow.track_title + " (" + onnow.track_album + ")"); + var track = onnow.track_artist + " – " + onnow.track_title + ""; + if(onnow.track_album) + track += " (" + onnow.track_album + ")"; + $(".home-currenttrack").html(track); var time = $("#time").val(); var nowPlaying = $(".recently-played"); From f0c13223615de561431a2d3fdd81dd2cb1dbc01b Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Mon, 12 Feb 2024 12:35:26 +0000 Subject: [PATCH 10/11] enhanced Discogs album match in Library Editor closes #430 --- js/editor.common.js | 3 +-- ui/Editor.php | 52 +++++++++++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/js/editor.common.js b/js/editor.common.js index a14487cf..a4cbe800 100644 --- a/js/editor.common.js +++ b/js/editor.common.js @@ -2,7 +2,7 @@ // Zookeeper Online // // @author Jim Mason -// @copyright Copyright (C) 1997-2023 Jim Mason +// @copyright Copyright (C) 1997-2024 Jim Mason // @link https://zookeeper.ibinx.com/ // @license GPL-3.0 // @@ -502,7 +502,6 @@ $().ready(function() { $(".clear-prefill").removeClass('zk-hidden'); } else { $("#discogs-no-match-album").text($("input[name=album]").val()); - $("#discogs-no-match-media").text(mediaTypes[$("input[name=medium]").val()]); $(".discogs-no-match").slideDown(); } }); diff --git a/ui/Editor.php b/ui/Editor.php index 27d3170d..7ae2f5ea 100644 --- a/ui/Editor.php +++ b/ui/Editor.php @@ -3,7 +3,7 @@ * Zookeeper Online * * @author Jim Mason - * @copyright Copyright (C) 1997-2023 Jim Mason + * @copyright Copyright (C) 1997-2024 Jim Mason * @link https://zookeeper.ibinx.com/ * @license GPL-3.0 * @@ -218,6 +218,16 @@ private function getUrlAutofill() { && $this->session->isAuth("p"); } + private static function isSpecialEdition($formats) { + return array_reduce($formats, + function($carry, $item) { + return $carry || + $item == "Promo" || + strpos($item, "Edition") !== false || + strpos($item, "Test") !== false; + }); + } + private function prefillTracks() { $config = $this->getDiscogsConfig(); if($config) { @@ -232,7 +242,7 @@ private function prefillTracks() { switch($_GET["medium"] ?? null) { case 'S': - $format = "Vinyl, 7\""; + $format = "7\""; break; case 'T': case 'V': @@ -241,6 +251,9 @@ private function prefillTracks() { case 'M': $format = "Cassette"; break; + case 'D': + $format = "File"; + break; default: $format = "CD"; break; @@ -250,35 +263,35 @@ private function prefillTracks() { RequestOptions::QUERY => [ "artist" => $_GET["artist"] ?? "Various", "release_title" => $_GET["album"], - "format" => $format, - "per_page" => 20 + "per_page" => 40 ] ]); $page = $response->getBody()->getContents(); $json = json_decode($page); + // precedence: preferred-medium > master > CD/Vinyl > other if($json->results && ($result = $json->results[0])) { foreach($json->results as $r) { - if($r->master_id != $result->master_id) - continue; - - // master releases are definitive - if($r->type == "master") { + // exact medium match is definitive + // use if current best is Promo or Limited/Special Edition + if(in_array($format, $r->format) && + (!in_array($format, $result->format) || + self::isSpecialEdition($result->format))) { $result = $r; break; } - // ignore promos and limited/special editions - if(array_reduce($r->format, - function($carry, $item) { - return $carry || - $item == "Promo" || - strpos($item, "Edition") !== false; - })) + // master releases take precedence... + if($result->type == "master") continue; - $result = $r; + // ...followed by CDs and Vinyl that are neither Promos nor Limited/Special Editions + if($r->type == "master" || + count(array_intersect($r->format, ['CD', 'Vinyl'])) && + !self::isSpecialEdition($r->format)) { + $result = $r; + } } $imageUrl = $result->cover_image && @@ -1297,10 +1310,7 @@ private function emitTrackList($focusTrack, $isCollection) { if the tracks do not match the album.

No Discogs tracks for - with media type - found.

-

If you believe the album is in Discogs, please check that you - have specified the correct media type.

+ found.

Artist" : ""; From 47f4339267d5ce3c96c0d68873128caa71db1918 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Mon, 12 Feb 2024 22:35:57 +0000 Subject: [PATCH 11/11] finessed previous revision to preference exact match only if not Promo or Special Edition --- ui/Editor.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/Editor.php b/ui/Editor.php index 7ae2f5ea..aa68da85 100644 --- a/ui/Editor.php +++ b/ui/Editor.php @@ -274,10 +274,9 @@ private function prefillTracks() { if($json->results && ($result = $json->results[0])) { foreach($json->results as $r) { // exact medium match is definitive - // use if current best is Promo or Limited/Special Edition + // if not Promo or Limited/Special Edition if(in_array($format, $r->format) && - (!in_array($format, $result->format) || - self::isSpecialEdition($result->format))) { + !self::isSpecialEdition($r->format)) { $result = $r; break; }