feat: add remaining links to modrinth modpacks

This commit is contained in:
flow 2022-05-24 11:52:27 -03:00
parent 5e17d53c7f
commit d0337da8ea
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
3 changed files with 45 additions and 10 deletions

View File

@ -62,8 +62,22 @@ void loadIndexedInfo(Modpack& pack, QJsonObject& obj)
{ {
pack.extra.body = Json::ensureString(obj, "body"); pack.extra.body = Json::ensureString(obj, "body");
pack.extra.projectUrl = QString("https://modrinth.com/modpack/%1").arg(Json::ensureString(obj, "slug")); pack.extra.projectUrl = QString("https://modrinth.com/modpack/%1").arg(Json::ensureString(obj, "slug"));
pack.extra.issuesUrl = Json::ensureString(obj, "issues_url");
if(pack.extra.issuesUrl.endsWith('/'))
pack.extra.issuesUrl.chop(1);
pack.extra.sourceUrl = Json::ensureString(obj, "source_url"); pack.extra.sourceUrl = Json::ensureString(obj, "source_url");
if(pack.extra.sourceUrl.endsWith('/'))
pack.extra.sourceUrl.chop(1);
pack.extra.wikiUrl = Json::ensureString(obj, "wiki_url"); pack.extra.wikiUrl = Json::ensureString(obj, "wiki_url");
if(pack.extra.wikiUrl.endsWith('/'))
pack.extra.wikiUrl.chop(1);
pack.extra.discordUrl = Json::ensureString(obj, "discord_url");
if(pack.extra.discordUrl.endsWith('/'))
pack.extra.discordUrl.chop(1);
auto donate_arr = Json::ensureArray(obj, "donation_urls"); auto donate_arr = Json::ensureArray(obj, "donation_urls");
for(auto d : donate_arr){ for(auto d : donate_arr){

View File

@ -68,8 +68,11 @@ struct ModpackExtra {
QString body; QString body;
QString projectUrl; QString projectUrl;
QString issuesUrl;
QString sourceUrl; QString sourceUrl;
QString wikiUrl; QString wikiUrl;
QString discordUrl;
QList<DonationData> donate; QList<DonationData> donate;

View File

@ -224,19 +224,37 @@ void ModrinthPage::updateUI()
// TODO: Implement multiple authors with links // TODO: Implement multiple authors with links
text += "<br>" + tr(" by ") + QString("<a href=%1>%2</a>").arg(std::get<1>(current.author).toString(), std::get<0>(current.author)); text += "<br>" + tr(" by ") + QString("<a href=%1>%2</a>").arg(std::get<1>(current.author).toString(), std::get<0>(current.author));
if(!current.extra.donate.isEmpty()) { if(current.extraInfoLoaded) {
text += tr("<br><br>Donate information:<br>"); if (!current.extra.donate.isEmpty()) {
auto donateToStr = [](Modrinth::DonationData& donate) -> QString { text += "<br><br>" + tr("Donate information: ");
return QString("<a href=\"%1\">%2</a>").arg(donate.url, donate.platform); auto donateToStr = [](Modrinth::DonationData& donate) -> QString {
}; return QString("<a href=\"%1\">%2</a>").arg(donate.url, donate.platform);
QStringList donates; };
for (auto& donate : current.extra.donate) { QStringList donates;
donates.append(donateToStr(donate)); for (auto& donate : current.extra.donate) {
donates.append(donateToStr(donate));
}
text += donates.join(", ");
} }
text += donates.join(", ");
if (!current.extra.issuesUrl.isEmpty()
|| !current.extra.sourceUrl.isEmpty()
|| !current.extra.wikiUrl.isEmpty()
|| !current.extra.discordUrl.isEmpty()) {
text += "<br><br>" + tr("External links:") + "<br>";
}
if (!current.extra.issuesUrl.isEmpty())
text += "- " + tr("Issues: <a href=%1>%1</a>").arg(current.extra.issuesUrl) + "<br>";
if (!current.extra.wikiUrl.isEmpty())
text += "- " + tr("Wiki: <a href=%1>%1</a>").arg(current.extra.wikiUrl) + "<br>";
if (!current.extra.sourceUrl.isEmpty())
text += "- " + tr("Source code: <a href=%1>%1</a>").arg(current.extra.sourceUrl) + "<br>";
if (!current.extra.discordUrl.isEmpty())
text += "- " + tr("Discord: <a href=%1>%1</a>").arg(current.extra.discordUrl) + "<br>";
} }
text += "<br>"; text += "<hr>";
HoeDown h; HoeDown h;
text += h.process(current.extra.body.toUtf8()); text += h.process(current.extra.body.toUtf8());