add related links
artist links to feed page (/feed/:ID) release links to feed xml (release description)
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Edit Feed: {{ feed.name }}</h2>
|
||||
|
||||
<h3>Artists in this feed</h3>
|
||||
<ul>
|
||||
{% for artist in feed.artists %}
|
||||
<li>
|
||||
{{ artist.name }}
|
||||
{% if artist.links %}
|
||||
{% for type, link in artist.links.items() %}
|
||||
<a href="{{ link }}" target="_blank">{{ type }}</a>{% if not loop.last %} | {% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<div class="item-actions">
|
||||
<form class="form-inline" action="{{ url_for('remove_artist', feed_id=feed.id, artist_id=artist.id) }}" method="post">
|
||||
<button type="submit">Remove</button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>No artists in this feed.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h3>Add Artist</h3>
|
||||
<form onsubmit="return false;">
|
||||
<input type="text" id="artist-search" placeholder="Search for an artist...">
|
||||
</form>
|
||||
<div id="search-results"></div>
|
||||
|
||||
<script>
|
||||
const searchInput = document.getElementById('artist-search');
|
||||
const resultsDiv = document.getElementById('search-results');
|
||||
let searchTimeout;
|
||||
|
||||
searchInput.addEventListener('input', () => {
|
||||
clearTimeout(searchTimeout);
|
||||
const query = searchInput.value;
|
||||
if (query.length < 3) {
|
||||
resultsDiv.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
searchTimeout = setTimeout(() => {
|
||||
fetch(`{{ url_for('search_artist') }}?q=${encodeURIComponent(query)}`)
|
||||
.then(response => response.json())
|
||||
.then(artists => {
|
||||
resultsDiv.innerHTML = '<h4>Search Results</h4>';
|
||||
if (artists.length === 0) {
|
||||
resultsDiv.innerHTML += '<p>No artists found.</p>';
|
||||
return;
|
||||
}
|
||||
const list = document.createElement('ul');
|
||||
artists.forEach(artist => {
|
||||
const item = document.createElement('li');
|
||||
item.innerHTML = `
|
||||
<div>
|
||||
${artist.name} (${artist.country || 'N/A'})
|
||||
</div>
|
||||
<div class="item-actions">
|
||||
<form class="form-inline" action="{{ url_for('add_artist', feed_id=feed.id) }}" method="post">
|
||||
<input type="hidden" name="artist_id" value="${artist.id}">
|
||||
<input type="hidden" name="artist_name" value="${artist.name}">
|
||||
<button type="submit">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
list.appendChild(item);
|
||||
});
|
||||
resultsDiv.appendChild(list);
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ feed.name }}</title>
|
||||
<link>{{ request.url_root }}</link>
|
||||
<description>Latest album releases for artists in the '{{ feed.name }}' feed.</description>
|
||||
<language>en</language>
|
||||
<lastBuildDate>{{ last_build_date }}</lastBuildDate>
|
||||
<atom:link href="{{ request.url }}" rel="self" type="application/rss+xml" />
|
||||
|
||||
{% for release in releases %}
|
||||
<item>
|
||||
<title>{{ release.artist.name }} - {{ release.title }}</title>
|
||||
<link>https://musicbrainz.org/release/{{ release.id }}</link>
|
||||
<guid isPermaLink="false">{{ release.id }}</guid>
|
||||
<description><![CDATA[
|
||||
{% if release.hasCoverArt %}
|
||||
<img src="https://coverartarchive.org/release/{{ release.id }}/front" alt="Cover Art {{ release.title }}">
|
||||
{% endif %}
|
||||
<p><b>{{ release.artist.name }}</b> <i>{{ release.title }}</i><br>
|
||||
Release Date: {{ release.date }}</p>
|
||||
{% if release.links %}
|
||||
<p><b>Links: </b>
|
||||
{% for type, url in release.links.items() %}
|
||||
<a href="{{ url }}" target="_blank">{{ type | capitalize }}</a>{% if not loop.last %} | {% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
]]></description>
|
||||
{% if release.pub_date %}
|
||||
<pubDate>{{ release.pub_date }}</pubDate>
|
||||
{% endif %}
|
||||
</item>
|
||||
{% endfor %}
|
||||
</channel>
|
||||
</rss>
|
||||
Reference in New Issue
Block a user