Added artist tag cloud
This commit is contained in:
@@ -13,11 +13,16 @@
|
||||
<message id="template-artist">
|
||||
<div class="page-header">
|
||||
<h2>${name}</h2>
|
||||
${tags}
|
||||
${play-btn}${add-btn}
|
||||
</div>
|
||||
${releases class="list-group"}
|
||||
</message>
|
||||
|
||||
<message id="template-artist-tag-entry">
|
||||
<span class="badge">${name}</span>
|
||||
</message>
|
||||
|
||||
<message id="template-artist-entry">
|
||||
<div class="media list-group-item">
|
||||
<div class="pull-left media-middle">
|
||||
|
||||
@@ -183,6 +183,25 @@ Artist::getReleases(const std::set<id_type>& clusterIds) const
|
||||
return std::vector< Wt::Dbo::ptr<Release> > (res.begin(), res.end());
|
||||
}
|
||||
|
||||
std::vector<Wt::Dbo::ptr<Cluster>>
|
||||
Artist::getClusters(int size) const
|
||||
{
|
||||
assert(self());
|
||||
assert(self()->id() != Wt::Dbo::dbo_traits<Artist>::invalidId() );
|
||||
assert(session());
|
||||
|
||||
Wt::Dbo::Query<Cluster::pointer> query = session()->query<Cluster::pointer>
|
||||
("select c from cluster c INNER JOIN track t ON c.id = t_c.cluster_id INNER JOIN track_cluster t_c ON t_c.track_id = t.id INNER JOIN artist a ON t.artist_id = a.id")
|
||||
.where("a.id = ?").bind(self()->id())
|
||||
.groupBy("c.id")
|
||||
.orderBy("COUNT(c.id) DESC")
|
||||
.limit(size);
|
||||
|
||||
Wt::Dbo::collection<Cluster::pointer> res = query;
|
||||
|
||||
return std::vector<Cluster::pointer>(res.begin(), res.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Database
|
||||
|
||||
@@ -63,9 +63,12 @@ class Artist : public Wt::Dbo::Dbo<Artist>
|
||||
std::string getName(void) const { return _name; }
|
||||
std::string getMBID(void) const { return _MBID; }
|
||||
|
||||
// Get the releases that have at least one track for this artist + belongs to optonal cluster filters
|
||||
// Get the releases that have at least one track for this artist that belongs to optional cluster filters
|
||||
std::vector<Wt::Dbo::ptr<Release>> getReleases(const std::set<id_type>& clusterIds = std::set<id_type>()) const;
|
||||
|
||||
// Get the cluster of the tracks made by this artist
|
||||
std::vector<Wt::Dbo::ptr<Cluster>> getClusters(int size) const;
|
||||
|
||||
void setMBID(std::string mbid) { _MBID = mbid; }
|
||||
|
||||
// Create
|
||||
|
||||
@@ -74,6 +74,20 @@ Artist::refresh()
|
||||
auto t = new Wt::WTemplate(Wt::WString::tr("template-artist"), this);
|
||||
t->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
|
||||
auto clusterContainers = new Wt::WContainerWidget();
|
||||
t->bindWidget("tags", clusterContainers);
|
||||
|
||||
{
|
||||
auto clusters = artist->getClusters(3);
|
||||
|
||||
for (auto cluster : clusters)
|
||||
{
|
||||
auto entry = new Wt::WTemplate(Wt::WString::tr("template-artist-tag-entry"), clusterContainers);
|
||||
|
||||
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::PlainText);
|
||||
}
|
||||
}
|
||||
|
||||
t->bindString("name", Wt::WString::fromUTF8(artist->getName()), Wt::PlainText);
|
||||
{
|
||||
auto playBtn = new Wt::WText(Wt::WString::tr("btn-artist-play-btn"), Wt::XHTMLText);
|
||||
|
||||
Reference in New Issue
Block a user