Compare commits
4 Commits
beea9a0dcf
...
15c153c56a
| Author | SHA1 | Date | |
|---|---|---|---|
| 15c153c56a | |||
| 010943e587 | |||
| 08aa5b8a2d | |||
| b08eb2573c |
@@ -1,30 +1,25 @@
|
||||
package com.discdrop.client.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record ReleaseGroupBrowseResponse(
|
||||
List<ReleaseGroup> releaseGroups,
|
||||
int releaseGroupCount
|
||||
@JsonProperty("release-groups") List<ReleaseGroup> releaseGroups,
|
||||
@JsonProperty("release-group-count") int releaseGroupCount
|
||||
) {
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record ReleaseGroup(
|
||||
String id,
|
||||
String title,
|
||||
String firstReleaseDate,
|
||||
PrimaryType primaryType,
|
||||
List<SecondaryType> secondaryTypes,
|
||||
List<ArtistCredit> artistCredit
|
||||
@JsonProperty("first-release-date") String firstReleaseDate,
|
||||
@JsonProperty("primary-type") String primaryType,
|
||||
@JsonProperty("secondary-types") List<String> secondaryTypes,
|
||||
@JsonProperty("artist-credit") List<ArtistCredit> artistCredit
|
||||
) {
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record PrimaryType(String id, String name) {}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record SecondaryType(String id, String name) {}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record ArtistCredit(Artist artist) {
|
||||
public record ArtistCredit(@JsonProperty("artist") Artist artist) {
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record Artist(String id, String name) {}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class DatabaseService {
|
||||
var typePlaceholders = String.join(",", primaryTypes.stream().map(t -> "?").toList());
|
||||
sql += " AND primary_type IN (" + typePlaceholders + ")";
|
||||
}
|
||||
sql += " ORDER BY first_release_date ASC";
|
||||
sql += " ORDER BY first_release_date DESC";
|
||||
|
||||
try (Connection conn = getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement(sql)) {
|
||||
|
||||
@@ -43,15 +43,14 @@ public class ReleaseGroupService {
|
||||
total = Math.min(page.releaseGroupCount(), MAX_RELEASE_GROUPS);
|
||||
|
||||
for (var rg : page.releaseGroups()) {
|
||||
String primaryType = rg.primaryType() != null ? rg.primaryType().name() : "Other";
|
||||
String primaryType = rg.primaryType() != null ? rg.primaryType() : "Other";
|
||||
|
||||
if (!monitoredTypes.contains(primaryType)) continue;
|
||||
|
||||
String secondaryTypes = "[]";
|
||||
if (rg.secondaryTypes() != null && !rg.secondaryTypes().isEmpty()) {
|
||||
try {
|
||||
secondaryTypes = json.writeValueAsString(
|
||||
rg.secondaryTypes().stream().map(s -> s.name()).toList());
|
||||
secondaryTypes = json.writeValueAsString(rg.secondaryTypes());
|
||||
} catch (Exception e) {
|
||||
secondaryTypes = "[]";
|
||||
}
|
||||
|
||||
@@ -79,8 +79,6 @@ public class RSSFeedBuilder {
|
||||
|
||||
private String buildDescription(ReleaseGroup rg) {
|
||||
var sb = new StringBuilder();
|
||||
sb.append("<img src=\"https://coverartarchive.org/release-group/")
|
||||
.append(rg.mbid()).append("/front\" alt=\"Cover\" onerror=\"this.style.display='none'\">");
|
||||
sb.append("<p><b>").append(escHtml(rg.artistName())).append("</b>")
|
||||
.append(" <i>").append(escHtml(rg.title())).append("</i><br>");
|
||||
sb.append("Type: ").append(escHtml(rg.primaryType()));
|
||||
@@ -88,6 +86,8 @@ public class RSSFeedBuilder {
|
||||
sb.append(" | Secondary: ").append(escHtml(rg.secondaryTypes()));
|
||||
}
|
||||
sb.append("<br>First Release Date: ").append(rg.firstReleaseDate());
|
||||
sb.append("<br><a href=\"https://coverartarchive.org/release-group/")
|
||||
.append(rg.mbid()).append("/front\">Cover Art</a>");
|
||||
sb.append("</p>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.quarkus.qute.TemplateInstance;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,12 +56,14 @@ public class ArtistController {
|
||||
@POST
|
||||
@Path("/{mbid}/track")
|
||||
@Produces(MediaType.TEXT_HTML)
|
||||
public TemplateInstance trackArtist(@PathParam("mbid") String mbid) {
|
||||
public Response trackArtist(@PathParam("mbid") String mbid) {
|
||||
var artist = artistService.addArtist(mbid);
|
||||
var types = getMonitoredTypes(artist);
|
||||
releaseGroupService.fetchAndCache(artist.mbid(), artist.name(), types);
|
||||
var allArtists = artistService.findAll();
|
||||
return artistListTemplate.data("artists", allArtists);
|
||||
var listHtml = artistListTemplate.data("artists", allArtists).render();
|
||||
var emptySearch = searchResultsTemplate.data("artists", List.of()).render();
|
||||
return Response.ok(emptySearch + listHtml).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{#include layouts/base}
|
||||
{#page-content}
|
||||
<div class="container mx-auto p-4">
|
||||
<div class="w-full max-w-4xl mx-auto">
|
||||
<h2 class="text-2xl font-bold mb-4">🎤 Artists</h2>
|
||||
<div id="artist-list" hx-get="/api/artists/list" hx-trigger="load">
|
||||
<span class="loading loading-spinner loading-lg"></span>
|
||||
<span class="loading loading-spinner loading-lg block mx-auto"></span>
|
||||
</div>
|
||||
</div>
|
||||
{/page-content}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<div id="artist-list" hx-swap-oob="true">
|
||||
{#if artists.isEmpty()}
|
||||
<div class="card bg-base-100 shadow-xl p-8 text-center">
|
||||
<p class="text-lg text-base-content/60">No artists tracked yet</p>
|
||||
@@ -30,35 +31,40 @@
|
||||
<input type="checkbox" class="checkbox checkbox-xs checkbox-primary"
|
||||
{#if artist.albumMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=album"
|
||||
hx-target="#artist-list" hx-swap="innerHTML">
|
||||
hx-target="#artist-list"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs">Album</span>
|
||||
</label>
|
||||
<label class="label cursor-pointer gap-1">
|
||||
<input type="checkbox" class="checkbox checkbox-xs"
|
||||
{#if artist.singleMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=single"
|
||||
hx-target="#artist-list" hx-swap="innerHTML">
|
||||
hx-target="#artist-list"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs">Single</span>
|
||||
</label>
|
||||
<label class="label cursor-pointer gap-1">
|
||||
<input type="checkbox" class="checkbox checkbox-xs"
|
||||
{#if artist.epMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=ep"
|
||||
hx-target="#artist-list" hx-swap="innerHTML">
|
||||
hx-target="#artist-list"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs">EP</span>
|
||||
</label>
|
||||
<label class="label cursor-pointer gap-1">
|
||||
<input type="checkbox" class="checkbox checkbox-xs"
|
||||
{#if artist.broadcastMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=broadcast"
|
||||
hx-target="#artist-list" hx-swap="innerHTML">
|
||||
hx-target="#artist-list"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs">Broadcast</span>
|
||||
</label>
|
||||
<label class="label cursor-pointer gap-1">
|
||||
<input type="checkbox" class="checkbox checkbox-xs"
|
||||
{#if artist.otherMonitored}checked{/if}
|
||||
hx-patch="/api/artists/{artist.mbid}/monitor?type=other"
|
||||
hx-target="#artist-list" hx-swap="innerHTML">
|
||||
hx-target="#artist-list"
|
||||
hx-swap="innerHTML">
|
||||
<span class="label-text text-xs">Other</span>
|
||||
</label>
|
||||
</div>
|
||||
@@ -78,3 +84,4 @@
|
||||
</table>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="card bg-base-100 shadow-xl mt-1 max-h-64 overflow-y-auto">
|
||||
<div class="bg-base-100 shadow-xl border border-base-300 rounded-box mt-1 max-h-64 overflow-y-auto">
|
||||
{#if artists.isEmpty()}
|
||||
<div class="p-3 text-sm text-base-content/60">No artists found</div>
|
||||
{#else}
|
||||
@@ -18,9 +18,9 @@
|
||||
{#else}
|
||||
<button class="btn btn-primary btn-xs"
|
||||
hx-post="/api/artists/{artist.mbid}/track"
|
||||
hx-target="#artist-list"
|
||||
hx-target="#search-results"
|
||||
hx-swap="innerHTML"
|
||||
onclick="this.closest('#search-results').innerHTML=''; document.querySelector('[name=q]').value=''">
|
||||
onclick="document.getElementById('search-input').value=''">
|
||||
+ Add
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
@@ -7,40 +7,63 @@
|
||||
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.23/dist/full.min.css" rel="stylesheet">
|
||||
<script src="https://unpkg.com/htmx.org@2.0.4/dist/htmx.min.js"></script>
|
||||
<style>
|
||||
.search-dropdown {
|
||||
#search-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
#search-results {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 50;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var saved = localStorage.getItem('daisyui-theme');
|
||||
if (saved) document.documentElement.setAttribute('data-theme', saved);
|
||||
});
|
||||
function setTheme(sel) {
|
||||
var theme = sel.value;
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('daisyui-theme', theme);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body class="min-h-screen bg-base-200">
|
||||
<div class="navbar bg-base-100 shadow-lg px-4">
|
||||
<div class="flex-1 gap-2">
|
||||
<a href="/" class="text-xl font-bold">🎵 DiscDrop</a>
|
||||
<div class="tabs tabs-box ml-4 hidden sm:flex">
|
||||
<a href="/" class="tab {#if activeTab == 'releases'}tab-active{/if}">Releases</a>
|
||||
<a href="/artists" class="tab {#if activeTab == 'artists'}tab-active{/if}">Artists</a>
|
||||
<div class="navbar-start">
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="/" class="text-xl font-bold">🎵 DiscDrop</a>
|
||||
<div class="tabs tabs-box ml-2 hidden sm:flex">
|
||||
<a href="/" class="tab {#if activeTab == 'releases'}tab-active{/if}">Releases</a>
|
||||
<a href="/artists" class="tab {#if activeTab == 'artists'}tab-active{/if}">Artists</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-none gap-2 relative">
|
||||
<div class="form-control">
|
||||
<input type="text" placeholder="Search artists..."
|
||||
class="input input-bordered input-sm w-48 md:w-64"
|
||||
name="q"
|
||||
hx-get="/api/artists/search"
|
||||
hx-trigger="keyup changed delay:300ms"
|
||||
hx-target="#search-results"
|
||||
hx-swap="innerHTML"
|
||||
autocomplete="off">
|
||||
<div class="navbar-center">
|
||||
<div id="search-wrapper" class="w-48 md:w-64">
|
||||
<form hx-get="/api/artists/search"
|
||||
hx-target="#search-results"
|
||||
hx-swap="innerHTML"
|
||||
hx-trigger="keyup changed delay:300ms from:#search-input">
|
||||
<input id="search-input"
|
||||
type="text"
|
||||
placeholder="Search artists..."
|
||||
class="input input-bordered input-sm w-full"
|
||||
name="q"
|
||||
autocomplete="off">
|
||||
</form>
|
||||
<div id="search-results"></div>
|
||||
</div>
|
||||
<div id="search-results" class="search-dropdown"></div>
|
||||
</div>
|
||||
|
||||
<select class="select select-bordered select-sm w-full max-w-[8rem]" data-choose-theme>
|
||||
<option value="dark">Dark</option>
|
||||
<div class="navbar-end gap-2">
|
||||
<select class="select select-bordered select-sm w-full max-w-[8rem]"
|
||||
onchange="setTheme(this)">
|
||||
<option value="dark" selected>Dark</option>
|
||||
<option value="light">Light</option>
|
||||
<option value="synthwave">Synthwave</option>
|
||||
<option value="retro">Retro</option>
|
||||
@@ -60,7 +83,7 @@
|
||||
</main>
|
||||
|
||||
<dialog id="settingsModal" class="modal">
|
||||
<div class="modal-box" id="settings-modal-content"
|
||||
<div class="modal-box max-w-md" id="settings-modal-content"
|
||||
hx-get="/api/settings/form"
|
||||
hx-trigger="load"
|
||||
hx-swap="innerHTML">
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{#include layouts/base}
|
||||
{#page-content}
|
||||
<div class="container mx-auto p-4">
|
||||
<h2 class="text-2xl font-bold mb-4">📡 Releases</h2>
|
||||
<div class="w-full max-w-4xl mx-auto">
|
||||
<h2 class="text-2xl font-bold mb-4 text-center">📡 Releases</h2>
|
||||
<div id="feed-entries" hx-get="/api/artists/feed-table" hx-trigger="load">
|
||||
<span class="loading loading-spinner loading-lg"></span>
|
||||
<span class="loading loading-spinner loading-lg block mx-auto"></span>
|
||||
</div>
|
||||
<div class="mt-4 flex gap-4">
|
||||
<div class="mt-6 flex justify-center gap-4">
|
||||
<a href="/feed/rss.xml" class="btn btn-primary">📥 RSS Feed</a>
|
||||
<a href="/feed/opml" class="btn btn-ghost">📋 OPML</a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user