Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge hotfix-3-0-0-rc-6 #434

Merged
merged 11 commits into from
Mar 3, 2024
1 change: 1 addition & 0 deletions api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
1 change: 1 addition & 0 deletions controllers/TemplateFactoryXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ public function __construct() {
$escaper->setDefaultStrategy('xml');

$this->app->baseUrl = Engine::getBaseUrl();
$this->app->UA = Engine::UA;
}
}
1 change: 1 addition & 0 deletions controllers/templates/default/rss/adds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<description>{{ app.station_title }} A-File Adds</description>
<managingEditor>{{ app.email.md }}</managingEditor>
<language>en-us</language>
<generator>{{ app.UA }}</generator>
{% for add in adds %}
{%~ set title = app.station ~ " Adds for " ~ add.addDate | date(dateSpec) %}
{%~ set link = app.baseUrl ~ "?action=addmgr&amp;subaction=adds&amp;date=" ~ add.addDate %}
Expand Down
1 change: 1 addition & 0 deletions controllers/templates/default/rss/charts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<description>{{ app.station_title }} Airplay Charts</description>
<managingEditor>{{ app.email.md }}</managingEditor>
<language>en-us</language>
<generator>{{ app.UA }}</generator>
{% for chart in charts %}
{%~ set title = app.station ~ " TOP " ~ limit ~ " for the week ending " ~ chart.endDate | date(dateSpec) %}
{%~ set link = app.baseUrl ~ "?action=viewChart&amp;subaction=weekly&amp;year=" ~ chart.endDate | slice(0, 4) ~ "&amp;month=" ~ chart.endDate | slice(5, 2) ~ "&amp;day=" ~ chart.endDate | slice(8, 2) %}
Expand Down
1 change: 1 addition & 0 deletions controllers/templates/default/rss/reviews.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<managingEditor>{{ app.email.md }}</managingEditor>
<ttl>20</ttl>
<language>en-us</language>
<generator>{{ app.UA }}</generator>
{% for review in reviews %}
<item>
<description><![CDATA[
Expand Down
29 changes: 22 additions & 7 deletions css/topnav.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -255,6 +255,7 @@ nav .search-icon {
nav .logo {
flex: 2;
text-align: center;
margin-right: inherit;
}
nav .nav-items {
position: fixed;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -471,6 +481,11 @@ nav .search-icon {
display: none;
}
}
@media (max-width: 400px) {
.breadcrumbs {
left: -20px;
}
}
/* end breadcrumbs */

/* start topnav extra */
Expand Down
1 change: 1 addition & 0 deletions engine/ILibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface ILibrary {
"C"=>"Country",
"G"=>"General",
"1"=>"General - Electronic",
"3"=>"General - Experimental",
"2"=>"General - Loud",
"H"=>"Hip-hop",
"J"=>"Jazz",
Expand Down
3 changes: 1 addition & 2 deletions js/editor.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Zookeeper Online
//
// @author Jim Mason <[email protected]>
// @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]>
// @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
// @link https://zookeeper.ibinx.com/
// @license GPL-3.0
//
Expand Down Expand Up @@ -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();
}
});
Expand Down
5 changes: 4 additions & 1 deletion js/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ $().ready(function(){
if(onnow.id == 0) {
$(".home-currenttrack").html("&nbsp;");
} else {
$(".home-currenttrack").html(onnow.track_artist + " &#8211; <i>" + onnow.track_title + "</i> (" + onnow.track_album + ")");
var track = onnow.track_artist + " &#8211; <i>" + onnow.track_title + "</i>";
if(onnow.track_album)
track += " (" + onnow.track_album + ")";
$(".home-currenttrack").html(track);

var time = $("#time").val();
var nowPlaying = $(".recently-played");
Expand Down
4 changes: 3 additions & 1 deletion js/playlists.track.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
Expand Down
51 changes: 30 additions & 21 deletions ui/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -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) {
Expand All @@ -232,7 +242,7 @@ private function prefillTracks() {

switch($_GET["medium"] ?? null) {
case 'S':
$format = "Vinyl, 7\"";
$format = "7\"";
break;
case 'T':
case 'V':
Expand All @@ -241,6 +251,9 @@ private function prefillTracks() {
case 'M':
$format = "Cassette";
break;
case 'D':
$format = "File";
break;
default:
$format = "CD";
break;
Expand All @@ -250,35 +263,34 @@ 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
// if not Promo or Limited/Special Edition
if(in_array($format, $r->format) &&
!self::isSpecialEdition($r->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 &&
Expand Down Expand Up @@ -1297,10 +1309,7 @@ private function emitTrackList($focusTrack, $isCollection) {
if the tracks do not match the album.</p></div>
<div class='user-tip discogs-no-match'>
<p>No Discogs tracks for <span id='discogs-no-match-album'></span>
with media type <span id='discogs-no-match-media'></span>
found.</p>
<p>If you believe the album is in Discogs, please check that you
have specified the correct media type.</p></div>
found.</p></div>
<table class='trackEditor'>
<?php
$artistHdr = $isCollection ? "<TH>Artist</TH>" : "";
Expand Down
11 changes: 7 additions & 4 deletions ui/Reviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -443,7 +443,10 @@ public function editReview() {
$airnames[] = $row['airname'];
$airnames[] = $self;

$this->template = "review.edit.html";
$slack = Engine::param('slack');
$export = $slack && $slack['token'] && $slack['review_channel'];

$this->setTemplate("review.edit.html");
$this->addVar("id", $id ?? 0);
$this->addVar("album", $albums[0]);
$this->addVar("errorMessage", $errorMessage);
Expand All @@ -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);
}
Expand Down
14 changes: 7 additions & 7 deletions ui/UICommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions ui/UIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public function processRequest() {
$isJson = isset($_SERVER["HTTP_ACCEPT"]) &&
substr($_SERVER["HTTP_ACCEPT"], 0, 16) === 'application/json';
ob_start("ob_gzhandler");
header("X-Powered-By: " . Engine::UA);
if ($isJson) {
header("Content-Type: application/json");
$this->dispatch($action, $subaction);
Expand Down
2 changes: 2 additions & 0 deletions ui/templates/default/topnav.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
<span class="fas fa-bars"></span>
</div>
<div class="logo">
{% block logo %}
{{ app.station_title }}
{% endblock %}
</div>
<menu class="nav-items">
{% for item in app.menu %}
Expand Down
Loading