Moved the copyright information in the new release info view

This commit is contained in:
emeric
2019-03-08 17:17:56 +01:00
parent c1ffe8ab57
commit d5ead9193f
4 changed files with 48 additions and 40 deletions
-7
View File
@@ -20,13 +20,6 @@
${play-btn}${add-btn} ${play-btn}${add-btn}
</div> </div>
${tracks} ${tracks}
${<if-has-copyright-or-copyright-url>}
<div class="page-header">
<h4><small>${tr:Lms.Explore.Release.copyright}</small></h4>
</div>
${<if-has-copyright>}<small>${copyright}</small>${</if-has-copyright>}
${<if-has-copyright-url>}<small>${copyright-url}</small>${</if-has-copyright-url>}
${</if-has-copyright-or-copyright-url>}
</message> </message>
<message id="Lms.Explore.Release.template.entry"> <message id="Lms.Explore.Release.template.entry">
+5
View File
@@ -3,6 +3,11 @@
<messages xmlns:if="Wt.WTemplate.conditions"> <messages xmlns:if="Wt.WTemplate.conditions">
<message id="Lms.Explore.ReleaseInfo.template"> <message id="Lms.Explore.ReleaseInfo.template">
${<if-has-copyright-or-copyright-url>}
<h3>${tr:Lms.Explore.Release.copyright}</h3>
${<if-has-copyright>}<small>${copyright}</small>${</if-has-copyright>}
${<if-has-copyright-url>}<small>${copyright-url}</small>${</if-has-copyright-url>}
${</if-has-copyright-or-copyright-url>}
<h3>${tr:Lms.Explore.ReleaseInfo.similar-releases}</h3> <h3>${tr:Lms.Explore.ReleaseInfo.similar-releases}</h3>
${similar-releases} ${similar-releases}
</message> </message>
+42 -10
View File
@@ -19,6 +19,8 @@
#include "ReleaseInfoView.hpp" #include "ReleaseInfoView.hpp"
#include <Wt/WAnchor.h>
#include "database/Release.hpp" #include "database/Release.hpp"
#include "main/Services.hpp" #include "main/Services.hpp"
#include "similarity/SimilaritySearcher.hpp" #include "similarity/SimilaritySearcher.hpp"
@@ -55,29 +57,59 @@ void
ReleaseInfo::refresh() ReleaseInfo::refresh()
{ {
_similarReleasesContainer->clear(); _similarReleasesContainer->clear();
setCondition("if-has-copyright-or-copyright-url", false);
setCondition("if-has-copyright-url", false);
setCondition("if-has-copyright", false);
if (!wApp->internalPathMatches("/release/")) if (!wApp->internalPathMatches("/release/"))
return; return;
auto releaseId = readAs<Database::IdType>(wApp->internalPathNextPart("/release/")); auto releaseId {readAs<Database::IdType>(wApp->internalPathNextPart("/release/"))};
if (!releaseId) if (!releaseId)
return; return;
auto releasesIds = getServices().similaritySearcher->getSimilarReleases(LmsApp->getDboSession(), *releaseId, 5); std::vector<Database::IdType> releasesIds {getServices().similaritySearcher->getSimilarReleases(LmsApp->getDboSession(), *releaseId, 5)};
Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); Wt::Dbo::Transaction transaction {LmsApp->getDboSession()};
std::vector<Database::Release::pointer> releases; Database::Release::pointer release {Database::Release::getById(LmsApp->getDboSession(), *releaseId)};
for (auto releaseId : releasesIds) if (!release)
return;
boost::optional<std::string> copyright {release->getCopyright()};
boost::optional<std::string> copyrightURL {release->getCopyrightURL()};
setCondition("if-has-copyright-or-copyright-url", copyright || copyrightURL);
if (copyrightURL)
{ {
auto release = Database::Release::getById(LmsApp->getDboSession(), releaseId); setCondition("if-has-copyright-url", true);
if (release) Wt::WLink link {*copyrightURL};
releases.push_back(release); link.setTarget(Wt::LinkTarget::NewWindow);
Wt::WAnchor* anchor {bindNew<Wt::WAnchor>("copyright-url", link)};
anchor->setTextFormat(Wt::TextFormat::XHTML);
anchor->setText(Wt::WString::tr("Lms.Explore.Release.template.link-btn"));
} }
for (auto release : releases) if (copyright)
_similarReleasesContainer->addNew<ReleaseLink>(release); {
setCondition("if-has-copyright", true);
bindString("copyright", Wt::WString::fromUTF8(*copyright), Wt::TextFormat::Plain);
}
std::vector<Database::Release::pointer> similarReleases;
for (Database::IdType id : releasesIds)
{
Database::Release::pointer similarRelease {Database::Release::getById(LmsApp->getDboSession(), id)};
if (similarRelease)
similarReleases.emplace_back(similarRelease);
}
for (const auto& similarRelease : similarReleases)
_similarReleasesContainer->addNew<ReleaseLink>(similarRelease);
} }
} // namespace UserInterface } // namespace UserInterface
+1 -23
View File
@@ -19,8 +19,8 @@
#include "ReleaseView.hpp" #include "ReleaseView.hpp"
#include <Wt/WApplication.h>
#include <Wt/WAnchor.h> #include <Wt/WAnchor.h>
#include <Wt/WApplication.h>
#include <Wt/WImage.h> #include <Wt/WImage.h>
#include <Wt/WTemplate.h> #include <Wt/WTemplate.h>
#include <Wt/WText.h> #include <Wt/WText.h>
@@ -94,28 +94,6 @@ Release::refresh()
} }
} }
boost::optional<std::string> copyright = release->getCopyright();
boost::optional<std::string> copyrightURL = release->getCopyrightURL();
t->setCondition("if-has-copyright-or-copyright-url", copyright || copyrightURL);
if (copyrightURL)
{
t->setCondition("if-has-copyright-url", true);
Wt::WLink link(*copyrightURL);
link.setTarget(Wt::LinkTarget::NewWindow);
Wt::WAnchor* anchor = t->bindNew<Wt::WAnchor>("copyright-url", link);
anchor->setTextFormat(Wt::TextFormat::XHTML);
anchor->setText(Wt::WString::tr("Lms.Explore.Release.template.link-btn"));
}
if (copyright)
{
t->setCondition("if-has-copyright", true);
t->bindString("copyright", Wt::WString::fromUTF8(*copyright), Wt::TextFormat::Plain);
}
{ {
auto artists = release->getArtists(); auto artists = release->getArtists();
if (artists.size() > 1) if (artists.size() > 1)