Added release tag cloud
This commit is contained in:
+2
-2
@@ -13,13 +13,13 @@
|
|||||||
<message id="template-artist">
|
<message id="template-artist">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2>${name}</h2>
|
<h2>${name}</h2>
|
||||||
${tags}
|
${clusters}
|
||||||
${play-btn}${add-btn}
|
${play-btn}${add-btn}
|
||||||
</div>
|
</div>
|
||||||
${releases class="list-group"}
|
${releases class="list-group"}
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
<message id="template-artist-tag-entry">
|
<message id="template-artist-cluster-entry">
|
||||||
<span class="badge">${name}</span>
|
<span class="badge">${name}</span>
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,16 @@
|
|||||||
<h2>${name}</h2>
|
<h2>${name}</h2>
|
||||||
<h4>${artist-name}</h4>
|
<h4>${artist-name}</h4>
|
||||||
<h4>${<if-has-year>}${year}${</if-has-year>}${<if-has-orig-year>} (${orig-year})${</if-has-orig-year>}</h4>
|
<h4>${<if-has-year>}${year}${</if-has-year>}${<if-has-orig-year>} (${orig-year})${</if-has-orig-year>}</h4>
|
||||||
|
${clusters}
|
||||||
${play-btn}${add-btn}
|
${play-btn}${add-btn}
|
||||||
</div>
|
</div>
|
||||||
${tracks}
|
${tracks}
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<message id="template-release-cluster-entry">
|
||||||
|
<span class="badge">${name}</span>
|
||||||
|
</message>
|
||||||
|
|
||||||
<message id="template-release-entry">
|
<message id="template-release-entry">
|
||||||
${<if-has-disc-number>}${disc-number}-${</if-has-disc-number>}${<if-has-track-number>}${track-number}. ${</if-has-track-number>}
|
${<if-has-disc-number>}${disc-number}-${</if-has-disc-number>}${<if-has-track-number>}${track-number}. ${</if-has-track-number>}
|
||||||
${<if-has-artist>}${artist-name} - ${</if-has-artist>}
|
${<if-has-artist>}${artist-name} - ${</if-has-artist>}
|
||||||
|
|||||||
@@ -202,6 +202,4 @@ Artist::getClusters(int size) const
|
|||||||
return std::vector<Cluster::pointer>(res.begin(), res.end());
|
return std::vector<Cluster::pointer>(res.begin(), res.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Database
|
} // namespace Database
|
||||||
|
|||||||
@@ -225,4 +225,23 @@ Release::getTracks(const std::set<id_type>& clusterIds) const
|
|||||||
return std::vector< Wt::Dbo::ptr<Track> > (res.begin(), res.end());
|
return std::vector< Wt::Dbo::ptr<Track> > (res.begin(), res.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Wt::Dbo::ptr<Cluster>>
|
||||||
|
Release::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 release r ON t.release_id = r.id")
|
||||||
|
.where("r.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
|
} // namespace Database
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class Release : public Wt::Dbo::Dbo<Release>
|
|||||||
bool& moreExpected);
|
bool& moreExpected);
|
||||||
|
|
||||||
std::vector<Wt::Dbo::ptr<Track>> getTracks(const std::set<id_type>& clusters = std::set<id_type>()) const;
|
std::vector<Wt::Dbo::ptr<Track>> getTracks(const std::set<id_type>& clusters = std::set<id_type>()) const;
|
||||||
|
std::vector<Wt::Dbo::ptr<Cluster>> getClusters(int size) const;
|
||||||
|
|
||||||
// Create
|
// Create
|
||||||
static pointer create(Wt::Dbo::Session& session, const std::string& name, const std::string& MBID = "");
|
static pointer create(Wt::Dbo::Session& session, const std::string& name, const std::string& MBID = "");
|
||||||
|
|||||||
@@ -75,14 +75,14 @@ Artist::refresh()
|
|||||||
t->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
t->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||||
|
|
||||||
auto clusterContainers = new Wt::WContainerWidget();
|
auto clusterContainers = new Wt::WContainerWidget();
|
||||||
t->bindWidget("tags", clusterContainers);
|
t->bindWidget("clusters", clusterContainers);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto clusters = artist->getClusters(3);
|
auto clusters = artist->getClusters(3);
|
||||||
|
|
||||||
for (auto cluster : clusters)
|
for (auto cluster : clusters)
|
||||||
{
|
{
|
||||||
auto entry = new Wt::WTemplate(Wt::WString::tr("template-artist-tag-entry"), clusterContainers);
|
auto entry = new Wt::WTemplate(Wt::WString::tr("template-artist-cluster-entry"), clusterContainers);
|
||||||
|
|
||||||
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::PlainText);
|
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::PlainText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,20 @@ Release::refresh()
|
|||||||
cover->setImageLink(Wt::WLink (SessionImageResource()->getReleaseUrl(release.id(), 512)));
|
cover->setImageLink(Wt::WLink (SessionImageResource()->getReleaseUrl(release.id(), 512)));
|
||||||
t->bindWidget("cover", cover);
|
t->bindWidget("cover", cover);
|
||||||
|
|
||||||
|
auto clusterContainers = new Wt::WContainerWidget();
|
||||||
|
t->bindWidget("clusters", clusterContainers);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto clusters = release->getClusters(3);
|
||||||
|
|
||||||
|
for (auto cluster : clusters)
|
||||||
|
{
|
||||||
|
auto entry = new Wt::WTemplate(Wt::WString::tr("template-release-cluster-entry"), clusterContainers);
|
||||||
|
|
||||||
|
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::PlainText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto playBtn = new Wt::WText(Wt::WString::tr("btn-release-play-btn"), Wt::XHTMLText);
|
auto playBtn = new Wt::WText(Wt::WString::tr("btn-release-play-btn"), Wt::XHTMLText);
|
||||||
t->bindWidget("play-btn", playBtn);
|
t->bindWidget("play-btn", playBtn);
|
||||||
|
|||||||
Reference in New Issue
Block a user